1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 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 CL_INTERFACES_MANAGER_H
20 #define CL_INTERFACES_MANAGER_H
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/debug.h"
29 #include "nel/misc/ucstring.h"
31 #include "nel/3d/u_texture.h"
34 #include "button_base.h"
51 using NL3D::UTextureFile
;
55 * Class to manage the interfaces.
56 * \author Guillaume PUZIN
57 * \author Nevrax France
86 typedef std::map
<uint
, TTypCtrl
> TMapCtrls
;
87 typedef std::map
<uint
, ucstring
> TMapTexts
;
88 typedef std::map
<uint
, UTextureFile
*> TMapTextures
;
89 typedef std::map
<uint
, CPen
*> TMapPens
;
90 typedef std::map
<uint
, CButtonBase
*> TMapButtons
;
91 typedef std::map
<uint
, COSDBase
*> TMapOSDBase
;
93 typedef std::map
<uint
, COSD
*> TMapWindows
;
94 typedef std::list
<COSD
*> TOSD
;
95 typedef std::vector
<uint
> TUint
;
97 /// Type of the callback function parameter.
98 typedef void * TParam
;
99 /// Callback function for the interface controls.
100 typedef void (*TFuncCtrl
) (uint
, TParam
);
101 // map callback functions with their id (uint16)
102 typedef map
<uint16
, TFuncCtrl
> TMapFuncCtrl
;
104 static uint32 _WindowSizeX
;
105 static uint32 _WindowSizeY
;
108 /// Map all ctrl functions with their number (defined in functions.cpp)
109 static TMapFuncCtrl _CtrlFunctions
;
111 /// A Map to contain all the texts in the Interfaces.
112 static TMapCtrls _Ctrls
;
113 static TMapTexts _Texts
;
114 static TMapTextures _Textures
;
115 /// Default Pen Properties.
116 static CPen _DefaultPen
;
117 /// Some Specific Pen Properties.
118 static TMapPens _Pens
;
119 /// Default Button Look.
120 static CButtonBase _DefaultButton
;
121 /// Some specific Button Look
122 static TMapButtons _Buttons
;
123 /// Default OSD Look.
124 static COSDBase _DefaultOSDLook
;
125 /// Some specific OSD Look.
126 static TMapOSDBase _OSDLook
;
128 static TMapWindows _Windows
;
131 /// The list of OSD (id) that are waiting destruction (they are destroyed at the beginning of the 'update' method)
132 static TUint _OSDWaitingDestruction
;
134 /// list of the OSD (and their id) that were created since the last call to update and that are waiting insertion into _OSD and _Windows
135 static TOSD _OSDWaitingInsertion
;
138 /// Load all texts for the interfaces. CALL THIS FUNCTION BEFORE.
139 static void loadTexts();
140 /// Load all textures needed for the interfaces.
141 static void loadTextures();
142 /// Load Pens from file.
143 static void loadPens();
144 /// Load the array to convert a control id into a control type.
145 static void loadCtrls();
146 /// Load Buttons from file.
147 static void loadButtons();
148 /// Load The look of OSDs.
149 static void loadOSDLook();
152 * set the controls function map
153 * \param a map of ctrl functions
155 static void setFuncCtrl(const TMapFuncCtrl
&funcCtrlMap
);
158 /// Initialize the interfaces manager.
159 static void init(const TMapFuncCtrl
&funcCtrlMap
, uint32 width
, uint32 height
);
160 /// Release all the interface.
161 static void release();
163 /// Get the type of the control.
164 static TTypCtrl
getType(uint id
);
165 /// Return the text corresponding to the Id.
166 static ucstring
getText(uint id
);
167 /// Return the texture file Corresponding to the id.
168 static UTextureFile
*getTexture(uint id
);
169 /// Get the right Pen for the control.
170 static CPen
getPen(uint id
);
171 /// Get the right Button for the control.
172 static CButtonBase
getButton(uint id
);
174 /// Get the OSD Look.
175 static COSDBase
getOSDLook(uint id
);
178 static void runFuncCtrl(uint num
, uint ctrlId
, TParam param
= 0)
180 TMapFuncCtrl::iterator it
= _CtrlFunctions
.find( num
);
181 if (it
!= _CtrlFunctions
.end() )
183 TFuncCtrl func
= (*it
).second
;
188 nlwarning("Invalid function called - Num function: %d, Ctrl: %d", num
, ctrlId
);
193 * Create the OSD "id", NB : the OSD is inserted into the _OSD list at the beginning of the next call of 'update()'
194 * \param uint the OSD 'id'
195 * \param bool true if the window is a pop-up window (default = false)
196 * \return COSD* adress of the newly created OSD, or NULL if creation failed
198 static COSD
* createOSD(uint id
, bool popUp
= false);
201 * get the OSD which 'id' is specified
202 * \param uint the OSD 'id'
203 * \return COSD* adress of the OSD if found, NULL otherwise
205 static COSD
* getOSD(uint id
);
207 /// Delete the OSD "id".
208 static void deleteOSD(uint id
);
210 static CControl
* getCtrl(uint idCtrl
);
212 /// Update Interfaces (for timer, etc.).
213 static void update(float x
, float y
);
214 /// Display the interfaces in progress.
215 static void display();
218 * Return the cursor used by the interface at the moment.
219 * \return ECursor : 'Cur_None' if no cursor needed for the interface.
220 * \warning This method should be called after the update one to be up to date.
222 static COSD::ECursor
cursor();
224 /// Manage the mouse click.
225 static bool click(float x
, float y
);
227 /// Manage the mouse click with the right button
228 static bool clickRight(float x
, float y
);
230 /// The window size has changed -> resize interface.
231 static void resize(uint32 width
, uint32 height
);
233 static void getWindowSize(uint32
&x
, uint32
&y
)
242 #endif // CL_INTERFACES_MANAGER_H
244 /* End of interfaces_manager.h */