Mercurial > fife-parpg
diff engine/core/controller/engine.cpp @ 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 | e201abd8c807 |
children |
line wrap: on
line diff
--- a/engine/core/controller/engine.cpp Fri Jun 10 23:37:46 2011 -1000 +++ b/engine/core/controller/engine.cpp Sat Jun 18 00:28:40 2011 -1000 @@ -35,8 +35,9 @@ #include "util/log/logger.h" #include "util/time/timemanager.h" #include "audio/soundmanager.h" -#include "gui/console/console.h" -#include "gui/guimanager.h" +#include "gui/console.h" +#include "gui/guichan/guichanguimanager.h" +#include "gui/guichan/gui_font.h" #include "vfs/vfs.h" #include "vfs/vfsdirectory.h" #include "vfs/directoryprovider.h" @@ -53,10 +54,7 @@ #ifdef HAVE_OPENGL #include "video/opengl/fife_opengl.h" #include "video/opengl/renderbackendopengl.h" -#include "gui/base/opengl/opengl_gui_graphics.h" #endif -#include "gui/base/sdl/sdl_gui_graphics.h" -#include "gui/base/gui_font.h" #include "video/sdl/renderbackendsdl.h" #include "video/fonts/abstractfont.h" #include "loaders/native/video_loaders/subimage_loader.h" @@ -76,7 +74,6 @@ #include "view/renderers/genericrenderer.h" #include "view/renderers/lightrenderer.h" #include "video/image.h" -#include "gui/console/console.h" #include "engine.h" #ifdef USE_COCOA @@ -104,7 +101,6 @@ m_soundclippool(0), m_vfs(0), m_model(0), - m_gui_graphics(0), m_logmanager(0), m_cursor(0), m_prerender_callback(0), @@ -145,8 +141,7 @@ Image* screen = m_renderbackend->setScreenMode(mode); - m_guimanager->resizeTopContainer(0,0,mode.getWidth(), mode.getHeight()); - m_guimanager->getConsole()->reLayout(); + m_guimanager->resize(0, 0, mode.getWidth(), mode.getHeight()); std::vector<IEngineChangeListener*>::iterator i = m_changelisteners.begin(); while (i != m_changelisteners.end()) { @@ -256,30 +251,30 @@ FL_LOG(_log, "Main screen created"); #ifdef HAVE_OPENGL - if( rbackend != "SDL" ) { - m_gui_graphics = new OpenGLGuiGraphics(*m_imagepool); - } - if (m_settings.getLightingModel() != 0) { m_renderbackend->setLightingModel(m_settings.getLightingModel()); } - #endif - if( rbackend == "SDL" ) { - m_gui_graphics = new SdlGuiGraphics(*m_imagepool); - } FL_LOG(_log, "Constructing GUI manager"); - m_guimanager = new GUIManager(*m_imagepool); + // TODO M. George Hansen 2011-06-15: There needs to be a plugin-like + // mechanism to select which GuiManager subclass to use. + m_guimanager = new GuiChanGuiManager(*m_imagepool); FL_LOG(_log, "Events bind to GUI manager"); m_eventmanager->addSdlEventListener(m_guimanager); FL_LOG(_log, "Creating default font"); + // FIXME M. George Hansen 2011-06-17: A font has to be created before + // the GuiManager is initialized (at least for GuiChan). This is not + // obvious if you just look at the code. m_defaultfont = m_guimanager->setDefaultFont( m_settings.getDefaultFontPath(), m_settings.getDefaultFontSize(), - m_settings.getDefaultFontGlyphs()); + m_settings.getDefaultFontGlyphs() + ); + FL_LOG(_log, "Initializing GUI manager"); - m_guimanager->init(m_gui_graphics, m_renderbackend->getScreenWidth(), m_renderbackend->getScreenHeight()); + m_guimanager->init(m_renderbackend, m_renderbackend->getScreenWidth(), + m_renderbackend->getScreenHeight()); FL_LOG(_log, "GUI manager initialized"); SDL_EnableUNICODE(1); @@ -322,7 +317,6 @@ delete m_model; delete m_soundmanager; delete m_guimanager; - delete m_gui_graphics; // Note the dependancy between image and animation pools // as animations reference images they have to be deleted