From ec7e741ad324717e6d44b421552dada65d6be721 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 5 Apr 2010 21:41:33 +0000 Subject: [PATCH] Updated screen loading feature to support all supported image types --- source/glest_game/game/game.cpp | 49 +++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index e3e4a895..36859cd5 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -106,36 +106,51 @@ void Game::load(){ scenarioDir = scenarioDir.erase(scenarioDir.size() - gameSettings.getScenario().size(), gameSettings.getScenario().size() + 1); } // use a scenario based loading screen - string senarioLogo = scenarioDir + "/" + "loading_screen.jpg"; - if(fileExists(senarioLogo) == true) { - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found loading screen '%s'\n",__FILE__,__FUNCTION__,senarioLogo.c_str()); + vector loadScreenList; + findAll(scenarioDir + "/" + "loading_screen.*", loadScreenList, false, false); + if(loadScreenList.size() > 0) { + //string senarioLogo = scenarioDir + "/" + "loading_screen.jpg"; + string senarioLogo = scenarioDir + "/" + loadScreenList[0]; + if(fileExists(senarioLogo) == true) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found scenario loading screen '%s'\n",__FILE__,__FUNCTION__,senarioLogo.c_str()); - logger.loadLoadingScreen(senarioLogo); - scenarioLoadingImageUsed=true; + logger.loadLoadingScreen(senarioLogo); + scenarioLoadingImageUsed=true; + } } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameSettings.getScenarioDir() = [%s] gameSettings.getScenario() = [%s] scenarioDir = [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getScenarioDir().c_str(),gameSettings.getScenario().c_str(),scenarioDir.c_str()); } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Searching for loading screen\n",__FILE__,__FUNCTION__); - if(!scenarioLoadingImageUsed){ + if(scenarioLoadingImageUsed == false){ // try to use a faction related loading screen for ( int i=0; i < gameSettings.getFactionCount(); ++i ) { if(gameSettings.getFactionControl(i)==ctHuman){ vector pathList=config.getPathListForType(ptTechs,scenarioDir); for(int idx = 0; idx < pathList.size(); idx++) { - const string path = pathList[idx]+ "/" +techName+ "/"+ "factions"+ "/"+ gameSettings.getFactionTypeName(i); + const string path = pathList[idx]+ "/" +techName+ "/"+ "factions"+ "/"+ gameSettings.getFactionTypeName(i); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] possible loading screen dir '%s'\n",__FILE__,__FUNCTION__,path.c_str()); if(isdir(path.c_str()) == true) { - string factionLogo = path + "/" + "loading_screen.jpg"; - - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,factionLogo.c_str()); - - if(fileExists(factionLogo) == true) { - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found loading screen '%s'\n",__FILE__,__FUNCTION__,factionLogo.c_str()); - - logger.loadLoadingScreen(factionLogo); - break; - } + vector loadScreenList; + findAll(path + "/" + "loading_screen.*", loadScreenList, false, false); + if(loadScreenList.size() > 0) { + //string factionLogo = path + "/" + "loading_screen.jpg"; + string factionLogo = path + "/" + loadScreenList[0]; + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,factionLogo.c_str()); + + if(fileExists(factionLogo) == true) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found loading screen '%s'\n",__FILE__,__FUNCTION__,factionLogo.c_str()); + + logger.loadLoadingScreen(factionLogo); + scenarioLoadingImageUsed = true; + break; + } + } + } + + if(scenarioLoadingImageUsed == true) { + break; } } break;