From 42a7d602af9e37b25ca19da9adbba69af16cc915 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 1 Jul 2016 21:37:26 +0300 Subject: [PATCH] Changed: If char keys/icfg file does not exist, use shared keys/icfg file --HG-- branch : develop --- .../client/src/interface_v3/group_map.cpp | 7 ++++- .../src/interface_v3/interface_manager.cpp | 26 ++++++++++++++-- code/ryzom/client/src/r2/editor.cpp | 31 +++++++++++++++++-- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 6e1022e76..64c81df66 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -2511,7 +2511,12 @@ CCtrlButton *CGroupMap::addUserLandMark(const NLMISC::CVector2f &pos, const ucst // Save the config file each time a user landmark is created CInterfaceManager *pIM = CInterfaceManager::getInstance(); uint8 currMode = pIM->getMode(); - pIM->saveConfig ("save/interface_" + PlayerSelectedFileName + ".icfg"); + std::string filename = "save/interface_" + PlayerSelectedFileName + ".icfg"; + if (!CFile::fileExists(filename) && CFile::fileExists("save/shared_interface.icfg")) + { + filename = "save/shared_interface.icfg"; + } + pIM->saveConfig (filename); if (currMode != pIM->getMode()) { pIM->setMode(currMode); diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 2ff42b7e9..3e2a0ba0e 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1222,6 +1222,14 @@ void CInterfaceManager::loadKeys() // Load the user key file xmlFilesToParse.push_back (userKeyFileName); } + else + { + string filename = "save/shared_keys.xml"; + if(CFile::fileExists(filename) && CFile::getFileSize(filename) > 0) + { + xmlFilesToParse.push_back(filename); + } + } // Load the default key (but don't replace existings bounds, see keys.xml "key_def_no_replace") xmlFilesToParse.push_back ("keys.xml"); @@ -1240,7 +1248,11 @@ void CInterfaceManager::loadInterfaceConfig() if (ClientCfg.R2EDEnabled) // in R2ED mode the CEditor class deals with it return; - loadConfig ("save/interface_" + PlayerSelectedFileName + ".icfg"); // Invalidate coords of changed groups + string filename = "save/interface_" + PlayerSelectedFileName + ".icfg"; + if (!CFile::fileExists(filename)) + filename = "save/shared_interface.icfg"; + + loadConfig(filename); // Invalidate coords of changed groups _ConfigLoaded = true; } @@ -1254,7 +1266,11 @@ void CInterfaceManager::uninitInGame0 () { if (!ClientCfg.R2EDEnabled) { - saveKeys ("save/keys_" + PlayerSelectedFileName + ".xml"); + string filename = "save/keys_" + PlayerSelectedFileName + ".xml"; + if (!CFile::fileExists(filename) && CFile::fileExists("save/shared_keys.xml")) + filename = "save/shared_keys.xml"; + + saveKeys(filename); } _KeysLoaded = false; } @@ -1264,7 +1280,11 @@ void CInterfaceManager::uninitInGame0 () { if (!ClientCfg.R2EDEnabled) { - saveConfig ("save/interface_" + PlayerSelectedFileName + ".icfg"); + string filename = "save/interface_" + PlayerSelectedFileName + ".icfg"; + if (!CFile::fileExists(filename) && CFile::fileExists("save/shared_interface.icfg")) + filename = "save/shared_interface.icfg"; + + saveConfig(filename); } _ConfigLoaded = false; } diff --git a/code/ryzom/client/src/r2/editor.cpp b/code/ryzom/client/src/r2/editor.cpp index 93acc1d98..2bcc56285 100644 --- a/code/ryzom/client/src/r2/editor.cpp +++ b/code/ryzom/client/src/r2/editor.cpp @@ -2149,6 +2149,14 @@ void CEditor::loadKeySet(const std::string &keySet) // Load the user key file xmlFilesToParse.push_back (userKeyFileName); } + else + { + std::string filename = "save/shared_" + keySet + ".xml"; + if (CFile::fileExists(filename) && CFile::getFileSize(filename) > 0) + { + xmlFilesToParse.push_back(filename); + } + } // Load the default key (but don't replace existings bounds, see keys.xml "key_def_no_replace") xmlFilesToParse.push_back (keySet + ".xml"); @@ -2179,7 +2187,13 @@ void CEditor::saveCurrentKeySet() CHECK_EDITOR std::string prefix = getKeySetPrefix(getMode()); if (prefix.empty()) return; - getUI().saveKeys ("save/" + prefix + "_" + PlayerSelectedFileName + ".xml"); + + std::string filename = "save/" + prefix + "_" + PlayerSelectedFileName + ".xml"; + std::string sharedfile ="save/shared_" + prefix + ".xml"; + if (!CFile::fileExists(filename) && CFile::fileExists(sharedfile)) + filename = sharedfile; + + getUI().saveKeys (filename); } // ********************************************************************************************************* @@ -2844,7 +2858,12 @@ bool CEditor::loadUIConfig(const std::string &prefix) { //H_AUTO(R2_CEditor_loadUIConfig) CHECK_EDITOR - return getUI().loadConfig("save/" + prefix + PlayerSelectedFileName + ".icfg"); + + std::string filename = "save/" + prefix + PlayerSelectedFileName + ".icfg"; + if (!CFile::fileExists(filename)) + filename = "save/shared_" + prefix + ".icfg"; + + return getUI().loadConfig(filename); } // ********************************************************************************************************* @@ -2871,7 +2890,13 @@ void CEditor::saveUIConfig() } } } - getUI().saveConfig("save/" + getUIPrefix(_Mode) + PlayerSelectedFileName + ".icfg"); + + std::string filename = "save/" + getUIPrefix(_Mode) + PlayerSelectedFileName + ".icfg"; + std::string sharedfile = "save/shared_" + getUIPrefix(_Mode) + ".icfg"; + if (!CFile::fileExists(filename) && CFile::fileExists(sharedfile)) + filename = sharedfile; + + getUI().saveConfig(filename); } // *********************************************************************************************************