|
|
|
@ -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();
|
|
|
|
|
|
|
|
|
|
CCtrlButton *pCB = NULL;
|
|
|
|
|
// Unselect
|
|
|
|
|
if (MainlandSelected.asInt() != 0)
|
|
|
|
|
//nlinfo("CAHMainlandSelect called");
|
|
|
|
|
struct CUnpush : public CInterfaceElementVisitor
|
|
|
|
|
{
|
|
|
|
|
pCB = dynamic_cast<CCtrlButton*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND ":"+toString(MainlandSelected)+":but"));
|
|
|
|
|
if (pCB != NULL)
|
|
|
|
|
pCB->setPushed(false);
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
pCB = dynamic_cast<CCtrlButton*>(pCaller);
|
|
|
|
|
if (pCB != NULL)
|
|
|
|
|
// unselect
|
|
|
|
|
if (Params.empty())
|
|
|
|
|
{
|
|
|
|
|
string name = pCB->getId();
|
|
|
|
|
name = name.substr(0,name.rfind(':'));
|
|
|
|
|
CUnpush unpusher;
|
|
|
|
|
unpusher.Ref = pCaller;
|
|
|
|
|
list->visit(&unpusher);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// now select
|
|
|
|
|
uint32 mainland;
|
|
|
|
|
fromString(name.substr(name.rfind(':')+1,name.size()), mainland);
|
|
|
|
|
MainlandSelected = (TSessionId)mainland;
|
|
|
|
|
if (Params.empty())
|
|
|
|
|
{
|
|
|
|
|
CCtrlButton *pCB = dynamic_cast<CCtrlButton*>(pCaller);
|
|
|
|
|
if (!pCB)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
std::string name = pCB->getId();
|
|
|
|
|
name = name.substr(0, name.rfind(':'));
|
|
|
|
|
|
|
|
|
|
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,59 +2473,66 @@ 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;
|
|
|
|
|
virtual void visitCtrl(CCtrlBase *ctrl)
|
|
|
|
|
{
|
|
|
|
|
if (ctrl == Ref) return;
|
|
|
|
|
CCtrlBaseButton *but = dynamic_cast<CCtrlBaseButton *>(ctrl);
|
|
|
|
|
CCtrlBaseButton *but = dynamic_cast<CCtrlBaseButton*>(ctrl);
|
|
|
|
|
if (but)
|
|
|
|
|
{
|
|
|
|
|
but->setPushed(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
|
|
|
|
CInterfaceGroup * list = dynamic_cast<CInterfaceGroup *>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
|
|
|
|
|
if (list)
|
|
|
|
|
{
|
|
|
|
|
CInterfaceGroup *list = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
|
|
|
|
|
if (!list)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// unselect
|
|
|
|
|
CUnpush unpusher;
|
|
|
|
|
unpusher.Ref = pCaller;
|
|
|
|
|
list->visit(&unpusher);
|
|
|
|
|
}
|
|
|
|
|
CCtrlBaseButton *but = dynamic_cast<CCtrlBaseButton *>(pCaller);
|
|
|
|
|
|
|
|
|
|
// 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");
|
|
|
|
|