mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 23:21:19 +02:00
- added support for translated techtrees. To produce a default techtree lng file in the proper techtree folder run:
megaglest --translate-techtrees=megapack where megapack is the name of the techtree
This commit is contained in:
@@ -2515,6 +2515,261 @@ void runTechValidationForPath(string techPath, string techName,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void runTechTranslationExtractionForPath(string techPath, string techName,
|
||||||
|
const std::vector<string> &filteredFactionList, World &world) {
|
||||||
|
//Config &config = Config::getInstance();
|
||||||
|
vector<string> factionsList;
|
||||||
|
findDirs(techPath + techName + "/factions/", factionsList, false, false);
|
||||||
|
|
||||||
|
if(factionsList.empty() == false) {
|
||||||
|
Checksum checksum;
|
||||||
|
set<string> factions;
|
||||||
|
for(int j = 0; j < factionsList.size(); ++j) {
|
||||||
|
if( filteredFactionList.empty() == true ||
|
||||||
|
std::find(filteredFactionList.begin(),filteredFactionList.end(),factionsList[j]) != filteredFactionList.end()) {
|
||||||
|
factions.insert(factionsList[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n----------------------------------------------------------------");
|
||||||
|
printf("\nChecking techPath [%s] techName [%s] total faction count = %d\n",techPath.c_str(), techName.c_str(),(int)factionsList.size());
|
||||||
|
for(int j = 0; j < factionsList.size(); ++j) {
|
||||||
|
if( filteredFactionList.empty() == true ||
|
||||||
|
std::find(filteredFactionList.begin(),filteredFactionList.end(),factionsList[j]) != filteredFactionList.end()) {
|
||||||
|
printf("Using faction [%s]\n",factionsList[j].c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(factions.empty() == false) {
|
||||||
|
bool techtree_errors = false;
|
||||||
|
|
||||||
|
std::map<string,vector<pair<string, string> > > loadedFileList;
|
||||||
|
//vector<string> pathList = config.getPathListForType(ptTechs,"");
|
||||||
|
vector<string> pathList;
|
||||||
|
pathList.push_back(techPath);
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
vector<string> otherTechPaths = config.getPathListForType(ptTechs,"");
|
||||||
|
pathList.insert(pathList.end(), otherTechPaths.begin(), otherTechPaths.end());
|
||||||
|
world.loadTech(pathList, techName, factions, &checksum, loadedFileList);
|
||||||
|
|
||||||
|
const TechTree *techtree = world.getTechTree();
|
||||||
|
string translationFile = techtree->getPath();
|
||||||
|
endPathWithSlash(translationFile);
|
||||||
|
translationFile += "lang/" + techName + "_default.lng";
|
||||||
|
if(fileExists(translationFile) == false) {
|
||||||
|
string txFilePath = extractDirectoryPathFromFile(translationFile);
|
||||||
|
createDirectoryPaths(txFilePath);
|
||||||
|
|
||||||
|
#if defined(WIN32) && !defined(__MINGW32__)
|
||||||
|
FILE *fp = _wfopen(utf8_decode(translationFile).c_str(), L"w");
|
||||||
|
std::ofstream txFile(fp);
|
||||||
|
#else
|
||||||
|
std::ofstream txFile;
|
||||||
|
txFile.open(translationFile.c_str(), ios_base::out | ios_base::trunc);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(txFile.is_open() == true) {
|
||||||
|
txFile << "TechTreeName=" << techName << std::endl;
|
||||||
|
|
||||||
|
txFile << "; --------------" << std::endl;
|
||||||
|
txFile << "; Types of Armor" << std::endl;
|
||||||
|
for(unsigned int index = 0; index < techtree->getArmorTypeCount(); ++index) {
|
||||||
|
const ArmorType *at = techtree->getArmorTypeByIndex(index);
|
||||||
|
txFile << "ArmorTypeName_" << at->getName(false) << "=" << at->getName(false) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
txFile << "; -------------- " << std::endl;
|
||||||
|
txFile << "; Types of Attack" << std::endl;
|
||||||
|
for(unsigned int index = 0; index < techtree->getAttackTypeCount(); ++index) {
|
||||||
|
const AttackType *at = techtree->getAttackTypeByIndex(index);
|
||||||
|
txFile << "AttackTypeName_" << at->getName(false) << "=" << at->getName(false) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
txFile << "; ------------------" << std::endl;
|
||||||
|
txFile << "; Types of Resources" << std::endl;
|
||||||
|
for(unsigned int index = 0; index < techtree->getResourceTypeCount(); ++index) {
|
||||||
|
const ResourceType *rt = techtree->getResourceType(index);
|
||||||
|
txFile << "ResourceTypeName_" << rt->getName(false) << "=" << rt->getName(false) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
txFile << "; -----------------" << std::endl;
|
||||||
|
txFile << "; Types of Factions" << std::endl;
|
||||||
|
for(unsigned int index = 0; index < techtree->getTypeCount(); ++index) {
|
||||||
|
const FactionType *ft = techtree->getType(index);
|
||||||
|
txFile << "FactionName_" << ft->getName(false) << "=" << ft->getName(false) << std::endl;
|
||||||
|
|
||||||
|
txFile << "; ----------------------------------" << std::endl;
|
||||||
|
txFile << "; Types of Upgrades for this Faction" << std::endl;
|
||||||
|
for(unsigned int upgradeIndex = 0; upgradeIndex < ft->getUpgradeTypeCount(); ++upgradeIndex) {
|
||||||
|
const UpgradeType *upt = ft->getUpgradeType(upgradeIndex);
|
||||||
|
txFile << "UpgradeTypeName_" << upt->getName(false) << "=" << upt->getName(false) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
txFile << "; -------------------------------" << std::endl;
|
||||||
|
txFile << "; Types of Units for this Faction" << std::endl;
|
||||||
|
for(unsigned int unitIndex = 0; unitIndex < ft->getUnitTypeCount(); ++unitIndex) {
|
||||||
|
const UnitType *ut = ft->getUnitType(unitIndex);
|
||||||
|
txFile << "UnitTypeName_" << ut->getName(false) << "=" << ut->getName(false) << std::endl;
|
||||||
|
|
||||||
|
txFile << "; --------------------" << std::endl;
|
||||||
|
txFile << "; Levels for this Unit" << std::endl;
|
||||||
|
for(unsigned int levelIndex = 0; levelIndex < ut->getLevelCount(); ++levelIndex) {
|
||||||
|
const Level *level = ut->getLevel(levelIndex);
|
||||||
|
txFile << "LevelName_" << level->getName(false) << "=" << level->getName(false) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
txFile << "; -------------------------------" << std::endl;
|
||||||
|
txFile << "; Types of Commands for this Unit" << std::endl;
|
||||||
|
for(unsigned int commandIndex = 0; commandIndex < ut->getCommandTypeCount(); ++commandIndex) {
|
||||||
|
const CommandType *ct = ut->getCommandType(commandIndex);
|
||||||
|
txFile << "CommandName_" << ct->getName(false) << "=" << ct->getName(false) << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
txFile.close();
|
||||||
|
|
||||||
|
#if defined(WIN32) && !defined(__MINGW32__)
|
||||||
|
if(fp) {
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("\n** Cannot product techtree translation file [%s] for techPath [%s] techName [%s] because the file already exists!\n",translationFile.c_str(),techPath.c_str(), techName.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("----------------------------------------------------------------");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void runTechTranslationExtraction(int argc, char** argv) {
|
||||||
|
//disableBacktrace=true;
|
||||||
|
printf("====== Started Translation Extraction ======\n");
|
||||||
|
|
||||||
|
bool purgeDuplicateFiles = false;
|
||||||
|
bool showDuplicateFiles = true;
|
||||||
|
bool purgeUnusedFiles = false;
|
||||||
|
bool svnPurgeFiles = false;
|
||||||
|
|
||||||
|
double purgedMegaBytes=0;
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
|
||||||
|
// Did the user pass a specific list of factions to validate?
|
||||||
|
std::vector<string> filteredFactionList;
|
||||||
|
|
||||||
|
vector<string> results;
|
||||||
|
findDirs(config.getPathListForType(ptTechs), results);
|
||||||
|
vector<string> techTreeFiles = results;
|
||||||
|
// Did the user pass a specific list of techtrees to validate?
|
||||||
|
std::vector<string> filteredTechTreeList;
|
||||||
|
if(hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_TRANSLATE_TECHTREES]) + string("=")) == true) {
|
||||||
|
int foundParamIndIndex = -1;
|
||||||
|
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_TRANSLATE_TECHTREES]) + string("="),&foundParamIndIndex);
|
||||||
|
string filterList = argv[foundParamIndIndex];
|
||||||
|
vector<string> paramPartTokens;
|
||||||
|
Tokenize(filterList,paramPartTokens,"=");
|
||||||
|
if(paramPartTokens.size() >= 2) {
|
||||||
|
string techtreeList = paramPartTokens[1];
|
||||||
|
Tokenize(techtreeList,filteredTechTreeList,",");
|
||||||
|
|
||||||
|
if(filteredTechTreeList.empty() == false) {
|
||||||
|
printf("Filtering techtrees and only looking for the following:\n");
|
||||||
|
for(int idx = 0; idx < filteredTechTreeList.size(); ++idx) {
|
||||||
|
filteredTechTreeList[idx] = trim(filteredTechTreeList[idx]);
|
||||||
|
printf("%s\n",filteredTechTreeList[idx].c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(paramPartTokens.size() >= 3) {
|
||||||
|
// if(paramPartTokens[2] == "purgeunused") {
|
||||||
|
// purgeUnusedFiles = true;
|
||||||
|
// printf("*NOTE All unused techtree files will be deleted!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[2] == "purgeduplicates") {
|
||||||
|
// purgeDuplicateFiles = true;
|
||||||
|
// printf("*NOTE All duplicate techtree files will be merged!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[2] == "svndelete") {
|
||||||
|
// svnPurgeFiles = true;
|
||||||
|
// printf("*NOTE All unused / duplicate techtree files will be removed from svn!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[2] == "hideduplicates") {
|
||||||
|
// showDuplicateFiles = false;
|
||||||
|
// printf("*NOTE All duplicate techtree files will NOT be shown!\n");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(paramPartTokens.size() >= 4) {
|
||||||
|
// if(paramPartTokens[3] == "purgeunused") {
|
||||||
|
// purgeUnusedFiles = true;
|
||||||
|
// printf("*NOTE All unused techtree files will be deleted!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[3] == "purgeduplicates") {
|
||||||
|
// purgeDuplicateFiles = true;
|
||||||
|
// printf("*NOTE All duplicate techtree files will be merged!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[3] == "svndelete") {
|
||||||
|
// svnPurgeFiles = true;
|
||||||
|
// printf("*NOTE All unused / duplicate techtree files will be removed from svn!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[3] == "hideduplicates") {
|
||||||
|
// showDuplicateFiles = false;
|
||||||
|
// printf("*NOTE All duplicate techtree files will NOT be shown!\n");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(paramPartTokens.size() >= 5) {
|
||||||
|
// if(paramPartTokens[4] == "purgeunused") {
|
||||||
|
// purgeUnusedFiles = true;
|
||||||
|
// printf("*NOTE All unused techtree files will be deleted!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[4] == "purgeduplicates") {
|
||||||
|
// purgeDuplicateFiles = true;
|
||||||
|
// printf("*NOTE All duplicate techtree files will be merged!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[4] == "svndelete") {
|
||||||
|
// svnPurgeFiles = true;
|
||||||
|
// printf("*NOTE All unused / duplicate techtree files will be removed from svn!\n");
|
||||||
|
// }
|
||||||
|
// else if(paramPartTokens[4] == "hideduplicates") {
|
||||||
|
// showDuplicateFiles = false;
|
||||||
|
// printf("*NOTE All duplicate techtree files will NOT be shown!\n");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
printf("\n---------------- Loading factions inside world ----------------");
|
||||||
|
World world;
|
||||||
|
|
||||||
|
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||||
|
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||||
|
string &techPath = techPaths[idx];
|
||||||
|
endPathWithSlash(techPath);
|
||||||
|
|
||||||
|
//printf("techPath [%s]\n",techPath.c_str());
|
||||||
|
|
||||||
|
for(int idx2 = 0; idx2 < techTreeFiles.size(); idx2++) {
|
||||||
|
string &techName = techTreeFiles[idx2];
|
||||||
|
|
||||||
|
if( filteredTechTreeList.empty() == true ||
|
||||||
|
std::find(filteredTechTreeList.begin(),filteredTechTreeList.end(),techName) != filteredTechTreeList.end()) {
|
||||||
|
|
||||||
|
runTechTranslationExtractionForPath(techPath, techName,
|
||||||
|
filteredFactionList,world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n====== Finished Translation ======\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void runTechValidationReport(int argc, char** argv) {
|
void runTechValidationReport(int argc, char** argv) {
|
||||||
//disableBacktrace=true;
|
//disableBacktrace=true;
|
||||||
printf("====== Started Validation ======\n");
|
printf("====== Started Validation ======\n");
|
||||||
@@ -3290,6 +3545,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == true ||
|
||||||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_TRANSLATE_TECHTREES]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_MAPS]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_MAPS]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TECHTRESS]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TECHTRESS]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_SCENARIOS]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_SCENARIOS]) == true ||
|
||||||
@@ -3414,6 +3670,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == true ||
|
||||||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_TRANSLATE_TECHTREES]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_MAPS]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_MAPS]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TECHTRESS]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TECHTRESS]) == true ||
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_SCENARIOS]) == true ||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_SCENARIOS]) == true ||
|
||||||
@@ -3471,6 +3728,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == false &&
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == false &&
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) == false &&
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_SCENARIO]) == false &&
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == false &&
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == false &&
|
||||||
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_TRANSLATE_TECHTREES]) == false &&
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_MAPS]) == false &&
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_MAPS]) == false &&
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TECHTRESS]) == false &&
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_TECHTRESS]) == false &&
|
||||||
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_SCENARIOS]) == false &&
|
hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LIST_SCENARIOS]) == false &&
|
||||||
@@ -4935,6 +5193,13 @@ int glestMain(int argc, char** argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_TRANSLATE_TECHTREES]) == true) {
|
||||||
|
runTechTranslationExtraction(argc, argv);
|
||||||
|
delete mainWindow;
|
||||||
|
mainWindow=NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == true) {
|
if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TILESET]) == true) {
|
||||||
runTilesetValidationReport(argc, argv);
|
runTilesetValidationReport(argc, argv);
|
||||||
|
|
||||||
|
@@ -51,6 +51,13 @@ ResourceType::~ResourceType() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string ResourceType::getName(bool translatedValue) const {
|
||||||
|
if(translatedValue == false) return name;
|
||||||
|
|
||||||
|
Lang &lang = Lang::getInstance();
|
||||||
|
return lang.getTechTreeString("ResourceTypeName_" + name,name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum,
|
void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtreeChecksum,
|
||||||
std::map<string,vector<pair<string, string> > > &loadedFileList, string techtreePath) {
|
std::map<string,vector<pair<string, string> > > &loadedFileList, string techtreePath) {
|
||||||
|
|
||||||
@@ -64,7 +71,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||||||
name= lastDir(dir);
|
name= lastDir(dir);
|
||||||
|
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,Lang::getInstance().get("LogScreenGameLoadingResourceType","",true).c_str(),formatString(name).c_str());
|
snprintf(szBuf,8096,Lang::getInstance().get("LogScreenGameLoadingResourceType","",true).c_str(),formatString(getName(true)).c_str());
|
||||||
Logger::getInstance().add(szBuf, true);
|
Logger::getInstance().add(szBuf, true);
|
||||||
|
|
||||||
string currentPath = dir;
|
string currentPath = dir;
|
||||||
@@ -188,13 +195,6 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string ResourceType::getName(bool translatedValue) const {
|
|
||||||
if(translatedValue == false) return name;
|
|
||||||
|
|
||||||
Lang &lang = Lang::getInstance();
|
|
||||||
return lang.getTechTreeString("ResourceTypeName_" + name,name.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== misc ====================
|
// ==================== misc ====================
|
||||||
|
|
||||||
ResourceClass ResourceType::strToRc(const string &s){
|
ResourceClass ResourceType::strToRc(const string &s){
|
||||||
|
@@ -45,6 +45,13 @@ TechTree::TechTree(const vector<string> pathList) {
|
|||||||
attackTypes.clear();
|
attackTypes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string TechTree::getName(bool translatedValue) const {
|
||||||
|
if(translatedValue == false) return name;
|
||||||
|
|
||||||
|
Lang &lang = Lang::getInstance();
|
||||||
|
return lang.getTechTreeString("TechTreeName",name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
Checksum TechTree::loadTech(const string &techName,
|
Checksum TechTree::loadTech(const string &techName,
|
||||||
set<string> &factions, Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
|
set<string> &factions, Checksum* checksum, std::map<string,vector<pair<string, string> > > &loadedFileList) {
|
||||||
name = "";
|
name = "";
|
||||||
@@ -90,8 +97,11 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
treePath = currentPath;
|
treePath = currentPath;
|
||||||
name= lastDir(currentPath);
|
name= lastDir(currentPath);
|
||||||
|
|
||||||
|
Lang &lang = Lang::getInstance();
|
||||||
|
lang.loadTechTreeStrings(name);
|
||||||
|
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,Lang::getInstance().get("LogScreenGameLoadingTechtree","",true).c_str(),formatString(name).c_str());
|
snprintf(szBuf,8096,Lang::getInstance().get("LogScreenGameLoadingTechtree","",true).c_str(),formatString(getName(true)).c_str());
|
||||||
Logger::getInstance().add(szBuf, true);
|
Logger::getInstance().add(szBuf, true);
|
||||||
|
|
||||||
vector<string> filenames;
|
vector<string> filenames;
|
||||||
@@ -237,9 +247,6 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
*techtreeChecksum = checksumValue;
|
*techtreeChecksum = checksumValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lang &lang = Lang::getInstance();
|
|
||||||
lang.loadTechTreeStrings(name);
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ public:
|
|||||||
int getTypeCount() const {return factionTypes.size();}
|
int getTypeCount() const {return factionTypes.size();}
|
||||||
const FactionType *getType(int i) const {return &factionTypes[i];}
|
const FactionType *getType(int i) const {return &factionTypes[i];}
|
||||||
const ResourceType *getResourceType(int i) const {return &resourceTypes[i];}
|
const ResourceType *getResourceType(int i) const {return &resourceTypes[i];}
|
||||||
const string getName() const {return name;}
|
string getName(bool translatedValue=false) const;
|
||||||
vector<string> getPathList() const {return pathList;}
|
vector<string> getPathList() const {return pathList;}
|
||||||
//const string &getDesc() const {return desc;}
|
//const string &getDesc() const {return desc;}
|
||||||
|
|
||||||
@@ -81,8 +81,15 @@ public:
|
|||||||
const ResourceType *getResourceType(const string &name) const;
|
const ResourceType *getResourceType(const string &name) const;
|
||||||
const ResourceType *getTechResourceType(int i) const;
|
const ResourceType *getTechResourceType(int i) const;
|
||||||
const ResourceType *getFirstTechResourceType() const;
|
const ResourceType *getFirstTechResourceType() const;
|
||||||
const ArmorType *getArmorType(const string &name) const;
|
|
||||||
|
const ArmorType *getArmorType(const string &name) const;
|
||||||
const AttackType *getAttackType(const string &name) const;
|
const AttackType *getAttackType(const string &name) const;
|
||||||
|
|
||||||
|
int getArmorTypeCount() const { return armorTypes.size(); }
|
||||||
|
const ArmorType * getArmorTypeByIndex(int index) const { return &armorTypes[index]; }
|
||||||
|
int getAttackTypeCount() const { return attackTypes.size(); }
|
||||||
|
const AttackType * getAttackTypeByIndex(int index) const { return &attackTypes[index]; }
|
||||||
|
|
||||||
float getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
|
float getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
|
||||||
std::vector<std::string> validateFactionTypes();
|
std::vector<std::string> validateFactionTypes();
|
||||||
std::vector<std::string> validateResourceTypes();
|
std::vector<std::string> validateResourceTypes();
|
||||||
|
@@ -50,6 +50,8 @@ const char *GAME_ARGS[] = {
|
|||||||
"--validate-scenario",
|
"--validate-scenario",
|
||||||
"--validate-tileset",
|
"--validate-tileset",
|
||||||
|
|
||||||
|
"--translate-techtrees",
|
||||||
|
|
||||||
"--list-maps",
|
"--list-maps",
|
||||||
"--list-techtrees",
|
"--list-techtrees",
|
||||||
"--list-scenarios",
|
"--list-scenarios",
|
||||||
@@ -123,6 +125,8 @@ enum GAME_ARG_TYPE {
|
|||||||
GAME_ARG_VALIDATE_SCENARIO,
|
GAME_ARG_VALIDATE_SCENARIO,
|
||||||
GAME_ARG_VALIDATE_TILESET,
|
GAME_ARG_VALIDATE_TILESET,
|
||||||
|
|
||||||
|
GAME_ARG_TRANSLATE_TECHTREES,
|
||||||
|
|
||||||
GAME_ARG_LIST_MAPS,
|
GAME_ARG_LIST_MAPS,
|
||||||
GAME_ARG_LIST_TECHTRESS,
|
GAME_ARG_LIST_TECHTRESS,
|
||||||
GAME_ARG_LIST_SCENARIOS,
|
GAME_ARG_LIST_SCENARIOS,
|
||||||
@@ -308,6 +312,11 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
|||||||
printf("\n \t\texample:");
|
printf("\n \t\texample:");
|
||||||
printf("\n %s %s=desert2",extractFileFromDirectoryPath(argv0).c_str(),GAME_ARGS[GAME_ARG_VALIDATE_TILESET]);
|
printf("\n %s %s=desert2",extractFileFromDirectoryPath(argv0).c_str(),GAME_ARGS[GAME_ARG_VALIDATE_TILESET]);
|
||||||
|
|
||||||
|
printf("\n%s=x",GAME_ARGS[GAME_ARG_TRANSLATE_TECHTREES]);
|
||||||
|
printf("\n \t\tProduces a deafult lng file for the specified techtree");
|
||||||
|
printf("\n \t\tto prepare for translation into other languages.");
|
||||||
|
printf("\n \t\tWhere x is a techtree name");
|
||||||
|
|
||||||
printf("\n%s=x",GAME_ARGS[GAME_ARG_LIST_MAPS]);
|
printf("\n%s=x",GAME_ARGS[GAME_ARG_LIST_MAPS]);
|
||||||
printf("\n \t\tdisplay a list of game content: maps");
|
printf("\n \t\tdisplay a list of game content: maps");
|
||||||
printf("\n \t\twhere x is an optional name filter.");
|
printf("\n \t\twhere x is an optional name filter.");
|
||||||
|
Reference in New Issue
Block a user