From 5823e98356f7537c02c7045ec40752f98d3bf09e Mon Sep 17 00:00:00 2001 From: Nimetu Date: Fri, 11 May 2018 14:42:49 +0300 Subject: [PATCH] Added: Duplicating macro or macro commands --HG-- branch : develop --- .../data/gamedev/interfaces_v3/macros.xml | 4 ++ .../src/interface_v3/macrocmd_manager.cpp | 42 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/macros.xml b/code/ryzom/client/data/gamedev/interfaces_v3/macros.xml index 8c2eb9f82..d3c886282 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/macros.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/macros.xml @@ -234,6 +234,8 @@ + + @@ -324,6 +326,8 @@ + + diff --git a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp index fdb4f45c8..cff97fc68 100644 --- a/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp +++ b/code/ryzom/client/src/interface_v3/macrocmd_manager.cpp @@ -777,6 +777,25 @@ public: }; REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdEdit, "new_macro_cmd_edit"); +// *************************************************************************** +// Called from context menu when we right click on a command of the new_macro container +class CHandlerNewMacroCmdCopy: public IActionHandler +{ +public: + virtual void execute(CCtrlBase *pCaller, const string &/* Params */) + { + CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); + sint nCmdNb = getCmdNbFromId(pCaller->getId()); + pMCM->CurrentEditMacro.addCommand(pMCM->CurrentEditMacro.Commands[nCmdNb].Name, + pMCM->CurrentEditMacro.Commands[nCmdNb].Params, + nCmdNb); + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CMacroCmdManager::getInstance()->EditCmd->deactivate(); + CAHManager::getInstance()->runActionHandler("new_macro_open",NULL); + } +}; +REGISTER_ACTION_HANDLER( CHandlerNewMacroCmdCopy, "new_macro_cmd_copy"); + // *************************************************************************** // Called from context menu when we right click on a command of the new_macro container class CHandlerNewMacroCmdDelete: public IActionHandler @@ -1087,6 +1106,29 @@ public: }; REGISTER_ACTION_HANDLER( CHandlerMacrosEdit, "macros_edit"); +// *************************************************************************** +// Called from context menu on a macro +class CHandlerMacrosCopy : public IActionHandler +{ +public: + virtual void execute(CCtrlBase *pCaller, const string &/* Params */) + { + sint nMacNb = getMacroFromId(pCaller->getId()); + CInterfaceManager *pIM = CInterfaceManager::getInstance(); + CMacroCmdManager *pMCM = CMacroCmdManager::getInstance(); + + // duplicate selected macro + CMacroCmd m = pMCM->getMacros()[nMacNb]; + m.ID = -1; + m.Combo.Key = KeyCount; + m.Combo.KeyButtons = noKeyButton; + pMCM->addMacro(m, nMacNb+1); + + CAHManager::getInstance()->runActionHandler("macros_open",NULL); + } +}; +REGISTER_ACTION_HANDLER( CHandlerMacrosCopy, "macros_copy"); + // *************************************************************************** // Called from context menu on a macro class CHandlerMacrosDel : public IActionHandler