|
|
|
@ -2118,7 +2118,7 @@ public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
|
|
|
|
|
{
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
//CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
|
|
|
|
|
CInterfaceGroup *pList = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND));
|
|
|
|
|
if (pList == NULL)
|
|
|
|
@ -2197,7 +2197,7 @@ public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
|
|
|
|
|
{
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
//CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
CInterfaceGroup *pList = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND));
|
|
|
|
|
pList->clearGroups();
|
|
|
|
|
}
|
|
|
|
@ -2208,32 +2208,56 @@ REGISTER_ACTION_HANDLER (CAHResetMainlandList, "reset_mainland_list");
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
class CAHMainlandSelect : public IActionHandler
|
|
|
|
|
{
|
|
|
|
|
virtual void execute (CCtrlBase *pCaller, const string &/* Params */)
|
|
|
|
|
virtual void execute (CCtrlBase *pCaller, const std::string &Params)
|
|
|
|
|
{
|
|
|
|
|
nlinfo("CAHMainlandSelect called");
|
|
|
|
|
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
//nlinfo("CAHMainlandSelect called");
|
|
|
|
|
struct CUnpush : public CInterfaceElementVisitor
|
|
|
|
|
{
|
|
|
|
|
CCtrlBase *Ref;
|
|
|
|
|
virtual void visitCtrl(CCtrlBase *ctrl)
|
|
|
|
|
{
|
|
|
|
|
if (ctrl == Ref) return;
|
|
|
|
|
CCtrlBaseButton *but = dynamic_cast<CCtrlBaseButton*>(ctrl);
|
|
|
|
|
if (but)
|
|
|
|
|
{
|
|
|
|
|
but->setPushed(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
CInterfaceGroup *list = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND));
|
|
|
|
|
if (!list)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CCtrlButton *pCB = NULL;
|
|
|
|
|
// Unselect
|
|
|
|
|
if (MainlandSelected.asInt() != 0)
|
|
|
|
|
// unselect
|
|
|
|
|
if (Params.empty())
|
|
|
|
|
{
|
|
|
|
|
pCB = dynamic_cast<CCtrlButton*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND ":"+toString(MainlandSelected)+":but"));
|
|
|
|
|
if (pCB != NULL)
|
|
|
|
|
pCB->setPushed(false);
|
|
|
|
|
CUnpush unpusher;
|
|
|
|
|
unpusher.Ref = pCaller;
|
|
|
|
|
list->visit(&unpusher);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pCB = dynamic_cast<CCtrlButton*>(pCaller);
|
|
|
|
|
if (pCB != NULL)
|
|
|
|
|
// now select
|
|
|
|
|
uint32 mainland;
|
|
|
|
|
if (Params.empty())
|
|
|
|
|
{
|
|
|
|
|
string name = pCB->getId();
|
|
|
|
|
CCtrlButton *pCB = dynamic_cast<CCtrlButton*>(pCaller);
|
|
|
|
|
if (!pCB)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
std::string name = pCB->getId();
|
|
|
|
|
name = name.substr(0, name.rfind(':'));
|
|
|
|
|
uint32 mainland;
|
|
|
|
|
fromString(name.substr(name.rfind(':')+1,name.size()), mainland);
|
|
|
|
|
MainlandSelected = (TSessionId)mainland;
|
|
|
|
|
|
|
|
|
|
if (!fromString(name.substr(name.rfind(':')+1, name.size()), mainland))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pCB->setPushed(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (!fromString(Params, mainland))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// and store
|
|
|
|
|
MainlandSelected = (TSessionId)mainland;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
REGISTER_ACTION_HANDLER (CAHMainlandSelect, "mainland_select");
|
|
|
|
@ -2438,7 +2462,7 @@ public:
|
|
|
|
|
|
|
|
|
|
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
|
|
|
|
|
{
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
//CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
CInterfaceGroup *pList = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
|
|
|
|
|
pList->clearGroups();
|
|
|
|
|
}
|
|
|
|
@ -2449,21 +2473,18 @@ REGISTER_ACTION_HANDLER (CAHResetKeysetList, "reset_keyset_list");
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
class CAHResetKeysetSelect : public IActionHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
std::string getIdPostFix(const std::string fullId)
|
|
|
|
|
{
|
|
|
|
|
std::string::size_type pos = fullId.find_last_of(":");
|
|
|
|
|
if (pos != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
return fullId.substr(pos + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
virtual void execute (CCtrlBase *pCaller, const string &/* Params */)
|
|
|
|
|
|
|
|
|
|
virtual void execute(CCtrlBase *pCaller, const std::string &Params)
|
|
|
|
|
{
|
|
|
|
|
if (!pCaller) return;
|
|
|
|
|
// 'unpush' all groups but the caller
|
|
|
|
|
//
|
|
|
|
|
struct CUnpush : public CInterfaceElementVisitor
|
|
|
|
|
{
|
|
|
|
|
CCtrlBase *Ref;
|
|
|
|
@ -2477,31 +2498,41 @@ public:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
CInterfaceGroup *list = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
|
|
|
|
|
if (list)
|
|
|
|
|
{
|
|
|
|
|
if (!list)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unselect
|
|
|
|
|
CUnpush unpusher;
|
|
|
|
|
unpusher.Ref = pCaller;
|
|
|
|
|
list->visit(&unpusher);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// now select
|
|
|
|
|
CCtrlBaseButton *but = dynamic_cast<CCtrlBaseButton*>(pCaller);
|
|
|
|
|
if (but)
|
|
|
|
|
{
|
|
|
|
|
but->setPushed(true);
|
|
|
|
|
|
|
|
|
|
std::string id;
|
|
|
|
|
if (Params.empty())
|
|
|
|
|
{
|
|
|
|
|
if (!pCaller) return;
|
|
|
|
|
if (!pCaller->getParent()) return;
|
|
|
|
|
|
|
|
|
|
id = getIdPostFix(pCaller->getParent()->getId());
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
else
|
|
|
|
|
id = getIdPostFix(Params);
|
|
|
|
|
|
|
|
|
|
GameKeySet = "keys.xml";
|
|
|
|
|
RingEditorKeySet = "keys_r2ed.xml";
|
|
|
|
|
if (!pCaller->getParent()) return;
|
|
|
|
|
// compute the 2 filenames from the id
|
|
|
|
|
// if id is in the built-in keysets :
|
|
|
|
|
|
|
|
|
|
// compute the two filenames from the id
|
|
|
|
|
// if id is in the built-in keysets
|
|
|
|
|
CConfigFile::CVar *keySetVar = ClientCfg.ConfigFile.getVarPtr(KeySetVarName);
|
|
|
|
|
if (keySetVar && keySetVar->size() != 0)
|
|
|
|
|
if (keySetVar && keySetVar->size() > 0)
|
|
|
|
|
{
|
|
|
|
|
for (uint k = 0; k < keySetVar->size(); ++k)
|
|
|
|
|
{
|
|
|
|
|
std::string id = getIdPostFix(pCaller->getParent()->getId());
|
|
|
|
|
if (keySetVar->asString(k) == id)
|
|
|
|
|
{
|
|
|
|
|
GameKeySet = "keys" + string(id.empty() ? "" : "_") + id + ".xml";
|
|
|
|
@ -2510,17 +2541,15 @@ public:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ... else maybe from a previous character ?
|
|
|
|
|
if (CFile::isExists("save/keys_" + getIdPostFix(pCaller->getParent()->getId()) + ".xml") )
|
|
|
|
|
{
|
|
|
|
|
GameKeySet = "keys_" + getIdPostFix(pCaller->getParent()->getId()) + ".xml";
|
|
|
|
|
}
|
|
|
|
|
if (CFile::isExists("save/keys_r2ed_" + getIdPostFix(pCaller->getParent()->getId()) + ".xml") )
|
|
|
|
|
{
|
|
|
|
|
RingEditorKeySet = "keys_r2ed_" + getIdPostFix(pCaller->getParent()->getId()) + ".xml";
|
|
|
|
|
}
|
|
|
|
|
// NB : key file will be copied for real when the new 'character summary' is
|
|
|
|
|
|
|
|
|
|
// else maybe from a previous character?
|
|
|
|
|
if (CFile::isExists("save/keys_" + id + ".xml"))
|
|
|
|
|
GameKeySet = "keys_" + id + ".xml";
|
|
|
|
|
|
|
|
|
|
if (CFile::isExists("save/keys_r2ed_" + id + ".xml"))
|
|
|
|
|
RingEditorKeySet = "keys_r2ed_" + id + ".xml";
|
|
|
|
|
|
|
|
|
|
// NB: key file will be copied for real when the new character summary is
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
REGISTER_ACTION_HANDLER (CAHResetKeysetSelect, "keyset_select");
|
|
|
|
|