From 51a0b50bc268baaf862cb30c361cfa0d70105023 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 16 Jan 2013 21:16:59 +0000 Subject: [PATCH] - applied changes from Muwuum for full translatable game experience --- source/glest_game/type_instances/unit.cpp | 6 ++--- source/glest_game/types/command_type.cpp | 26 +++++++++---------- source/glest_game/types/damage_multiplier.cpp | 14 ++++++++++ source/glest_game/types/damage_multiplier.h | 4 +-- source/glest_game/types/element_type.cpp | 7 +++++ source/glest_game/types/element_type.h | 2 +- source/glest_game/types/faction_type.cpp | 7 +++++ source/glest_game/types/faction_type.h | 2 +- source/glest_game/types/unit_type.cpp | 7 +++++ source/glest_game/types/unit_type.h | 2 +- 10 files changed, 56 insertions(+), 21 deletions(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 4fa98041..bc883e2f 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -794,7 +794,7 @@ const Level *Unit::getNextLevel() const{ string Unit::getFullName() const{ string str=""; if(level != NULL){ - str += (level->getName() + " "); + str += (level->getName(true) + " "); } if(type == NULL) { throw megaglest_runtime_error("type == NULL in Unit::getFullName()!"); @@ -2649,7 +2649,7 @@ string Unit::getDesc() const { if(totalUpgrade.getArmor()!=0){ str+="+"+intToStr(totalUpgrade.getArmor()); } - str+= " ("+getType()->getArmorType()->getName()+")"; + str+= " ("+getType()->getArmorType()->getName(true)+")"; //sight str+="\n"+ lang.get("Sight")+ ": " + intToStr(getType()->getSight()); @@ -2662,7 +2662,7 @@ string Unit::getDesc() const { if(enemyKills > 0 || nextLevel != NULL) { str+= "\n" + lang.get("Kills") +": " + intToStr(enemyKills); if(nextLevel != NULL) { - str+= " (" + nextLevel->getName() + ": " + intToStr(nextLevel->getKills()) + ")"; + str+= " (" + nextLevel->getName(true) + ": " + intToStr(nextLevel->getKills()) + ")"; } } diff --git a/source/glest_game/types/command_type.cpp b/source/glest_game/types/command_type.cpp index d90324d2..a27673d0 100644 --- a/source/glest_game/types/command_type.cpp +++ b/source/glest_game/types/command_type.cpp @@ -121,7 +121,7 @@ string StopCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ string str; Lang &lang= Lang::getInstance(); - str= name+"\n"; + str= getName(true)+"\n"; str+= lang.get("ReactionSpeed")+": "+ intToStr(stopSkillType->getSpeed())+"\n"; if(stopSkillType->getEpCost()!=0) str+= lang.get("EpCost")+": "+intToStr(stopSkillType->getEpCost())+"\n"; @@ -177,7 +177,7 @@ string MoveCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ string str; Lang &lang= Lang::getInstance(); - str= name+"\n"; + str=getName(true)+"\n"; str+= lang.get("WalkSpeed")+": "+ intToStr(moveSkillType->getSpeed()); if(totalUpgrade->getMoveSpeed(moveSkillType) != 0) { str+= "+" + intToStr(totalUpgrade->getMoveSpeed(moveSkillType)); @@ -233,7 +233,7 @@ string AttackCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ string str; Lang &lang= Lang::getInstance(); - str= name+"\n"; + str=getName(true)+"\n"; if(attackSkillType->getEpCost()!=0){ str+= lang.get("EpCost") + ": " + intToStr(attackSkillType->getEpCost()) + "\n"; } @@ -249,7 +249,7 @@ string AttackCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ if(totalUpgrade->getAttackStrength(attackSkillType) != 0) { str+= "+"+intToStr(totalUpgrade->getAttackStrength(attackSkillType)); } - str+= " ("+ attackSkillType->getAttackType()->getName() +")"; + str+= " ("+ attackSkillType->getAttackType()->getName(true) +")"; str+= "\n"; //splash radius @@ -327,7 +327,7 @@ string AttackStoppedCommandType::getDesc(const TotalUpgrade *totalUpgrade) const Lang &lang= Lang::getInstance(); string str; - str= name+"\n"; + str=getName(true)+"\n"; if(attackSkillType->getEpCost()!=0){ str+= lang.get("EpCost")+": "+intToStr(attackSkillType->getEpCost())+"\n"; } @@ -342,7 +342,7 @@ string AttackStoppedCommandType::getDesc(const TotalUpgrade *totalUpgrade) const str+= intToStr(attackSkillType->getAttackStrength()+attackSkillType->getAttackVar()); if(totalUpgrade->getAttackStrength(attackSkillType) != 0) str+= "+"+intToStr(totalUpgrade->getAttackStrength(attackSkillType)); - str+= " ("+ attackSkillType->getAttackType()->getName() +")"; + str+= " ("+ attackSkillType->getAttackType()->getName(true) +")"; str+="\n"; //splash radius @@ -462,7 +462,7 @@ string BuildCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ string str; Lang &lang= Lang::getInstance(); - str= name+"\n"; + str=getName(true)+"\n"; str+= lang.get("BuildSpeed")+": "+ intToStr(buildSkillType->getSpeed())+"\n"; if(buildSkillType->getEpCost()!=0){ str+= lang.get("EpCost")+": "+intToStr(buildSkillType->getEpCost())+"\n"; @@ -536,7 +536,7 @@ string HarvestCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ Lang &lang= Lang::getInstance(); string str; - str= name+"\n"; + str=getName(true)+"\n"; str+= lang.get("HarvestSpeed")+": "+ intToStr(harvestSkillType->getSpeed()/hitsPerUnit)+"\n"; str+= lang.get("MaxLoad")+": "+ intToStr(maxLoad)+"\n"; str+= lang.get("LoadedSpeed")+": "+ intToStr(moveLoadedSkillType->getSpeed())+"\n"; @@ -612,7 +612,7 @@ string RepairCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ Lang &lang= Lang::getInstance(); string str; - str= name+"\n"; + str=getName(true)+"\n"; str+= lang.get("RepairSpeed")+": "+ intToStr(repairSkillType->getSpeed())+"\n"; if(repairSkillType->getEpCost()!=0){ str+= lang.get("EpCost")+": "+intToStr(repairSkillType->getEpCost())+"\n"; @@ -677,7 +677,7 @@ void ProduceCommandType::load(int id, const XmlNode *n, const string &dir, } string ProduceCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ - string str= name+"\n"; + string str=getName(true)+"\n"; Lang &lang= Lang::getInstance(); //prod speed @@ -747,7 +747,7 @@ string UpgradeCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ string str; Lang &lang= Lang::getInstance(); - str= name+"\n"; + str=getName(true)+"\n"; str+= lang.get("UpgradeSpeed")+": "+ intToStr(upgradeSkillType->getSpeed())+"\n"; if(upgradeSkillType->getEpCost()!=0) str+= lang.get("EpCost")+": "+intToStr(upgradeSkillType->getEpCost())+"\n"; @@ -816,7 +816,7 @@ void MorphCommandType::load(int id, const XmlNode *n, const string &dir, } string MorphCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ - string str= name+"\n"; + string str=getName(true)+"\n"; Lang &lang= Lang::getInstance(); //prod speed @@ -881,7 +881,7 @@ void SwitchTeamCommandType::load(int id, const XmlNode *n, const string &dir, } string SwitchTeamCommandType::getDesc(const TotalUpgrade *totalUpgrade) const{ - string str= name+"\n"; + string str= getName(true)+"\n"; //Lang &lang= Lang::getInstance(); //prod speed diff --git a/source/glest_game/types/damage_multiplier.cpp b/source/glest_game/types/damage_multiplier.cpp index 26e14df5..49370a17 100644 --- a/source/glest_game/types/damage_multiplier.cpp +++ b/source/glest_game/types/damage_multiplier.cpp @@ -11,6 +11,7 @@ #include "damage_multiplier.h" #include "conversion.h" +#include "lang.h" #include "leak_dumper.h" using namespace Shared::Util; @@ -27,6 +28,13 @@ void AttackType::saveGame(XmlNode *rootNode) { attackTypeNode->addAttribute("id",intToStr(id), mapTagReplacements); } +string AttackType::getName(bool translatedValue) const { + if(translatedValue == false) return name; + + Lang &lang = Lang::getInstance(); + return lang.getTechTreeString("AttackTypeName_" + name,name.c_str()); +} + void ArmorType::saveGame(XmlNode *rootNode) { std::map mapTagReplacements; XmlNode *armorTypeNode = rootNode->addChild("ArmorType"); @@ -37,6 +45,12 @@ void ArmorType::saveGame(XmlNode *rootNode) { armorTypeNode->addAttribute("id",intToStr(id), mapTagReplacements); } +string ArmorType::getName(bool translatedValue) const { + if(translatedValue == false) return name; + + Lang &lang = Lang::getInstance(); + return lang.getTechTreeString("ArmorTypeName_" + name,name.c_str()); +} // ===================================================== // class DamageMultiplierTable // ===================================================== diff --git a/source/glest_game/types/damage_multiplier.h b/source/glest_game/types/damage_multiplier.h index b95762c5..b811f999 100644 --- a/source/glest_game/types/damage_multiplier.h +++ b/source/glest_game/types/damage_multiplier.h @@ -40,7 +40,7 @@ public: id = -1; } int getId() const {return id;} - const string &getName() const {return name;} + string getName(bool translatedValue=false) const; void setName(const string &name) {this->name= name;} void setId(int id) {this->id= id;} @@ -62,7 +62,7 @@ public: id = -1; } int getId() const {return id;} - const string &getName() const {return name;} + string getName(bool translatedValue=false) const; void setName(const string &name) {this->name= name;} void setId(int id) {this->id= id;} diff --git a/source/glest_game/types/element_type.cpp b/source/glest_game/types/element_type.cpp index 8ade151c..046f7efe 100644 --- a/source/glest_game/types/element_type.cpp +++ b/source/glest_game/types/element_type.cpp @@ -35,6 +35,13 @@ DisplayableType::DisplayableType(){ image= NULL; } +string DisplayableType::getName(bool translatedValue) const { + if(translatedValue == false) return name; + + Lang &lang = Lang::getInstance(); + return lang.getTechTreeString("CommandName_" + name,name.c_str()); +} + //void DisplayableType::saveGame(XmlNode *rootNode) const { // std::map mapTagReplacements; // XmlNode *displayableTypeNode = rootNode->addChild("DisplayableType"); diff --git a/source/glest_game/types/element_type.h b/source/glest_game/types/element_type.h index 99a3b3f5..fef102f5 100644 --- a/source/glest_game/types/element_type.h +++ b/source/glest_game/types/element_type.h @@ -53,7 +53,7 @@ public: virtual ~DisplayableType(){}; //get - virtual string getName(bool translatedValue=false) const { return name; } + virtual string getName(bool translatedValue=false) const; virtual const Texture2D *getImage() const { return image; } //virtual void saveGame(XmlNode *rootNode) const; diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index 69c7c86e..b2e8205e 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -908,6 +908,13 @@ std::string FactionType::toString() const { return result; } +string FactionType::getName(bool translatedValue) const { + if(translatedValue == false) return name; + + Lang &lang = Lang::getInstance(); + return lang.getTechTreeString("FactionName_" + name,name.c_str()); +} + void FactionType::saveGame(XmlNode *rootNode) { std::map mapTagReplacements; XmlNode *factionTypeNode = rootNode->addChild("FactionType"); diff --git a/source/glest_game/types/faction_type.h b/source/glest_game/types/faction_type.h index 7bf1bc77..5bf4a395 100644 --- a/source/glest_game/types/faction_type.h +++ b/source/glest_game/types/faction_type.h @@ -111,7 +111,7 @@ public: bool getIsLinked() const { return isLinked; } int getUnitTypeCount() const {return unitTypes.size();} int getUpgradeTypeCount() const {return upgradeTypes.size();} - string getName() const {return name;} + virtual string getName(bool translatedValue=false) const; const UnitType *getUnitType(int i) const {return &unitTypes[i];} const UpgradeType *getUpgradeType(int i) const {return &upgradeTypes[i];} StrSound *getMusic() const {return music;} diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 5eeacbca..9d8533a4 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -45,6 +45,13 @@ void Level::init(string name, int kills){ this->kills= kills; } +string Level::getName(bool translatedValue) const { + if(translatedValue == false) return name; + + Lang &lang = Lang::getInstance(); + return lang.getTechTreeString("LevelName_" + name,name.c_str()); +} + void Level::saveGame(XmlNode *rootNode) const { std::map mapTagReplacements; XmlNode *levelNode = rootNode->addChild("Level"); diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index c0fa25f9..148668b1 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -56,7 +56,7 @@ public: } void init(string name, int kills); - const string &getName() const {return name;} + string getName(bool translatedValue=false) const; int getKills() const {return kills;} void saveGame(XmlNode *rootNode) const ;