From fe808556bddd2b6901dfffdbec40f4c89ff8eea7 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Fri, 24 Jan 2014 17:51:06 -0800 Subject: [PATCH] - added more fields for dev path support.. onlu ico files for linxu left to fix --- mk/linux/data | 1 - mk/linux/g3d_viewer | 1 - mk/linux/glest-dev.ini | 3 ++- mk/linux/glestkeys.ini | 1 - mk/linux/servers.ini | 1 - mk/windoze/CopySharedBinarySetup.bat | 2 +- mk/windoze/glest-dev.ini | 3 ++- source/glest_game/global/config.cpp | 19 ++++++++++---- source/glest_game/global/config.h | 4 +-- source/glest_game/main/main.cpp | 26 ++++++++++++++++++- .../glest_game/menu/menu_state_join_game.cpp | 17 +++++++++++- 11 files changed, 62 insertions(+), 16 deletions(-) delete mode 120000 mk/linux/data delete mode 120000 mk/linux/g3d_viewer delete mode 120000 mk/linux/glestkeys.ini delete mode 120000 mk/linux/servers.ini diff --git a/mk/linux/data b/mk/linux/data deleted file mode 120000 index 25450aee..00000000 --- a/mk/linux/data +++ /dev/null @@ -1 +0,0 @@ -../../data/glest_game/data \ No newline at end of file diff --git a/mk/linux/g3d_viewer b/mk/linux/g3d_viewer deleted file mode 120000 index 6cab6529..00000000 --- a/mk/linux/g3d_viewer +++ /dev/null @@ -1 +0,0 @@ -../../source/g3d_viewer \ No newline at end of file diff --git a/mk/linux/glest-dev.ini b/mk/linux/glest-dev.ini index b9b86d20..c2c91931 100644 --- a/mk/linux/glest-dev.ini +++ b/mk/linux/glest-dev.ini @@ -1,2 +1,3 @@ DataPath=$APPLICATIONPATH/../../data/glest_game/ - +ServerListPath=$APPLICATIONPATH/../shared/ +GlestKeysIniPath=$APPLICATIONPATH/../shared/ diff --git a/mk/linux/glestkeys.ini b/mk/linux/glestkeys.ini deleted file mode 120000 index efb84862..00000000 --- a/mk/linux/glestkeys.ini +++ /dev/null @@ -1 +0,0 @@ -../shared/glestkeys.ini \ No newline at end of file diff --git a/mk/linux/servers.ini b/mk/linux/servers.ini deleted file mode 120000 index d5e81969..00000000 --- a/mk/linux/servers.ini +++ /dev/null @@ -1 +0,0 @@ -../shared/servers.ini \ No newline at end of file diff --git a/mk/windoze/CopySharedBinarySetup.bat b/mk/windoze/CopySharedBinarySetup.bat index a0d676b4..bb56f8e6 100644 --- a/mk/windoze/CopySharedBinarySetup.bat +++ b/mk/windoze/CopySharedBinarySetup.bat @@ -1,5 +1,5 @@ @echo off -copy ..\shared\*.ini .\ +rem copy ..\shared\*.ini .\ rem copy glest.ini ..\..\data\glest_game\ if not "%1" == "nopause" pause diff --git a/mk/windoze/glest-dev.ini b/mk/windoze/glest-dev.ini index 47796a5a..ee4695bd 100644 --- a/mk/windoze/glest-dev.ini +++ b/mk/windoze/glest-dev.ini @@ -1,2 +1,3 @@ DataPath=$APPLICATIONPATH\..\..\data\glest_game\ - +ServerListPath=$APPLICATIONPATH\..\shared\ +GlestKeysIniPath=$APPLICATIONPATH\..\shared\ diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 6130dfe7..2f75caed 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -152,7 +152,7 @@ bool Config::tryCustomPath(std::pair &type, std::pair type, std::pair file, std::pair fileMustExist) { +Config::Config(std::pair type, std::pair file, std::pair fileMustExist,string custom_path) { fileLoaded.first = false; fileLoaded.second = false; cfgType = type; @@ -164,8 +164,17 @@ Config::Config(std::pair type, std::pair f fileName.second = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.second; } - string currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath()); - bool foundPath = tryCustomPath(cfgType, fileName, currentpath); + bool foundPath = false; + string currentpath = custom_path; + + if(custom_path != "") { + foundPath = tryCustomPath(cfgType, fileName, custom_path); + } + + if(foundPath == false) { + currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath()); + foundPath = tryCustomPath(cfgType, fileName, currentpath); + } #if defined(CUSTOM_DATA_INSTALL_PATH) if(foundPath == false) { @@ -291,11 +300,11 @@ Config::Config(std::pair type, std::pair f } } -Config &Config::getInstance(std::pair type, std::pair file, std::pair fileMustExist) { +Config &Config::getInstance(std::pair type, std::pair file, std::pair fileMustExist, string custom_path) { if(configList.find(type.first) == configList.end()) { if(SystemFlags::VERBOSE_MODE_ENABLED) if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Config config(type, file, fileMustExist); + Config config(type, file, fileMustExist, custom_path); if(SystemFlags::VERBOSE_MODE_ENABLED) if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/global/config.h b/source/glest_game/global/config.h index 788b1a3e..6d4d558b 100644 --- a/source/glest_game/global/config.h +++ b/source/glest_game/global/config.h @@ -73,7 +73,7 @@ public: protected: Config(); - Config(std::pair type, std::pair file, std::pair fileMustExist); + Config(std::pair type, std::pair file, std::pair fileMustExist,string custom_path=""); bool tryCustomPath(std::pair &type, std::pair &file, string custom_path); static void CopyAll(Config *src,Config *dest); vector > getPropertiesFromContainer(const Properties &propertiesObj) const; @@ -83,7 +83,7 @@ public: static Config &getInstance(std::pair type = std::make_pair(cfgMainGame,cfgUserGame) , std::pair file = std::make_pair(glest_ini_filename,glestuser_ini_filename) , - std::pair fileMustExist = std::make_pair(true,false) ); + std::pair fileMustExist = std::make_pair(true,false),string custom_path="" ); void save(const string &path=""); void reload(); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 65701e7a..35dc70c4 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1304,6 +1304,30 @@ int setupGameItemPaths(int argc, char** argv, Config *config) { string devPropertyFile = Properties::getApplicationPath() + "glest-dev.ini"; if(fileExists(devPropertyFile) == true) { devProperties.load(devPropertyFile); + + if(devProperties.hasString("ServerListPath") == true) { + string devItem = devProperties.getString("ServerListPath"); + Properties::applyTagsToValue(devItem); + if(devItem != "") { + endPathWithSlash(devItem); + } + + if(config != NULL) { + config->setString("ServerListPath",devItem,true); + } + } + + if(devProperties.hasString("GlestKeysIniPath") == true) { + string devItem = devProperties.getString("GlestKeysIniPath"); + Properties::applyTagsToValue(devItem); + if(devItem != "") { + endPathWithSlash(devItem); + } + + if(config != NULL) { + config->setString("GlestKeysIniPath",devItem,true); + } + } } //GAME_ARG_DATA_PATH @@ -4695,7 +4719,7 @@ int glestMain(int argc, char** argv) { Config &configKeys = Config::getInstance( std::pair(cfgMainKeys,cfgUserKeys), std::pair(Config::glestkeys_ini_filename,Config::glestuserkeys_ini_filename), - std::pair(true,false)); + std::pair(true,false),config.getString("GlestKeysIniPath","")); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/menu/menu_state_join_game.cpp b/source/glest_game/menu/menu_state_join_game.cpp index 18faac12..eea11216 100644 --- a/source/glest_game/menu/menu_state_join_game.cpp +++ b/source/glest_game/menu/menu_state_join_game.cpp @@ -77,7 +77,13 @@ void MenuStateJoinGame::CommonInit(bool connect, Ip serverIp,int portNumberOverr networkManager.init(nrClient); serversSavedFile = serverFileName; - string userData = config.getString("UserData_Root",""); + + string serverListPath = config.getString("ServerListPath",""); + if(serverListPath != "") { + endPathWithSlash(serverListPath); + } + + string userData = config.getString("UserData_Root",""); if(userData != "") { endPathWithSlash(userData); } @@ -86,6 +92,15 @@ void MenuStateJoinGame::CommonInit(bool connect, Ip serverIp,int portNumberOverr if(fileExists(serversSavedFile) == true) { servers.load(serversSavedFile); } + else if(fileExists(serverListPath + serverFileName) == true) { + servers.load(serverListPath + serverFileName); + } + else if(fileExists(Properties::getApplicationPath() + serverFileName) == true) { + servers.load(Properties::getApplicationPath() + serverFileName); + } + else if(fileExists(serverFileName) == true) { + servers.load(serverFileName); + } //buttons buttonReturn.registerGraphicComponent(containerName,"buttonReturn");