Added: save_ui action handler to save keys and icfg files
--HG-- branch : develop
This commit is contained in:
parent
8ef8b2d62d
commit
1dc3d51ce2
3 changed files with 61 additions and 27 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue