From b84c69a93bbd3fc4f0e6855c936bab8f540624a8 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 2 May 2012 21:00:57 +0000 Subject: [PATCH] - translatable techtrees, currently supported resource names, unit names and upgrade names. For each techtree created a lang folder in the techtree main folder. Now create language specific files _language.lng as we do for scenarios. In the file add: ResourceTypeName_=My new resource name UnitTypeName_==my new unit name UpgradeTypeName_=my new upgrade name --- source/glest_game/types/unit_type.cpp | 7 +++++++ source/glest_game/types/unit_type.h | 2 ++ source/glest_game/types/upgrade_type.cpp | 7 +++++++ source/glest_game/types/upgrade_type.h | 3 +++ 4 files changed, 19 insertions(+) diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index a9463015f..9f1b85140 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -982,6 +982,13 @@ string UnitType::getReqDesc() const{ return ProducibleType::getReqDesc()+"\nLimits: "+resultTxt; } +string UnitType::getName(bool translatedValue) const { + if(translatedValue == false) return name; + + Lang &lang = Lang::getInstance(); + return lang.getTechTreeString("UnitTypeName_" + name,name.c_str()); +} + std::string UnitType::toString() const { std::string result = ""; diff --git a/source/glest_game/types/unit_type.h b/source/glest_game/types/unit_type.h index 9f2d56e6b..38644907c 100644 --- a/source/glest_game/types/unit_type.h +++ b/source/glest_game/types/unit_type.h @@ -157,6 +157,8 @@ public: const FactionType *factionType, Checksum* checksum, Checksum* techtreeChecksum, std::map > > &loadedFileList); + virtual string getName(bool translatedValue=false) const; + //get inline int getId() const {return id;} inline int getMaxHp() const {return maxHp;} diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index 7cfb51c78..321173a97 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -476,6 +476,13 @@ const UpgradeType * UpgradeTypeBase::loadGame(const XmlNode *rootNode, Faction * // ==================== misc ==================== +string UpgradeType::getName(bool translatedValue) const { + if(translatedValue == false) return name; + + Lang &lang = Lang::getInstance(); + return lang.getTechTreeString("UpgradeTypeName_" + name,name.c_str()); +} + string UpgradeType::getReqDesc() const{ Lang &lang= Lang::getInstance(); string str= ProducibleType::getReqDesc(); diff --git a/source/glest_game/types/upgrade_type.h b/source/glest_game/types/upgrade_type.h index 592dc561e..d183a4813 100644 --- a/source/glest_game/types/upgrade_type.h +++ b/source/glest_game/types/upgrade_type.h @@ -81,6 +81,7 @@ protected: std::map prodSpeedMorphIsMultiplierValueList; public: + int getMaxHp() const {return maxHp;} bool getMaxHpIsMultiplier() const {return maxHpIsMultiplier;} int getMaxHpRegeneration() const {return maxHpRegeneration;} @@ -158,6 +159,8 @@ public: const FactionType *factionType, Checksum* checksum, Checksum* techtreeChecksum, std::map > > &loadedFileList); + virtual string getName(bool translatedValue=false) const; + //get all int getEffectCount() const {return effects.size();} const UnitType * getEffect(int i) const {return effects[i];}