[Scummvm-git-logs] scummvm master -> 0a92f7c3b802826152dc7bacd770476b5997ea27

mduggan noreply at scummvm.org
Tue Dec 20 00:18:01 UTC 2022


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:
0a92f7c3b8 ULTIMA8: Switch to CursorManager for mouse cursor


Commit: 0a92f7c3b802826152dc7bacd770476b5997ea27
    https://github.com/scummvm/scummvm/commit/0a92f7c3b802826152dc7bacd770476b5997ea27
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2022-12-20T09:17:48+09:00

Commit Message:
ULTIMA8: Switch to CursorManager for mouse cursor

Changed paths:
    engines/ultima/ultima8/kernel/mouse.cpp
    engines/ultima/ultima8/kernel/mouse.h
    engines/ultima/ultima8/ultima8.cpp


diff --git a/engines/ultima/ultima8/kernel/mouse.cpp b/engines/ultima/ultima8/kernel/mouse.cpp
index d945c6f42ee..d4037dc9147 100644
--- a/engines/ultima/ultima8/kernel/mouse.cpp
+++ b/engines/ultima/ultima8/kernel/mouse.cpp
@@ -29,6 +29,9 @@
 #include "ultima/ultima8/misc/direction_util.h"
 #include "ultima/ultima8/world/get_object.h"
 #include "ultima/ultima8/world/actors/main_actor.h"
+#include "ultima/ultima8/graphics/shape.h"
+#include "ultima/ultima8/graphics/shape_frame.h"
+#include "ultima/ultima8/graphics/palette.h"
 
 namespace Ultima {
 namespace Ultima8 {
@@ -41,15 +44,13 @@ Mouse::Mouse() : _flashingCursorTime(0), _mouseOverGump(0),
 	_instance = this;
 
 	_cursors.push(MOUSE_NONE);
+	CursorMan.showMouse(false);
 }
 
 Mouse::~Mouse() {
 	_instance = nullptr;
 }
 
-void Mouse::setup() {
-}
-
 bool Mouse::buttonDown(Shared::MouseButton button) {
 	assert(button != Shared::MOUSE_LAST);
 	bool handled = false;
@@ -121,6 +122,7 @@ bool Mouse::buttonUp(Shared::MouseButton button) {
 void Mouse::popAllCursors() {
 	_cursors.clear();
 	_cursors.push(MOUSE_NONE);
+	update();
 }
 
 bool Mouse::isMouseDownEvent(Shared::MouseButton button) const {
@@ -339,6 +341,7 @@ void Mouse::setMouseCoords(int mx, int my) {
 void Mouse::setMouseCursor(MouseCursor cursor) {
 	_cursors.pop();
 	_cursors.push(cursor);
+	update();
 }
 
 void Mouse::flashCrossCursor() {
@@ -347,10 +350,12 @@ void Mouse::flashCrossCursor() {
 
 void Mouse::pushMouseCursor(MouseCursor cursor) {
 	_cursors.push(cursor);
+	update();
 }
 
 void Mouse::popMouseCursor() {
 	_cursors.pop();
+	update();
 }
 
 void Mouse::startDragging(int startx, int starty) {
@@ -531,18 +536,21 @@ Gump *Mouse::getMouseOverGump() const {
 	return getGump(_mouseOverGump);
 }
 
-void Mouse::paint() {
-	RenderSurface *screen = Ultima8Engine::get_instance()->getRenderScreen();
+void Mouse::update() {
 	GameData *gamedata = GameData::get_instance();
-
 	if (!gamedata)
 		return;
 
 	const Shape *mouse = gamedata->getMouse();
 	if (mouse) {
 		int frame = getMouseFrame();
-		if (frame >= 0) {
-			screen->Paint(mouse, frame, _mousePos.x, _mousePos.y, true);
+		if (frame >= 0 && (uint)frame < mouse->frameCount()) {
+			const ShapeFrame *f = mouse->getFrame(frame);
+			CursorMan.replaceCursor(f->_pixels, f->_width, f->_height, f->_xoff, f->_yoff, f->_keycolor);
+			CursorMan.replaceCursorPalette(mouse->getPalette()->_palette, 0, 256);
+			CursorMan.showMouse(true);
+		} else {
+			CursorMan.showMouse(false);
 		}
 	}
 }
diff --git a/engines/ultima/ultima8/kernel/mouse.h b/engines/ultima/ultima8/kernel/mouse.h
index b43836add63..d19d188cb5d 100644
--- a/engines/ultima/ultima8/kernel/mouse.h
+++ b/engines/ultima/ultima8/kernel/mouse.h
@@ -130,11 +130,6 @@ public:
 	Mouse();
 	~Mouse();
 
-	/**
-	 * Setup the mouse cursors
-	 */
-	void setup();
-
 	/**
 	 * Called when a mouse button is pressed down
 	 */
@@ -214,7 +209,7 @@ public:
 	Gump *getMouseOverGump() const;
 	void resetMouseOverGump() { _mouseOverGump = 0; }
 
-	void paint();
+	void update();
 };
 
 } // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 9aba5ad0cc2..0180b8776ad 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -638,8 +638,8 @@ void Ultima8Engine::paint() {
 	}
 #endif
 
-	// Draw the mouse
-	_mouse->paint();
+	// Update the mouse
+	_mouse->update();
 
 	// End _painting
 	_screen->EndPainting();
@@ -696,10 +696,6 @@ void Ultima8Engine::GraphicSysInit() {
 		return;
 	}
 
-	// setup normal mouse cursor
-	debugN(MM_INFO, "Loading Default Mouse Cursor...\n");
-	_mouse->setup();
-
 	_desktopGump = new DesktopGump(0, 0, width, height);
 	_desktopGump->InitGump(0);
 	_desktopGump->MakeFocus();
@@ -1246,9 +1242,9 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
 	}
 
 	_mouse->pushMouseCursor(Mouse::MOUSE_WAIT);
-	_screen->BeginPainting();
-	_mouse->paint();
-	_screen->EndPainting();
+
+	// Redraw to indicate busy
+	paint();
 
 	Common::SeekableReadStream *ds;
 	GameInfo saveinfo;




More information about the Scummvm-git-logs mailing list