[Scummvm-cvs-logs] CVS: scummvm/saga gfx.cpp,1.65,1.66 gfx.h,1.40,1.41

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Sun Oct 9 12:11:54 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27958

Modified Files:
	gfx.cpp gfx.h 
Log Message:
Added optional parameter to setCursor() to specify which type of cursor you
want. ITE has only one cursor, so in that case the parameter is ignored, 
and IHNM currently always gets the hourglass cursor. So it could be
improved. Lots. :-)


Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- gfx.cpp	5 Oct 2005 02:01:52 -0000	1.65
+++ gfx.cpp	9 Oct 2005 19:10:58 -0000	1.66
@@ -396,22 +396,57 @@
 	g_system->showMouse(state);
 }
 
-void Gfx::setCursor() {
-	// Set up the mouse cursor
-	const byte A = kITEColorLightGrey;
-	const byte B = kITEColorWhite;
+void Gfx::setCursor(CursorType cursorType) {
+	if (_vm->getGameType() == GType_ITE) {
+		// Set up the mouse cursor
+		const byte A = kITEColorLightGrey;
+		const byte B = kITEColorWhite;
 
-	const byte cursor_img[CURSOR_W * CURSOR_H] = {
-		0, 0, 0, A, 0, 0, 0,
-		0, 0, 0, A, 0, 0, 0,
-		0, 0, 0, A, 0, 0, 0,
-		A, A, A, B, A, A, A,
-		0, 0, 0, A, 0, 0, 0,
-		0, 0, 0, A, 0, 0, 0,
-		0, 0, 0, A, 0, 0, 0,
-	};
+		const byte cursor_img[CURSOR_W * CURSOR_H] = {
+			0, 0, 0, A, 0, 0, 0,
+			0, 0, 0, A, 0, 0, 0,
+			0, 0, 0, A, 0, 0, 0,
+			A, A, A, B, A, A, A,
+			0, 0, 0, A, 0, 0, 0,
+			0, 0, 0, A, 0, 0, 0,
+			0, 0, 0, A, 0, 0, 0,
+		};
 
-	_system->setMouseCursor(cursor_img, CURSOR_W, CURSOR_H, 3, 3, 0);
+		_system->setMouseCursor(cursor_img, CURSOR_W, CURSOR_H, 3, 3, 0);
+	} else {
+		uint32 resourceId;
+
+		switch (cursorType) {
+		case kCursorBusy:
+			resourceId = RID_IHNM_HOURGLASS_CURSOR;
+			break;
+		default:
+			// Assume normal cursor
+			// TODO: Find the correct resource for it
+			resourceId = RID_IHNM_HOURGLASS_CURSOR;
+			break;
+		}
+
+		ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE);
+
+		byte *resource;
+		size_t resourceLength;
+
+		_vm->_resource->loadResource(context, resourceId, resource, resourceLength);
+
+		byte *image;
+		size_t imageLength;
+		int width, height;
+
+		_vm->decodeBGImage(resource, resourceLength, &image, &imageLength, &width, &height);
+
+		// TODO: Hotspot?
+
+		_system->setMouseCursor(image, width, height, 0, 0, 0);
+
+		free(image);
+		free(resource);
+	}
 }
 
 bool hitTestPoly(const Point *points, unsigned int npoints, const Point& test_point) {

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- gfx.h	5 Oct 2005 01:40:55 -0000	1.40
+++ gfx.h	9 Oct 2005 19:10:59 -0000	1.41
@@ -33,6 +33,11 @@
 using Common::Point;
 using Common::Rect;
 
+enum CursorType {
+	kCursorNormal,
+	kCursorBusy
+};
+
 struct ClipData {
 	// input members
 	Rect sourceRect;
@@ -144,7 +149,7 @@
 	void showCursor(bool state);
 
 private:
-	void setCursor();
+	void setCursor(CursorType cursorType = kCursorNormal);
 	int _init;
 	Surface _backBuffer;
 	byte _currentPal[PAL_ENTRIES * 4];





More information about the Scummvm-git-logs mailing list