diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index cbef2066..74aa619b 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -209,6 +209,28 @@ string formatString(const string &str){ return outStr; } +string getGameCustomCoreDataPath(string originalBasePath, string uniqueFilePath) { + if(originalBasePath != "") { + endPathWithSlash(originalBasePath); + } + + string result = originalBasePath + uniqueFilePath; + //string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); + Config &config = Config::getInstance(); + string data_path = config.getString("UserData_Root",""); + if(data_path != "") { + endPathWithSlash(data_path); + } + + if(data_path != "" && + (uniqueFilePath == "" || fileExists(data_path + uniqueFilePath) == true)) { + result = data_path + uniqueFilePath; + } + + //printf("data_path [%s] result [%s]\n",data_path.c_str(),result.c_str()); + return result; +} + string getGameReadWritePath(string lookupKey) { string path = ""; diff --git a/source/glest_game/facilities/game_util.h b/source/glest_game/facilities/game_util.h index b531f3ba..d79196e1 100644 --- a/source/glest_game/facilities/game_util.h +++ b/source/glest_game/facilities/game_util.h @@ -43,6 +43,7 @@ string getCompileDateTime(); string formatString(const string &str); string getGameReadWritePath(string lookupKey=""); +string getGameCustomCoreDataPath(string originalBasePath, string uniqueFilePath); }}//end namespace diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 755698d8..0e680a56 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -223,7 +223,7 @@ void Game::endGame() { logger.loadLoadingScreen(""); logger.setState(Lang::getInstance().get("Deleting")); //logger.add("Game", true); - logger.add("Game", false); + logger.add(Lang::getInstance().get("LogScreenGameLoading"), false); logger.hideProgress(); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -286,7 +286,7 @@ Game::~Game() { logger.loadLoadingScreen(""); logger.setState(Lang::getInstance().get("Deleting")); //logger.add("Game", true); - logger.add("Game", false); + logger.add(Lang::getInstance().get("LogScreenGameLoading"), false); logger.hideProgress(); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -889,7 +889,9 @@ void Game::init(bool initForPreviewOnly) { Faction *faction= world.getFaction(i); if(faction->getCpuControl(enableServerControlledAI,isNetworkGame,role) == true) { aiInterfaces[i]= new AiInterface(*this, i, faction->getTeam()); - logger.add("Creating AI for faction " + intToStr(i), true); + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingCreatingAIFaction","",true).c_str(),i); + logger.add(szBuf, true); } else { aiInterfaces[i]= NULL; @@ -910,15 +912,15 @@ void Game::init(bool initForPreviewOnly) { if(withRainEffect){ //weather particle systems - if(world.getTileset()->getWeather() == wRainy){ - logger.add("Creating rain particle system", true); + if(world.getTileset()->getWeather() == wRainy) { + logger.add(Lang::getInstance().get("LogScreenGameLoadingCreatingRainParticles"), true); weatherParticleSystem= new RainParticleSystem(); weatherParticleSystem->setSpeed(12.f / GameConstants::updateFps); weatherParticleSystem->setPos(gameCamera.getPos()); renderer.manageParticleSystem(weatherParticleSystem, rsGame); } - else if(world.getTileset()->getWeather() == wSnowy){ - logger.add("Creating snow particle system", true); + else if(world.getTileset()->getWeather() == wSnowy) { + logger.add(Lang::getInstance().get("LogScreenGameLoadingCreatingSnowParticles"), true); weatherParticleSystem= new SnowParticleSystem(1200); weatherParticleSystem->setSpeed(1.5f / GameConstants::updateFps); weatherParticleSystem->setPos(gameCamera.getPos()); @@ -930,7 +932,7 @@ void Game::init(bool initForPreviewOnly) { //init renderer state if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Initializing renderer\n",__FILE__,__FUNCTION__); - logger.add("Initializing renderer", true); + logger.add(Lang::getInstance().get("LogScreenGameLoadingInitRenderer"), true); renderer.initGame(this); for(int i=0; i < world.getFactionCount(); ++i) { @@ -949,13 +951,13 @@ void Game::init(bool initForPreviewOnly) { SDL_PumpEvents(); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Waiting for network\n",__FILE__,__FUNCTION__); - logger.add("Waiting for network players", true); + logger.add(Lang::getInstance().get("LogScreenGameLoadingWaitForNetworkPlayers"), true); networkManager.getGameNetworkInterface()->waitUntilReady(&checksum); //std::string worldLog = world.DumpWorldToLog(true); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Starting music stream\n",__FILE__,__FUNCTION__,__LINE__); - logger.add("Starting music stream", true); + logger.add(Lang::getInstance().get("LogScreenGameLoadingStartingMusic"), true); if(this->masterserverMode == false) { if(world.getThisFaction() == NULL) { @@ -979,7 +981,7 @@ void Game::init(bool initForPreviewOnly) { //rain if(tileset->getWeather() == wRainy && ambientSounds->isEnabledRain()) { - logger.add("Starting ambient stream", true); + logger.add(Lang::getInstance().get("LogScreenGameLoadingStartingAmbient"), true); currentAmbientSound = ambientSounds->getRain(); //printf("In [%s:%s] Line: %d currentAmbientSound = [%p]\n",__FILE__,__FUNCTION__,__LINE__,currentAmbientSound); soundRenderer.playAmbient(currentAmbientSound); @@ -987,7 +989,7 @@ void Game::init(bool initForPreviewOnly) { //snow if(tileset->getWeather() == wSnowy && ambientSounds->isEnabledSnow()) { - logger.add("Starting ambient stream", true); + logger.add(Lang::getInstance().get("LogScreenGameLoadingStartingAmbient"), true); currentAmbientSound = ambientSounds->getSnow(); //printf("In [%s:%s] Line: %d currentAmbientSound = [%p]\n",__FILE__,__FUNCTION__,__LINE__,currentAmbientSound); soundRenderer.playAmbient(currentAmbientSound); @@ -998,7 +1000,7 @@ void Game::init(bool initForPreviewOnly) { soundRenderer.playMusic(gameMusic); } - logger.add("Launching game"); + logger.add(Lang::getInstance().get("LogScreenGameLoadingLaunchGame")); } logger.setCancelLoadingEnabled(false); @@ -1384,7 +1386,10 @@ void Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRo if(faction->getType()->getPersonalityType() != fpt_Observer) { faction->setControlType(ctCpu); aiInterfaces[i] = new AiInterface(*this, i, faction->getTeam(), faction->getStartLocationIndex()); - logger.add("Creating AI for faction " + intToStr(i), true); + + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingCreatingAIFaction","",true).c_str(),i); + logger.add(szBuf, true); Lang &lang= Lang::getInstance(); string msg = "Player #%d [%s] has disconnected, switching player to AI mode!"; diff --git a/source/glest_game/global/core_data.cpp b/source/glest_game/global/core_data.cpp index 94718d06..4b3c906c 100644 --- a/source/glest_game/global/core_data.cpp +++ b/source/glest_game/global/core_data.cpp @@ -88,8 +88,8 @@ void CoreData::load() { endPathWithSlash(data_path); } - const string dir = data_path + "data/core"; - Logger::getInstance().add("Core data"); + //const string dir = data_path + "data/core"; + Logger::getInstance().add(Lang::getInstance().get("LogScreenCoreDataLoading")); Renderer &renderer= Renderer::getInstance(); @@ -97,21 +97,21 @@ void CoreData::load() { backgroundTexture= renderer.newTexture2D(rsGlobal); if(backgroundTexture) { backgroundTexture->setMipmap(false); - backgroundTexture->getPixmap()->load(dir+"/menu/textures/back.tga"); + backgroundTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/back.tga")); } fireTexture= renderer.newTexture2D(rsGlobal); if(fireTexture) { fireTexture->setFormat(Texture::fAlpha); fireTexture->getPixmap()->init(1); - fireTexture->getPixmap()->load(dir+"/misc_textures/fire_particle.tga"); + fireTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/fire_particle.tga")); } teamColorTexture= renderer.newTexture2D(rsGlobal); if(teamColorTexture) { teamColorTexture->setFormat(Texture::fAlpha); teamColorTexture->getPixmap()->init(1); - teamColorTexture->getPixmap()->load(dir+"/misc_textures/team_color_texture.tga"); + teamColorTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/team_color_texture.tga")); } snowTexture= renderer.newTexture2D(rsGlobal); @@ -119,36 +119,40 @@ void CoreData::load() { snowTexture->setMipmap(false); snowTexture->setFormat(Texture::fAlpha); snowTexture->getPixmap()->init(1); - snowTexture->getPixmap()->load(dir+"/misc_textures/snow_particle.tga"); + snowTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/snow_particle.tga")); } customTexture= renderer.newTexture2D(rsGlobal); if(customTexture) { - customTexture->getPixmap()->load(dir+"/menu/textures/custom_texture.tga"); + customTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/custom_texture.tga")); } notOnServerTexture= renderer.newTexture2D(rsGlobal); if(notOnServerTexture) { - notOnServerTexture->getPixmap()->load(dir+"/menu/textures/not_on_server.tga"); + notOnServerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/not_on_server.tga")); } onServerDifferentTexture= renderer.newTexture2D(rsGlobal); if(onServerDifferentTexture) { - onServerDifferentTexture->getPixmap()->load(dir+"/menu/textures/on_server_different.tga"); + onServerDifferentTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server_different.tga")); + onServerTexture= renderer.newTexture2D(rsGlobal); - onServerTexture->getPixmap()->load(dir+"/menu/textures/on_server.tga"); + onServerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server.tga")); + onServerInstalledTexture= renderer.newTexture2D(rsGlobal); - onServerInstalledTexture->getPixmap()->load(dir+"/menu/textures/on_server_installed.tga"); + onServerInstalledTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server_installed.tga")); } logoTexture= renderer.newTexture2D(rsGlobal); if(logoTexture) { logoTexture->setMipmap(false); - logoTexture->getPixmap()->load(dir+"/menu/textures/logo.tga"); + logoTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/logo.tga")); } logoTextureList.clear(); - string logosPath= dir+"/menu/textures/logo*.*"; + + + string logosPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/textures/logo*.*"; vector logoFilenames; findAll(logosPath, logoFilenames, false, false); for(int i = 0; i < logoFilenames.size(); ++i) { @@ -157,14 +161,32 @@ void CoreData::load() { Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); if(logoTextureExtra) { logoTextureExtra->setMipmap(true); - logoTextureExtra->getPixmap()->load(dir+"/menu/textures/" + logo); + logoTextureExtra->getPixmap()->load(logosPath + "data/core/menu/textures/" + logo); logoTextureList.push_back(logoTextureExtra); } } } + if(logoTextureList.size() == 0) { + logosPath= data_path + "data/core/menu/textures/logo*.*"; + vector logoFilenames; + findAll(logosPath, logoFilenames, false, false); + for(int i = 0; i < logoFilenames.size(); ++i) { + string logo = logoFilenames[i]; + if(strcmp("logo.tga",logo.c_str()) != 0) { + Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); + if(logoTextureExtra) { + logoTextureExtra->setMipmap(true); + logoTextureExtra->getPixmap()->load(data_path + "data/core/menu/textures/" + logo); + logoTextureList.push_back(logoTextureExtra); + } + } + } + } + miscTextureList.clear(); - string introPath= dir+"/menu/textures/intro*.*"; + + string introPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/textures/intro*.*"; vector introFilenames; findAll(introPath, introFilenames, false, false); for(int i = 0; i < introFilenames.size(); ++i) { @@ -173,59 +195,75 @@ void CoreData::load() { Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); if(logoTextureExtra) { logoTextureExtra->setMipmap(true); - logoTextureExtra->getPixmap()->load(dir+"/menu/textures/" + logo); + logoTextureExtra->getPixmap()->load(introPath + "data/core/menu/textures/" + logo); miscTextureList.push_back(logoTextureExtra); } //} } + if(logoTextureList.size() == 0) { + introPath= data_path + "data/core/menu/textures/intro*.*"; + vector introFilenames; + findAll(introPath, introFilenames, false, false); + for(int i = 0; i < introFilenames.size(); ++i) { + string logo = introFilenames[i]; + //if(strcmp("logo.tga",logo.c_str()) != 0) { + Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); + if(logoTextureExtra) { + logoTextureExtra->setMipmap(true); + logoTextureExtra->getPixmap()->load(data_path + "data/core/menu/textures/" + logo); + miscTextureList.push_back(logoTextureExtra); + } + //} + } + } waterSplashTexture= renderer.newTexture2D(rsGlobal); if(waterSplashTexture) { waterSplashTexture->setFormat(Texture::fAlpha); waterSplashTexture->getPixmap()->init(1); - waterSplashTexture->getPixmap()->load(dir+"/misc_textures/water_splash.tga"); + waterSplashTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/water_splash.tga")); } buttonSmallTexture= renderer.newTexture2D(rsGlobal); if(buttonSmallTexture) { buttonSmallTexture->setForceCompressionDisabled(true); - buttonSmallTexture->getPixmap()->load(dir+"/menu/textures/button_small.tga"); + buttonSmallTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/button_small.tga")); } buttonBigTexture= renderer.newTexture2D(rsGlobal); if(buttonBigTexture) { buttonBigTexture->setForceCompressionDisabled(true); - buttonBigTexture->getPixmap()->load(dir+"/menu/textures/button_big.tga"); + buttonBigTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/button_big.tga")); } horizontalLineTexture= renderer.newTexture2D(rsGlobal); if(horizontalLineTexture) { horizontalLineTexture->setForceCompressionDisabled(true); - horizontalLineTexture->getPixmap()->load(dir+"/menu/textures/line_horizontal.tga"); + horizontalLineTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/line_horizontal.tga")); } verticalLineTexture= renderer.newTexture2D(rsGlobal); if(verticalLineTexture) { verticalLineTexture->setForceCompressionDisabled(true); - verticalLineTexture->getPixmap()->load(dir+"/menu/textures/line_vertical.tga"); + verticalLineTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/line_vertical.tga")); } checkBoxTexture= renderer.newTexture2D(rsGlobal); if(checkBoxTexture) { checkBoxTexture->setForceCompressionDisabled(true); - checkBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox.tga"); + checkBoxTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/checkbox.tga")); } checkedCheckBoxTexture= renderer.newTexture2D(rsGlobal); if(checkedCheckBoxTexture) { checkedCheckBoxTexture->setForceCompressionDisabled(true); - checkedCheckBoxTexture->getPixmap()->load(dir+"/menu/textures/checkbox_checked.tga"); + checkedCheckBoxTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/checkbox_checked.tga")); } gameWinnerTexture= renderer.newTexture2D(rsGlobal); if(gameWinnerTexture) { gameWinnerTexture->setForceCompressionDisabled(true); - gameWinnerTexture->getPixmap()->load(dir+"/misc_textures/game_winner.png"); + gameWinnerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/game_winner.png")); } loadFonts(); @@ -233,15 +271,15 @@ void CoreData::load() { //sounds XmlTree xmlTree; //string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); - xmlTree.load(data_path + "data/core/menu/menu.xml",Properties::getTagReplacementValues()); + xmlTree.load(getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml"),Properties::getTagReplacementValues()); const XmlNode *menuNode= xmlTree.getRootNode(); const XmlNode *introNode= menuNode->getChild("intro"); - clickSoundA.load(dir+"/menu/sound/click_a.wav"); - clickSoundB.load(dir+"/menu/sound/click_b.wav"); - clickSoundC.load(dir+"/menu/sound/click_c.wav"); - attentionSound.load(dir+"/menu/sound/attention.wav"); - highlightSound.load(dir+"/menu/sound/highlight.wav"); + clickSoundA.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_a.wav")); + clickSoundB.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_b.wav")); + clickSoundC.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_c.wav")); + attentionSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/attention.wav")); + highlightSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/highlight.wav")); // intro info const XmlNode *menuPathNode= introNode->getChild("menu-music-path"); @@ -251,9 +289,9 @@ void CoreData::load() { const XmlNode *menuMusicNode= introNode->getChild("menu-music"); string menuMusicFile = menuMusicNode->getAttribute("value")->getRestrictedValue(); - introMusic.open(dir + menuMusicPath + menuIntroMusicFile); + introMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuIntroMusicFile)); introMusic.setNext(&menuMusic); - menuMusic.open(dir + menuMusicPath + menuMusicFile); + menuMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuMusicFile)); menuMusic.setNext(&menuMusic); waterSounds.resize(6); @@ -261,7 +299,7 @@ void CoreData::load() { for(int i=0; i<6; ++i){ waterSounds[i]= new StaticSound(); if(waterSounds[i]) { - waterSounds[i]->load(dir+"/water_sounds/water"+intToStr(i)+".wav"); + waterSounds[i]->load(getGameCustomCoreDataPath(data_path, "data/core/water_sounds/water"+intToStr(i)+".wav")); } } @@ -296,22 +334,28 @@ void CoreData::loadFonts() { if(displayFont) { renderer.endFont(displayFont, rsGlobal); + displayFont=NULL; } - displayFont= renderer.newFont(rsGlobal); - if(displayFont) { - displayFont->setType(displayFontName,config.getString("FontDisplay","")); - displayFont->setSize(displayFontSize); - //displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == false) { + displayFont= renderer.newFont(rsGlobal); + if(displayFont) { + displayFont->setType(displayFontName,config.getString("FontDisplay","")); + displayFont->setSize(displayFontSize); + //displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(displayFont3D) { renderer.endFont(displayFont3D, rsGlobal); + displayFont3D=NULL; } - displayFont3D= renderer.newFont3D(rsGlobal); - if(displayFont3D) { - displayFont3D->setType(displayFontName,config.getString("FontDisplay","")); - displayFont3D->setSize(displayFontSize); - //displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == true) { + displayFont3D= renderer.newFont3D(rsGlobal); + if(displayFont3D) { + displayFont3D->setType(displayFontName,config.getString("FontDisplay","")); + displayFont3D->setSize(displayFontSize); + //displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontName = [%s] displayFontSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontName.c_str(),displayFontSize); @@ -335,22 +379,28 @@ void CoreData::loadFonts() { if(displayFontSmall) { renderer.endFont(displayFontSmall, rsGlobal); + displayFontSmall=NULL; } - displayFontSmall= renderer.newFont(rsGlobal); - if(displayFontSmall) { - displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); - displayFontSmall->setSize(displayFontNameSmallSize); - //displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == false) { + displayFontSmall= renderer.newFont(rsGlobal); + if(displayFontSmall) { + displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); + displayFontSmall->setSize(displayFontNameSmallSize); + //displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(displayFontSmall3D) { renderer.endFont(displayFontSmall3D, rsGlobal); + displayFontSmall3D=NULL; } - displayFontSmall3D= renderer.newFont3D(rsGlobal); - if(displayFontSmall3D) { - displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); - displayFontSmall3D->setSize(displayFontNameSmallSize); - //displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == true) { + displayFontSmall3D= renderer.newFont3D(rsGlobal); + if(displayFontSmall3D) { + displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); + displayFontSmall3D->setSize(displayFontNameSmallSize); + //displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontSmallName = [%s] displayFontSmallNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontNameSmall.c_str(),displayFontNameSmallSize); @@ -373,24 +423,30 @@ void CoreData::loadFonts() { if(menuFontNormal) { renderer.endFont(menuFontNormal, rsGlobal); + menuFontNormal=NULL; } - menuFontNormal= renderer.newFont(rsGlobal); - if(menuFontNormal) { - menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); - menuFontNormal->setSize(menuFontNameNormalSize); - menuFontNormal->setWidth(Font::wBold); - //menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == false) { + menuFontNormal= renderer.newFont(rsGlobal); + if(menuFontNormal) { + menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); + menuFontNormal->setSize(menuFontNameNormalSize); + menuFontNormal->setWidth(Font::wBold); + //menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(menuFontNormal3D) { renderer.endFont(menuFontNormal3D, rsGlobal); + menuFontNormal3D=NULL; } - menuFontNormal3D= renderer.newFont3D(rsGlobal); - if(menuFontNormal3D) { - menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); - menuFontNormal3D->setSize(menuFontNameNormalSize); - menuFontNormal3D->setWidth(Font::wBold); - //menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == true) { + menuFontNormal3D= renderer.newFont3D(rsGlobal); + if(menuFontNormal3D) { + menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); + menuFontNormal3D->setSize(menuFontNameNormalSize); + menuFontNormal3D->setWidth(Font::wBold); + //menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNormalName = [%s] menuFontNormalNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameNormal.c_str(),menuFontNameNormalSize); @@ -413,22 +469,28 @@ void CoreData::loadFonts() { if(menuFontBig) { renderer.endFont(menuFontBig, rsGlobal); + menuFontBig=NULL; } - menuFontBig= renderer.newFont(rsGlobal); - if(menuFontBig) { - menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig","")); - menuFontBig->setSize(menuFontNameBigSize); - //menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == false) { + menuFontBig= renderer.newFont(rsGlobal); + if(menuFontBig) { + menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig","")); + menuFontBig->setSize(menuFontNameBigSize); + //menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(menuFontBig3D) { renderer.endFont(menuFontBig3D, rsGlobal); + menuFontBig3D=NULL; } - menuFontBig3D= renderer.newFont3D(rsGlobal); - if(menuFontBig3D) { - menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig","")); - menuFontBig3D->setSize(menuFontNameBigSize); - //menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == true) { + menuFontBig3D= renderer.newFont3D(rsGlobal); + if(menuFontBig3D) { + menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig","")); + menuFontBig3D->setSize(menuFontNameBigSize); + //menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameBig = [%s] menuFontNameBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameBig.c_str(),menuFontNameBigSize); @@ -451,22 +513,28 @@ void CoreData::loadFonts() { if(menuFontVeryBig) { renderer.endFont(menuFontVeryBig, rsGlobal); + menuFontVeryBig=NULL; } - menuFontVeryBig= renderer.newFont(rsGlobal); - if(menuFontVeryBig) { - menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); - menuFontVeryBig->setSize(menuFontNameVeryBigSize); - //menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == false) { + menuFontVeryBig= renderer.newFont(rsGlobal); + if(menuFontVeryBig) { + menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); + menuFontVeryBig->setSize(menuFontNameVeryBigSize); + //menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(menuFontVeryBig3D) { renderer.endFont(menuFontVeryBig3D, rsGlobal); + menuFontVeryBig3D=NULL; } - menuFontVeryBig3D= renderer.newFont3D(rsGlobal); - if(menuFontVeryBig3D) { - menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); - menuFontVeryBig3D->setSize(menuFontNameVeryBigSize); - //menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == true) { + menuFontVeryBig3D= renderer.newFont3D(rsGlobal); + if(menuFontVeryBig3D) { + menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); + menuFontVeryBig3D->setSize(menuFontNameVeryBigSize); + //menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } //printf("CoreData menuFontVeryBig3D [%d] menuFontVeryBig3D [%p]\n",menuFontVeryBig3D->getSize(),menuFontVeryBig3D); @@ -492,22 +560,28 @@ void CoreData::loadFonts() { if(consoleFont) { renderer.endFont(consoleFont, rsGlobal); + consoleFont=NULL; } - consoleFont= renderer.newFont(rsGlobal); - if(consoleFont) { - consoleFont->setType(consoleFontName,config.getString("FontConsole","")); - consoleFont->setSize(consoleFontNameSize); - //consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == false) { + consoleFont= renderer.newFont(rsGlobal); + if(consoleFont) { + consoleFont->setType(consoleFontName,config.getString("FontConsole","")); + consoleFont->setSize(consoleFontNameSize); + //consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(consoleFont3D) { renderer.endFont(consoleFont3D, rsGlobal); + consoleFont3D=NULL; } - consoleFont3D= renderer.newFont3D(rsGlobal); - if(consoleFont3D) { - consoleFont3D->setType(consoleFontName,config.getString("FontConsole","")); - consoleFont3D->setSize(consoleFontNameSize); - //consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + if(Renderer::renderText3DEnabled == true) { + consoleFont3D= renderer.newFont3D(rsGlobal); + if(consoleFont3D) { + consoleFont3D->setType(consoleFontName,config.getString("FontConsole","")); + consoleFont3D->setSize(consoleFontNameSize); + //consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); + } } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] consoleFontName = [%s] consoleFontNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,consoleFontName.c_str(),consoleFontNameSize); diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index 81607de4..161e75c4 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -31,6 +31,7 @@ using namespace Shared::Platform; namespace Glest{ namespace Game{ +const char *DEFAULT_LANGUAGE = "english"; // ===================================================== // class Lang // ===================================================== @@ -45,10 +46,10 @@ Lang &Lang::getInstance() { return lang; } -void Lang::loadStrings(const string &language, bool loadFonts) { - bool languageChanged = (language != this->language); - this->language= language; - loadStrings(language, strings, true); +void Lang::loadStrings(const string &uselanguage, bool loadFonts) { + bool languageChanged = (uselanguage != this->language); + this->language= uselanguage; + loadStrings(uselanguage, strings, true); if(languageChanged == true) { Font::resetToDefaults(); @@ -161,10 +162,11 @@ void Lang::loadStrings(const string &language, bool loadFonts) { } } -void Lang::loadStrings(const string &language, Properties &properties, bool fileMustExist) { +void Lang::loadStrings(const string &uselanguage, Properties &properties, bool fileMustExist) { properties.clear(); string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); - string languageFile = data_path + "data/lang/" + language + ".lng"; + //string languageFile = data_path + "data/lang/" + uselanguage + ".lng"; + string languageFile = getGameCustomCoreDataPath(data_path, "data/lang/" + uselanguage + ".lng"); if(fileMustExist == false && fileExists(languageFile) == false) { return; } @@ -209,41 +211,52 @@ void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenario } } -bool Lang::hasString(const string &s, string language) { - bool hasString = false; +bool Lang::hasString(const string &s, string uselanguage, bool fallbackToDefault) { + bool result = false; try { - if(language != "") { - if(otherLanguageStrings.find(language) == otherLanguageStrings.end()) { - loadStrings(language, otherLanguageStrings[language], false); + if(uselanguage != "") { + //printf("#a fallbackToDefault = %d [%s] uselanguage [%s] DEFAULT_LANGUAGE [%s] this->language [%s]\n",fallbackToDefault,s.c_str(),uselanguage.c_str(),DEFAULT_LANGUAGE,this->language.c_str()); + if(otherLanguageStrings.find(uselanguage) == otherLanguageStrings.end()) { + loadStrings(uselanguage, otherLanguageStrings[uselanguage], false); } - string result = otherLanguageStrings[language].getString(s); - hasString = true; + string result2 = otherLanguageStrings[uselanguage].getString(s); + //printf("#b result2 [%s]\n",result2.c_str()); + + result = true; } else { - string result = strings.getString(s); - hasString = true; + string result2 = strings.getString(s); + result = true; } } catch(exception &ex) { if(strings.getpath() != "") { - if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] for language [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what(),language.c_str()); + if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] for uselanguage [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what(),uselanguage.c_str()); + } + + //printf("#1 fallbackToDefault = %d [%s] uselanguage [%s] DEFAULT_LANGUAGE [%s] this->language [%s]\n",fallbackToDefault,s.c_str(),uselanguage.c_str(),DEFAULT_LANGUAGE,this->language.c_str()); + if(fallbackToDefault == true && uselanguage != DEFAULT_LANGUAGE && this->language != DEFAULT_LANGUAGE) { + result = hasString(s, DEFAULT_LANGUAGE, false); + } + else { + } } - return hasString; + return result; } bool Lang::isLanguageLocal(string compareLanguage) const { return (compareLanguage == language); } -string Lang::get(const string &s, string language) { +string Lang::get(const string &s, string uselanguage, bool fallbackToDefault) { try { string result = ""; - if(language != "") { - if(otherLanguageStrings.find(language) == otherLanguageStrings.end()) { - loadStrings(language, otherLanguageStrings[language], false); + if(uselanguage != "") { + if(otherLanguageStrings.find(uselanguage) == otherLanguageStrings.end()) { + loadStrings(uselanguage, otherLanguageStrings[uselanguage], false); } - result = otherLanguageStrings[language].getString(s); + result = otherLanguageStrings[uselanguage].getString(s); replaceAll(result, "\\n", "\n"); } else { @@ -254,8 +267,14 @@ string Lang::get(const string &s, string language) { } catch(exception &ex) { if(strings.getpath() != "") { - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] language [%s] text [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what(),language.c_str(),s.c_str()); + if(fallbackToDefault == false || SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] uselanguage [%s] text [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what(),uselanguage.c_str(),s.c_str()); } + + //printf("#2 fallbackToDefault = %d [%s] uselanguage [%s] DEFAULT_LANGUAGE [%s] this->language [%s]\n",fallbackToDefault,s.c_str(),uselanguage.c_str(),DEFAULT_LANGUAGE,this->language.c_str()); + if(fallbackToDefault == true && uselanguage != DEFAULT_LANGUAGE && this->language != DEFAULT_LANGUAGE) { + return get(s, DEFAULT_LANGUAGE, false); + } + return "???" + s + "???"; } } diff --git a/source/glest_game/global/lang.h b/source/glest_game/global/lang.h index 1b39b4d0..88f70457 100644 --- a/source/glest_game/global/lang.h +++ b/source/glest_game/global/lang.h @@ -42,11 +42,11 @@ private: public: static Lang &getInstance(); - void loadStrings(const string &language, bool loadFonts=true); + void loadStrings(const string &uselanguage, bool loadFonts=true); void loadScenarioStrings(const string &scenarioDir, const string &scenarioName); - string get(const string &s,string language=""); - bool hasString(const string &s, string language=""); + string get(const string &s,string uselanguage="", bool fallbackToDefault=false); + bool hasString(const string &s, string uselanguage="", bool fallbackToDefault=false); string getScenarioString(const string &s); string getLanguage() const { return language; } diff --git a/source/glest_game/main/intro.cpp b/source/glest_game/main/intro.cpp index 0b890a32..3bb6382f 100644 --- a/source/glest_game/main/intro.cpp +++ b/source/glest_game/main/intro.cpp @@ -106,7 +106,7 @@ Intro::Intro(Program *program): XmlTree xmlTree; string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); - xmlTree.load(data_path + "data/core/menu/menu.xml",Properties::getTagReplacementValues()); + xmlTree.load(getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml"),Properties::getTagReplacementValues()); const XmlNode *menuNode= xmlTree.getRootNode(); const XmlNode *introNode= menuNode->getChild("intro"); @@ -160,19 +160,36 @@ Intro::Intro(Program *program): modelIndex = 0; models.clear(); if(showIntroModels == true) { - string introPath = data_path + "data/core/menu/main_model/intro*.g3d"; + + //getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml") + string introPath = getGameCustomCoreDataPath(data_path, "") + "data/core/menu/main_model/intro*.g3d"; vector introModels; findAll(introPath, introModels, false, false); for(int i = 0; i < introModels.size(); ++i) { string logo = introModels[i]; Model *model= renderer.newModel(rsMenu); if(model) { - model->load(data_path + "data/core/menu/main_model/" + logo); + model->load(introPath + "data/core/menu/main_model/" + logo); models.push_back(model); //printf("model [%s]\n",model->getFileName().c_str()); } } + if(models.size() == 0) { + introPath = data_path + "data/core/menu/main_model/intro*.g3d"; + //vector introModels; + findAll(introPath, introModels, false, false); + for(int i = 0; i < introModels.size(); ++i) { + string logo = introModels[i]; + Model *model= renderer.newModel(rsMenu); + if(model) { + model->load(data_path + "data/core/menu/main_model/" + logo); + models.push_back(model); + //printf("model [%s]\n",model->getFileName().c_str()); + } + } + } + if(showIntroModelsRandom == true) { std::vector modelList; @@ -202,6 +219,144 @@ Intro::Intro(Program *program): int appear= Intro::appearTime; int disappear= Intro::showTime+Intro::appearTime+(Intro::disapearTime * 2); + const int maxIntroLines = 100; + Lang &lang= Lang::getInstance(); + for(unsigned int i = 1; i < maxIntroLines; ++i) { + string introTagName = "IntroText" + intToStr(i); + string introTagTextureName = "IntroTexture" + intToStr(i); + + if(lang.hasString(introTagName,"",true) == true || + lang.hasString(introTagTextureName,"",true) == true) { + string lineText = ""; + + if(lang.hasString(introTagName,"",true) == true) { + lineText = lang.get(introTagName,"",true); + } + + string showStartTime = "IntroStartMilliseconds" + intToStr(i); + + int displayTime = appear; + if(lang.hasString(showStartTime,"",true) == true) { + displayTime = strToInt(lang.get(showStartTime,"",true)); + } + else { + if(i == 1) { + displayTime = appear; + } + else if(i == 2) { + displayTime = disappear; + } + else if(i >= 3) { + displayTime = disappear *(++displayItemNumber); + } + } + + // Is this a texture? + if(lang.hasString(introTagName,"",true) == false && + lang.hasString(introTagTextureName,"",true) == true) { + + string introTagTextureWidthName = "IntroTextureWidth" + intToStr(i); + string introTagTextureHeightName = "IntroTextureHeight" + intToStr(i); + + lineText = lang.get(introTagTextureName,"",true); + Texture2D *logoTexture= renderer.newTexture2D(rsGlobal); + if(logoTexture) { + logoTexture->setMipmap(false); + logoTexture->getPixmap()->load(lineText); + + renderer.initTexture(rsGlobal, logoTexture); + } + + + int textureWidth = logoTexture->getTextureWidth(); + if(lang.hasString(introTagTextureWidthName,"",true) == true) { + textureWidth = strToInt(lang.get(introTagTextureWidthName,"",true)); + } + + int textureHeight = logoTexture->getTextureHeight(); + if(lang.hasString(introTagTextureHeightName,"",true) == true) { + textureHeight = strToInt(lang.get(introTagTextureHeightName,"",true)); + } + + texts.push_back(new Text(logoTexture, Vec2i(w/2-(textureWidth/2), h/2-(textureHeight/2)), Vec2i(textureWidth, textureHeight), displayTime)); + } + // This is a line of text + else { + string introTagTextXName = "IntroTextX" + intToStr(i); + string introTagTextYName = "IntroTextY" + intToStr(i); + string introTagTextFontTypeName = "IntroTextFontType" + intToStr(i); + + int textX = -1; + if(lang.hasString(introTagTextXName,"",true) == true) { + string value = lang.get(introTagTextXName,"",true); + if(value.length() > 0 && + (value[0] == '+' || value[0] == '-')) { + textX = w/2 + strToInt(value); + } + else { + textX = strToInt(value); + } + } + + int textY = -1; + if(lang.hasString(introTagTextYName,"",true) == true) { + string value = lang.get(introTagTextYName,"",true); + if(value.length() > 0 && + (value[0] == '+' || value[0] == '-')) { + textY = h/2 + strToInt(value); + } + else { + textY = strToInt(value); + } + } + + Font2D *font = coreData.getMenuFontVeryBig(); + Font3D *font3d = coreData.getMenuFontVeryBig3D(); + + if(lang.hasString(introTagTextFontTypeName,"",true) == true) { + string value =lang.get(introTagTextFontTypeName,"",true); + if(value == "displaynormal") { + font = coreData.getDisplayFont(); + font3d = coreData.getDisplayFont3D(); + } + else if(value == "displaysmall") { + font = coreData.getDisplayFontSmall(); + font3d = coreData.getDisplayFontSmall3D(); + } + else if(value == "menunormal") { + font = coreData.getMenuFontNormal(); + font3d = coreData.getMenuFontNormal3D(); + } + else if(value == "menubig") { + font = coreData.getMenuFontBig(); + font3d = coreData.getMenuFontBig3D(); + } + else if(value == "menuverybig") { + font = coreData.getMenuFontVeryBig(); + font3d = coreData.getMenuFontVeryBig3D(); + } + else if(value == "consolenormal") { + font = coreData.getConsoleFont(); + font3d = coreData.getConsoleFont3D(); + } + + } + texts.push_back(new Text(lineText, Vec2i(textX, textY), displayTime, font,font3d)); + } + } + else { + break; + } + } + modelShowTime = disappear *(displayItemNumber); + if(lang.hasString("IntroModelStartMilliseconds","",true) == true) { + modelShowTime = strToInt(lang.get("IntroModelStartMilliseconds","",true)); + } + else { + modelShowTime = disappear *(displayItemNumber); + } + +/* string lineText = "Based on award-winning classic Glest"; texts.push_back(new Text(lineText, Vec2i(-1, -1), appear, coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D())); lineText = "the MegaGlest Team presents"; @@ -214,8 +369,9 @@ Intro::Intro(Program *program): lineText = "www.megaglest.org"; //texts.push_back(new Text(lineText, Vec2i(-1, -1), disappear *(displayItemNumber++), coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D())); texts.push_back(new Text(lineText, Vec2i(-1, h/2-45-18), disappear *(displayItemNumber-1), coreData.getMenuFontVeryBig(),coreData.getMenuFontVeryBig3D())); +*/ + - modelShowTime = disappear *(displayItemNumber); if(showIntroPics > 0 && coreData.getMiscTextureList().size() > 0) { const int showMiscTime = showIntroPicsTime; @@ -280,7 +436,12 @@ Intro::Intro(Program *program): texPlacement = Vec2i(w-tex->getTextureWidth(), (h/2) - (tex->getTextureHeight()/2)); } - texts.push_back(new Text(tex, texPlacement, Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), disappear *displayItemNumber+(showMiscTime*(i+1)))); + int textureStartTime = disappear * displayItemNumber; + if(lang.hasString("IntroTextureStartMilliseconds","",true) == true) { + textureStartTime = strToInt(lang.get("IntroTextureStartMilliseconds","",true)); + } + + texts.push_back(new Text(tex, texPlacement, Vec2i(tex->getTextureWidth(), tex->getTextureHeight()), textureStartTime +(showMiscTime*(i+1)))); } } @@ -300,6 +461,7 @@ Intro::Intro(Program *program): Intro::~Intro() { deleteValues(texts.begin(),texts.end()); + //deleteValues(introTextureList.begin(),introTextureList.end()); // if(test) { // glmDelete(test); // } diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 368f181b..1df8902d 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -866,15 +866,25 @@ void MainWindow::showLanguages() { vector langResults; string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); - findAll(data_path + "data/lang/*.lng", langResults, true); - if(langResults.empty()){ - throw runtime_error("There is no lang file"); - } + string userDataPath = getGameCustomCoreDataPath(data_path, ""); + findAll(userDataPath + "data/lang/*.lng", langResults, true, false); for(unsigned int i = 0; i < langResults.size(); ++i) { string testLanguage = langResults[i]; menuItems.push_back(testLanguage); } + + vector langResults2; + findAll(data_path + "data/lang/*.lng", langResults2, true); + if(langResults2.empty() && langResults.empty()) { + throw runtime_error("There are no lang files"); + } + for(unsigned int i = 0; i < langResults2.size(); ++i) { + string testLanguage = langResults2[i]; + if(std::find(menuItems.begin(),menuItems.end(),testLanguage) == menuItems.end()) { + menuItems.push_back(testLanguage); + } + } menuItems.push_back(lang.get("ExitGame?")); cancelLanguageSelection = menuItems.size()-1; @@ -900,9 +910,20 @@ void MainWindow::toggleLanguage(string language) { vector langResults; string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); - findAll(data_path + "data/lang/*.lng", langResults, true); - if(langResults.empty()){ - throw runtime_error("There is no lang file"); + + string userDataPath = getGameCustomCoreDataPath(data_path, ""); + findAll(userDataPath + "data/lang/*.lng", langResults, true, false); + + vector langResults2; + findAll(data_path + "data/lang/*.lng", langResults2, true); + if(langResults2.empty() && langResults.empty()) { + throw runtime_error("There are no lang files"); + } + for(unsigned int i = 0; i < langResults2.size(); ++i) { + string testLanguage = langResults2[i]; + if(std::find(langResults.begin(),langResults.end(),testLanguage) == langResults.end()) { + langResults.push_back(testLanguage); + } } for(unsigned int i = 0; i < langResults.size(); ++i) { @@ -2366,6 +2387,7 @@ int glestMain(int argc, char** argv) { preCacheThread=NULL; Properties::setApplicationPath(executable_path(argv[0])); + Properties::setGameVersion(glestVersionString); ServerSocket::setMaxPlayerCount(GameConstants::maxPlayers); SystemFlags::VERBOSE_MODE_ENABLED = false; @@ -2737,7 +2759,6 @@ int glestMain(int argc, char** argv) { } } - // Set some statics based on ini entries SystemFlags::ENABLE_THREADED_LOGGING = config.getBool("ThreadedLogging","true"); FontGl::setDefault_fontType(config.getString("DefaultFont",FontGl::getDefault_fontType().c_str())); @@ -3484,7 +3505,7 @@ int glestMain(int argc, char** argv) { } catch(const exception &e) { if(isMasterServerModeEnabled == false) { - soundThreadManager = program->getSoundThreadManager(true); + soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL); if(soundThreadManager) { SoundRenderer &soundRenderer= SoundRenderer::getInstance(); soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds); @@ -3496,7 +3517,7 @@ int glestMain(int argc, char** argv) { } catch(const char *e) { if(isMasterServerModeEnabled == false) { - soundThreadManager = program->getSoundThreadManager(true); + soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL); if(soundThreadManager) { SoundRenderer &soundRenderer= SoundRenderer::getInstance(); soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds); @@ -3508,7 +3529,7 @@ int glestMain(int argc, char** argv) { } catch(const string &ex) { if(isMasterServerModeEnabled == false) { - soundThreadManager = program->getSoundThreadManager(true); + soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL); if(soundThreadManager) { SoundRenderer &soundRenderer= SoundRenderer::getInstance(); soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds); @@ -3520,7 +3541,7 @@ int glestMain(int argc, char** argv) { } catch(...) { if(isMasterServerModeEnabled == false) { - soundThreadManager = program->getSoundThreadManager(true); + soundThreadManager = (program != NULL ? program->getSoundThreadManager(true) : NULL); if(soundThreadManager) { SoundRenderer &soundRenderer= SoundRenderer::getInstance(); soundRenderer.stopAllSounds(shutdownFadeSoundMilliseconds); diff --git a/source/glest_game/menu/main_menu.cpp b/source/glest_game/menu/main_menu.cpp index bffce914..fb7ef9c2 100644 --- a/source/glest_game/menu/main_menu.cpp +++ b/source/glest_game/menu/main_menu.cpp @@ -224,7 +224,7 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa //camera XmlTree xmlTree; - xmlTree.load(data_path + "data/core/menu/menu.xml",Properties::getTagReplacementValues()); + xmlTree.load(getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml"),Properties::getTagReplacementValues()); const XmlNode *menuNode= xmlTree.getRootNode(); const XmlNode *cameraNode= menuNode->getChild("camera"); diff --git a/source/glest_game/menu/menu_background.cpp b/source/glest_game/menu/menu_background.cpp index e41e5084..47daa7de 100644 --- a/source/glest_game/menu/menu_background.cpp +++ b/source/glest_game/menu/menu_background.cpp @@ -40,7 +40,7 @@ MenuBackground::MenuBackground(){ string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); XmlTree xmlTree; - xmlTree.load(data_path + "data/core/menu/menu.xml",Properties::getTagReplacementValues()); + xmlTree.load(getGameCustomCoreDataPath(data_path, "data/core/menu/menu.xml"),Properties::getTagReplacementValues()); const XmlNode *menuNode= xmlTree.getRootNode(); //water @@ -53,7 +53,7 @@ MenuBackground::MenuBackground(){ waterTexture= renderer.newTexture2D(rsMenu); if(waterTexture) { waterTexture->getPixmap()->init(4); - waterTexture->getPixmap()->load(data_path + "data/core/menu/textures/water.tga"); + waterTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/water.tga")); } } @@ -111,14 +111,14 @@ MenuBackground::MenuBackground(){ const XmlNode *mainMenuModelNode= menuNode->getChild("menu-background-model"); string mainModelFile = mainMenuModelNode->getAttribute("value")->getRestrictedValue(); - mainModel->load(data_path + mainModelFile); + mainModel->load(getGameCustomCoreDataPath(data_path, mainModelFile)); } //models for(int i=0; i<5; ++i){ characterModels[i]= renderer.newModel(rsMenu); if(characterModels[i]) { - characterModels[i]->load(data_path + "data/core/menu/about_models/character"+intToStr(i)+".g3d"); + characterModels[i]->load(getGameCustomCoreDataPath(data_path, "data/core/menu/about_models/character"+intToStr(i)+".g3d")); } } diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 1b21a88d..41d72143 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -1786,7 +1786,14 @@ void MenuStateConnectedGame::render() { int offsetPosition=0; for(int i=0; i < GameConstants::maxPlayers; ++i) { const Metrics &metrics= Metrics::getInstance(); - FontMetrics *fontMetrics= CoreData::getInstance().getMenuFontNormal()->getMetrics(); + FontMetrics *fontMetrics= NULL; + if(Renderer::renderText3DEnabled == false) { + fontMetrics = CoreData::getInstance().getMenuFontNormal()->getMetrics(); + } + else { + fontMetrics = CoreData::getInstance().getMenuFontNormal3D()->getMetrics(); + } + if(fontMetrics == NULL) { throw runtime_error("fontMetrics == NULL"); } diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 789c72b6..484c9976 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -1677,7 +1677,13 @@ void MenuStateCustomGame::render() { int offsetPosition=0; for(int i=0; i < GameConstants::maxPlayers; ++i) { const Metrics &metrics= Metrics::getInstance(); - FontMetrics *fontMetrics= CoreData::getInstance().getMenuFontNormal()->getMetrics(); + FontMetrics *fontMetrics= NULL; + if(Renderer::renderText3DEnabled == false) { + fontMetrics = CoreData::getInstance().getMenuFontNormal()->getMetrics(); + } + else { + fontMetrics = CoreData::getInstance().getMenuFontNormal3D()->getMetrics(); + } if(fontMetrics == NULL) { throw runtime_error("fontMetrics == NULL"); } diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index bdeb450f..2fb54a51 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -293,10 +293,22 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): vector langResults; string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); - findAll(data_path + "data/lang/*.lng", langResults, true); - if(langResults.empty()){ - throw runtime_error("There is no lang file"); + + string userDataPath = getGameCustomCoreDataPath(data_path, ""); + findAll(userDataPath + "data/lang/*.lng", langResults, true, false); + + vector langResults2; + findAll(data_path + "data/lang/*.lng", langResults2, true); + if(langResults2.empty() && langResults.empty()) { + throw runtime_error("There are no lang files"); } + for(unsigned int i = 0; i < langResults2.size(); ++i) { + string testLanguage = langResults2[i]; + if(std::find(langResults.begin(),langResults.end(),testLanguage) == langResults.end()) { + langResults.push_back(testLanguage); + } + } + listBoxLang.setItems(langResults); listBoxLang.setSelectedItem(config.getString("Lang")); currentLine-=lineOffset; diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index bcc6d0ee..0cda9d4a 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -52,7 +52,9 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch personalityType = fpt_Observer; } - Logger::getInstance().add("Faction type: "+ formatString(name), true); + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingFactionType","",true).c_str(),formatString(name).c_str()); + Logger::getInstance().add(szBuf, true); if(personalityType == fpt_Normal) { // a1) preload units diff --git a/source/glest_game/types/resource_type.cpp b/source/glest_game/types/resource_type.cpp index d1600d41..359594f7 100644 --- a/source/glest_game/types/resource_type.cpp +++ b/source/glest_game/types/resource_type.cpp @@ -18,6 +18,7 @@ #include "xml_parser.h" #include "game_util.h" #include "properties.h" +#include "lang.h" #include "leak_dumper.h" using namespace Shared::Util; @@ -58,7 +59,10 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre name= lastDir(dir); - Logger::getInstance().add("Resource type: "+ formatString(name), true); + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingResourceType","",true).c_str(),formatString(name).c_str()); + Logger::getInstance().add(szBuf, true); + string currentPath = dir; endPathWithSlash(currentPath); path= currentPath + name + ".xml"; diff --git a/source/glest_game/types/tech_tree.cpp b/source/glest_game/types/tech_tree.cpp index 5d2a5b09..184edb96 100644 --- a/source/glest_game/types/tech_tree.cpp +++ b/source/glest_game/types/tech_tree.cpp @@ -58,9 +58,11 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum treePath = currentPath; name= lastDir(currentPath); - vector filenames; - Logger::getInstance().add("TechTree: "+ formatString(name), true); + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingTechtree","",true).c_str(),formatString(name).c_str()); + Logger::getInstance().add(szBuf, true); + vector filenames; //load resources string str= currentPath + "resources/*."; @@ -201,7 +203,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum TechTree::~TechTree() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("Tech tree", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingTechtree"), true); } std::vector TechTree::validateFactionTypes() { diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 228ff0f3..43cdac05 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -132,11 +132,10 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, try { Lang &lang= Lang::getInstance(); - string unitTypeText = "Unit type: "; - if(lang.hasString("UnitType") == true) { - unitTypeText = lang.get("UnitType"); - } - Logger::getInstance().add(unitTypeText + " " + formatString(name), true); + + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingUnitType","",true).c_str(),formatString(name).c_str()); + Logger::getInstance().add(szBuf, true); //file load checksum->addFile(path); diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index 282c33bd..c74dfe03 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -207,7 +207,9 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, Checksum* techtreeChecksum, std::map > > &loadedFileList) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("Upgrade type: "+ formatString(name), true); + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingUpgradeType","",true).c_str(),formatString(name).c_str()); + Logger::getInstance().add(szBuf, true); string currentPath = dir; endPathWithSlash(currentPath); diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 1c2b8417..f2d2c1d6 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -155,7 +155,7 @@ Map::Map() { } Map::~Map() { - Logger::getInstance().add("Cells", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingMapCells"), true); delete [] cells; cells = NULL; @@ -167,7 +167,7 @@ Map::~Map() { void Map::end(){ if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("Map", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingMap"), true); //read heightmap for(int j = 0; j < surfaceH; ++j) { for(int i = 0; i < surfaceW; ++i) { @@ -358,7 +358,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) { } void Map::init(Tileset *tileset) { - Logger::getInstance().add("Heightmap computations", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingMap"), true); maxMapHeight=0.0f; smoothSurface(tileset); computeNormals(); diff --git a/source/glest_game/world/minimap.cpp b/source/glest_game/world/minimap.cpp index bc06f382..49f115d7 100644 --- a/source/glest_game/world/minimap.cpp +++ b/source/glest_game/world/minimap.cpp @@ -109,7 +109,7 @@ void Minimap::init(int w, int h, const World *world, bool fogOfWar) { } Minimap::~Minimap() { - Logger::getInstance().add("Minimap", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingMiniMap"), true); delete fowPixmap0; fowPixmap0=NULL; delete fowPixmap1; diff --git a/source/glest_game/world/scenario.cpp b/source/glest_game/world/scenario.cpp index f511651f..6571761f 100644 --- a/source/glest_game/world/scenario.cpp +++ b/source/glest_game/world/scenario.cpp @@ -49,7 +49,10 @@ Checksum Scenario::load(const string &path) { checksumValue.addFile(path); string name= cutLastExt(lastDir(path)); - Logger::getInstance().add("Scenario: " + formatString(name), true); + + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingScenario","",true).c_str(),formatString(name).c_str()); + Logger::getInstance().add(szBuf, true); Scenario::loadScenarioInfo(path, &info); diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index 5db89cfa..4508cd47 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -20,6 +20,7 @@ #include "game_util.h" #include "leak_dumper.h" #include "properties.h" +#include "lang.h" #include "platform_util.h" using namespace Shared::Util; @@ -152,7 +153,10 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck checksumValue.addFile(path); try { - Logger::getInstance().add("Tileset: "+formatString(name), true); + char szBuf[1024]=""; + sprintf(szBuf,Lang::getInstance().get("LogScreenGameLoadingTileset","",true).c_str(),formatString(name).c_str()); + Logger::getInstance().add(szBuf, true); + Renderer &renderer= Renderer::getInstance(); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -346,7 +350,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck } Tileset::~Tileset() { - Logger::getInstance().add("Tileset", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingTileset"), true); } const Pixmap2D *Tileset::getSurfPixmap(int type, int var) const{ diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 6ca3fe3b..5f2a61a6 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -149,7 +149,7 @@ World::~World() { void World::endScenario() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("World", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingWorld"), true); ExploredCellsLookupItemCache.clear(); ExploredCellsLookupItemCacheTimer.clear(); @@ -165,7 +165,7 @@ void World::endScenario() { void World::end(){ if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("World", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameUnLoadingWorld"), true); ExploredCellsLookupItemCache.clear(); ExploredCellsLookupItemCacheTimer.clear(); @@ -1187,7 +1187,7 @@ int World::getUnitCountOfType(int factionIndex, const string &typeName) { void World::initCells(bool fogOfWar) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("State cells", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameLoadingStateCells"), true); for(int i=0; i< map.getSurfaceW(); ++i) { for(int j=0; j< map.getSurfaceH(); ++j) { @@ -1255,7 +1255,7 @@ void World::initSplattedTextures() { //creates each faction looking at each faction name contained in GameSettings void World::initFactionTypes(GameSettings *gs) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("Faction types", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameLoadingFactionTypes"), true); if(gs == NULL) { throw runtime_error("gs == NULL"); @@ -1311,14 +1311,14 @@ void World::initMinimap() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); minimap.init(map.getW(), map.getH(), this, game->getGameSettings()->getFogOfWar()); - Logger::getInstance().add("Compute minimap surface", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameLoadingMinimapSurface"), true); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } void World::initUnitsForScenario() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("Generate elements", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameLoadingGenerateGameElements"), true); //put starting units for(int i = 0; i < getFactionCount(); ++i) { @@ -1363,7 +1363,7 @@ void World::initUnitsForScenario() { //place units randomly aroud start location void World::initUnits() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Logger::getInstance().add("Generate elements", true); + Logger::getInstance().add(Lang::getInstance().get("LogScreenGameLoadingGenerateGameElements"), true); //put starting units for(int i = 0; i < getFactionCount(); ++i) { diff --git a/source/shared_lib/include/util/properties.h b/source/shared_lib/include/util/properties.h index eb84d4fd..c3243152 100644 --- a/source/shared_lib/include/util/properties.h +++ b/source/shared_lib/include/util/properties.h @@ -44,11 +44,15 @@ private: PropertyMap propertyMap; string path; static string applicationPath; + static string gameVersion; public: static void setApplicationPath(string value) { applicationPath=value; } static string getApplicationPath() { return applicationPath; } + static void setGameVersion(string value) { gameVersion=value; } + static string getGameVersion() { return gameVersion; } + void clear(); void load(const string &path,bool clearCurrentProperties=true); void save(const string &path); diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index dbe106a4..73f8b894 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -44,6 +44,7 @@ using namespace Shared::Graphics; namespace Shared{ namespace Util{ string Properties::applicationPath = ""; +string Properties::gameVersion = ""; // ===================================================== // class Properties @@ -506,6 +507,8 @@ std::map Properties::getTagReplacementValues(std::map *mapTag //replaceAll(value, "%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/"); #endif + replaceAll(value, "$GAMEVERSION", Properties::gameVersion); } //if(originalValue != value || originalValue.find("$APPLICATIONDATAPATH") != string::npos) {