aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Cawley2019-08-09 20:45:27 +0100
committerFilippos Karapetis2019-08-09 23:58:32 +0300
commitfe5dddf901eb40ac3c04b7d01bd078d65dafc5ab (patch)
tree96dff48a310a3873fb9fc6cb48454997a26aba17
parent4667aae4c407a3a54f44e07227897cf077f82fe2 (diff)
downloadscummvm-rg350-fe5dddf901eb40ac3c04b7d01bd078d65dafc5ab.tar.gz
scummvm-rg350-fe5dddf901eb40ac3c04b7d01bd078d65dafc5ab.tar.bz2
scummvm-rg350-fe5dddf901eb40ac3c04b7d01bd078d65dafc5ab.zip
GRAPHICS: Add a version of CursorManager::replaceCursor that accepts a Graphics::Cursor
-rw-r--r--engines/composer/composer.cpp4
-rw-r--r--engines/cryomni3d/cryomni3d.cpp6
-rw-r--r--engines/gnap/gnap.cpp4
-rw-r--r--engines/mohawk/cursors.cpp14
-rw-r--r--engines/sci/graphics/cursor.cpp4
-rw-r--r--graphics/cursorman.cpp8
-rw-r--r--graphics/cursorman.h10
7 files changed, 27 insertions, 23 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp
index bd486e8324..6aafec276c 100644
--- a/engines/composer/composer.cpp
+++ b/engines/composer/composer.cpp
@@ -105,9 +105,7 @@ Common::Error ComposerEngine::run() {
_screen.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor();
- CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(),
- cursor->getHotspotY(), cursor->getKeyColor());
- CursorMan.replaceCursorPalette(cursor->getPalette(), cursor->getPaletteStartIndex(), cursor->getPaletteCount());
+ CursorMan.replaceCursor(cursor);
delete cursor;
_console = new Console(this);
diff --git a/engines/cryomni3d/cryomni3d.cpp b/engines/cryomni3d/cryomni3d.cpp
index 452d6b7794..95da49a7e2 100644
--- a/engines/cryomni3d/cryomni3d.cpp
+++ b/engines/cryomni3d/cryomni3d.cpp
@@ -252,14 +252,12 @@ bool CryOmni3DEngine::displayHLZ(const Common::String &filename, uint32 timeout)
}
void CryOmni3DEngine::setCursor(const Graphics::Cursor &cursor) const {
- CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(),
- cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor());
+ CursorMan.replaceCursor(&cursor);
}
void CryOmni3DEngine::setCursor(uint cursorId) const {
const Graphics::Cursor &cursor = _sprites.getCursor(cursorId);
- CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(),
- cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor());
+ CursorMan.replaceCursor(&cursor);
}
bool CryOmni3DEngine::pollEvents() {
diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp
index aece4da004..1d31e6549b 100644
--- a/engines/gnap/gnap.cpp
+++ b/engines/gnap/gnap.cpp
@@ -547,9 +547,7 @@ void GnapEngine::setCursor(int cursorIndex) {
Graphics::WinCursorGroup *cursorGroup = Graphics::WinCursorGroup::createCursorGroup(*_exe, Common::WinResourceID(cursorName));
if (cursorGroup) {
Graphics::Cursor *cursor = cursorGroup->cursors[0].cursor;
- CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(),
- cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor());
- CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256);
+ CursorMan.replaceCursor(cursor);
delete cursorGroup;
}
_cursorIndex = cursorIndex;
diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index 8adcbf62ed..2cb41be65e 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -51,9 +51,7 @@ void CursorManager::hideCursor() {
void CursorManager::setDefaultCursor() {
Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor();
- CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(),
- cursor->getHotspotY(), cursor->getKeyColor());
- CursorMan.replaceCursorPalette(cursor->getPalette(), cursor->getPaletteStartIndex(), cursor->getPaletteCount());
+ CursorMan.replaceCursor(cursor);
delete cursor;
}
@@ -71,9 +69,7 @@ void CursorManager::setMacCursor(Common::SeekableReadStream *stream) {
if (!macCursor->readFromStream(*stream))
error("Could not parse Mac cursor");
- CursorMan.replaceCursor(macCursor->getSurface(), macCursor->getWidth(), macCursor->getHeight(),
- macCursor->getHotspotX(), macCursor->getHotspotY(), macCursor->getKeyColor());
- CursorMan.replaceCursorPalette(macCursor->getPalette(), 0, 256);
+ CursorMan.replaceCursor(macCursor);
delete macCursor;
delete stream;
@@ -165,8 +161,7 @@ void NECursorManager::setCursor(uint16 id) {
if (cursorGroup) {
Graphics::Cursor *cursor = cursorGroup->cursors[0].cursor;
- CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor());
- CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256);
+ CursorMan.replaceCursor(cursor);
delete cursorGroup;
return;
}
@@ -272,8 +267,7 @@ void PECursorManager::setCursor(uint16 id) {
for (uint i = 0; i < _cursors.size(); i++) {
if (_cursors[i].id == id) {
Graphics::Cursor *cursor = _cursors[i].cursorGroup->cursors[0].cursor;
- CursorMan.replaceCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(), cursor->getHotspotY(), cursor->getKeyColor());
- CursorMan.replaceCursorPalette(cursor->getPalette(), 0, 256);
+ CursorMan.replaceCursor(cursor);
return;
}
}
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index 56177db9f3..bcddd16083 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -514,9 +514,7 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu
return;
}
- CursorMan.replaceCursor(macCursor->getSurface(), macCursor->getWidth(), macCursor->getHeight(),
- macCursor->getHotspotX(), macCursor->getHotspotY(), macCursor->getKeyColor());
- CursorMan.replaceCursorPalette(macCursor->getPalette(), 0, 256);
+ CursorMan.replaceCursor(macCursor);
delete macCursor;
kernelShow();
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 {
@@ -100,6 +101,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
* stack when returning to the launcher from an engine.