1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * > www.orxonox.net < |
---|
4 | * |
---|
5 | * |
---|
6 | * License notice: |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
21 | * |
---|
22 | * Author: |
---|
23 | * Reto Grieder |
---|
24 | * Benjamin Knecht |
---|
25 | * Co-authors: |
---|
26 | * ... |
---|
27 | * |
---|
28 | */ |
---|
29 | |
---|
30 | #include "GUIManager.h" |
---|
31 | |
---|
32 | #include <memory> |
---|
33 | #include <boost/bind.hpp> |
---|
34 | |
---|
35 | #include <CEGUIDefaultLogger.h> |
---|
36 | #include <CEGUIExceptions.h> |
---|
37 | #include <CEGUIInputEvent.h> |
---|
38 | #include <CEGUIMouseCursor.h> |
---|
39 | #include <CEGUIResourceProvider.h> |
---|
40 | #include <CEGUISystem.h> |
---|
41 | #include <CEGUIWindow.h> |
---|
42 | #include <CEGUIWindowManager.h> |
---|
43 | #include <elements/CEGUIListbox.h> |
---|
44 | #include <elements/CEGUIListboxItem.h> |
---|
45 | |
---|
46 | #include <CEGUILua.h> |
---|
47 | #include <ogreceguirenderer/OgreCEGUIRenderer.h> |
---|
48 | |
---|
49 | #include "util/Clock.h" |
---|
50 | #include "util/Convert.h" |
---|
51 | #include "util/Debug.h" |
---|
52 | #include "util/Exception.h" |
---|
53 | #include "util/OrxAssert.h" |
---|
54 | #include "ConfigValueIncludes.h" |
---|
55 | #include "Core.h" |
---|
56 | #include "CoreIncludes.h" |
---|
57 | #include "Game.h" |
---|
58 | #include "GraphicsManager.h" |
---|
59 | #include "LuaState.h" |
---|
60 | #include "PathConfig.h" |
---|
61 | #include "Resource.h" |
---|
62 | #include "command/ConsoleCommand.h" |
---|
63 | #include "input/InputManager.h" |
---|
64 | #include "input/InputState.h" |
---|
65 | #include "input/KeyBinderManager.h" |
---|
66 | |
---|
67 | namespace orxonox |
---|
68 | { |
---|
69 | static void key_esc() |
---|
70 | { GUIManager::getInstance().keyESC(); } |
---|
71 | SetConsoleCommand("keyESC", &key_esc); |
---|
72 | |
---|
73 | class CEGUILogger : public CEGUI::DefaultLogger |
---|
74 | { |
---|
75 | public: |
---|
76 | void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard) |
---|
77 | { |
---|
78 | int orxonoxLevel = CEGUI::Standard; |
---|
79 | switch (level) |
---|
80 | { |
---|
81 | case CEGUI::Errors: orxonoxLevel = 1; break; |
---|
82 | case CEGUI::Warnings: orxonoxLevel = 2; break; |
---|
83 | case CEGUI::Standard: orxonoxLevel = 4; break; |
---|
84 | case CEGUI::Informative: orxonoxLevel = 5; break; |
---|
85 | case CEGUI::Insane: orxonoxLevel = 6; break; |
---|
86 | default: OrxAssert(false, "CEGUI log level out of range, inpect immediately!"); |
---|
87 | } |
---|
88 | OutputHandler::getOutStream(orxonoxLevel) |
---|
89 | << "CEGUI: " << message << std::endl; |
---|
90 | |
---|
91 | CEGUI::DefaultLogger::logEvent(message, level); |
---|
92 | } |
---|
93 | }; |
---|
94 | |
---|
95 | static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); |
---|
96 | |
---|
97 | GUIManager* GUIManager::singletonPtr_s = 0; |
---|
98 | /*static*/ const std::string GUIManager::defaultScheme_ = "TaharezGreen"; |
---|
99 | |
---|
100 | SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false); |
---|
101 | SetConsoleCommand("hideGUI", &GUIManager::hideGUI); |
---|
102 | |
---|
103 | /** |
---|
104 | @brief |
---|
105 | Constructs the GUIManager by starting up CEGUI |
---|
106 | |
---|
107 | Creates the interface to Ogre, sets up the CEGUI renderer and the Lua script module together with the Lua engine. |
---|
108 | The log is set up and connected to the CEGUILogger. |
---|
109 | After Lua setup tolua++-elements are linked to Lua-state to give Lua access to C++-code. |
---|
110 | Finally initial Lua code is executed (maybe we can do this with the CEGUI startup script automatically). |
---|
111 | @return true if success, otherwise false |
---|
112 | */ |
---|
113 | GUIManager::GUIManager(const std::pair<int, int>& mousePosition) |
---|
114 | : destroyer_(*this, &GUIManager::cleanup) |
---|
115 | , guiRenderer_(NULL) |
---|
116 | , luaState_(NULL) |
---|
117 | , scriptModule_(NULL) |
---|
118 | , guiSystem_(NULL) |
---|
119 | , resourceProvider_(NULL) |
---|
120 | , camera_(NULL) |
---|
121 | { |
---|
122 | RegisterRootObject(GUIManager); |
---|
123 | this->setConfigValues(); |
---|
124 | |
---|
125 | using namespace CEGUI; |
---|
126 | |
---|
127 | COUT(3) << "Initialising CEGUI." << std::endl; |
---|
128 | |
---|
129 | // Note: No SceneManager specified yet |
---|
130 | guiRenderer_ = new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000); |
---|
131 | resourceProvider_ = guiRenderer_->createResourceProvider(); |
---|
132 | resourceProvider_->setDefaultResourceGroup("General"); |
---|
133 | |
---|
134 | // Setup scripting |
---|
135 | luaState_ = new LuaState(); |
---|
136 | rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua"); |
---|
137 | // This is necessary to ensure that input events also use the right resource info when triggering lua functions |
---|
138 | luaState_->setDefaultResourceInfo(this->rootFileInfo_); |
---|
139 | scriptModule_ = new LuaScriptModule(luaState_->getInternalLuaState()); |
---|
140 | scriptModule_->setDefaultPCallErrorHandler(LuaState::ERROR_HANDLER_NAME); |
---|
141 | |
---|
142 | // Create our own logger to specify the filepath |
---|
143 | std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger()); |
---|
144 | ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log"); |
---|
145 | // Set the log level according to ours (translate by subtracting 1) |
---|
146 | ceguiLogger->setLoggingLevel( |
---|
147 | static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1)); |
---|
148 | this->ceguiLogger_ = ceguiLogger.release(); |
---|
149 | |
---|
150 | // Create the CEGUI system singleton |
---|
151 | guiSystem_ = new System(guiRenderer_, resourceProvider_, 0, scriptModule_); |
---|
152 | |
---|
153 | // Align CEGUI mouse with OIS mouse |
---|
154 | guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second); |
---|
155 | |
---|
156 | // Initialise the Lua framework and load the schemes |
---|
157 | this->luaState_->doFile("InitialiseGUI.lua"); |
---|
158 | |
---|
159 | // Create the root nodes |
---|
160 | this->rootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("MenuWidgets/StaticImage", "AbsoluteRootWindow"); |
---|
161 | this->rootWindow_->setProperty("FrameEnabled", "False"); |
---|
162 | this->hudRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "HUDRootWindow"); |
---|
163 | this->menuRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MenuRootWindow"); |
---|
164 | // And connect them |
---|
165 | CEGUI::System::getSingleton().setGUISheet(this->rootWindow_); |
---|
166 | this->rootWindow_->addChildWindow(this->hudRootWindow_); |
---|
167 | this->rootWindow_->addChildWindow(this->menuRootWindow_); |
---|
168 | |
---|
169 | // No background to start with (sets the alpha value to 0) |
---|
170 | this->setBackgroundImage(""); |
---|
171 | |
---|
172 | // Set up the sheet manager in the Lua framework |
---|
173 | this->luaState_->doFile("SheetManager.lua"); |
---|
174 | } |
---|
175 | |
---|
176 | void GUIManager::cleanup() |
---|
177 | { |
---|
178 | using namespace CEGUI; |
---|
179 | |
---|
180 | delete guiSystem_; |
---|
181 | delete guiRenderer_; |
---|
182 | delete scriptModule_; |
---|
183 | delete luaState_; |
---|
184 | } |
---|
185 | |
---|
186 | void GUIManager::setConfigValues(void) |
---|
187 | { |
---|
188 | SetConfigValue(guiScheme_, GUIManager::defaultScheme_) .description("Changes the current GUI scheme.") .callback(this, &GUIManager::changedGUIScheme); |
---|
189 | } |
---|
190 | |
---|
191 | void GUIManager::changedGUIScheme(void) |
---|
192 | { |
---|
193 | |
---|
194 | } |
---|
195 | |
---|
196 | /** |
---|
197 | @brief |
---|
198 | used to tick the GUI |
---|
199 | @param time |
---|
200 | clock which provides time value for the GUI System |
---|
201 | |
---|
202 | Ticking the GUI means updating it with a certain regularity. |
---|
203 | The elapsed time since the last call is given in the time value provided by the clock. |
---|
204 | This time value is then used to provide a fluent animation of the GUI. |
---|
205 | */ |
---|
206 | void GUIManager::preUpdate(const Clock& time) |
---|
207 | { |
---|
208 | assert(guiSystem_); |
---|
209 | this->protectedCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime())); |
---|
210 | } |
---|
211 | |
---|
212 | /** |
---|
213 | @brief |
---|
214 | Tells the GUIManager which SceneManager to use |
---|
215 | @param camera |
---|
216 | The current camera on which the GUI should be displayed on. |
---|
217 | |
---|
218 | In fact the GUIManager needs the SceneManager and not the Camera to display the GUI. |
---|
219 | This means the GUI is not bound to a camera but rather to the SceneManager. |
---|
220 | Hiding the GUI when needed can therefore not be resolved by just NOT setting the current camera. |
---|
221 | */ |
---|
222 | void GUIManager::setCamera(Ogre::Camera* camera) |
---|
223 | { |
---|
224 | this->camera_ = camera; |
---|
225 | if (camera == NULL) |
---|
226 | this->guiRenderer_->setTargetSceneManager(0); |
---|
227 | else |
---|
228 | this->guiRenderer_->setTargetSceneManager(camera->getSceneManager()); |
---|
229 | } |
---|
230 | |
---|
231 | /** |
---|
232 | @brief |
---|
233 | Executes Lua code |
---|
234 | @param str |
---|
235 | reference to string object holding the Lua code which is to be executed |
---|
236 | */ |
---|
237 | void GUIManager::executeCode(const std::string& str) |
---|
238 | { |
---|
239 | this->luaState_->doString(str, rootFileInfo_); |
---|
240 | } |
---|
241 | |
---|
242 | /** Loads a GUI sheet by Lua script |
---|
243 | @param name |
---|
244 | The name of the GUI (like the script name, but without the extension) |
---|
245 | */ |
---|
246 | void GUIManager::loadGUI(const std::string& name) |
---|
247 | { |
---|
248 | this->executeCode("loadSheet(\"" + name + "\")"); |
---|
249 | } |
---|
250 | |
---|
251 | /** |
---|
252 | @brief |
---|
253 | Displays specified GUI on screen |
---|
254 | @param name |
---|
255 | The name of the GUI |
---|
256 | @param bHidePrevious |
---|
257 | If true all displayed GUIs on the stack, that are below this GUI are hidden. |
---|
258 | @param bNoInput |
---|
259 | If true the GUI is transparent to input. |
---|
260 | |
---|
261 | The function executes the Lua function with the same name in case the GUIManager is ready. |
---|
262 | */ |
---|
263 | /*static*/ void GUIManager::showGUI(const std::string& name, bool bHidePrevious, bool bNoInput) |
---|
264 | { |
---|
265 | GUIManager::getInstance().executeCode("showMenuSheet(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ")"); |
---|
266 | } |
---|
267 | |
---|
268 | /** |
---|
269 | @brief |
---|
270 | Hack-ish. Needed for GUIOverlay. |
---|
271 | */ |
---|
272 | void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious, bool bNoInput) |
---|
273 | { |
---|
274 | this->executeCode("showMenuSheet(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ", " + ptr + ")"); |
---|
275 | } |
---|
276 | |
---|
277 | /** |
---|
278 | @brief |
---|
279 | Hides specified GUI. |
---|
280 | @param name |
---|
281 | The name of the GUI. |
---|
282 | */ |
---|
283 | /*static*/ void GUIManager::hideGUI(const std::string& name) |
---|
284 | { |
---|
285 | GUIManager::getInstance().executeCode("hideMenuSheet(\"" + name + "\")"); |
---|
286 | } |
---|
287 | |
---|
288 | const std::string& GUIManager::createInputState(const std::string& name, TriBool::Value showCursor, TriBool::Value useKeyboard, bool bBlockJoyStick) |
---|
289 | { |
---|
290 | InputState* state = InputManager::getInstance().createInputState(name); |
---|
291 | if (!state) |
---|
292 | return BLANKSTRING; |
---|
293 | |
---|
294 | /* Table that maps isFullScreen() and showCursor to mouseExclusive |
---|
295 | isFullscreen / showCursor | True | False | Dontcare |
---|
296 | ---------------------------------------------------- |
---|
297 | true | True | True | Dontcare |
---|
298 | ---------------------------------------------------- |
---|
299 | false | False | True | Dontcare |
---|
300 | */ |
---|
301 | if (showCursor == TriBool::Dontcare) |
---|
302 | state->setMouseExclusive(TriBool::Dontcare); |
---|
303 | else if (GraphicsManager::getInstance().isFullScreen() || showCursor == TriBool::False) |
---|
304 | state->setMouseExclusive(TriBool::True); |
---|
305 | else |
---|
306 | state->setMouseExclusive(TriBool::False); |
---|
307 | |
---|
308 | if (showCursor == TriBool::True) |
---|
309 | state->setMouseHandler(this); |
---|
310 | else if (showCursor == TriBool::False) |
---|
311 | state->setMouseHandler(&InputHandler::EMPTY); |
---|
312 | |
---|
313 | if (useKeyboard == TriBool::True) |
---|
314 | state->setKeyHandler(this); |
---|
315 | else if (useKeyboard == TriBool::False) |
---|
316 | state->setKeyHandler(&InputHandler::EMPTY); |
---|
317 | |
---|
318 | if (bBlockJoyStick) |
---|
319 | state->setJoyStickHandler(&InputHandler::EMPTY); |
---|
320 | |
---|
321 | return state->getName(); |
---|
322 | } |
---|
323 | |
---|
324 | void GUIManager::keyESC() |
---|
325 | { |
---|
326 | this->executeCode("keyESC()"); |
---|
327 | } |
---|
328 | |
---|
329 | void GUIManager::setBackgroundImage(const std::string& imageSet, const std::string imageName) |
---|
330 | { |
---|
331 | if (imageSet.empty() || imageName.empty()) |
---|
332 | this->setBackgroundImage(""); |
---|
333 | else |
---|
334 | this->setBackgroundImage("set: " + imageSet + " image: " + imageName); |
---|
335 | } |
---|
336 | |
---|
337 | void GUIManager::setBackgroundImage(const std::string& image) |
---|
338 | { |
---|
339 | if (image.empty()) |
---|
340 | this->rootWindow_->setProperty("Alpha", "0.0"); |
---|
341 | else |
---|
342 | this->rootWindow_->setProperty("Alpha", "1.0"); |
---|
343 | this->rootWindow_->setProperty("Image", image); |
---|
344 | } |
---|
345 | |
---|
346 | void GUIManager::buttonPressed(const KeyEvent& evt) |
---|
347 | { |
---|
348 | this->protectedCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode())); |
---|
349 | this->protectedCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText())); |
---|
350 | } |
---|
351 | |
---|
352 | void GUIManager::buttonReleased(const KeyEvent& evt) |
---|
353 | { |
---|
354 | this->protectedCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode())); |
---|
355 | } |
---|
356 | |
---|
357 | /** |
---|
358 | @brief |
---|
359 | Function receiving a mouse button pressed event. |
---|
360 | @param id |
---|
361 | ID of the mouse button which got pressed |
---|
362 | |
---|
363 | This function is inherited by MouseHandler and injects the event into CEGUI. |
---|
364 | It is for CEGUI to process the event. |
---|
365 | */ |
---|
366 | void GUIManager::buttonPressed(MouseButtonCode::ByEnum id) |
---|
367 | { |
---|
368 | this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id))); |
---|
369 | } |
---|
370 | |
---|
371 | /** |
---|
372 | @brief |
---|
373 | Function receiving a mouse button released event. |
---|
374 | @param id |
---|
375 | ID of the mouse button which got released |
---|
376 | |
---|
377 | This function is inherited by MouseHandler and injects the event into CEGUI. |
---|
378 | It is for CEGUI to process the event. |
---|
379 | */ |
---|
380 | void GUIManager::buttonReleased(MouseButtonCode::ByEnum id) |
---|
381 | { |
---|
382 | this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id))); |
---|
383 | } |
---|
384 | |
---|
385 | void GUIManager::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) |
---|
386 | { |
---|
387 | this->protectedCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y)); |
---|
388 | } |
---|
389 | |
---|
390 | void GUIManager::mouseScrolled(int abs, int rel) |
---|
391 | { |
---|
392 | this->protectedCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)rel)); |
---|
393 | } |
---|
394 | |
---|
395 | /** |
---|
396 | @brief Indicates that the mouse left the application's window. |
---|
397 | */ |
---|
398 | void GUIManager::mouseLeft() |
---|
399 | { |
---|
400 | this->protectedCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1)); |
---|
401 | } |
---|
402 | |
---|
403 | /** |
---|
404 | @brief |
---|
405 | converts mouse event code to CEGUI event code |
---|
406 | @param button |
---|
407 | code of the mouse button as we use it in Orxonox |
---|
408 | @return |
---|
409 | code of the mouse button as it is used by CEGUI |
---|
410 | |
---|
411 | Simple conversion from mouse event code in Orxonox to the one used in CEGUI. |
---|
412 | */ |
---|
413 | static inline CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button) |
---|
414 | { |
---|
415 | switch (button) |
---|
416 | { |
---|
417 | case MouseButtonCode::Left: |
---|
418 | return CEGUI::LeftButton; |
---|
419 | |
---|
420 | case MouseButtonCode::Right: |
---|
421 | return CEGUI::RightButton; |
---|
422 | |
---|
423 | case MouseButtonCode::Middle: |
---|
424 | return CEGUI::MiddleButton; |
---|
425 | |
---|
426 | case MouseButtonCode::Button3: |
---|
427 | return CEGUI::X1Button; |
---|
428 | |
---|
429 | case MouseButtonCode::Button4: |
---|
430 | return CEGUI::X2Button; |
---|
431 | |
---|
432 | default: |
---|
433 | return CEGUI::NoButton; |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | /** Executes a CEGUI function normally, but catches CEGUI::ScriptException. |
---|
438 | When a ScriptException occurs, the error message will be displayed and |
---|
439 | the program carries on. |
---|
440 | @remarks |
---|
441 | The exception behaviour may pose problems if the code is not written |
---|
442 | exception-safe (and you can forget about that in Lua). The program might |
---|
443 | be left in an undefined state. But otherwise one script error would |
---|
444 | terminate the whole program... |
---|
445 | @note |
---|
446 | Your life gets easier if you use boost::bind to create the object/function. |
---|
447 | @param function |
---|
448 | Any callable object/function that takes this->guiSystem_ as its only parameter. |
---|
449 | @return |
---|
450 | True if input was handled, false otherwise. A caught exception yields true. |
---|
451 | */ |
---|
452 | template <typename FunctionType> |
---|
453 | bool GUIManager::protectedCall(FunctionType function) |
---|
454 | { |
---|
455 | try |
---|
456 | { |
---|
457 | return function(this->guiSystem_); |
---|
458 | } |
---|
459 | catch (CEGUI::ScriptException& ex) |
---|
460 | { |
---|
461 | // Display the error and proceed. See @remarks why this can be dangerous. |
---|
462 | COUT(1) << ex.getMessage() << std::endl; |
---|
463 | return true; |
---|
464 | } |
---|
465 | } |
---|
466 | |
---|
467 | /** |
---|
468 | @brief |
---|
469 | Subscribe the input function to the input event for the input window. |
---|
470 | This is a helper to be used in lua, because subscribeScriptedEvent() doesn't work in lua. |
---|
471 | @param window |
---|
472 | The window for which the event is subscribed. |
---|
473 | @param event |
---|
474 | The type of event to which we subscribe. |
---|
475 | @param function |
---|
476 | The function that is called when the event occurs. |
---|
477 | */ |
---|
478 | void GUIManager::subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function) |
---|
479 | { |
---|
480 | window->subscribeScriptedEvent(event, function); |
---|
481 | } |
---|
482 | |
---|
483 | /** |
---|
484 | @brief |
---|
485 | Set the input tooltip text for the input ListboxItem. |
---|
486 | @param item |
---|
487 | The ListboxItem for which the tooltip should be set. |
---|
488 | @param tooltip |
---|
489 | The tooltip text that should be set. |
---|
490 | */ |
---|
491 | void GUIManager::setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& tooltip) |
---|
492 | { |
---|
493 | item->setTooltipText(tooltip); |
---|
494 | } |
---|
495 | |
---|
496 | /** |
---|
497 | @brief |
---|
498 | Set whether the tooltips for the input Listbox are enabled. |
---|
499 | @param listbox |
---|
500 | The Listbox for which to enable (or disable) tooltips. |
---|
501 | @param enabled |
---|
502 | Whether to enable or disabel the tooltips. |
---|
503 | */ |
---|
504 | void GUIManager::setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled) |
---|
505 | { |
---|
506 | listbox->setItemTooltipsEnabled(enabled); |
---|
507 | } |
---|
508 | |
---|
509 | /** |
---|
510 | @brief Callback of window event listener, called if the window is resized. Sets the display size of CEGUI. |
---|
511 | */ |
---|
512 | void GUIManager::windowResized(unsigned int newWidth, unsigned int newHeight) |
---|
513 | { |
---|
514 | this->guiRenderer_->setDisplaySize(CEGUI::Size(newWidth, newHeight)); |
---|
515 | } |
---|
516 | |
---|
517 | /** |
---|
518 | @brief Notify CEGUI if the windows loses the focus (stops higlight of menu items, etc). |
---|
519 | */ |
---|
520 | void GUIManager::windowFocusChanged(bool bFocus) |
---|
521 | { |
---|
522 | if (!bFocus) |
---|
523 | this->mouseLeft(); |
---|
524 | } |
---|
525 | |
---|
526 | } |
---|