Mercurial > fife-parpg
view ext/guichan-0.8.2/examples/helloworld.hpp @ 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 source
/** * Code to populate a global Gui object with a simple * Hello World example. */ namespace helloworld { gcn::Container* top; gcn::ImageFont* font; gcn::Label* label; /** * Initialises the Hello World example by populating the global Gui * object. */ void init() { // We first create a container to be used as the top widget. // The top widget in Guichan can be any kind of widget, but // in order to make the Gui contain more than one widget we // make the top widget a container. top = new gcn::Container(); // We set the dimension of the top container to match the screen. top->setDimension(gcn::Rectangle(0, 0, 640, 480)); // Finally we pass the top widget to the Gui object. globals::gui->setTop(top); // Now we load the font used in this example. font = new gcn::ImageFont("fixedfont.bmp", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); // Widgets may have a global font so we don't need to pass the // font object to every created widget. The global font is static. gcn::Widget::setGlobalFont(font); // Now we create a label with the text "Hello World". label = new gcn::Label("Hello World"); // We give the label a position. label->setPosition(280, 220); // And finally we add the label to the top container. top->add(label); } /** * Halts the Hello World example. */ void halt() { delete label; delete font; delete top; } }