[Scummvm-git-logs] scummvm master -> 5a3a131b0972fecbe354dc8146340453da139952

sev- noreply at scummvm.org
Fri Aug 9 12:18:05 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5a3a131b09 GRAPHICS: Added an arrow cursor to CursorMan


Commit: 5a3a131b0972fecbe354dc8146340453da139952
    https://github.com/scummvm/scummvm/commit/5a3a131b0972fecbe354dc8146340453da139952
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-08-09T14:17:52+02:00

Commit Message:
GRAPHICS: Added an arrow cursor to CursorMan

It is meant to be used as a sane cursor when the game is relying on
system cursor, like some Windows titles.

If you want to improve the cursor graphics, you are welcome.

Changed paths:
    graphics/cursorman.cpp
    graphics/cursorman.h


diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp
index 6727422433d..ba691e83265 100644
--- a/graphics/cursorman.cpp
+++ b/graphics/cursorman.cpp
@@ -31,6 +31,32 @@ DECLARE_SINGLETON(Graphics::CursorManager);
 
 namespace Graphics {
 
+static const int CURSOR_W = 12;
+static const int CURSOR_H = 20;
+static const byte ARROW_CURSOR[CURSOR_W * CURSOR_H] = {
+	1,1,0,0,0,0,0,0,0,0,0,0,
+	1,2,1,0,0,0,0,0,0,0,0,0,
+	1,2,2,1,0,0,0,0,0,0,0,0,
+	1,2,2,2,1,0,0,0,0,0,0,0,
+	1,2,2,2,2,1,0,0,0,0,0,0,
+	1,2,2,2,2,2,1,0,0,0,0,0,
+	1,2,2,2,2,2,2,1,0,0,0,0,
+	1,2,2,2,2,2,2,2,1,0,0,0,
+	1,2,2,2,2,2,2,2,2,1,0,0,
+	1,2,2,2,2,2,2,2,2,2,1,0,
+	1,2,2,2,2,2,2,1,1,1,1,1,
+	1,2,2,2,1,2,2,1,0,0,0,0,
+	1,2,2,1,1,2,2,1,0,0,0,0,
+	1,2,1,0,0,1,2,2,1,0,0,0,
+	1,1,0,0,0,1,2,2,1,0,0,0,
+	1,0,0,0,0,0,1,2,2,1,0,0,
+	0,0,0,0,0,0,1,2,2,1,0,0,
+	0,0,0,0,0,0,0,1,2,2,1,0,
+	0,0,0,0,0,0,0,1,2,2,1,0,
+	0,0,0,0,0,0,0,0,1,1,0,0,
+};
+static const byte CURSOR_PALETTE[] = { 0x80, 0x80, 0x80, 0, 0, 0, 0xff, 0xff, 0xff };
+
 CursorManager::~CursorManager() {
 	for (Common::Stack<Cursor *>::size_type i = 0; i < _cursorStack.size(); ++i)
 		delete _cursorStack[i];
@@ -275,6 +301,18 @@ void CursorManager::lock(bool locked) {
 	_locked = locked;
 }
 
+void CursorManager::setDefaultArrowCursor(bool push) {
+	Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
+
+	if (push) {
+		pushCursorPalette(CURSOR_PALETTE, 0, ARRAYSIZE(CURSOR_PALETTE) / 3);
+		pushCursor(ARROW_CURSOR, CURSOR_W, CURSOR_H, 0, 0, 0, true, &format);
+	} else {
+		replaceCursorPalette(CURSOR_PALETTE, 0, ARRAYSIZE(CURSOR_PALETTE) / 3);
+		replaceCursor(ARROW_CURSOR, CURSOR_W, CURSOR_H, 0, 0, 0, true, &format);
+	}
+}
+
 CursorManager::Cursor::Cursor(const Surface &surf, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const byte *mask) {
 	const uint32 keycolor_mask = (((uint32) -1) >> (sizeof(uint32) * 8 - surf.format.bytesPerPixel * 8));
 	_keycolor = keycolor & keycolor_mask;
diff --git a/graphics/cursorman.h b/graphics/cursorman.h
index 14d2545cb88..3208a41b98c 100644
--- a/graphics/cursorman.h
+++ b/graphics/cursorman.h
@@ -242,6 +242,17 @@ public:
 	 * and returns false.
 	 */
 	void lock(bool locked);
+
+	/**
+	 * Sets default arrow cursor
+	 *
+	 * This is supposed to be used as a sane fallback for system cursor for
+	 * games that rely on the system cursor
+	 *
+	 * @param push		Specified if cursor should be pushed on replaced (defailt)
+	 */
+	void setDefaultArrowCursor(bool push = false);
+
 private:
 	/**
 	* Generic class for implementing the singleton design pattern.




More information about the Scummvm-git-logs mailing list