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 _MouseDown : 1;
bool _CallingAH : 1; bool _CallingAH : 1;
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
bool _Keyboard : 1;
bool _Frozen : 1; bool _Frozen : 1;
bool _Scale : 1; bool _Scale : 1;

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

@ -2118,7 +2118,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)
@ -2197,7 +2197,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();
} }
@ -2208,32 +2208,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);
if (!pCB)
return;
std::string name = pCB->getId();
name = name.substr(0, name.rfind(':')); name = name.substr(0, name.rfind(':'));
uint32 mainland;
fromString(name.substr(name.rfind(':')+1,name.size()), mainland); if (!fromString(name.substr(name.rfind(':')+1, name.size()), mainland))
MainlandSelected = (TSessionId)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");
@ -2438,7 +2462,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_KEYSET)); CInterfaceGroup *pList = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
pList->clearGroups(); pList->clearGroups();
} }
@ -2449,21 +2473,18 @@ REGISTER_ACTION_HANDLER (CAHResetKeysetList, "reset_keyset_list");
// *************************************************************************** // ***************************************************************************
class CAHResetKeysetSelect : public IActionHandler class CAHResetKeysetSelect : public IActionHandler
{ {
public:
std::string getIdPostFix(const std::string fullId) std::string getIdPostFix(const std::string fullId)
{ {
std::string::size_type pos = fullId.find_last_of(":"); std::string::size_type pos = fullId.find_last_of(":");
if (pos != std::string::npos) if (pos != std::string::npos)
{
return fullId.substr(pos + 1); return fullId.substr(pos + 1);
}
return ""; 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 // 'unpush' all groups but the caller
//
struct CUnpush : public CInterfaceElementVisitor struct CUnpush : public CInterfaceElementVisitor
{ {
CCtrlBase *Ref; CCtrlBase *Ref;
@ -2477,31 +2498,41 @@ public:
} }
} }
}; };
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CInterfaceGroup *list = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); CInterfaceGroup *list = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET));
if (list) if (!list)
{ return;
// unselect
CUnpush unpusher; CUnpush unpusher;
unpusher.Ref = pCaller; unpusher.Ref = pCaller;
list->visit(&unpusher); list->visit(&unpusher);
}
// now select
CCtrlBaseButton *but = dynamic_cast<CCtrlBaseButton*>(pCaller); CCtrlBaseButton *but = dynamic_cast<CCtrlBaseButton*>(pCaller);
if (but) if (but)
{
but->setPushed(true); 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"; GameKeySet = "keys.xml";
RingEditorKeySet = "keys_r2ed.xml"; RingEditorKeySet = "keys_r2ed.xml";
if (!pCaller->getParent()) return;
// compute the 2 filenames from the id // compute the two filenames from the id
// if id is in the built-in keysets : // if id is in the built-in keysets
CConfigFile::CVar *keySetVar = ClientCfg.ConfigFile.getVarPtr(KeySetVarName); 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) for (uint k = 0; k < keySetVar->size(); ++k)
{ {
std::string id = getIdPostFix(pCaller->getParent()->getId());
if (keySetVar->asString(k) == id) if (keySetVar->asString(k) == id)
{ {
GameKeySet = "keys" + string(id.empty() ? "" : "_") + id + ".xml"; 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"); REGISTER_ACTION_HANDLER (CAHResetKeysetSelect, "keyset_select");

@ -4610,9 +4610,9 @@ public:
REGISTER_ACTION_HANDLER( CHandlerSortTribeFame, "sort_tribefame"); 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()) if (!pCaller->getParent())
return; return;
@ -4629,12 +4629,18 @@ class CHandlerCharselNaviGetKeys : public IActionHandler
if (Driver->AsyncListener.isKeyPushed(KeyRETURN)) event = 2; if (Driver->AsyncListener.isKeyPushed(KeyRETURN)) event = 2;
if (Driver->AsyncListener.isKeyPushed(KeyDOWN)) event = 3; if (Driver->AsyncListener.isKeyPushed(KeyDOWN)) event = 3;
if (Driver->AsyncListener.isKeyPushed(KeyUP)) event = 4; 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) 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 // reset previous input
Driver->AsyncListener.reset(); Driver->AsyncListener.reset();
} }
}; };
REGISTER_ACTION_HANDLER( CHandlerCharselNaviGetKeys, "navigate_charsel" ); REGISTER_ACTION_HANDLER( CHandlerOutgameNaviGetKeys, "navigate_outgame" );

Loading…
Cancel
Save