- added more fields for dev path support.. onlu ico files for linxu left to fix

This commit is contained in:
SoftCoder 2014-01-24 17:51:06 -08:00
parent 86c6c6ee17
commit fe808556bd
11 changed files with 62 additions and 16 deletions

View File

@ -1 +0,0 @@
../../data/glest_game/data

View File

@ -1 +0,0 @@
../../source/g3d_viewer

View File

@ -1,2 +1,3 @@
DataPath=$APPLICATIONPATH/../../data/glest_game/
ServerListPath=$APPLICATIONPATH/../shared/
GlestKeysIniPath=$APPLICATIONPATH/../shared/

View File

@ -1 +0,0 @@
../shared/glestkeys.ini

View File

@ -1 +0,0 @@
../shared/servers.ini

View File

@ -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

View File

@ -1,2 +1,3 @@
DataPath=$APPLICATIONPATH\..\..\data\glest_game\
ServerListPath=$APPLICATIONPATH\..\shared\
GlestKeysIniPath=$APPLICATIONPATH\..\shared\

View File

@ -152,7 +152,7 @@ bool Config::tryCustomPath(std::pair<ConfigType,ConfigType> &type, std::pair<str
return wasFound;
}
Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist) {
Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist,string custom_path) {
fileLoaded.first = false;
fileLoaded.second = false;
cfgType = type;
@ -164,8 +164,17 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> 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<ConfigType,ConfigType> type, std::pair<string,string> f
}
}
Config &Config::getInstance(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist) {
Config &Config::getInstance(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> 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__);

View File

@ -73,7 +73,7 @@ public:
protected:
Config();
Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist);
Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist,string custom_path="");
bool tryCustomPath(std::pair<ConfigType,ConfigType> &type, std::pair<string,string> &file, string custom_path);
static void CopyAll(Config *src,Config *dest);
vector<pair<string,string> > getPropertiesFromContainer(const Properties &propertiesObj) const;
@ -83,7 +83,7 @@ public:
static Config &getInstance(std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame) ,
std::pair<string,string> file = std::make_pair(glest_ini_filename,glestuser_ini_filename) ,
std::pair<bool,bool> fileMustExist = std::make_pair(true,false) );
std::pair<bool,bool> fileMustExist = std::make_pair(true,false),string custom_path="" );
void save(const string &path="");
void reload();

View File

@ -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<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys),
std::pair<string,string>(Config::glestkeys_ini_filename,Config::glestuserkeys_ini_filename),
std::pair<bool,bool>(true,false));
std::pair<bool,bool>(true,false),config.getString("GlestKeysIniPath",""));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@ -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");