1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2016 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef RZ_MACROCMD_MANAGER_H
20 #define RZ_MACROCMD_MANAGER_H
22 #include "nel/misc/stream.h"
23 #include "../actions.h"
25 // ***************************************************************************
26 class CActionsManager
;
27 class CModalContainerEditCmd
;
29 // ***************************************************************************
33 class CCommand
// An action handler
39 // ------------------------------
42 CCommand(const char *name
)
47 CCommand(const char *name
, const char *params
)
53 void serial (NLMISC::IStream
&f
);
57 std::vector
<CCommand
> Commands
;
61 // Display bitmap form
62 uint8 BitmapBack
; // 0xFF = Pas de Back
63 uint8 BitmapIcon
; // 0xFF = Pas de Ico
64 uint8 BitmapOver
; // 0xFF = Pas de Over
65 std::string DispText
; // Simple text (A-Z,0-9)
67 // Display strings form
73 // ------------------------------
77 void addCommand (const std::string
&sName
, const std::string
&sParam
, sint32 nPos
=-1);
78 void delCommand (uint cmdNb
);
79 void moveUpCommand (uint cmdNb
);
80 void moveDownCommand (uint cmdNb
);
82 void writeTo (xmlNodePtr node
) const;
83 bool readFrom (xmlNodePtr node
);
86 // ***************************************************************************
87 class CMacroCmdManager
91 static CMacroCmdManager
*getInstance()
93 if (_Instance
== NULL
)
94 _Instance
= new CMacroCmdManager
;
99 static void releaseInstance();
104 const std::vector
<CMacroCmd
> &getMacros() { return _Macros
; }
105 void addMacro (const CMacroCmd
&m
, sint32 nPos
=-1);
106 void delMacro(sint32 nMacNb
);
107 void removeAllMacros();
109 void refreshMacroCombo();
111 sint32
getTexIdBack(uint8 nb
) { return (nb
>=_OptBackId
.size()) ? _OptBackId
[_OptBackId
.size()-1] : _OptBackId
[nb
]; }
112 sint32
getTexIdIcon(uint8 nb
) { return (nb
>=_OptIconId
.size()) ? _OptIconId
[_OptIconId
.size()-1] : _OptIconId
[nb
]; }
113 sint32
getTexIdOver(uint8 nb
) { return (nb
>=_OptOverId
.size()) ? _OptOverId
[_OptOverId
.size()-1] : _OptOverId
[nb
]; }
115 void execute (uint nMacroNb
);
116 void executeID (sint32 nMacroID
);
117 void updateMacroExecution ();
118 void receiveActionEnd(uint8 actionId
);
120 uint32
getActionId() { return _ActionId
; }
121 void incActionId() { _ActionId
++; }
123 const CMacroCmd
*getMacroFromMacroID(sint32 id
);
125 // Call This method when keys changed (delete, edit, etc...)
126 void refreshAllKeyDisplays();
129 std::vector
<CActionsManager
*> ActionManagers
;
131 CMacroCmd CurrentEditMacro
;
132 sint32 CurrentEditMacroNb
; // -1 -> create;
134 CModalContainerEditCmd
*EditCmd
;
135 CModalContainerEditCmd
*NewKey
;
139 std::vector
<CMacroCmd
> _Macros
;
141 std::vector
<sint32
> _OptBackId
; // All the back bitmap possible
142 std::vector
<sint32
> _OptIconId
; // All the icon bitmap possible
143 std::vector
<sint32
> _OptOverId
; // All the over bitmap possible
145 sint32 _CurExecMac
; // Current macro in execution
147 sint32 _CurExecCmdWait
;
148 sint32 _CurExecCmdWaitId
;
149 bool _CurExecCmdWaitEnded
;
153 sint32 _MacroIDGenerator
;
156 static CMacroCmdManager
*_Instance
;
160 void delActionManagerEntries();
161 void addActionManagerEntries();
165 // ***************************************************************************
167 // ***************************************************************************
169 #define AH_MACRO_EXEC "macro_exec"
171 #define WIN_MACRO "ui:interface:macros"
172 #define WIN_MACRO_CONTENT "ui:interface:macros:content:macros:list"
173 #define TEMPLATE_MACRO_ELT "element_macro"
174 #define TEMPLATE_MACRO_ELT_TEXT "macro_name"
175 #define TEMPLATE_MACRO_ELT_ICON "icon"
176 #define TEMPLATE_MACRO_ELT_KEYTEXT "macro_key"
179 #define WIN_NEWMACRO "ui:interface:new_macro"
180 #define VIEW_NEWMACRO_TITLE "ui:interface:new_macro:header_opened:title"
181 #define NEWMACRO_TITLE_NEW "uiNewMacro"
182 #define NEWMACRO_TITLE_EDIT "uiEditMacro"
183 #define CTRL_NEWMACRO_ICON "ui:interface:new_macro:content:icon"
184 #define GROUP_NEWMACRO_EDIT_NAME "ui:interface:new_macro:content:edit_name"
185 #define GROUP_NEWMACRO_COMMANDS "ui:interface:new_macro:content:cmds:macros:list"
186 #define VIEW_NEWMACRO_KEY "ui:interface:new_macro:content:macro_key"
187 #define TEMPLATE_NEWMACRO_COMMAND "macro_command"
188 #define TEMPLATE_NEWMACRO_COMMAND_TEXT "macro_name"
190 #define WIN_MACROICONCREATION "ui:interface:macro_icon_creation"
191 #define CTRL_MACROICONCREATION_ICON "ui:interface:macro_icon_creation:icon"
192 #define GROUP_MACROICONCREATION_BACK "ui:interface:macro_icon_creation:IconBackground"
193 #define GROUP_MACROICONCREATION_ICON "ui:interface:macro_icon_creation:IconForeground"
194 #define GROUP_MACROICONCREATION_OVER "ui:interface:macro_icon_creation:IconPattern"
195 #define CTRL_MACROICONCREATION_BUTTON ":but"
196 #define CTRL_MACROICONCREATION_EDITTEXT "ui:interface:macro_icon_creation:edit_name"
198 // ***************************************************************************
201 #endif // RZ_MACROCMD_MANAGER_H