diff options
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/cursorman.cpp | 14 | ||||
-rw-r--r-- | graphics/cursorman.h | 27 |
2 files changed, 23 insertions, 18 deletions
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index bf6de44fbf..b35bbe73ae 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -57,7 +57,7 @@ bool CursorManager::showMouse(bool visible) { return g_system->showMouse(visible); } -void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, Graphics::PixelFormat *format) { +void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) { Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, format); cur->_visible = isVisible(); @@ -77,7 +77,7 @@ void CursorManager::popCursor() { if (!_cursorStack.empty()) { cur = _cursorStack.top(); - g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, &(cur->_format)); + g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, cur->_format); } g_system->showMouse(isVisible()); @@ -100,7 +100,7 @@ void CursorManager::popAllCursors() { g_system->showMouse(isVisible()); } -void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, Graphics::PixelFormat *format) { +void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, const Graphics::PixelFormat *format) { if (_cursorStack.empty()) { pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, format); @@ -110,10 +110,10 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, Cursor *cur = _cursorStack.top(); #ifdef ENABLE_RGB_COLOR + uint size; if (!format) - format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); - - uint size = w * h * format->bytesPerPixel; + size = w * h; + else size = w * h * format->bytesPerPixel; #else uint size = w * h; #endif @@ -134,7 +134,7 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, cur->_keycolor = keycolor; cur->_targetScale = targetScale; #ifdef ENABLE_RGB_COLOR - cur->_format = *format; + cur->_format = format; #endif g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, format); diff --git a/graphics/cursorman.h b/graphics/cursorman.h index 2b2f34f952..044a787e71 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -61,7 +61,7 @@ public: * useful to push a "dummy" cursor and modify it later. The * cursor will be added to the stack, but not to the backend. */ - void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, Graphics::PixelFormat *format = NULL); + void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL); /** * Pop a cursor from the stack, and restore the previous one to the @@ -83,7 +83,7 @@ public: * @param targetScale the scale for which the cursor is designed * @param format the pixel format which the cursor graphic uses */ - void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, Graphics::PixelFormat *format = NULL); + void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL); /** * Pop all of the cursors and cursor palettes from their respective stacks. @@ -148,22 +148,27 @@ private: int _hotspotX; int _hotspotY; uint32 _keycolor; -#ifdef ENABLE_RGB_COLOR - Graphics::PixelFormat _format; -#endif + const Graphics::PixelFormat *_format; byte _targetScale; uint _size; - Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, Graphics::PixelFormat *format = NULL) { + Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, const Graphics::PixelFormat *format = NULL) { #ifdef ENABLE_RGB_COLOR if (!format) - format = new Graphics::PixelFormat(1,8,8,8,8,0,0,0,0); - _size = w * h * format->bytesPerPixel; - _keycolor &= ((1 << (format->bytesPerPixel << 3)) - 1); - _format = *format; + { + _size = w * h; + _keycolor &= 0xFF; + } + else + { + _size = w * h * format->bytesPerPixel; + _keycolor &= ((1 << (format->bytesPerPixel << 3)) - 1); + } + _format = format; #else + _format = NULL; _size = w * h; - _keycolor = keycolor & 0xFF; + _keycolor &= 0xFF; #endif _data = new byte[_size]; if (data && _data) |