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

npjg nathanael.gentrydb8 at gmail.com
Sat Jul 18 04:38:04 UTC 2020


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

Summary:
0b6e441241 GRAPHICS: MacCursor: Change private to protected
79acd63dc0 GRAPHICS: MACGUI: Generalize WM cursor handling
4f15cb4af4 DIRECTOR: Introduce Cursor class
5fb984e99f DIRECTOR: Mostly implement cursor of sprite


Commit: 0b6e4412415c81dcfd7b8bf2cbca1b3429b9cbcb
    https://github.com/scummvm/scummvm/commit/0b6e4412415c81dcfd7b8bf2cbca1b3429b9cbcb
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-18T00:37:57-04:00

Commit Message:
GRAPHICS: MacCursor: Change private to protected

Changed paths:
    graphics/maccursor.h


diff --git a/graphics/maccursor.h b/graphics/maccursor.h
index a4da7cb46f..ae998761a4 100644
--- a/graphics/maccursor.h
+++ b/graphics/maccursor.h
@@ -65,7 +65,7 @@ public:
 	/** Read the cursor's data out of a stream. */
 	bool readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome = false, byte monochromeInvertedPixelColor = 0xff);
 
-private:
+protected:
 	bool readFromCURS(Common::SeekableReadStream &stream, byte monochromeInvertedPixelColor);
 	bool readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome, byte monochromeInvertedPixelColor);
 


Commit: 79acd63dc06d053c0c7ec5a5475a14ed9b83fc53
    https://github.com/scummvm/scummvm/commit/79acd63dc06d053c0c7ec5a5475a14ed9b83fc53
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-18T00:37:57-04:00

Commit Message:
GRAPHICS: MACGUI: Generalize WM cursor handling

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


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index 67dcce9de2..d1d7bc1b8c 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -191,9 +191,9 @@ MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns) {
 
 	_fontMan = new MacFontManager(mode);
 
+	_cursorType = kMacCursorArrow;
 	CursorMan.replaceCursorPalette(palette, 0, ARRAYSIZE(palette) / 3);
 	CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
-	_cursorIsArrow = true;
 	CursorMan.showMouse(true);
 }
 
@@ -479,15 +479,13 @@ 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 (_cursorIsArrow) {
-				CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
-				_cursorIsArrow = false;
+			if (_cursorType != kMacCursorBeam) {
+				_tempType = _cursorType;
+				replaceCursor(kMacCursorBeam);
 			}
 		} else {
-			if (_cursorIsArrow == false) {
-				CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
-				_cursorIsArrow = true;
-			}
+			if (_cursorType == kMacCursorBeam)
+				replaceCursor(_tempType, _cursor);
 		}
 	}
 
@@ -647,6 +645,77 @@ void MacWindowManager::pushWatchCursor() {
 	CursorMan.pushCursorPalette(cursorPalette, 0, 2);
 }
 
+void MacWindowManager::pushCursor(MacCursorType type, Cursor *cursor) {
+	if (_cursorType == kMacCursorOff && _cursorType != type)
+		CursorMan.showMouse(true);
+
+	switch (type) {
+	case kMacCursorOff:
+		CursorMan.showMouse(false);
+		break;
+	case kMacCursorArrow:
+		pushArrowCursor();
+		break;
+	case kMacCursorBeam:
+		pushBeamCursor();
+		break;
+	case kMacCursorCrossHair:
+		pushCrossHairCursor();
+		break;
+	case kMacCursorCrossBar:
+		pushCrossBarCursor();
+		break;
+	case kMacCursorWatch:
+		pushWatchCursor();
+		break;
+	case kMacCursorCustom:
+		if (!cursor) {
+			warning("MacWindowManager::pushCursor(): Custom cursor signified but not provided");
+			return;
+		}
+
+		pushCustomCursor(cursor);
+	}
+
+	_cursorType = type;
+}
+
+void MacWindowManager::replaceCursor(MacCursorType type, Cursor *cursor) {
+	if (_cursorType == kMacCursorOff && _cursorType != type)
+		CursorMan.showMouse(true);
+
+	switch (type) {
+	case kMacCursorOff:
+		CursorMan.showMouse(false);
+		break;
+	case kMacCursorArrow:
+		CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+		break;
+	case kMacCursorBeam:
+		CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
+		break;
+	case kMacCursorCrossHair:
+		CursorMan.replaceCursor(macCursorCrossHair, 11, 16, 1, 1, 3);
+		break;
+	case kMacCursorCrossBar:
+		CursorMan.replaceCursor(macCursorCrossBar, 11, 16, 1, 1, 3);
+		break;
+	case kMacCursorWatch:
+		CursorMan.replaceCursor(macCursorWatch, 11, 16, 1, 1, 3);
+		break;
+	case kMacCursorCustom:
+		if (!cursor) {
+			warning("MacWindowManager::replaceCursor(): Custom cursor signified but not provided");
+			return;
+		}
+
+		CursorMan.replaceCursor(cursor);
+		break;
+	}
+
+	_cursorType = 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);
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 8846b019d9..075221255c 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -58,6 +58,16 @@ enum {
 	kPatternDarkGray = 6
 };
 
