From 1dc3d51ce238b884270abb0527252e50ebeb49fe Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 11 Oct 2018 15:24:03 +0300 Subject: [PATCH] Added: save_ui action handler to save keys and icfg files --HG-- branch : develop --- .../client/src/interface_v3/group_map.cpp | 14 +--- .../src/interface_v3/interface_manager.cpp | 70 +++++++++++++++---- .../src/interface_v3/interface_manager.h | 4 ++ 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_map.cpp b/code/ryzom/client/src/interface_v3/group_map.cpp index 37a0a8a57..e6cfcf824 100644 --- a/code/ryzom/client/src/interface_v3/group_map.cpp +++ b/code/ryzom/client/src/interface_v3/group_map.cpp @@ -2665,18 +2665,8 @@ CCtrlButton *CGroupMap::addUserLandMark(const NLMISC::CVector2f &pos, const ucst addLandMark(_UserLM, pos, title, getUserLandMarkOptions((uint32)_CurContinent->UserLandMarks.size() - 1)); // Save the config file each time a user landmark is created - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - uint8 currMode = pIM->getMode(); - 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); - } + CInterfaceManager::getInstance()->saveConfig(); + return _UserLM.back(); } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 6ec32a34d..debe0b9ab 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -1270,32 +1270,19 @@ void CInterfaceManager::loadInterfaceConfig() // ------------------------------------------------------------------------------------------------ void CInterfaceManager::uninitInGame0 () { - // Autosave of the keys if (_KeysLoaded) { - if (!ClientCfg.R2EDEnabled) - { - string filename = "save/keys_" + PlayerSelectedFileName + ".xml"; - if (!CFile::fileExists(filename) && CFile::fileExists("save/shared_keys.xml")) - filename = "save/shared_keys.xml"; + saveKeys(); - saveKeys(filename); - } _KeysLoaded = false; } // Autosave of the interface in interface.cfg if (_ConfigLoaded) { - if (!ClientCfg.R2EDEnabled) - { - string filename = "save/interface_" + PlayerSelectedFileName + ".icfg"; - if (!CFile::fileExists(filename) && CFile::fileExists("save/shared_interface.icfg")) - filename = "save/shared_interface.icfg"; + saveConfig(); - saveConfig(filename); - } _ConfigLoaded = false; } } @@ -1884,6 +1871,29 @@ public: } }; +// ------------------------------------------------------------------------------------------------ +// +bool CInterfaceManager::saveConfig (bool verbose) +{ + bool ret = true; + + if (!ClientCfg.R2EDEnabled) + { + uint8 currMode = getMode(); + + string filename = "save/interface_" + PlayerSelectedFileName + ".icfg"; + if (!CFile::fileExists(filename) && CFile::fileExists("save/shared_interface.icfg")) + filename = "save/shared_interface.icfg"; + + if (verbose) CInterfaceManager::getInstance()->displaySystemInfo("Saving " + filename); + ret = saveConfig(filename); + + if (currMode != getMode()) + setMode(currMode); + } + + return ret; +} // ------------------------------------------------------------------------------------------------ bool CInterfaceManager::saveConfig (const string &filename) @@ -2722,7 +2732,25 @@ void writeMacros (xmlNodePtr node) } // *************************************************************************** +bool CInterfaceManager::saveKeys(bool verbose) +{ + bool ret = true; + + if (!ClientCfg.R2EDEnabled) + { + string filename = "save/keys_" + PlayerSelectedFileName + ".xml"; + if (!CFile::fileExists(filename) && CFile::fileExists("save/shared_keys.xml")) + filename = "save/shared_keys.xml"; + + if (verbose) CInterfaceManager::getInstance()->displaySystemInfo("Saving " + filename); + + ret = saveKeys(filename); + } + + return ret; +} +// *************************************************************************** bool CInterfaceManager::saveKeys(const std::string &filename) { bool ret = false; @@ -2924,6 +2952,18 @@ void CInterfaceManager::displayWebWindow(const string & name, const string & url CAHManager::getInstance()->runActionHandler("browse", NULL, "name="+name+":content:html|url="+url); } + +// *************************************************************************** +class CAHSaveUI : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + CInterfaceManager::getInstance()->saveKeys(true); + CInterfaceManager::getInstance()->saveConfig(true); + } +}; +REGISTER_ACTION_HANDLER (CAHSaveUI, "save_ui"); + /* // *************************************************************************** class CHandlerDispWebOnQuit : public IActionHandler diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 93089a826..e83192a3d 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -205,10 +205,14 @@ public: // Load/Save position, size, etc.. of windows bool loadConfig (const std::string &filename); + // Save config to default location, if verbose is true, display message in game sysinfo + bool saveConfig (bool verbose = false); bool saveConfig (const std::string &filename); // delete the user config (give the player ident fileName) bool deletePlayerConfig (const std::string &playerFileIdent); + // Save keys to default location, if verbose is true, display message in game sysinfo + bool saveKeys (bool verbose = false); // Save the keys config file bool saveKeys (const std::string &filename); // delete the user Keysconfig (give the player ident fileName)