From f5e9b7703c710fc67dd421d4169a4f40b23cf278 Mon Sep 17 00:00:00 2001 From: Inky Date: Sun, 23 Jun 2019 02:13:39 +0300 Subject: [PATCH 1/5] Changed: added keyboard events to CCtrlScroll elements --HG-- branch : menu_navi --- code/nel/include/nel/gui/ctrl_scroll.h | 1 + code/nel/src/gui/ctrl_scroll.cpp | 42 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/code/nel/include/nel/gui/ctrl_scroll.h b/code/nel/include/nel/gui/ctrl_scroll.h index a22da2cbd..8a47691a5 100644 --- a/code/nel/include/nel/gui/ctrl_scroll.h +++ b/code/nel/include/nel/gui/ctrl_scroll.h @@ -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; diff --git a/code/nel/src/gui/ctrl_scroll.cpp b/code/nel/src/gui/ctrl_scroll.cpp index e97bd8cd4..ba38b32c2 100644 --- a/code/nel/src/gui/ctrl_scroll.cpp +++ b/code/nel/src/gui/ctrl_scroll.cpp @@ -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; From 5d1233e8050aa301900dafc0b260d8ec2f5a1fcf Mon Sep 17 00:00:00 2001 From: Inky Date: Mon, 24 Jun 2019 02:15:04 +0300 Subject: [PATCH 2/5] Changed: update button selection handler mainland_select --HG-- branch : menu_navi --- code/ryzom/client/src/connection.cpp | 62 +++++++++++++++++++--------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 045822370..df557dd45 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -2110,7 +2110,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); + //CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND)); if (pList == NULL) @@ -2189,7 +2189,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); + //CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND)); pList->clearGroups(); } @@ -2200,32 +2200,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(ctrl); + if (but) + { + but->setPushed(false); + } + } + }; + CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_MAINLAND)); + if (!list) + return; - CCtrlButton *pCB = NULL; - // Unselect - if (MainlandSelected.asInt() != 0) + // unselect + if (Params.empty()) { - pCB = dynamic_cast(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(pCaller); - if (pCB != NULL) + // now select + uint32 mainland; + if (Params.empty()) { - string name = pCB->getId(); - name = name.substr(0,name.rfind(':')); - uint32 mainland; - fromString(name.substr(name.rfind(':')+1,name.size()), mainland); - MainlandSelected = (TSessionId)mainland; + CCtrlButton *pCB = dynamic_cast(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"); From c8927c9c4bdbf18f2521a7a682356c74dcaaf505 Mon Sep 17 00:00:00 2001 From: Inky Date: Mon, 24 Jun 2019 20:34:01 +0300 Subject: [PATCH 3/5] Changed: update button selection handler keyset_select --HG-- branch : menu_navi --- code/ryzom/client/src/connection.cpp | 73 +++++++++++++++------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index df557dd45..17a042efd 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -2454,7 +2454,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); + //CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceGroup *pList = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); pList->clearGroups(); } @@ -2465,59 +2465,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(ctrl); + CCtrlBaseButton *but = dynamic_cast(ctrl); if (but) { but->setPushed(false); } } }; - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CInterfaceGroup * list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); - if (list) - { - CUnpush unpusher; - unpusher.Ref = pCaller; - list->visit(&unpusher); - } - CCtrlBaseButton *but = dynamic_cast(pCaller); + CInterfaceGroup *list = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(GROUP_LIST_KEYSET)); + if (!list) + return; + + // unselect + CUnpush unpusher; + unpusher.Ref = pCaller; + list->visit(&unpusher); + + // now select + CCtrlBaseButton *but = dynamic_cast(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"; @@ -2526,17 +2533,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"); From 0f3f64cdc231ee71cef004353551a478f04824d4 Mon Sep 17 00:00:00 2001 From: Inky Date: Tue, 25 Jun 2019 15:52:28 +0300 Subject: [PATCH 4/5] Changed: character creation handler Todo: fusion both handler --HG-- branch : menu_navi --- .../src/interface_v3/action_handler_game.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index a9dcb54ea..c35493475 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -4638,3 +4638,35 @@ class CHandlerCharselNaviGetKeys : public IActionHandler } }; REGISTER_ACTION_HANDLER( CHandlerCharselNaviGetKeys, "navigate_charsel" ); + +// *************************************************************************** +class CHandlerCharcreateGetKeys : public IActionHandler +{ + virtual void execute (CCtrlBase *pCaller, const string &Params) + { + if (!pCaller->getParent()) + return; + + if (pCaller->getParent()->getId() != "ui:outgame") + return; + + if (Params.empty()) + { + sint32 event = -1; + + if (Driver->AsyncListener.isKeyPushed(KeyESCAPE)) event = 0; + //if (Driver->AsyncListener.isKeyPushed(KeyDELETE)) event = 1; + 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; + + if (event != -1) + CLuaManager::getInstance().executeLuaScript(toString("outgame:eventCharcreateKeyGet(%i)", event)); + } + // reset previous input + Driver->AsyncListener.reset(); + } +}; +REGISTER_ACTION_HANDLER( CHandlerCharcreateGetKeys, "navigate_charcreate" ); \ No newline at end of file From b2b16e3ccecc73b3818b4818b604bcaf3cdeb7e0 Mon Sep 17 00:00:00 2001 From: Inky Date: Tue, 25 Jun 2019 22:55:22 +0300 Subject: [PATCH 5/5] Changed: fusion selection and creation handler --HG-- branch : menu_navi --- .../src/interface_v3/action_handler_game.cpp | 42 ++++--------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index c35493475..706099741 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -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,44 +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 (event != -1) - CLuaManager::getInstance().executeLuaScript(toString("outgame:eventCharselKeyGet(%i)", event)); - } - // reset previous input - Driver->AsyncListener.reset(); - } -}; -REGISTER_ACTION_HANDLER( CHandlerCharselNaviGetKeys, "navigate_charsel" ); - -// *************************************************************************** -class CHandlerCharcreateGetKeys : public IActionHandler -{ - virtual void execute (CCtrlBase *pCaller, const string &Params) - { - if (!pCaller->getParent()) - return; - - if (pCaller->getParent()->getId() != "ui:outgame") - return; - - if (Params.empty()) - { - sint32 event = -1; - - if (Driver->AsyncListener.isKeyPushed(KeyESCAPE)) event = 0; - //if (Driver->AsyncListener.isKeyPushed(KeyDELETE)) event = 1; - 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:eventCharcreateKeyGet(%i)", event)); + CLuaManager::getInstance().executeLuaScript(toString("outgame:eventChar%sKeyGet(%i)", id.c_str(), event)); } // reset previous input Driver->AsyncListener.reset(); } }; -REGISTER_ACTION_HANDLER( CHandlerCharcreateGetKeys, "navigate_charcreate" ); \ No newline at end of file +REGISTER_ACTION_HANDLER( CHandlerOutgameNaviGetKeys, "navigate_outgame" );