[Scummvm-git-logs] scummvm master -> 421c8471adc3445bfce358c3a20537702cf4a174

djsrv dservilla at gmail.com
Fri Aug 6 05:19:57 UTC 2021


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

Summary:
93f585c524 GRAPHICS: MACGUI: Clean up cursor management
1e61684570 GRAPHICS: MACGUI: Add replaceCustomCursor
19dab8f130 DIRECTOR: Set cursors per-movie, not globally
2cc0ad6e0c DIRECTOR: LINGO: Update cursor in updateStage
421c8471ad DIRECTOR: Always playSoundChannel in renderFrame


Commit: 93f585c524470c08f5715aa50b7775961da449c6
    https://github.com/scummvm/scummvm/commit/93f585c524470c08f5715aa50b7775961da449c6
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-06T01:11:30-04:00

Commit Message:
GRAPHICS: MACGUI: Clean up cursor management

Cursor types are now stored in a stack. Pushes and pops to the cursor
stack, cursor palette stack, and cursor type stack are now fully
synchronized.

Changed paths:
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 72efa6143d..aa9c701862 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -220,9 +220,8 @@ MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns, Common::L
 	_fontMan = new MacFontManager(mode, language);
 
 	_cursor = nullptr;
-	_cursorType = _tempType = kMacCursorArrow;
-	CursorMan.replaceCursorPalette(palette, 0, ARRAYSIZE(palette) / 3);
-	CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+	_tempType = kMacCursorArrow;
+	replaceCursor(kMacCursorArrow);
 	CursorMan.showMouse(true);
 
 	loadDataBundle();