+enum MacCursorType {
+ kMacCursorArrow,
+ kMacCursorBeam,
+ kMacCursorCrossHair,
+ kMacCursorCrossBar,
+ kMacCursorWatch,
+ kMacCursorCustom,
+ kMacCursorOff
+};
+
 enum {
 	kWMModeNone         	= 0,
 	kWMModeNoDesktop    	= (1 << 0),
@@ -77,6 +87,7 @@ class Cursor;
 
 class ManagedSurface;
 
+class MacCursor;
 class MacMenu;
 class MacTextWindow;
 class MacWidget;
@@ -241,11 +252,15 @@ public:
 
 	MacWidget *getActiveWidget() { return _activeWidget; }
 
+	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();
@@ -317,7 +332,9 @@ private:
 	void *_engineR;
 	void (*_redrawEngineCallback)(void *engine);
 
-	bool _cursorIsArrow;
+	MacCursorType _tempType;
+	MacCursorType _cursorType;
+	Cursor *_cursor;
 
 	MacWidget *_activeWidget;
 


Commit: 4f15cb4af404e270dbfd01d6e539327a38bc9f54
    https://github.com/scummvm/scummvm/commit/4f15cb4af404e270dbfd01d6e539327a38bc9f54
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-18T00:37:57-04:00

Commit Message:
DIRECTOR: Introduce Cursor class

Changed paths:
  A engines/director/cursor.cpp
  A engines/director/cursor.h
    engines/director/lingo/lingo-funcs.cpp
    engines/director/lingo/lingo.cpp
    engines/director/lingo/lingo.h
    engines/director/module.mk


diff --git a/engines/director/cursor.cpp b/engines/director/cursor.cpp
new file mode 100644
index 0000000000..9ae302bd90
--- /dev/null
+++ b/engines/director/cursor.cpp
@@ -0,0 +1,137 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "director/director.h"
+#include "director/cursor.h"
+#include "director/movie.h"
+#include "director/castmember.h"
+
+namespace Director {
+
+Cursor::Cursor() {
+	_cursorResId = 0;
+	_cursorType = Graphics::kMacCursorArrow;
+
+	_cursorCastId = 0;
+	_cursorMaskId = 0;
+}
+
+bool Cursor::operator==(const Cursor &c) {
+	return _cursorType == c._cursorType &&
+		_cursorResId == c._cursorResId &&
+		_cursorCastId == c._cursorCastId &&
+		_cursorMaskId == c._cursorMaskId;
+}
+
+void Cursor::readFromCast(uint cursorId, uint maskId) {
+	if (cursorId == _cursorCastId && maskId == _cursorMaskId)
+		return;
+
+	CastMember *cursorCast = g_director->getCurrentMovie()->getCastMember(cursorId);
+	CastMember *maskCast = g_director->getCurrentMovie()->getCastMember(maskId);
+
+	if (!cursorCast || !cursorCast->_widget || cursorCast->_type != kCastBitmap) {
+		warning("Cursor::readFromCast: No bitmap cast for cursor");
+		return;
+	} else if (!maskCast || !maskCast->_widget || maskCast->_type != kCastBitmap) {
+		warning("Cursor::readFromCast: No bitmap mask for cursor");
+		return;
+	}
+
+	_cursorType = Graphics::kMacCursorCustom;
+	_cursorResId = 0;
+	_cursorCastId = cursorId;
+	_cursorMaskId = maskId;
+
+	clear();
+	_surface = new byte[getWidth() * getHeight()];
+	byte *dst = _surface;
+
+	for (int y = 0; y < 16; y++) {
+		const byte *cursor = nullptr, *mask = nullptr;
+
+		if (y < cursorCast->_widget->getSurface()->h &&
+				y < maskCast->_widget->getSurface()->h) {
+			cursor = (const byte *)cursorCast->_widget->getSurface()->getBasePtr(0, y);
+			mask = (const byte *)maskCast->_widget->getSurface()->getBasePtr(0, y);
+		}
+
+		for (int x = 0; x < 16; x++) {
+			if (x >= cursorCast->_widget->getSurface()->w ||
+					x >= maskCast->_widget->getSurface()->w) {
+				cursor = mask = nullptr;
+			}
+
+			if (!cursor) {
+				*dst = 3;
+			} else {
+				*dst = *mask ? 3 : (*cursor ? 1 : 0);
+				cursor++;
+				mask++;
+			}
+			dst++;
+		}
+	}
+
+	BitmapCastMember *bc = (BitmapCastMember *)(cursorCast);
+	_hotspotX = bc->_initialRect.left - bc->_regX;
+	_hotspotY = bc->_initialRect.top - bc->_regY;
+}
+
+void Cursor::readFromResource(int resourceId) {
+	if (resourceId == _cursorResId)
+		return;
+
+	clear();
+
+	_cursorCastId = 0;
+	_cursorMaskId = 0;
+
+	_cursorResId = resourceId;
+
+	switch(resourceId) {
+	case -1:
+		_cursorType = Graphics::kMacCursorArrow;
+		break;
+	case 1:
+		_cursorType = Graphics::kMacCursorBeam;
+		break;
+	case 2:
+		_cursorType = Graphics::kMacCursorCrossHair;
+		break;
+	case 3:
+		_cursorType = Graphics::kMacCursorCrossBar;
+		break;
+	case 4:
+		_cursorType = Graphics::kMacCursorWatch;
+		break;
+	case 200:
+		_cursorType = Graphics::kMacCursorOff;
+		break;
+	default:
+		_cursorType = Graphics::kMacCursorCustom;
+
+		// TODO: Load custom cursors from resource
+	}
+
+}
+
+} // end of namespace Director
diff --git a/engines/director/cursor.h b/engines/director/cursor.h
new file mode 100644
index 0000000000..259413c4d7
--- /dev/null
+++ b/engines/director/cursor.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef DIRECTOR_CURSOR_H
+#define DIRECTOR_CURSOR_H
+
+#include "graphics/maccursor.h"
+
+#include "graphics/macgui/macwindowmanager.h"
+
+namespace Graphics {
+class ManagedSurface;
+class MacCursor;
+}
+
+namespace Director {
+
+class Cursor : public Graphics::MacCursor {
+ public:
+	Cursor();
+
+	void readFromCast(uint cursorId, uint maskId);
+	void readFromResource(int resourceId);
+
+	bool isEmpty() { return !(_cursorResId || _cursorCastId); }
+	bool operator==(const Cursor &c);
+
+ public:
+	Graphics::MacCursorType _cursorType;
+	int _cursorResId;
+
+	uint _cursorCastId;
+	uint _cursorMaskId;
+};
+
+} // end of namespace Director
+
+#endif
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp
index a77455094a..67df00d695 100644
--- a/engines/director/lingo/lingo-funcs.cpp
+++ b/engines/director/lingo/lingo-funcs.cpp
@@ -30,6 +30,7 @@
 
 #include "director/director.h"
 #include "director/castmember.h"
+#include "director/cursor.h"
 #include "director/movie.h"
 #include "director/score.h"
 #include "director/sound.h"
@@ -302,83 +303,16 @@ void Lingo::func_play(Datum &frame, Datum &movie) {
 }
 
 void Lingo::func_cursor(int cursorId, int maskId) {
-	if (_cursorOnStack) {
-		// pop cursor
-		_vm->getMacWindowManager()->popCursor();
-	}
-
-	if (maskId != -1) {
-		CastMember *cursorCast = _vm->getCurrentMovie()->getCastMember(cursorId);
-		CastMember *maskCast = _vm->getCurrentMovie()->getCastMember(maskId);
-		if (!cursorCast || !maskCast) {
-			warning("func_cursor(): non-existent cast reference");
-			return;
-		}
-
-		if (cursorCast->_type != kCastBitmap || maskCast->_type != kCastBitmap) {
-			warning("func_cursor(): wrong cast reference type");
-			return;
-		}
-
-		byte *assembly = (byte *)malloc(16 * 16);
-		byte *dst = assembly;
-
-		for (int y = 0; y < 16; y++) {
-			const byte *cursor = nullptr, *mask = nullptr;
-
-			if (y < cursorCast->_widget->getSurface()->h &&
-					y < maskCast->_widget->getSurface()->h) {
-				cursor = (const byte *)cursorCast->_widget->getSurface()->getBasePtr(0, y);
-				mask = (const byte *)maskCast->_widget->getSurface()->getBasePtr(0, y);
-			}
-
-			for (int x = 0; x < 16; x++) {
-				if (x >= cursorCast->_widget->getSurface()->w ||
-						x >= maskCast->_widget->getSurface()->w) {
-					cursor = mask = nullptr;
-				}
-
-				if (!cursor) {
-					*dst = 3;
-				} else {
-					*dst = *mask ? 3 : (*cursor ? 1 : 0);
-					cursor++;
-					mask++;
-				}
-				dst++;
-			}
-		}
-
-		warning("STUB: func_cursor(): Hotspot is the registration point of the cast member");
-		_vm->getMacWindowManager()->pushCustomCursor(assembly, 16, 16, 1, 1, 3);
-
-		free(assembly);
-
-		return;
-	}
+	Cursor cursor;
 
-	// and then push cursor.
-	switch (cursorId) {
-	case 0:
-	case -1:
-	default:
-		_vm->getMacWindowManager()->pushArrowCursor();
-		break;
-	case 1:
-		_vm->getMacWindowManager()->pushBeamCursor();
-		break;
-	case 2:
-		_vm->getMacWindowManager()->pushCrossHairCursor();
-		break;
-	case 3:
-		_vm->getMacWindowManager()->pushCrossBarCursor();
-		break;
-	case 4:
-		_vm->getMacWindowManager()->pushWatchCursor();
-		break;
+	if (maskId == -1) {
+		cursor.readFromResource(cursorId);
+	} else {
+		cursor.readFromCast(cursorId, maskId);
 	}
 
-	_cursorOnStack = true;
+	// TODO: Figure out why there are artifacts here
+	_vm->_wm->replaceCursor(cursor._cursorType, ((Graphics::Cursor *)&cursor));
 }
 
 void Lingo::func_beep(int repeats) {
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 1923dc5f32..9418bc4ac4 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -168,8 +168,6 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {
 	_floatPrecision = 4;
 	_floatPrecisionFormat = "%.4f";
 
-	_cursorOnStack = false;
-
 	_localvars = NULL;
 
 	// events
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index f128dbc87b..1a9cb8f410 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -422,8 +422,6 @@ public:
 
 	bool _inCond;
 
-	bool _cursorOnStack;
-
 private:
 	int parse(const char *code);
 	void parseMenu(const char *code);
diff --git a/engines/director/module.mk b/engines/director/module.mk
index 2cc1df1a28..3d78ec2cb0 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS = \
 	cast.o \
 	castmember.o \
 	channel.o \
+	cursor.o \
 	detection.o \
 	director.o \
 	events.o \


Commit: 5fb984e99fefb8c2fae5afa0d5aff580c3678292
    https://github.com/scummvm/scummvm/commit/5fb984e99fefb8c2fae5afa0d5aff580c3678292
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-18T00:37:57-04:00

Commit Message:
DIRECTOR: Mostly implement cursor of sprite

Changed paths:
    engines/director/channel.cpp
    engines/director/channel.h
    engines/director/events.cpp
    engines/director/lingo/lingo-builtins.cpp
    engines/director/lingo/lingo-code.cpp
    engines/director/lingo/lingo-the.cpp
    engines/director/score.cpp
    engines/director/score.h
    engines/director/stage.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index 2f7dbdafe5..bd91dd9329 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -23,6 +23,7 @@
 #include "director/director.h"
 #include "director/movie.h"
 #include "director/score.h"
+#include "director/cursor.h"
 #include "director/channel.h"
 #include "director/sprite.h"
 #include "director/castmember.h"
diff --git a/engines/director/channel.h b/engines/director/channel.h
index 48f832e54c..5e6bfa8de7 100644
--- a/engines/director/channel.h
+++ b/engines/director/channel.h
@@ -31,6 +31,7 @@ namespace Graphics {
 namespace Director {
 
 class Sprite;
+class Cursor;
 
 class Channel {
 public:
@@ -53,6 +54,7 @@ public:
 
 public:
 	Sprite *_sprite;
+	Cursor _cursor;
 
 	bool _dirty;
 	bool _visible;
diff --git a/engines/director/events.cpp b/engines/director/events.cpp
index 7eebd66ae8..fd148c9f66 100644
--- a/engines/director/events.cpp
+++ b/engines/director/events.cpp
@@ -27,6 +27,7 @@
 #include "director/director.h"
 #include "director/movie.h"
 #include "director/score.h"
+#include "director/cursor.h"
 #include "director/channel.h"
 #include "director/sprite.h"
 #include "director/stage.h"
@@ -81,9 +82,13 @@ void DirectorEngine::processEvents(bool bufferLingoEvents) {
 				break;
 
 			case Common::EVENT_MOUSEMOVE:
+				pos = _currentStage->getMousePos();
+
 				m->_lastEventTime = g_director->getMacTicks();
 				m->_lastRollTime =	 m->_lastEventTime;
 
+				sc->renderCursor(sc->getSpriteIDFromPos(pos));
+
 				if (_currentDraggedChannel) {
 					if (_currentDraggedChannel->_sprite->_moveable) {
 						pos = getCurrentStage()->getMousePos();
@@ -147,6 +152,7 @@ void DirectorEngine::processEvents(bool bufferLingoEvents) {
 				}
 
 				_lingo->registerEvent(kEventMouseUp, spriteId);
+				sc->renderCursor(sc->getSpriteIDFromPos(pos));
 				m->_currentMouseDownSpriteId = 0;
 				break;
 
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 57789e6fe6..88643d972b 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -33,6 +33,7 @@
 #include "director/score.h"
 #include "director/sound.h"
 #include "director/sprite.h"
+#include "director/cursor.h"
 #include "director/channel.h"
 #include "director/stage.h"
 #include "director/stxt.h"
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index e94d2c5a9d..13720aed1a 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -46,6 +46,7 @@
 #include "director/director.h"
 #include "director/movie.h"
 #include "director/score.h"
+#include "director/cursor.h"
 #include "director/channel.h"
 #include "director/util.h"
 #include "director/lingo/lingo.h"
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index e7febe6895..40f6e551ee 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -25,6 +25,7 @@
 #include "director/director.h"
 #include "director/cast.h"
 #include "director/castmember.h"
+#include "director/cursor.h"
 #include "director/channel.h"
 #include "director/movie.h"
 #include "director/sound.h"
@@ -1060,7 +1061,15 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
 		d.u.i = channel->_constraint;
 		break;
 	case kTheCursor:
-		warning("STUB: Lingo::getTheSprite(): Unprocessed getting field \"%s\" of sprite", field2str(field));
+		if (channel->_cursor._cursorResId) {
+			d.u.i = channel->_cursor._cursorResId;
+		} else {
+			d.type = ARRAY;
+			d.u.farr = new DatumArray(2);
+
+			d.u.farr->operator[](0) = (int)channel->_cursor._cursorCastId;
+			d.u.farr->operator[](1) = (int)channel->_cursor._cursorMaskId;
+		}
 		break;
 	case kTheEditableText:
 		d.u.i = sprite->_cast ? sprite->_cast->isEditable() : 0;
@@ -1217,7 +1226,11 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
 		channel->_constraint = d.u.i;
 		break;
 	case kTheCursor:
-		warning("STUB: Lingo::setTheSprite(): Unprocessed setting field \"%s\" of sprite", field2str(field));
+		if (d.type == INT) {
+			channel->_cursor.readFromResource(d.asInt());
+		} else if (d.type == ARRAY && d.u.farr->size() == 2) {
+			channel->_cursor.readFromCast(d.u.farr->operator[](0).asInt(), d.u.farr->operator[](1).asInt());
+		}
 		break;
 	case kTheEditableText:
 		sprite->_cast ? sprite->_cast->setEditable(d.asInt()) : false;
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index f5d2b6ebdf..e9f5c82837 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -38,6 +38,7 @@
 #include "director/frame.h"
 #include "director/movie.h"
 #include "director/sound.h"
+#include "director/cursor.h"
 #include "director/channel.h"
 #include "director/sprite.h"
 #include "director/stage.h"
@@ -56,6 +57,7 @@ Score::Score(Movie *movie) {
 	_puppetTempo = 0x00;
 
 	_labels = nullptr;
+	_currentCursor = nullptr;
 
 	_currentFrameRate = 20;
 	_currentFrame = 0;
@@ -421,6 +423,25 @@ void Score::renderSprites(uint16 frameId, RenderMode mode) {
 	}
 }
 
+void Score::renderCursor(uint spriteId) {
+	if (_channels[spriteId]->_cursor.isEmpty()) {
+		if (_currentCursor) {
+			_vm->_wm->popCursor();
+			_currentCursor = nullptr;
+		}
+	} else {
+		if (_currentCursor) {
+			if (*_currentCursor == _channels[spriteId]->_cursor)
+				return;
+
+			_vm->_wm->popCursor();
+		}
+
+		_currentCursor = &_channels[spriteId]->_cursor;
+		_vm->_wm->pushCursor(_currentCursor->_cursorType, ((Graphics::Cursor *)_currentCursor));
+	}
+}
+
 void Score::screenShot() {
 	Graphics::Surface rawSurface = _stage->getSurface()->rawSurface();
 	const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 0, 8, 16, 24);
diff --git a/engines/director/score.h b/engines/director/score.h
index b8d872e94b..3faa0189de 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -48,6 +48,7 @@ class Frame;
 struct Label;
 class Movie;
 struct Resource;
+class Cursor;
 class Channel;
 class Sprite;
 class CastMember;
@@ -94,6 +95,7 @@ public:
 	bool renderTransition(uint16 frameId);
 	void renderFrame(uint16 frameId, RenderMode mode = kRenderModeNormal);
 	void renderSprites(uint16 frameId, RenderMode mode = kRenderModeNormal);
+	void renderCursor(uint spriteId);
 
 private:
 	void update();
@@ -116,6 +118,7 @@ public:
 	byte _puppetTempo;
 	PlayState _playState;
 	uint32 _nextFrameTime;
+	Cursor *_currentCursor;
 
 	int _numChannelsDisplayed;
 
diff --git a/engines/director/stage.cpp b/engines/director/stage.cpp
index 37ba1dcbde..dd22d56ae1 100644
--- a/engines/director/stage.cpp
+++ b/engines/director/stage.cpp
@@ -34,6 +34,7 @@
 #include "director/stage.h"
 #include "director/score.h"
 #include "director/castmember.h"
+#include "director/cursor.h"
 #include "director/channel.h"
 #include "director/sprite.h"
 #include "director/util.h"




More information about the Scummvm-git-logs mailing list