- added support for better user data customization and default linux path will now be ~/.megaglest/ for user related ini's and data content
This commit is contained in:
parent
2101a83a5d
commit
242b02c001
|
@ -77,6 +77,6 @@ SoundVolumeMusic=90
|
||||||
StencilBits=0
|
StencilBits=0
|
||||||
Textures3D=true
|
Textures3D=true
|
||||||
UnitParticles=true
|
UnitParticles=true
|
||||||
UserData_Root=mydata/
|
UserData_Root=$HOME/.megaglest/
|
||||||
VersionURL=http://master.megaglest.org/files/versions/
|
VersionURL=http://master.megaglest.org/files/versions/
|
||||||
Windowed=false
|
Windowed=false
|
||||||
|
|
|
@ -99,6 +99,8 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.first = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.first = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str());
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("-=-=-=-=-=-=-= About to load fileName.first = [%s]\n",fileName.first.c_str());
|
||||||
|
|
||||||
if(fileMustExist.first == true ||
|
if(fileMustExist.first == true ||
|
||||||
(fileMustExist.first == false && fileExists(fileName.first) == true)) {
|
(fileMustExist.first == false && fileExists(fileName.first) == true)) {
|
||||||
properties.first.load(fileName.first);
|
properties.first.load(fileName.first);
|
||||||
|
@ -108,9 +110,27 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
||||||
}
|
}
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.first = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.first = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str());
|
||||||
|
|
||||||
if(properties.first.getString("UserOverrideFile", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
string userData = "";
|
||||||
fileName.second = properties.first.getString("UserOverrideFile");
|
if(cfgType.first == cfgMainGame) {
|
||||||
|
if( properties.first.getString("UserData_Root", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||||
|
fileName.second = properties.first.getString("UserData_Root") + fileNameParameter.second;
|
||||||
|
}
|
||||||
|
else if(properties.first.getString("UserOverrideFile", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||||
|
fileName.second = properties.first.getString("UserOverrideFile") + fileNameParameter.second;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if(cfgType.first == cfgMainKeys) {
|
||||||
|
Config &mainCfg = Config::getInstance();
|
||||||
|
if( mainCfg.getString("UserData_Root", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||||
|
fileName.second = mainCfg.getString("UserData_Root") + fileNameParameter.second;
|
||||||
|
}
|
||||||
|
else if(mainCfg.getString("UserOverrideFile", defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||||
|
fileName.second = mainCfg.getString("UserOverrideFile") + fileNameParameter.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("-=-=-=-=-=-=-= About to load fileName.second = [%s]\n",fileName.second.c_str());
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str());
|
||||||
|
|
||||||
|
@ -183,6 +203,7 @@ void Config::save(const string &path){
|
||||||
if(path != "") {
|
if(path != "") {
|
||||||
fileName.second = path;
|
fileName.second = path;
|
||||||
}
|
}
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] save file [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str());
|
||||||
properties.second.save(fileName.second);
|
properties.second.save(fileName.second);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -190,6 +211,7 @@ void Config::save(const string &path){
|
||||||
if(path != "") {
|
if(path != "") {
|
||||||
fileName.first = path;
|
fileName.first = path;
|
||||||
}
|
}
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] save file [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.first.c_str());
|
||||||
properties.first.save(fileName.first);
|
properties.first.save(fileName.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,13 +707,13 @@ vector<string> Config::getPathListForType(PathType type, string scenarioDir) {
|
||||||
if(userData[userData.size()-1] != '/' && userData[userData.size()-1] != '\\') {
|
if(userData[userData.size()-1] != '/' && userData[userData.size()-1] != '\\') {
|
||||||
userData += '/';
|
userData += '/';
|
||||||
}
|
}
|
||||||
if(data_path == "") {
|
//if(data_path == "") {
|
||||||
userData = data_path + userData;
|
// userData = userData;
|
||||||
}
|
//}
|
||||||
else {
|
//else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("extractLastDirectoryFromPath(userData) [%s] from userData [%s]\n",extractLastDirectoryFromPath(userData).c_str(),userData.c_str());
|
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("extractLastDirectoryFromPath(userData) [%s] from userData [%s]\n",extractLastDirectoryFromPath(userData).c_str(),userData.c_str());
|
||||||
userData = data_path + extractLastDirectoryFromPath(userData);
|
// userData = data_path + extractLastDirectoryFromPath(userData);
|
||||||
}
|
//}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] userData path [%s]\n",__FILE__,__FUNCTION__,__LINE__,userData.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] userData path [%s]\n",__FILE__,__FUNCTION__,__LINE__,userData.c_str());
|
||||||
|
|
||||||
if(isdir(userData.c_str()) == false) {
|
if(isdir(userData.c_str()) == false) {
|
||||||
|
|
|
@ -2170,9 +2170,17 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
//if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||||
fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
|
// fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
|
||||||
|
//}
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
string userData = config.getString("UserData_Root","");
|
||||||
|
if(userData != "") {
|
||||||
|
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||||
|
userData += "/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fileName = userData + fileName;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
|
||||||
|
|
||||||
|
@ -2230,9 +2238,17 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
||||||
|
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
|
|
||||||
if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
//if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||||
fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
|
// fileName = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName;
|
||||||
|
//}
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
string userData = config.getString("UserData_Root","");
|
||||||
|
if(userData != "") {
|
||||||
|
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||||
|
userData += "/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fileName = userData + fileName;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,21 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
|
||||||
networkManager.init(nrClient);
|
networkManager.init(nrClient);
|
||||||
|
|
||||||
serversSavedFile = serverFileName;
|
serversSavedFile = serverFileName;
|
||||||
if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
//if(getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) != "") {
|
||||||
serversSavedFile = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + serversSavedFile;
|
// serversSavedFile = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + serversSavedFile;
|
||||||
|
//}
|
||||||
|
//Config &config = Config::getInstance();
|
||||||
|
string userData = config.getString("UserData_Root","");
|
||||||
|
if(userData != "") {
|
||||||
|
if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) {
|
||||||
|
userData += "/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
serversSavedFile = userData + serversSavedFile;
|
||||||
|
|
||||||
servers.load(serversSavedFile);
|
if(fileExists(serversSavedFile) == true) {
|
||||||
|
servers.load(serversSavedFile);
|
||||||
|
}
|
||||||
|
|
||||||
//buttons
|
//buttons
|
||||||
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
buttonReturn.registerGraphicComponent(containerName,"buttonReturn");
|
||||||
|
|
|
@ -207,14 +207,13 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
#else
|
#else
|
||||||
int result = unlink(userKeysFile.c_str());
|
int result = unlink(userKeysFile.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] delete file [%s] returned %d\n",__FILE__,__FUNCTION__,__LINE__,userKeysFile.c_str(),result);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] delete file [%s] returned %d\n",__FILE__,__FUNCTION__,__LINE__,userKeysFile.c_str(),result);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] delete file [%s] returned %d\n",__FILE__,__FUNCTION__,__LINE__,userKeysFile.c_str(),result);
|
||||||
configKeys.reload();
|
configKeys.reload();
|
||||||
|
|
||||||
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
mainMenu->setState(new MenuStateOptions(program, mainMenu));
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else if(buttonOk.mouseClick(x, y)){
|
else if(buttonOk.mouseClick(x, y)){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
|
@ -222,6 +221,10 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
if(userProperties.size() > 0) {
|
if(userProperties.size() > 0) {
|
||||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
|
string userKeysFile = configKeys.getFileName(true);
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] save file [%s] userProperties.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,userKeysFile.c_str(),userProperties.size());
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] save file [%s] userProperties.size() = %lu\n",__FILE__,__FUNCTION__,__LINE__,userKeysFile.c_str(),userProperties.size());
|
||||||
|
|
||||||
configKeys.setUserProperties(userProperties);
|
configKeys.setUserProperties(userProperties);
|
||||||
configKeys.save();
|
configKeys.save();
|
||||||
configKeys.reload();
|
configKeys.reload();
|
||||||
|
@ -323,7 +326,7 @@ void MenuStateKeysetup::showMessageBox(const string &text, const string &header,
|
||||||
void MenuStateKeysetup::keyDown(char key) {
|
void MenuStateKeysetup::keyDown(char key) {
|
||||||
hotkeyChar = key;
|
hotkeyChar = key;
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] hotkeyChar [%d]\n",__FILE__,__FUNCTION__,__LINE__,hotkeyChar);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] hotkeyChar [%d]\n",__FILE__,__FUNCTION__,__LINE__,hotkeyChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateKeysetup::keyPress(char c) {
|
void MenuStateKeysetup::keyPress(char c) {
|
||||||
|
|
Loading…
Reference in New Issue