Merge with menu_navi

--HG--
branch : yubo
hg/yubo
Inky 5 years ago
commit 6fcb6f0669

@ -174,6 +174,7 @@ namespace NLGUI
bool _MouseDown : 1;
bool _CallingAH : 1;
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
bool _Keyboard : 1;
bool _Frozen : 1;
bool _Scale : 1;

@ -53,6 +53,7 @@ namespace NLGUI
_MouseDown = false;
_CallingAH = false;
_Cancelable = false;
_Keyboard = false;
_Target = NULL;
_Inverted = false;
_IsDBLink = false;
@ -221,6 +222,11 @@ namespace NLGUI
return toString( _Cancelable );
}
else
if( name == "keyboard" )
{
return toString( _Keyboard );
}
else
if( name == "frozen" )
{
return toString( _Frozen );
@ -401,6 +407,14 @@ namespace NLGUI
return;
}
else
if( name == "keyboard" )
{
bool b;
if( fromString( value, b ) )
_Keyboard = b;
return;
}
else
if( name == "frozen" )
{
bool b;
@ -470,6 +484,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "target_stepy", BAD_CAST toString( _TargetStepY ).c_str() );
xmlSetProp( node, BAD_CAST "step_value", BAD_CAST toString( _StepValue ).c_str() );
xmlSetProp( node, BAD_CAST "cancelable", BAD_CAST toString( _Cancelable ).c_str() );
xmlSetProp( node, BAD_CAST "keyboard", BAD_CAST toString( _Keyboard ).c_str() );
xmlSetProp( node, BAD_CAST "frozen", BAD_CAST toString( _Frozen ).c_str() );
return node;
@ -585,6 +600,9 @@ namespace NLGUI
prop = (char*) xmlGetProp( node, (xmlChar*)"cancelable" );
if (prop) _Cancelable = convertBool(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"keyboard" );
if (prop) _Keyboard = convertBool(prop);
prop= (char*) xmlGetProp (node, (xmlChar*)"frozen");
_Frozen = false;
if (prop)
@ -850,6 +868,7 @@ namespace NLGUI
if (CCtrlBase::handleEvent(event)) return true;
if (!_Active || _Frozen)
return false;
if (event.getType() == NLGUI::CEventDescriptor::mouse)
{
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
@ -908,6 +927,28 @@ namespace NLGUI
return true;
}
}
else if (event.getType() == NLGUI::CEventDescriptor::key)
{
const NLGUI::CEventDescriptorKey &eventDesc = (const NLGUI::CEventDescriptorKey &)event;
if (eventDesc.getKeyEventType() == NLGUI::CEventDescriptorKey::keydown)
{
if (_Keyboard)
{
sint32 i = 0;
// direction
if (eventDesc.getKey() == KeyNEXT) i++;
if (eventDesc.getKey() == KeyPRIOR) i--;
if (_Vertical)
moveTrackY(-(i * _TargetStepY));
else
moveTrackX(-(i * _TargetStepX));
return true;
}
}
}
return false;
}
@ -1209,6 +1250,7 @@ namespace NLGUI
if(wReal <= maxWReal)
return;
// compute the new ofsX.
sint32 ofsX= _Target->getOfsX();
ofsX+= dx;

@ -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");

@ -4610,9 +4610,9 @@ public:
REGISTER_ACTION_HANDLER( CHandlerSortTribeFame, "sort_tribefame");
// ***************************************************************************
class CHandlerCharselNaviGetKeys : public IActionHandler
class CHandlerOutgameNaviGetKeys : public IActionHandler
{
virtual void execute (CCtrlBase *pCaller, const string &Params)
virtual void execute (CCtrlBase *pCaller, const std::string &Params)
{
if (!pCaller->getParent())
return;
@ -4629,12 +4629,18 @@ class CHandlerCharselNaviGetKeys : public IActionHandler
if (Driver->AsyncListener.isKeyPushed(KeyRETURN)) event = 2;
if (Driver->AsyncListener.isKeyPushed(KeyDOWN)) event = 3;
if (Driver->AsyncListener.isKeyPushed(KeyUP)) event = 4;
if (Driver->AsyncListener.isKeyPushed(KeyI)) event = 5;
if (Driver->AsyncListener.isKeyPushed(KeyP)) event = 6;
std::string id = "create";
if (pCaller->getId() == "ui:outgame:charsel")
id = "sel";
if (event != -1)
CLuaManager::getInstance().executeLuaScript(toString("outgame:eventCharselKeyGet(%i)", event));
CLuaManager::getInstance().executeLuaScript(toString("outgame:eventChar%sKeyGet(%i)", id.c_str(), event));
}
// reset previous input
Driver->AsyncListener.reset();
}
};
REGISTER_ACTION_HANDLER( CHandlerCharselNaviGetKeys, "navigate_charsel" );
REGISTER_ACTION_HANDLER( CHandlerOutgameNaviGetKeys, "navigate_outgame" );

Loading…
Cancel
Save