check if this fixes techtree name bug

This commit is contained in:
Mark Vejvoda 2013-10-31 20:12:49 +00:00
parent 5c71ebcf0e
commit ed4444a6da
3 changed files with 17 additions and 6 deletions

View File

@ -273,15 +273,17 @@ void Lang::loadScenarioStrings(string scenarioDir, string scenarioName, bool isT
}
}
void Lang::loadTechTreeStrings(string techTree,bool forceLoad) {
bool Lang::loadTechTreeStrings(string techTree,bool forceLoad) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] techTree = [%s]\n",__FILE__,__FUNCTION__,__LINE__,techTree.c_str());
//printf("Line: %d techTree = %s forceLoad = %d\n",__LINE__,techTree.c_str(),forceLoad);
if(forceLoad == false && techTree == techNameLoaded) {
return;
return true;
}
bool foundTranslation = false;
string currentPath = "";
Config &config = Config::getInstance();
vector<string> techPaths = config.getPathListForType(ptTechs);
@ -308,6 +310,7 @@ void Lang::loadTechTreeStrings(string techTree,bool forceLoad) {
//try to load the current language first
if(fileExists(path)) {
foundTranslation = true;
if(forceLoad == true ||
path != techTreeStringsAllLanguages[techTree][this->language].getpath()) {
@ -332,6 +335,7 @@ void Lang::loadTechTreeStrings(string techTree,bool forceLoad) {
//printf("Line: %d techTree = %s forceLoad = %d path = %s\n",__LINE__,techTree.c_str(),forceLoad,path.c_str());
if(fileExists(path)) {
foundTranslation = true;
if(forceLoad == true ||
path != techTreeStringsAllLanguages[techTree][default_language].getpath()) {
//printf("Line: %d techTree = %s forceLoad = %d path = %s\n",__LINE__,techTree.c_str(),forceLoad,path.c_str());
@ -347,6 +351,7 @@ void Lang::loadTechTreeStrings(string techTree,bool forceLoad) {
}
if(fileExists(pathDefault)) {
foundTranslation = true;
string default_language = "default";
//printf("Line: %d techTree = %s forceLoad = %d default_language = %s\n",__LINE__,techTree.c_str(),forceLoad,default_language.c_str());
@ -363,6 +368,8 @@ void Lang::loadTechTreeStrings(string techTree,bool forceLoad) {
techNameLoaded = techTree;
}
}
return foundTranslation;
}
void Lang::loadTilesetStrings(string tileset) {

View File

@ -63,7 +63,7 @@ public:
void loadGameStrings(string uselanguage, bool loadFonts=true, bool fallbackToDefault=false);
void loadScenarioStrings(string scenarioDir, string scenarioName, bool isTutorial);
void loadTechTreeStrings(string techTree, bool forceLoad=false);
bool loadTechTreeStrings(string techTree, bool forceLoad=false);
void loadTilesetStrings(string tileset);
string getString(const string &s,string uselanguage="", bool fallbackToDefault=false);

View File

@ -57,18 +57,22 @@ string TechTree::getName(bool translatedValue) {
return getNameUntranslated();
}
bool foundTranslation = false;
Lang &lang = Lang::getInstance();
if(lang.getTechNameLoaded() != name ||
lang.getLanguage() != languageUsedForCache) {
//printf("Line: %d Tech [%s]\n",__LINE__,name.c_str());
lang.loadTechTreeStrings(name,lang.getLanguage() != languageUsedForCache);
foundTranslation = lang.loadTechTreeStrings(name,lang.getLanguage() != languageUsedForCache);
languageUsedForCache = lang.getLanguage();
translatedTechFactionNames.erase(name);
translatedTechNames.erase(name);
}
string result = lang.getTechTreeString("TechTreeName",name.c_str());
string result = name;
if(foundTranslation == true) {
result = lang.getTechTreeString("TechTreeName",name.c_str());
}
//printf("Line: %d Tech [%s] result [%s]\n",__LINE__,name.c_str(),result.c_str());
return result;
@ -102,7 +106,7 @@ string TechTree::getTranslatedName(string techName, bool forceLoad, bool forceTe
result = getName(true);
printf("techName [%s] name [%s] result [%s]\n",techName.c_str(),name.c_str(),result.c_str());
//printf("techName [%s] name [%s] result [%s]\n",techName.c_str(),name.c_str(),result.c_str());
translatedTechNames[name] = result;
}