diff --git a/mk/linux/glest.ini b/mk/linux/glest.ini index db3e54d41..1b6307fcf 100644 --- a/mk/linux/glest.ini +++ b/mk/linux/glest.ini @@ -43,4 +43,5 @@ SoundVolumeFx=80 SoundVolumeMusic=90 StencilBits=0 Textures3D=1 +UnitParticles=1 Windowed=0 diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index ebb236df8..9f0e1dfeb 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -22,7 +22,7 @@ using namespace Shared::Util; namespace Glest{ namespace Game{ const string mailString= "contact_game@glest.org"; -const string glestVersionString= "v3.2.4-1-beta4"; +const string glestVersionString= "v3.2.4-2-beta4"; string getCrashDumpFileName(){ return "glest"+glestVersionString+".dmp"; @@ -43,7 +43,7 @@ string getAboutString1(int i){ string getAboutString2(int i){ switch(i){ - case 0: return "Web: http://glest.org"; + case 0: return "Web: http://sourceforge.net/projects/megaglest http://glest.org"; case 1: return "Mail: " + mailString; case 2: return "Irc: irc://irc.freenode.net/glest"; } @@ -59,6 +59,8 @@ string getTeammateName(int i){ case 4: return "F�lix Men�ndez"; case 5: return "Marcos Caruncho"; case 6: return "Matthias Braun"; + case 7: return "Titus Tscharntke"; + case 8: return "Mark Vejvoda"; } return ""; } @@ -74,6 +76,8 @@ string getTeammateRole(int i){ case 4: return l.get("Animation"); case 5: return l.get("3dArt"); case 6: return l.get("LinuxPort"); + case 7: return l.get("Megaglest3d2dProgramming"); + case 8: return l.get("MegaglestProgramming"); } return ""; } diff --git a/source/glest_game/menu/menu_state_about.cpp b/source/glest_game/menu/menu_state_about.cpp index 0553db7b4..9d1929d45 100644 --- a/source/glest_game/menu/menu_state_about.cpp +++ b/source/glest_game/menu/menu_state_about.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2005 Martiño Figueroa +// Copyright (C) 2001-2005 Marti�o Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -51,10 +51,14 @@ MenuStateAbout::MenuStateAbout(Program *program, MainMenu *mainMenu): labelTeammateRole[i].setText(getTeammateRole(i)); } - labelTeammateName[5].init(360, 160); - labelTeammateRole[5].init(360, 180); - labelTeammateName[6].init(540, 160); - labelTeammateRole[6].init(540, 180); + labelTeammateName[5].init(180, 160); + labelTeammateRole[5].init(180, 180); + labelTeammateName[6].init(360, 160); + labelTeammateRole[6].init(360, 180); + labelTeammateName[7].init(540, 160); + labelTeammateRole[7].init(540, 180); + labelTeammateName[8].init(720, 160); + labelTeammateRole[8].init(720, 180); } void MenuStateAbout::mouseClick(int x, int y, MouseButton mouseButton){ diff --git a/source/glest_game/menu/menu_state_about.h b/source/glest_game/menu/menu_state_about.h index ff2600c72..432dffcf1 100644 --- a/source/glest_game/menu/menu_state_about.h +++ b/source/glest_game/menu/menu_state_about.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2005 Martiño Figueroa +// Copyright (C) 2001-2005 Marti�o Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -24,7 +24,7 @@ class MenuStateAbout: public MenuState{ public: static const int aboutStringCount1= 3; static const int aboutStringCount2= 3; - static const int teammateCount= 7; + static const int teammateCount= 9; private: GraphicButton buttonReturn; diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index fb648798c..f1b27933e 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2005 Martiño Figueroa +// Copyright (C) 2001-2005 Marti�o Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -49,6 +49,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): labelShadows.init(200, 310); labelTextures3D.init(200, 280); labelLights.init(200, 250); + labelUnitParticles.init(200,220); //list boxes listBoxVolumeFx.init(350, 530, 80); @@ -62,7 +63,8 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): listBoxShadows.init(350, 310, 170); listBoxTextures3D.init(350, 280, 80); listBoxLights.init(350, 250, 80); - + listBoxUnitParticles.init(350,220,80); + //set text buttonReturn.setText(lang.get("Return")); buttonAutoConfig.setText(lang.get("AutoConfig")); @@ -71,6 +73,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): labelFilter.setText(lang.get("Filter")); labelTextures3D.setText(lang.get("Textures3D")); labelLights.setText(lang.get("MaxLights")); + labelUnitParticles.setText(lang.get("ShowUnitParticles")); labelVolumeFx.setText(lang.get("FxVolume")); labelVolumeAmbient.setText(lang.get("AmbientVolume")); labelVolumeMusic.setText(lang.get("MusicVolume")); @@ -103,6 +106,11 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): listBoxTextures3D.pushBackItem(lang.get("No")); listBoxTextures3D.pushBackItem(lang.get("Yes")); listBoxTextures3D.setSelectedItemIndex(clamp(config.getInt("Textures3D"), 0, 1)); + + //textures 3d + listBoxUnitParticles.pushBackItem(lang.get("No")); + listBoxUnitParticles.pushBackItem(lang.get("Yes")); + listBoxUnitParticles.setSelectedItemIndex(clamp(config.getInt("UnitParticles"), 0, 1)); //lights for(int i= 1; i<=8; ++i){ @@ -158,6 +166,10 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ config.setInt("Textures3D", listBoxTextures3D.getSelectedItemIndex()); saveConfig(); } + else if(listBoxUnitParticles.mouseClick(x, y)){ + config.setInt("UnitParticles", listBoxUnitParticles.getSelectedItemIndex()); + saveConfig(); + } else if(listBoxLights.mouseClick(x, y)){ config.setInt("MaxLights", listBoxLights.getSelectedItemIndex()+1); saveConfig(); @@ -190,6 +202,7 @@ void MenuStateOptions::mouseMove(int x, int y, const MouseState *ms){ listBoxFilter.mouseMove(x, y); listBoxShadows.mouseMove(x, y); listBoxTextures3D.mouseMove(x, y); + listBoxUnitParticles.mouseMove(x, y); listBoxLights.mouseMove(x, y); } @@ -201,6 +214,7 @@ void MenuStateOptions::render(){ renderer.renderListBox(&listBoxLang); renderer.renderListBox(&listBoxShadows); renderer.renderListBox(&listBoxTextures3D); + renderer.renderListBox(&listBoxUnitParticles); renderer.renderListBox(&listBoxLights); renderer.renderListBox(&listBoxFilter); renderer.renderListBox(&listBoxVolumeFx); @@ -209,6 +223,7 @@ void MenuStateOptions::render(){ renderer.renderLabel(&labelLang); renderer.renderLabel(&labelShadows); renderer.renderLabel(&labelTextures3D); + renderer.renderLabel(&labelUnitParticles); renderer.renderLabel(&labelLights); renderer.renderLabel(&labelFilter); renderer.renderLabel(&labelVolumeFx); diff --git a/source/glest_game/menu/menu_state_options.h b/source/glest_game/menu/menu_state_options.h index 3f56c561f..ae4ef1ce7 100644 --- a/source/glest_game/menu/menu_state_options.h +++ b/source/glest_game/menu/menu_state_options.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2005 Martiño Figueroa +// Copyright (C) 2001-2005 Marti�o Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -30,6 +30,7 @@ private: GraphicLabel labelFilter; GraphicLabel labelTextures3D; GraphicLabel labelLights; + GraphicLabel labelUnitParticles; GraphicLabel labelVolumeFx; GraphicLabel labelVolumeAmbient; GraphicLabel labelVolumeMusic; @@ -38,6 +39,7 @@ private: GraphicListBox listBoxFilter; GraphicListBox listBoxTextures3D; GraphicListBox listBoxLights; + GraphicListBox listBoxUnitParticles; GraphicListBox listBoxVolumeFx; GraphicListBox listBoxVolumeAmbient; GraphicListBox listBoxVolumeMusic; diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index d0dc22ed7..71f2f8b7a 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -110,8 +110,11 @@ Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map this->type=type; this->faction=faction; this->map= map; - this->id= id; + + Config &config= Config::getInstance(); + showUnitParticles= config.getBool("UnitParticles"); + lastPos= pos; progress= 0; lastAnimProgress= 0; @@ -159,6 +162,7 @@ Unit::~Unit(){ unitParticleSystems.back()->fade(); unitParticleSystems.pop_back(); } + stopDamageParticles(); } // ====================================== get ====================================== @@ -324,8 +328,8 @@ void Unit::setCurrSkill(const SkillType *currSkill){ unitParticleSystems.pop_back(); } } - if((!currSkill->unitParticleSystemTypes.empty()) - && (unitParticleSystems.empty()) ){ + if(showUnitParticles && (!currSkill->unitParticleSystemTypes.empty()) && + (unitParticleSystems.empty()) ){ for(UnitParticleSystemTypes::const_iterator it= currSkill->unitParticleSystemTypes.begin(); it!=currSkill->unitParticleSystemTypes.end(); ++it){ UnitParticleSystem *ups; ups= new UnitParticleSystem(200); @@ -375,6 +379,9 @@ void Unit::setVisible(const bool visible){ for(UnitParticleSystems::iterator it= unitParticleSystems.begin(); it!=unitParticleSystems.end(); ++it){ (*it)->setVisible(visible); } + for(UnitParticleSystems::iterator it= damageParticleSystems.begin(); it!=damageParticleSystems.end(); ++it){ + (*it)->setVisible(visible); + } } // =============================== Render related ================================== @@ -651,6 +658,10 @@ bool Unit::update(){ (*it)->setPos(getCurrVector()); (*it)->setRotation(getRotation()); } + for(UnitParticleSystems::iterator it= damageParticleSystems.begin(); it!=damageParticleSystems.end(); ++it){ + (*it)->setPos(getCurrVector()); + (*it)->setRotation(getRotation()); + } //checks if(animProgress>1.f){ animProgress= currSkill->getClass()==scDie? 1.f: 0.f; @@ -684,10 +695,9 @@ void Unit::tick(){ if(hp>type->getTotalMaxHp(&totalUpgrade)){ hp= type->getTotalMaxHp(&totalUpgrade); } - //stop fire - if(hp>type->getTotalMaxHp(&totalUpgrade)/2 && fire!=NULL){ - fire->fade(); - fire= NULL; + //stop DamageParticles + if(hp>type->getTotalMaxHp(&totalUpgrade)/2 ){ + stopDamageParticles(); } //regenerate ep ep+= type->getEpRegeneration(); @@ -727,10 +737,9 @@ bool Unit::repair(){ return true; } - //stop fire - if(hp>type->getTotalMaxHp(&totalUpgrade)/2 && fire!=NULL){ - fire->fade(); - fire= NULL; + //stop DamageParticles + if(hp>type->getTotalMaxHp(&totalUpgrade)/2 ){ + stopDamageParticles(); } return false; } @@ -743,27 +752,16 @@ bool Unit::decHp(int i){ hp-=i; - //fire - if(type->getProperty(UnitType::pBurnable) && hpgetMaxHp()/2 && fire==NULL){ - FireParticleSystem *fps; - fps= new FireParticleSystem(200); - fps->setSpeed(2.5f/GameConstants::updateFps); - fps->setPos(getCurrVector()); - fps->setRadius(type->getSize()/3.f); - fps->setTexture(CoreData::getInstance().getFireTexture()); - fps->setParticleSize(type->getSize()/3.f); - fire= fps; - Renderer::getInstance().manageParticleSystem(fps, rsGame); + //startDamageParticles + if(hpgetMaxHp()/2 ){ + startDamageParticles(); } - //stop fire on death + //stop DamageParticles on death if(hp<=0){ alive= false; hp=0; - if(fire!=NULL){ - fire->fade(); - fire= NULL; - } + stopDamageParticles(); return true; } return false; @@ -1021,5 +1019,67 @@ CommandResult Unit::undoCommand(Command *command){ return crSuccess; } +void Unit::stopDamageParticles(){ + // stop fire + if(fire!=NULL){ + fire->fade(); + fire= NULL; + } + // stop additional particles + while(!damageParticleSystems.empty()){ + damageParticleSystems.back()->fade(); + damageParticleSystems.pop_back(); + } +} + +void Unit::startDamageParticles(){ + //start additional particles + if( showUnitParticles && (!type->damageParticleSystemTypes.empty()) + && (damageParticleSystems.empty()) ){ + for(UnitParticleSystemTypes::const_iterator it= type->damageParticleSystemTypes.begin(); it!=type->damageParticleSystemTypes.end(); ++it){ + UnitParticleSystem *ups; + ups= new UnitParticleSystem(200); + (*it)->setValues(ups); + ups->setPos(getCurrVector()); + ups->setFactionColor(getFaction()->getTexture()->getPixmap()->getPixel3f(0,0)); + damageParticleSystems.push_back(ups); + Renderer::getInstance().manageParticleSystem(ups, rsGame); + } + } + // start fire + if(type->getProperty(UnitType::pBurnable) && fire==NULL){ + FireParticleSystem *fps; + fps= new FireParticleSystem(200); + fps->setSpeed(2.5f/GameConstants::updateFps); + fps->setPos(getCurrVector()); + fps->setRadius(type->getSize()/3.f); + fps->setTexture(CoreData::getInstance().getFireTexture()); + fps->setParticleSize(type->getSize()/3.f); + fire= fps; + Renderer::getInstance().manageParticleSystem(fps, rsGame); + if(showUnitParticles){ + // smoke + UnitParticleSystem *ups= new UnitParticleSystem(400); + ups->setColorNoEnergy(Vec4f(0.0f, 0.0f, 0.0f, 0.13f)); + ups->setColor(Vec4f(0.115f, 0.115f, 0.115f, 0.22f)); + ups->setPos(getCurrVector()); + ups->setBlendMode(ups->strToBlendMode("black")); + ups->setOffset(Vec3f(0,2,0)); + ups->setDirection(Vec3f(0,1,-0.2f)); + ups->setRadius(type->getSize()/3.f); + ups->setTexture(CoreData::getInstance().getFireTexture()); + ups->setSpeed(2.0f/GameConstants::updateFps); + ups->setGravity(0.0004f); + ups->setEmissionRate(1); + ups->setMaxParticleEnergy(150); + ups->setSizeNoEnergy(type->getSize()*0.6f); + ups->setParticleSize(type->getSize()*0.8f); + damageParticleSystems.push_back(ups); + Renderer::getInstance().manageParticleSystem(ups, rsGame); + } + + } +} + }}//end namespace diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index d8e837c13..8d84981c2 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -129,7 +129,7 @@ public: static const int maxDeadCount; static const float highlightTime; static const int invalidId; - //UnitParticleSystem *skillParticleSystem; + private: int id; @@ -166,6 +166,7 @@ private: bool toBeUndertaken; bool alive; + bool showUnitParticles; Faction *faction; ParticleSystem *fire; @@ -177,6 +178,7 @@ private: Commands commands; Observers observers; UnitParticleSystems unitParticleSystems; + UnitParticleSystems damageParticleSystems; public: Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map); @@ -297,6 +299,8 @@ private: void updateTarget(); void clearCommands(); CommandResult undoCommand(Command *command); + void stopDamageParticles(); + void startDamageParticles(); }; }}// end namespace diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 41f27cc27..c8db23015 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Marti�o Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -24,6 +24,7 @@ #include "renderer.h" #include "game_util.h" #include "leak_dumper.h" +#include "unit_particle_type.h" using namespace Shared::Xml; using namespace Shared::Graphics; @@ -76,6 +77,12 @@ UnitType::~UnitType(){ deleteValues(selectionSounds.getSounds().begin(), selectionSounds.getSounds().end()); deleteValues(commandSounds.getSounds().begin(), commandSounds.getSounds().end()); delete [] cellMap; + //remove damageParticleSystemTypes + while(!damageParticleSystemTypes.empty()){ + delete damageParticleSystemTypes.back(); + damageParticleSystemTypes.pop_back(); + } + } void UnitType::preLoad(const string &dir){ @@ -208,6 +215,20 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa throw runtime_error("Unknown property: " + propertyName); } } + //damage-particles + if(parametersNode->hasChild("damage-particles")){ + const XmlNode *particleNode= parametersNode->getChild("damage-particles"); + bool particleEnabled= particleNode->getAttribute("value")->getBoolValue(); + if(particleEnabled){ + for(int i=0; igetChildCount(); ++i){ + const XmlNode *particleFileNode= particleNode->getChild("particle-file", i); + string path= particleFileNode->getAttribute("path")->getRestrictedValue(); + UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType(); + unitParticleSystemType->load(dir, dir + "/" + path); + damageParticleSystemTypes.push_back(unitParticleSystemType); + } + } + } //light const XmlNode *lightNode= parametersNode->getChild("light"); diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index 1e079815c..bbc5dc24a 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Marti�o Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -25,6 +25,7 @@ using Shared::Util::Checksum; class UpgradeType; class UnitType; +class UnitParticleSystemType; class ResourceType; class TechTree; class FactionType; @@ -58,6 +59,8 @@ enum UnitClass{ ucBuilding }; +typedef list DamageParticleSystemTypes; + class UnitType: public ProducibleType{ public: enum Property{ @@ -68,7 +71,7 @@ public: }; static const char *propertyNames[]; - + DamageParticleSystemTypes damageParticleSystemTypes; private: typedef vector SkillTypes; typedef vector CommandTypes;