Mercurial > fife-parpg
diff engine/core/controller/engine.h @ 654:5d6b1820b953
* Added the ability to change screen modes on the fly. This works both in OpenGL and SDL modes.
* Added IEngineChangeListener so the client can update the cameras viewport if the screen mode has been changed. I chose to do it this way because the engine has no way to know which camera it should update. It will be up to the client to do it.
* The cursor surface is now correctly freed when exiting.
* Added DeviceCaps::getNearestScreenMode() for the client to request a supported screen mode.
closes[t:315]
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 21 Oct 2010 18:50:50 +0000 |
parents | 01acc9fc35ea |
children | ca1fcb96907d |
line wrap: on
line diff
--- a/engine/core/controller/engine.h Fri Oct 15 18:54:34 2010 +0000 +++ b/engine/core/controller/engine.h Thu Oct 21 18:50:50 2010 +0000 @@ -63,6 +63,17 @@ class Cursor; class SoundClipPool; class RendererBase; + class Image; + + + class IEngineChangeListener { + public: + virtual ~IEngineChangeListener() {} + + /** Screen mode has been changed + */ + virtual void onScreenModeChanged(const ScreenMode& newmode) = 0; + }; /** Engine acts as a controller to the whole system * Responsibilities of the engine are: @@ -88,6 +99,16 @@ */ const DeviceCaps& getDeviceCaps() const; + /** Changes the screen mode. + * This should be called instead of the renderer's setScreenMode() function. + * It takes care of any objects that need to be re-created after switching + * screen modes. + * + * @param mode A valid ScreenMode retrieved from FIFE::DeviceCaps::getNearestScreenMode() + * @return The new Screen Image + */ + Image* changeScreenMode(const ScreenMode& mode); + /** Initializes the engine */ void init(); @@ -163,6 +184,16 @@ */ Cursor* getCursor() const { return m_cursor; } + /** Adds new change listener + * @param listener to add + */ + void addChangeListener(IEngineChangeListener* listener); + + /** Removes associated change listener + * @param listener to remove + */ + void removeChangeListener(IEngineChangeListener* listener); + private: void preInit(); @@ -189,6 +220,8 @@ std::vector<RendererBase*> m_renderers; + std::vector<IEngineChangeListener*> m_changelisteners; + #ifdef USE_COCOA objc_object *m_autoreleasePool; #endif