@@ -994,15 +993,15 @@ bool MacWindowManager::processEvent(Common::Event &event) {
 				 ((MacWindow *)_windows[_activeWindow])->getInnerDimensions().contains(event.mouse.x, event.mouse.y)) ||
 				(_activeWidget && _activeWidget->isEditable() &&
 				 _activeWidget->getDimensions().contains(event.mouse.x, event.mouse.y))) {
-			if (_cursorType != kMacCursorBeam) {
-				_tempType = _cursorType;
+			if (getCursorType() != kMacCursorBeam) {
+				_tempType = getCursorType();
 				_inEditableArea = true;
 				replaceCursor(kMacCursorBeam);
 			}
 		} else {
 			// here, we use _inEditableArea is distinguish whether the current Beam cursor is set by director or ourself
 			// if we are not in the editable area but we are drawing the Beam cursor, then the cursor is set by director, thus we don't replace it
-			if (_cursorType == kMacCursorBeam && _inEditableArea) {
+			if (getCursorType() == kMacCursorBeam && _inEditableArea) {
 				replaceCursor(_tempType, _cursor);
 				_inEditableArea = false;
 			}
@@ -1159,53 +1158,45 @@ void MacWindowManager::zoomBoxInner(Common::Rect &r, Graphics::MacPlotData &pd)
 /////////////////
 // Cursor stuff
 /////////////////
-void MacWindowManager::pushArrowCursor() {
-	CursorMan.pushCursor(macCursorArrow, 11, 16, 1, 1, 3);
-	CursorMan.pushCursorPalette(cursorPalette, 0, 2);
-}
-
-void MacWindowManager::pushBeamCursor() {
-	CursorMan.pushCursor(macCursorBeam, 11, 16, 1, 1, 3);
-	CursorMan.pushCursorPalette(cursorPalette, 0, 2);
-}
-
-void MacWindowManager::pushCrossHairCursor() {
-	CursorMan.pushCursor(macCursorCrossHair, 11, 16, 1, 1, 3);
-	CursorMan.pushCursorPalette(cursorPalette, 0, 2);
+void MacWindowManager::replaceCursorType(MacCursorType type) {
+	if (_cursorTypeStack.empty())
+		_cursorTypeStack.push(type);
+	else
+		_cursorTypeStack.top() = type;
 }
 
-void MacWindowManager::pushCrossBarCursor() {
-	CursorMan.pushCursor(macCursorCrossBar, 11, 16, 1, 1, 3);
-	CursorMan.pushCursorPalette(cursorPalette, 0, 2);
-}
+MacCursorType MacWindowManager::getCursorType() const {
+	if (_cursorTypeStack.empty())
+		return kMacCursorOff;
 
-void MacWindowManager::pushWatchCursor() {
-	CursorMan.pushCursor(macCursorWatch, 11, 16, 1, 1, 3);
-	CursorMan.pushCursorPalette(cursorPalette, 0, 2);
+	return _cursorTypeStack.top();
 }
 
 void MacWindowManager::pushCursor(MacCursorType type, Cursor *cursor) {
-	if (_cursorType == kMacCursorOff && type != _cursorType)
-		CursorMan.showMouse(true);
-
 	switch (type) {
 	case kMacCursorOff:
-		CursorMan.showMouse(false);
+		CursorMan.pushCursor(nullptr, 0, 0, 0, 0, 0);
+		CursorMan.pushCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorArrow:
-		pushArrowCursor();
+		CursorMan.pushCursor(macCursorArrow, 11, 16, 1, 1, 3);
+		CursorMan.pushCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorBeam:
-		pushBeamCursor();
+		CursorMan.pushCursor(macCursorBeam, 11, 16, 1, 1, 3);
+		CursorMan.pushCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorCrossHair:
-		pushCrossHairCursor();
+		CursorMan.pushCursor(macCursorCrossHair, 11, 16, 1, 1, 3);
+		CursorMan.pushCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorCrossBar:
-		pushCrossBarCursor();
+		CursorMan.pushCursor(macCursorCrossBar, 11, 16, 1, 1, 3);
+		CursorMan.pushCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorWatch:
-		pushWatchCursor();
+		CursorMan.pushCursor(macCursorWatch, 11, 16, 1, 1, 3);
+		CursorMan.pushCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorCustom:
 		if (!cursor) {
@@ -1216,31 +1207,34 @@ void MacWindowManager::pushCursor(MacCursorType type, Cursor *cursor) {
 		pushCustomCursor(cursor);
 	}
 
-	_cursorType = type;
+	_cursorTypeStack.push(type);
 }
 
 void MacWindowManager::replaceCursor(MacCursorType type, Cursor *cursor) {
-	if (_cursorType == kMacCursorOff && type != _cursorType)
-		CursorMan.showMouse(true);
-
 	switch (type) {
 	case kMacCursorOff:
-		CursorMan.showMouse(false);
+		CursorMan.replaceCursor(nullptr, 0, 0, 0, 0, 0);
+		CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorArrow:
 		CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+		CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorBeam:
-		CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
+		CursorMan.replaceCursor(macCursorBeam, 11, 16, 1, 1, 3);
+		CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorCrossHair:
 		CursorMan.replaceCursor(macCursorCrossHair, 11, 16, 1, 1, 3);
+		CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorCrossBar:
 		CursorMan.replaceCursor(macCursorCrossBar, 11, 16, 1, 1, 3);
+		CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorWatch:
 		CursorMan.replaceCursor(macCursorWatch, 11, 16, 1, 1, 3);
+		CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
 		break;
 	case kMacCursorCustom:
 		if (!cursor) {
@@ -1252,12 +1246,13 @@ void MacWindowManager::replaceCursor(MacCursorType type, Cursor *cursor) {
 		break;
 	}
 
-	_cursorType = type;
+	replaceCursorType(type);
 }
 
 void MacWindowManager::pushCustomCursor(const byte *data, int w, int h, int hx, int hy, int transcolor) {
 	CursorMan.pushCursor(data, w, h, hx, hy, transcolor);
 	CursorMan.pushCursorPalette(cursorPalette, 0, 2);
+	_cursorTypeStack.push(kMacCursorCustom);
 }
 
 void MacWindowManager::pushCustomCursor(const Graphics::Cursor *cursor) {
@@ -1268,17 +1263,14 @@ void MacWindowManager::pushCustomCursor(const Graphics::Cursor *cursor) {
 		CursorMan.pushCursorPalette(cursor->getPalette(), cursor->getPaletteStartIndex(), cursor->getPaletteCount());
 	else
 		CursorMan.pushCursorPalette(cursorPalette, 0, 2);
+
+	_cursorTypeStack.push(kMacCursorCustom);
 }
 
 void MacWindowManager::popCursor() {
-	if (_cursorType == kMacCursorOff) {
-		CursorMan.showMouse(true);
-	} else {
-		CursorMan.popCursor();
-		CursorMan.popCursorPalette();
-		// since we may only have one cursor available when we using macCursor, so we restore the cursorType when we pop the cursor
-		_cursorType = kMacCursorArrow;
-	}
+	CursorMan.popCursor();
+	CursorMan.popCursorPalette();
+	_cursorTypeStack.pop();
 }
 
 ///////////////////
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 80c6c1117d..2b9c8b9d3c 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -25,6 +25,7 @@
 
 #include "common/hashmap.h"
 #include "common/list.h"
+#include "common/stack.h"
 #include "common/events.h"
 
 #include "graphics/font.h"
@@ -280,15 +281,15 @@ public:
 
 	void clearWidgetRefs(MacWidget *widget);
 
+private:
+	void replaceCursorType(MacCursorType type);
+
+public:
+	MacCursorType getCursorType() const;
+
 	void pushCursor(MacCursorType type, Cursor *cursor = nullptr);
 	void replaceCursor(MacCursorType type, Cursor *cursor = nullptr);
 
-	void pushArrowCursor();
-	void pushBeamCursor();
-	void pushCrossHairCursor();
-	void pushCrossBarCursor();
-	void pushWatchCursor();
-
 	void pushCustomCursor(const byte *data, int w, int h, int hx, int hy, int transcolor);
 	void pushCustomCursor(const Graphics::Cursor *cursor);
 	void popCursor();
@@ -420,7 +421,7 @@ private:
 	void (*_redrawEngineCallback)(void *engine);
 
 	MacCursorType _tempType;
-	MacCursorType _cursorType;
+	Common::Stack<MacCursorType> _cursorTypeStack;
 	Cursor *_cursor;
 
 	MacWidget *_activeWidget;


Commit: 1e61684570fc4d2b9ffdd1540a8cfd6d898d1d41
    https://github.com/scummvm/scummvm/commit/1e61684570fc4d2b9ffdd1540a8cfd6d898d1d41
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-06T01:11:39-04:00

Commit Message:
GRAPHICS: MACGUI: Add replaceCustomCursor

Changed paths:
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index aa9c701862..bbfcb010fd 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -1255,6 +1255,12 @@ void MacWindowManager::pushCustomCursor(const byte *data, int w, int h, int hx,
 	_cursorTypeStack.push(kMacCursorCustom);
 }
 
+void MacWindowManager::replaceCustomCursor(const byte *data, int w, int h, int hx, int hy, int transcolor) {
+	CursorMan.replaceCursor(data, w, h, hx, hy, transcolor);
+	CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
+	replaceCursorType(kMacCursorCustom);
+}
+
 void MacWindowManager::pushCustomCursor(const Graphics::Cursor *cursor) {
 	CursorMan.pushCursor(cursor->getSurface(), cursor->getWidth(), cursor->getHeight(), cursor->getHotspotX(),
 	                     cursor->getHotspotY(), cursor->getKeyColor());
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 2b9c8b9d3c..cdb77992b0 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -291,6 +291,7 @@ public:
 	void replaceCursor(MacCursorType type, Cursor *cursor = nullptr);
 
 	void pushCustomCursor(const byte *data, int w, int h, int hx, int hy, int transcolor);
+	void replaceCustomCursor(const byte *data, int w, int h, int hx, int hy, int transcolor);
 	void pushCustomCursor(const Graphics::Cursor *cursor);
 	void popCursor();
 


Commit: 19dab8f130cea9bfa262b7ce272ea2ac79ac22c8
    https://github.com/scummvm/scummvm/commit/19dab8f130cea9bfa262b7ce272ea2ac79ac22c8
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-06T01:11:49-04:00

Commit Message:
DIRECTOR: Set cursors per-movie, not globally

Changed paths:
    engines/director/cursor.cpp
    engines/director/cursor.h
    engines/director/director.cpp
    engines/director/director.h
    engines/director/events.cpp
    engines/director/graphics.cpp
    engines/director/lingo/lingo-funcs.cpp
    engines/director/score.cpp
    engines/director/score.h
    engines/director/types.h


diff --git a/engines/director/cursor.cpp b/engines/director/cursor.cpp
index 68a4e677aa..42348f13c1 100644
--- a/engines/director/cursor.cpp
+++ b/engines/director/cursor.cpp
@@ -40,6 +40,15 @@ Cursor::Cursor() {
 	_usePalette = false;
 }
 
+CursorRef Cursor::getRef() {
+	CursorRef res;
+	res._cursorType = _cursorType;
+	res._cursorResId = _cursorResId;
+	res._cursorCastId = _cursorCastId;
+	res._cursorMaskId = _cursorMaskId;
+	return res;
+}
+
 bool Cursor::operator==(const Cursor &c) {
 	return _cursorType == c._cursorType &&
 		_cursorResId == c._cursorResId &&
@@ -47,6 +56,13 @@ bool Cursor::operator==(const Cursor &c) {
 		_cursorMaskId == c._cursorMaskId;
 }
 
+bool Cursor::operator==(const CursorRef &c) {
+	return _cursorType == c._cursorType &&
+		_cursorResId == c._cursorResId &&
+		_cursorCastId == c._cursorCastId &&
+		_cursorMaskId == c._cursorMaskId;
+}
+
 void Cursor::readFromCast(CastMemberID cursorId, CastMemberID maskId) {
 	if (cursorId == _cursorCastId && maskId == _cursorMaskId)
 		return;
@@ -164,4 +180,25 @@ void Cursor::resetCursor(Graphics::MacCursorType type, bool shouldClear, int res
 	_hotspotY = 0;
 }
 
+CursorRef::CursorRef() {
+	_cursorType = Graphics::kMacCursorArrow;
+	_cursorResId = 0;
+	_cursorCastId = CastMemberID(0, 0);
+	_cursorMaskId = CastMemberID(0, 0);
+}
+
+bool CursorRef::operator==(const Cursor &c) {
+	return _cursorType == c._cursorType &&
+		_cursorResId == c._cursorResId &&
+		_cursorCastId == c._cursorCastId &&
+		_cursorMaskId == c._cursorMaskId;
+}
+
+bool CursorRef::operator==(const CursorRef &c) {
+	return _cursorType == c._cursorType &&
+		_cursorResId == c._cursorResId &&
+		_cursorCastId == c._cursorCastId &&
+		_cursorMaskId == c._cursorMaskId;
+}
+
 } // End of namespace Director
diff --git a/engines/director/cursor.h b/engines/director/cursor.h
index 119c2164b0..fe9e777767 100644
--- a/engines/director/cursor.h
+++ b/engines/director/cursor.h
@@ -33,15 +33,20 @@ class MacCursor;
 
 namespace Director {
 
+struct CursorRef;
+
 class Cursor : public Graphics::MacCursor {
  public:
 	Cursor();
 
+	CursorRef getRef();
+
 	void readFromCast(CastMemberID cursorId, CastMemberID maskId);
 	void readFromResource(int resourceId);
 
 	bool isEmpty() { return _cursorResId == 0 && _cursorCastId.member == 0; }
 	bool operator==(const Cursor &c);
+	bool operator==(const CursorRef &c);
 
 	virtual byte getKeyColor() const override { return _keyColor; }
 	virtual const byte *getPalette() const override { return _usePalette ? _palette : nullptr; }
@@ -61,6 +66,19 @@ private:
 	byte _keyColor;
 };
 
+// CursorRef acts as a reference to a cursor.
+// Doesn't contain a surface, palette, etc. like the cursor itself.
+struct CursorRef {
+	CursorRef();
+	bool operator==(const Cursor &c);
+	bool operator==(const CursorRef &c);
+
+	Graphics::MacCursorType _cursorType;
+	int _cursorResId;
+	CastMemberID _cursorCastId;
+	CastMemberID _cursorMaskId;
+};
+
 } // End of namespace Director
 
 #endif
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 7842d1df35..f6041eaf97 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -75,6 +75,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
 	_windowList->type = ARRAY;
 	_windowList->u.farr = new FArray;
 	_currentWindow = nullptr;
+	_cursorWindow = nullptr;
 	_lingo = nullptr;
 	_version = getDescriptionVersion();
 
diff --git a/engines/director/director.h b/engines/director/director.h
index 83ebba285f..fc00fb8f6e 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -196,6 +196,8 @@ public:
 	Window *getStage() const { return _stage; }
 	Window *getCurrentWindow() const { return _currentWindow; }
 	void setCurrentWindow(Window *window) { _currentWindow = window; };
+	Window *getCursorWindow() const { return _cursorWindow; }
+	void setCursorWindow(Window *window) { _cursorWindow = window; }
 	Movie *getCurrentMovie() const;
 	void setCurrentMovie(Movie *movie);
 	Common::String getCurrentPath() const;
@@ -219,7 +221,7 @@ public:
 	void loadPatterns();
 	uint32 transformColor(uint32 color);
 	Graphics::MacPatterns &getPatterns();
-	void setCursor(int type);
+	void setCursor(DirectorCursor type);
 	void draw();
 
 	Graphics::MacDrawPixPtr getInkDrawPixel();
@@ -263,6 +265,7 @@ private:
 	Window *_stage;
 	Datum *_windowList; // Lingo list
 	Window *_currentWindow;
+	Window *_cursorWindow;
 
 	Graphics::MacPatterns _director3Patterns;
 	Graphics::MacPatterns _director3QuickDrawPatterns;
diff --git a/engines/director/events.cpp b/engines/director/events.cpp
index 81bcc0c924..5e861d79c0 100644
--- a/engines/director/events.cpp
+++ b/engines/director/events.cpp
@@ -45,8 +45,24 @@ bool DirectorEngine::processEvents(bool captureClick) {
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
-		_wm->processEvent(event);
+		if (!_wm->processEvent(event)) {
+			// We only want to handle these events if the event
+			// wasn't handled by the window manager.
+			switch (event.type) {
+			case Common::EVENT_MOUSEMOVE:
+				if (_cursorWindow) {
+					// The cursor is no longer in a window.
+					// Set it to the default arrow cursor.
+					_wm->replaceCursor(Graphics::kMacCursorArrow);
+					_cursorWindow = nullptr;
+				}
+				break;
+			default:
+				break;
+			}
+		}
 
+		// We want to handle these events regardless.
 		switch (event.type) {
 		case Common::EVENT_QUIT:
 			_stage->getCurrentMovie()->getScore()->_playState = kPlayStopped;
@@ -89,7 +105,13 @@ bool Movie::processEvent(Common::Event &event) {
 		_lastEventTime = g_director->getMacTicks();
 		_lastRollTime =	 _lastEventTime;
 
-		sc->renderCursor(pos);
+		if (_vm->getCursorWindow() != _window) {
+			// Cursor just entered this window. Force a cursor update.
+			_vm->setCursorWindow(_window);
+			sc->renderCursor(pos, true);
+		} else {
+			sc->renderCursor(pos);
+		}
 
 		// hiliteChannelId is specified for BitMap castmember, so we deal with them separately with other castmember
 		// if we are moving out of bounds, then we don't hilite it anymore
@@ -133,7 +155,7 @@ bool Movie::processEvent(Common::Event &event) {
 	case Common::EVENT_LBUTTONDOWN:
 		if (sc->_waitForClick) {
 			sc->_waitForClick = false;
-			_vm->setCursor(kCursorDefault);
+			sc->renderCursor(_window->getMousePos(), true);
 		} else {
 			pos = _window->getMousePos();
 
diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp
index 4887cb7ce8..113194fc88 100644
--- a/engines/director/graphics.cpp
+++ b/engines/director/graphics.cpp
@@ -119,18 +119,13 @@ void DirectorEngine::clearPalettes() {
 	}
 }
 
-void DirectorEngine::setCursor(int type) {
+void DirectorEngine::setCursor(DirectorCursor type) {
 	switch (type) {
-	case kCursorDefault:
-		_wm->popCursor();
-		break;
-
 	case kCursorMouseDown:
-		_wm->pushCustomCursor(mouseDown, 16, 16, 0, 0, 3);
+		_wm->replaceCustomCursor(mouseDown, 16, 16, 0, 0, 3);
 		break;
-
 	case kCursorMouseUp:
-		_wm->pushCustomCursor(mouseUp, 16, 16, 0, 0, 3);
+		_wm->replaceCustomCursor(mouseUp, 16, 16, 0, 0, 3);
 		break;
 	}
 }
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp
index c87515f730..52b9945389 100644
--- a/engines/director/lingo/lingo-funcs.cpp
+++ b/engines/director/lingo/lingo-funcs.cpp
@@ -310,17 +310,15 @@ void Lingo::func_play(Datum &frame, Datum &movie) {
 }
 
 void Lingo::func_cursor(CastMemberID cursorId, CastMemberID maskId) {
-	Cursor cursor;
-	cursor.readFromCast(cursorId, maskId);
-	// TODO: Figure out why there are artifacts here
-	_vm->_wm->replaceCursor(cursor._cursorType, ((Graphics::Cursor *)&cursor));
+	Score *score = _vm->getCurrentMovie()->getScore();
+	score->_defaultCursor.readFromCast(cursorId, maskId);
+	score->_cursorDirty = true;
 }
 
 void Lingo::func_cursor(int cursorId) {
-	Cursor cursor;
-	cursor.readFromResource(cursorId);
-	// TODO: Figure out why there are artifacts here
-	_vm->_wm->replaceCursor(cursor._cursorType, ((Graphics::Cursor *)&cursor));
+	Score *score = _vm->getCurrentMovie()->getScore();
+	score->_defaultCursor.readFromResource(cursorId);
+	score->_cursorDirty = true;
 }
 
 void Lingo::func_beep(int repeats) {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 4590ddc77f..8187b3ee5f 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -62,7 +62,6 @@ Score::Score(Movie *movie) {
 	_lastPalette = 0;
 
 	_labels = nullptr;
-	_currentCursor = nullptr;
 
 	_currentFrameRate = 20;
 	_currentFrame = 0;
@@ -322,8 +321,7 @@ void Score::update() {
 		} else if (_waitForClick) {
 			if (g_system->getMillis() >= _nextFrameTime + 1000) {
 				_waitForClickCursor = !_waitForClickCursor;
-				_vm->setCursor(kCursorDefault);
-				_vm->setCursor(_waitForClickCursor ? kCursorMouseDown : kCursorMouseUp);
+				renderCursor(_movie->getWindow()->getMousePos());
 				_nextFrameTime = g_system->getMillis();
 			}
 			keepWaiting = true;
@@ -463,7 +461,7 @@ void Score::update() {
 			if (tempo == 128) {
 				_waitForClick = true;
 				_waitForClickCursor = false;
-				_vm->setCursor(kCursorMouseUp);
+				renderCursor(_movie->getWindow()->getMousePos());
 			} else if (tempo == 135) {
 				// Wait for sound channel 1
 				_waitForChannel = 1;
@@ -501,8 +499,9 @@ void Score::renderFrame(uint16 frameId, RenderMode mode) {
 	// this is currently only used in FPlayXObj
 	playQueuedSound();
 
-	if (_cursorDirty) {
-		renderCursor(_movie->getWindow()->getMousePos());
+	if (_cursorDirty || _window->_newMovieStarted) {
+		// Force cursor update if a new movie's started.
+		renderCursor(_movie->getWindow()->getMousePos(), _window->_newMovieStarted);
 		_cursorDirty = false;
 	}
 }
@@ -565,34 +564,41 @@ void Score::renderSprites(uint16 frameId, RenderMode mode) {
 	}
 }
 
-void Score::renderCursor(Common::Point pos) {
-	uint spriteId = 0;
+void Score::renderCursor(Common::Point pos, bool forceUpdate) {
+	if (_window != _vm->getCursorWindow()) {
+		// The cursor is outside of this window.
+		return;
+	}
 
-	if (_channels.empty())
+	if (_waitForClick) {
+		_vm->setCursor(_waitForClickCursor ? kCursorMouseDown : kCursorMouseUp);
 		return;
+	}
 
-	for (int i = _channels.size() - 1; i >= 0; i--)
-		if (_channels[i]->isMouseIn(pos) && !_channels[i]->_cursor.isEmpty()) {
-			spriteId = i;
-			break;
-		}
+	if (!_channels.empty()) {
+		uint spriteId = 0;
 
-	if (_channels[spriteId]->_cursor.isEmpty()) {
-		if (_currentCursor) {
-			_vm->_wm->popCursor();
-			_currentCursor = nullptr;
-		}
-	} else {
-		if (_currentCursor) {
-			if (*_currentCursor == _channels[spriteId]->_cursor)
+		for (int i = _channels.size() - 1; i >= 0; i--)
+			if (_channels[i]->isMouseIn(pos) && !_channels[i]->_cursor.isEmpty()) {
+				spriteId = i;
+				break;
+			}
+
+		if (!_channels[spriteId]->_cursor.isEmpty()) {
+			if (!forceUpdate && _currentCursor == _channels[spriteId]->_cursor)
 				return;
 
-			_vm->_wm->popCursor();
+			_vm->_wm->replaceCursor(_channels[spriteId]->_cursor._cursorType, &_channels[spriteId]->_cursor);
+			_currentCursor = _channels[spriteId]->_cursor.getRef();
+			return;
 		}
-
-		_currentCursor = &_channels[spriteId]->_cursor;
-		_vm->_wm->pushCursor(_currentCursor->_cursorType, _currentCursor);
 	}
+
+	if (!forceUpdate && _currentCursor == _defaultCursor)
+		return;
+
+	_vm->_wm->replaceCursor(_defaultCursor._cursorType, &_defaultCursor);
+	_currentCursor = _defaultCursor.getRef();
 }
 
 void Score::renderVideo() {
diff --git a/engines/director/score.h b/engines/director/score.h
index d34d3d03b5..9885ef9d62 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -25,6 +25,8 @@
 
 //#include "graphics/macgui/macwindowmanager.h"
 
+#include "director/cursor.h"
+
 namespace Graphics {
 	struct Surface;
 	class ManagedSurface;
@@ -110,7 +112,7 @@ public:
 	bool renderTransition(uint16 frameId);
 	void renderFrame(uint16 frameId, RenderMode mode = kRenderModeNormal);
 	void renderSprites(uint16 frameId, RenderMode mode = kRenderModeNormal);
-	void renderCursor(Common::Point pos);
+	void renderCursor(Common::Point pos, bool forceUpdate = false);
 	void renderVideo();
 
 	void playSoundChannel(uint16 frameId);
@@ -143,7 +145,8 @@ public:
 	bool _waitForClickCursor;
 	bool _cursorDirty;
 	int _activeFade;
-	Cursor *_currentCursor;
+	Cursor _defaultCursor;
+	CursorRef _currentCursor;
 
 	int _numChannelsDisplayed;
 
diff --git a/engines/director/types.h b/engines/director/types.h
index 863e8485b4..ce7c3b51ba 100644
--- a/engines/director/types.h
+++ b/engines/director/types.h
@@ -288,8 +288,7 @@ enum PaletteType {
 	kClutSystemWin = -101
 };
 
-enum {
-	kCursorDefault,
+enum DirectorCursor {
 	kCursorMouseDown,
 	kCursorMouseUp
 };


Commit: 2cc0ad6e0c402db3723f9822fce3af8785506751
    https://github.com/scummvm/scummvm/commit/2cc0ad6e0c402db3723f9822fce3af8785506751
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-06T01:11:57-04:00

Commit Message:
DIRECTOR: LINGO: Update cursor in updateStage

Changed paths:
    engines/director/lingo/lingo-builtins.cpp


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 2ec16558bb..d039a43acc 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -2296,6 +2296,11 @@ void LB::b_updateStage(int nargs) {
 	// play any puppet sounds that have been queued
 	score->playSoundChannel(score->getCurrentFrame());
 
+	if (score->_cursorDirty) {
+		score->renderCursor(movie->getWindow()->getMousePos());
+		score->_cursorDirty = false;
+	}
+
 	if (debugChannelSet(-1, kDebugFewFramesOnly)) {
 		score->_framesRan++;
 


Commit: 421c8471adc3445bfce358c3a20537702cf4a174
    https://github.com/scummvm/scummvm/commit/421c8471adc3445bfce358c3a20537702cf4a174
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-06T01:12:04-04:00

Commit Message:
DIRECTOR: Always playSoundChannel in renderFrame

Changed paths:
    engines/director/score.cpp


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 8187b3ee5f..b274946bb0 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -493,11 +493,8 @@ void Score::renderFrame(uint16 frameId, RenderMode mode) {
 
 	_window->render();
 
-	// sound stuff
-	if (_frames[frameId]->_sound1.member || _frames[frameId]->_sound2.member)
-		playSoundChannel(frameId);
-	// this is currently only used in FPlayXObj
-	playQueuedSound();
+	playSoundChannel(frameId);
+	playQueuedSound(); // this is currently only used in FPlayXObj
 
 	if (_cursorDirty || _window->_newMovieStarted) {
 		// Force cursor update if a new movie's started.




More information about the Scummvm-git-logs mailing list