Changed: update button selection handler mainland_select

--HG--
branch : menu_navi
hg/feature/menu-navi
Inky 5 years ago
parent f5e9b7703c
commit 5d1233e805

@ -2110,7 +2110,7 @@ public:
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) 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)); CInterfaceGroup *pList = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND));
if (pList == NULL) if (pList == NULL)
@ -2189,7 +2189,7 @@ public:
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) 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)); CInterfaceGroup *pList = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND));
pList->clearGroups(); pList->clearGroups();
} }
@ -2200,32 +2200,56 @@ REGISTER_ACTION_HANDLER (CAHResetMainlandList, "reset_mainland_list");
// *************************************************************************** // ***************************************************************************
class CAHMainlandSelect : public IActionHandler class CAHMainlandSelect : public IActionHandler
{ {
virtual void execute (CCtrlBase *pCaller, const string &/* Params */) virtual void execute (CCtrlBase *pCaller, const std::string &Params)
{ {
nlinfo("CAHMainlandSelect called"); //nlinfo("CAHMainlandSelect called");
struct CUnpush : public CInterfaceElementVisitor
CInterfaceManager *pIM = CInterfaceManager::getInstance(); {
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
// Unselect if (Params.empty())
if (MainlandSelected.asInt() != 0)
{ {
pCB = dynamic_cast<CCtrlButton*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND ":"+toString(MainlandSelected)+":but")); CUnpush unpusher;
if (pCB != NULL) unpusher.Ref = pCaller;
pCB->setPushed(false); list->visit(&unpusher);
} }
pCB = dynamic_cast<CCtrlButton*>(pCaller); // now select
if (pCB != NULL) uint32 mainland;
if (Params.empty())
{ {
string name = pCB->getId(); CCtrlButton *pCB = dynamic_cast<CCtrlButton*>(pCaller);
name = name.substr(0,name.rfind(':')); if (!pCB)
uint32 mainland; return;
fromString(name.substr(name.rfind(':')+1,name.size()), mainland);
MainlandSelected = (TSessionId)mainland; 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); pCB->setPushed(true);
} }
else
if (!fromString(Params, mainland))
return;
// and store
MainlandSelected = (TSessionId)mainland;
} }
}; };
REGISTER_ACTION_HANDLER (CAHMainlandSelect, "mainland_select"); REGISTER_ACTION_HANDLER (CAHMainlandSelect, "mainland_select");

Loading…
Cancel
Save