Mercurial > fife-parpg
diff 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 |
line wrap: on
line diff
--- a/engine/core/gui/guimanager.i Fri Jun 10 23:37:46 2011 -1000 +++ b/engine/core/gui/guimanager.i Sat Jun 18 00:28:40 2011 -1000 @@ -25,25 +25,81 @@ #include "gui/guimanager.h" %} -namespace gcn { - class Widget; -} namespace FIFE { + class ImagePool; class Console; - %feature("notabstract") GUIManager; - class GUIManager { + class GuiManager { public: - Console* getConsole() const; - void add(gcn::Widget* widget); - void remove(gcn::Widget* widget); - GuiFont* createFont(const std::string& path, unsigned int size, const std::string& glyphs); - void releaseFont(GuiFont* font); + /** Constructor. + */ + GuiManager(ImagePool& pool); + + /** Destructor. + */ + virtual ~GuiManager(); + + /** Performs the GUI logic and draws the GUI accordingly. + * + * This will be called each frame. + */ + virtual void turn() = 0; + + /** Inits the GUI Manager. + * @param graphics backend specific graphics object to use + * @param screenWidth width for the gui top container + * @param screenHeight height for the gui top container + */ + virtual void init(RenderBackend* render_backend, int screenWidth, + int screenHeight); + + /** Resizes the top container. + * + * @param x The new starting X coordinate. + * @param y The new starting Y coordinate. + * @param width The new width. + * @param height The new height. + */ + virtual void resize(unsigned int x, unsigned int y, unsigned int width, + unsigned int height) = 0; - KeyEvent translateKeyEvent(const gcn::KeyEvent& evt); - MouseEvent translateMouseEvent(const gcn::MouseEvent& evt); + /** Gets the console. + * + * @return The console. + */ + Console* getConsole() const { + return m_console; + } + + /** Display the in-game FIFE console. */ + virtual void showConsole() = 0; + + /** Hide the in-game FIFE console. */ + virtual void hideConsole() = 0; + + /** Toggle the visibility of the in-game FIFE console. */ + virtual void toggleConsole(); + + /** Gets the shared ImagePool instance. + * + * @return The ImagePool instance. + */ + ImagePool& getImagePool() const { + return m_image_pool; + } + + virtual bool onSdlEvent(SDL_Event& evt) = 0; + + GuiFont* setDefaultFont(const std::string& path, unsigned int size, + const std::string& glyphs); + GuiFont* createFont(const std::string& path = "", + unsigned int size = 0, const std::string& glyphs = ""); + void releaseFont(GuiFont* font); + void invalidateFonts(); + + protected: + // Whether the console is visible. + bool m_console_visible; - private: - GUIManager(); }; }