diff options
author | Jody Northup | 2009-06-13 10:24:52 +0000 |
---|---|---|
committer | Jody Northup | 2009-06-13 10:24:52 +0000 |
commit | 350dc4290fd5dd8f28af9e63713b48ef2c131f09 (patch) | |
tree | af86a10ccd48c275b362ca0407ddfd16180a8c0c /graphics | |
parent | 2ee51a8fa189fc7817fd6d78533664ec870fca48 (diff) | |
download | scummvm-rg350-350dc4290fd5dd8f28af9e63713b48ef2c131f09.tar.gz scummvm-rg350-350dc4290fd5dd8f28af9e63713b48ef2c131f09.tar.bz2 scummvm-rg350-350dc4290fd5dd8f28af9e63713b48ef2c131f09.zip |
Fixed cursor code to keep track of cursor formats so that ThemeEngine and/or GuiManager cursors will render properly over the game (on spacebar hit, for instance)
svn-id: r41491
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/cursorman.cpp | 55 | ||||
-rw-r--r-- | graphics/cursorman.h | 29 |
2 files changed, 81 insertions, 3 deletions
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 850b0044dc..e5a86b6bd8 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -101,6 +101,13 @@ void CursorManager::popAllCursors() { } } +#ifdef ENABLE_16BIT + while (!_cursorFormatStack.empty()) { + PixelFormat *form = _cursorFormatStack.pop(); + delete form; + } +#endif + g_system->showMouse(isVisible()); } @@ -118,8 +125,8 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, Cursor *cur = _cursorStack.top(); #ifdef ENABLE_16BIT - uint size; - { //limit the lifespan of the format variable to minimize memory impact + uint size; + { //limit the lifespan of the format variable to minimize memory impact Graphics::PixelFormat f = g_system->getScreenFormat(); size = w * h * (f.bytesPerPixel); } @@ -225,4 +232,48 @@ void CursorManager::replaceCursorPalette(const byte *colors, uint start, uint nu } } +#ifdef ENABLE_16BIT +void CursorManager::pushCursorFormat(PixelFormat format) { +// if (!g_system->hasFeature(OSystem::kFeatureCursorHasPalette)) +// return; + PixelFormat *form = new PixelFormat(format); + + _cursorFormatStack.push(form); + g_system->setCursorFormat(format); +} + +void CursorManager::popCursorFormat() { + + if (_cursorFormatStack.empty()) + return; + + PixelFormat *form = _cursorFormatStack.pop(); + delete form; + + if (_cursorFormatStack.empty()) { + g_system->setCursorFormat(g_system->getScreenFormat()); + return; + } + + form = _cursorFormatStack.top(); + disableCursorPalette(form->bytesPerPixel != 1); + + g_system->setCursorFormat(*form); +} + +void CursorManager::replaceCursorFormat(PixelFormat format) { +// if (!g_system->hasFeature(OSystem::kFeatureCursorHasPalette)) +// return; + + if (_cursorFormatStack.empty()) { + pushCursorFormat(format); + return; + } + + PixelFormat *form = _cursorFormatStack.top(); + + g_system->setCursorFormat(*form); +} +#endif + } // End of namespace Graphics diff --git a/graphics/cursorman.h b/graphics/cursorman.h index 0c02292818..834d0d2b02 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -142,6 +142,31 @@ public: */ void replaceCursorPalette(const byte *colors, uint start, uint num); +#ifdef ENABLE_16BIT + /** + * Push a new cursor pixel format onto the stack, and set it in the backend. + * + * @param format the new format data, in a Graphics::PixelFormat + */ + void pushCursorFormat(PixelFormat format); + + /** + * Pop a cursor pixel format from the stack, and restore the previous one to + * the backend. If there is no previous format, the screen format is + * used instead. + */ + void popCursorFormat(); + + /** + * Replace the current cursor pixel format on the stack. If the stack is + * empty, the format is pushed instead. It's a slightly more optimized + * way of popping the old format before pushing the new one. + * + * @param format the new format data, in a Graphics::PixelFormat + */ + void replaceCursorFormat(PixelFormat format); +#endif + private: friend class Common::Singleton<SingletonBaseType>; CursorManager(); @@ -216,9 +241,11 @@ private: delete[] _data; } }; - Common::Stack<Cursor *> _cursorStack; Common::Stack<Palette *> _cursorPaletteStack; +#ifdef ENABLE_16BIT + Common::Stack<Graphics::PixelFormat *> _cursorFormatStack; +#endif }; } // End of namespace Graphics |