annotate engine/core/gui/guimanager.i @ 697:ecaa4d98f05f tip

Abstracted the GUI code and refactored the GUIChan-specific code into its own module. * Most of the GUIChan code has been refactored into its own gui/guichan module. However, references to the GuiFont class still persist in the Engine and GuiManager code and these will need further refactoring. * GuiManager is now an abstract base class which specific implementations (e.g. GUIChan) should subclass. * The GUIChan GUI code is now a concrete implementation of GuiManager, most of which is in the new GuiChanGuiManager class. * The GUI code in the Console class has been refactored out of the Console and into the GUIChan module as its own GuiChanConsoleWidget class. The rest of the Console class related to executing commands was left largely unchanged. * Existing client code may need to downcast the GuiManager pointer received from FIFE::Engine::getGuiManager() to GuiChanGuiManager, since not all functionality is represented in the GuiManager abstract base class. Python client code can use the new GuiChanGuiManager.castTo static method for this purpose.
author M. George Hansen <technopolitica@gmail.com>
date Sat, 18 Jun 2011 00:28:40 -1000
parents 64738befdf3b
children
rev   line source
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
6 * FIFE is free software; you can redistribute it and/or *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
7 * modify it under the terms of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
8 * License as published by the Free Software Foundation; either *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
9 * version 2.1 of the License, or (at your option) any later version. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
11 * This library is distributed in the hope that it will be useful, *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
14 * Lesser General Public License for more details. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
16 * You should have received a copy of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
17 * License along with this library; if not, write to the *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 %module fife
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 %{
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 #include <guichan.hpp>
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 #include "gui/guimanager.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 %}
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 namespace FIFE {
697
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
29 class ImagePool;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 class Console;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31
697
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
32 class GuiManager {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 public:
697
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
34 /** Constructor.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
35 */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
36 GuiManager(ImagePool& pool);
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
37
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
38 /** Destructor.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
39 */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
40 virtual ~GuiManager();
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
41
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
42 /** Performs the GUI logic and draws the GUI accordingly.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
43 *
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
44 * This will be called each frame.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
45 */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
46 virtual void turn() = 0;
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
47
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
48 /** Inits the GUI Manager.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
49 * @param graphics backend specific graphics object to use
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
50 * @param screenWidth width for the gui top container
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
51 * @param screenHeight height for the gui top container
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
52 */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
53 virtual void init(RenderBackend* render_backend, int screenWidth,
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
54 int screenHeight);
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
55
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
56 /** Resizes the top container.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
57 *
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
58 * @param x The new starting X coordinate.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
59 * @param y The new starting Y coordinate.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
60 * @param width The new width.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
61 * @param height The new height.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
62 */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
63 virtual void resize(unsigned int x, unsigned int y, unsigned int width,
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
64 unsigned int height) = 0;
157
bb9902910067 input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
65
697
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
66 /** Gets the console.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
67 *
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
68 * @return The console.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
69 */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
70 Console* getConsole() const {
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
71 return m_console;
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
72 }
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
73
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
74 /** Display the in-game FIFE console. */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
75 virtual void showConsole() = 0;
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
76
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
77 /** Hide the in-game FIFE console. */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
78 virtual void hideConsole() = 0;
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
79
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
80 /** Toggle the visibility of the in-game FIFE console. */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
81 virtual void toggleConsole();
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
82
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
83 /** Gets the shared ImagePool instance.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
84 *
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
85 * @return The ImagePool instance.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
86 */
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
87 ImagePool& getImagePool() const {
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
88 return m_image_pool;
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
89 }
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
90
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
91 virtual bool onSdlEvent(SDL_Event& evt) = 0;
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
92
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
93 GuiFont* setDefaultFont(const std::string& path, unsigned int size,
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
94 const std::string& glyphs);
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
95 GuiFont* createFont(const std::string& path = "",
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
96 unsigned int size = 0, const std::string& glyphs = "");
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
97 void releaseFont(GuiFont* font);
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
98 void invalidateFonts();
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
99
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
100 protected:
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
101 // Whether the console is visible.
ecaa4d98f05f Abstracted the GUI code and refactored the GUIChan-specific code into its own module.
M. George Hansen <technopolitica@gmail.com>
parents: 378
diff changeset
102 bool m_console_visible;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 };
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 }