From fe5dddf901eb40ac3c04b7d01bd078d65dafc5ab Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Fri, 9 Aug 2019 20:45:27 +0100 Subject: GRAPHICS: Add a version of CursorManager::replaceCursor that accepts a Graphics::Cursor --- graphics/cursorman.cpp | 8 ++++++++ graphics/cursorman.h | 10 ++++++++++ 2 files changed, 18 insertions(+) (limited to 'graphics') diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index 678b074360..751554ffb7 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -147,6 +147,14 @@ void CursorManager::replaceCursor(const void *buf, uint w, uint h, int hotspotX, g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, dontScale, format); } +void CursorManager::replaceCursor(const Graphics::Cursor *cursor) { + replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), + cursor->getHotspotY(), cursor->getKeyColor()); + + if (cursor->getPalette()) + replaceCursorPalette(cursor->getPalette(), cursor->getPaletteStartIndex(), cursor->getPaletteCount()); +} + bool CursorManager::supportsCursorPalettes() { return g_system->hasFeature(OSystem::kFeatureCursorPalette); } diff --git a/graphics/cursorman.h b/graphics/cursorman.h index f4a0ebbd82..68f27b18f5 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/stack.h" #include "common/singleton.h" +#include "graphics/cursor.h" #include "graphics/pixelformat.h" namespace Graphics { @@ -99,6 +100,15 @@ public: */ void replaceCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale = false, const Graphics::PixelFormat *format = NULL); + /** + * Replace the current cursor on the stack. If the stack is empty, the + * cursor is pushed instead. It's a slightly more optimized way of + * popping the old cursor before pushing the new one. + * + * @param cursor the new cursor + */ + void replaceCursor(const Graphics::Cursor *cursor); + /** * Pop all of the cursors and cursor palettes from their respective stacks. * The purpose is to ensure that all unecessary cursors are removed from the -- cgit v1.2.3