[Scummvm-cvs-logs] CVS: scummvm/scumm scumm.h,1.256,1.257 verbs.cpp,1.56,1.57

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Tue Jun 17 00:13:30 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv11920

Modified Files:
	scumm.h verbs.cpp 
Log Message:
Make the mouse-over hilight work again on the inventory arrows in V2 games.


Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.256
retrieving revision 1.257
diff -u -d -r1.256 -r1.257
--- scumm.h	15 Jun 2003 01:42:15 -0000	1.256
+++ scumm.h	17 Jun 2003 07:11:58 -0000	1.257
@@ -146,6 +146,12 @@
 	byte text[256];
 };
 
+struct V2MouseoverBox {
+	ScummVM::Rect rect;
+	byte color;
+	byte hicolor;
+};
+
 enum ResTypes {
 	rtFirst = 1,
 	rtRoom = 1,
@@ -743,7 +749,7 @@
 
 
 	// TODO: This should be moved into Scumm_v2 if possible
-	ScummVM::Rect v2_mouseover_boxes[7];
+	V2MouseoverBox v2_mouseover_boxes[7];
 	int8 v2_mouseover_box;
 
 	void initV2MouseOver();

Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/verbs.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- verbs.cpp	16 Jun 2003 11:52:04 -0000	1.56
+++ verbs.cpp	17 Jun 2003 07:11:58 -0000	1.57
@@ -39,36 +39,53 @@
 	v2_mouseover_box = -1;
 
 	// Inventory items
+
 	for (i = 0; i < 2; i++) {
-		v2_mouseover_boxes[2 * i].left = 0;
-		v2_mouseover_boxes[2 * i].right = 144;
-		v2_mouseover_boxes[2 * i].top = 34 + 8 * i;
-		v2_mouseover_boxes[2 * i].bottom = v2_mouseover_boxes[2 * i].top + 8;
+		v2_mouseover_boxes[2 * i].rect.left = 0;
+		v2_mouseover_boxes[2 * i].rect.right = 144;
+		v2_mouseover_boxes[2 * i].rect.top = 34 + 8 * i;
+		v2_mouseover_boxes[2 * i].rect.bottom = v2_mouseover_boxes[2 * i].rect.top + 8;
 
-		v2_mouseover_boxes[2 * i + 1].left = 176;
-		v2_mouseover_boxes[2 * i + 1].right = 320;
-		v2_mouseover_boxes[2 * i + 1].top = v2_mouseover_boxes[2 * i].top;
-		v2_mouseover_boxes[2 * i + 1].bottom = v2_mouseover_boxes[2 * i].bottom;
+		v2_mouseover_boxes[2 * i].color = 5;
+		v2_mouseover_boxes[2 * i].hicolor = 14;
+
+
+		v2_mouseover_boxes[2 * i + 1].rect.left = 176;
+		v2_mouseover_boxes[2 * i + 1].rect.right = 320;
+		v2_mouseover_boxes[2 * i + 1].rect.top = v2_mouseover_boxes[2 * i].rect.top;
+		v2_mouseover_boxes[2 * i + 1].rect.bottom = v2_mouseover_boxes[2 * i].rect.bottom;
+
+		v2_mouseover_boxes[2 * i + 1].color = 5;
+		v2_mouseover_boxes[2 * i + 1].hicolor = 14;
 	}
 
 	// Inventory arrows
 
-	v2_mouseover_boxes[kInventoryUpArrow].left = 144;
-	v2_mouseover_boxes[kInventoryUpArrow].right = 176;
-	v2_mouseover_boxes[kInventoryUpArrow].top = 34;
-	v2_mouseover_boxes[kInventoryUpArrow].bottom = 40;
+	v2_mouseover_boxes[kInventoryUpArrow].rect.left = 144;
+	v2_mouseover_boxes[kInventoryUpArrow].rect.right = 176;
+	v2_mouseover_boxes[kInventoryUpArrow].rect.top = 34;
+	v2_mouseover_boxes[kInventoryUpArrow].rect.bottom = 42;
 
-	v2_mouseover_boxes[kInventoryDownArrow].left = 144;
-	v2_mouseover_boxes[kInventoryDownArrow].right = 176;
-	v2_mouseover_boxes[kInventoryDownArrow].top = 42;
-	v2_mouseover_boxes[kInventoryDownArrow].bottom = 50;
+	v2_mouseover_boxes[kInventoryUpArrow].color = 1;
+	v2_mouseover_boxes[kInventoryUpArrow].hicolor = 14;
+
+	v2_mouseover_boxes[kInventoryDownArrow].rect.left = 144;
+	v2_mouseover_boxes[kInventoryDownArrow].rect.right = 176;
+	v2_mouseover_boxes[kInventoryDownArrow].rect.top = 42;
+	v2_mouseover_boxes[kInventoryDownArrow].rect.bottom = 50;
+
+	v2_mouseover_boxes[kInventoryDownArrow].color = 1;
+	v2_mouseover_boxes[kInventoryDownArrow].hicolor = 14;
 
 	// Sentence line
 
-	v2_mouseover_boxes[kSentenceLine].left = 0;
-	v2_mouseover_boxes[kSentenceLine].right = 320;
-	v2_mouseover_boxes[kSentenceLine].top = 0;
-	v2_mouseover_boxes[kSentenceLine].bottom = 8;
+	v2_mouseover_boxes[kSentenceLine].rect.left = 0;
+	v2_mouseover_boxes[kSentenceLine].rect.right = 320;
+	v2_mouseover_boxes[kSentenceLine].rect.top = 0;
+	v2_mouseover_boxes[kSentenceLine].rect.bottom = 8;
+
+	v2_mouseover_boxes[kSentenceLine].color = 5;
+	v2_mouseover_boxes[kSentenceLine].hicolor = 14;
 }
 
 void Scumm::checkV2MouseOver(ScummVM::Point pos) {
@@ -85,7 +102,7 @@
 
 	if (_cursor.state > 0) {
 		for (i = 0; i < ARRAYSIZE(v2_mouseover_boxes); i++) {
-			if (v2_mouseover_boxes[i].contains(pos.x, pos.y - vs->topline)) {
+			if (v2_mouseover_boxes[i].rect.contains(pos.x, pos.y - vs->topline)) {
 				new_box = i;
 				break;
 			}
@@ -94,15 +111,15 @@
 
 	if (new_box != v2_mouseover_box) {
 		if (v2_mouseover_box != -1) {
-			rect = v2_mouseover_boxes[v2_mouseover_box];
+			rect = v2_mouseover_boxes[v2_mouseover_box].rect;
 
 			dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left;
 
-			// Hackish way to undo highlight: replace color 14 with color 5
+			// Remove highlight.
 			for (y = rect.height() - 1; y >= 0; y--) {
 				for (x = rect.width() - 1; x >= 0; x--) {
-					if (dst[x] == 14)
-						dst[x] = 5;
+					if (dst[x] == v2_mouseover_boxes[v2_mouseover_box].hicolor)
+						dst[x] = v2_mouseover_boxes[v2_mouseover_box].color;
 				}
 				dst += _screenWidth;
 			}
@@ -111,15 +128,15 @@
 		}
 
 		if (new_box != -1) {
-			rect = v2_mouseover_boxes[new_box];
+			rect = v2_mouseover_boxes[new_box].rect;
 
 			dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left;
 
-			// Hackish way to apply highlight: replace color 5 with color 14
+			// Apply highlight
 			for (y = rect.height() - 1; y >= 0; y--) {
 				for (x = rect.width() - 1; x >= 0; x--) {
-					if (dst[x] == 5)
-						dst[x] = 14;
+					if (dst[x] == v2_mouseover_boxes[new_box].color)
+						dst[x] = v2_mouseover_boxes[new_box].hicolor;
 				}
 				dst += _screenWidth;
 			}
@@ -139,12 +156,12 @@
 	if ((y < 34) || !(_mouseButStat & MBS_LEFT_CLICK)) 
 		return;
 
-	if (v2_mouseover_boxes[kInventoryUpArrow].contains(x, y)) {
+	if (v2_mouseover_boxes[kInventoryUpArrow].rect.contains(x, y)) {
 		_inventoryOffset -= 2;
 		if (_inventoryOffset < 0)
 			_inventoryOffset = 0;
 		redrawV2Inventory();
- 	} else if (v2_mouseover_boxes[kInventoryDownArrow].contains(x, y)) {
+ 	} else if (v2_mouseover_boxes[kInventoryDownArrow].rect.contains(x, y)) {
 		_inventoryOffset += 2;
 		if (_inventoryOffset > (getInventoryCount(_scummVars[VAR_EGO])-2))
 			_inventoryOffset = (getInventoryCount(_scummVars[VAR_EGO])-2);
@@ -152,7 +169,7 @@
 	}
 
 	for (object = 0; object < 4; object++) {
-		if (v2_mouseover_boxes[object].contains(x, y)) {
+		if (v2_mouseover_boxes[object].rect.contains(x, y)) {
 			break;
 		}
 	}
@@ -184,7 +201,6 @@
 		return;
 
 	_string[1].charset = 1;
-	_string[1].color = 5;
 
 	max_inv = getInventoryCount(_scummVars[VAR_EGO]) - _inventoryOffset;
 	if (max_inv > 4)
@@ -194,9 +210,10 @@
 		if (obj == 0)
 			break;
 		
-		_string[1].ypos = v2_mouseover_boxes[i].top + virtscr[2].topline;
-		_string[1].xpos = v2_mouseover_boxes[i].left;
+		_string[1].ypos = v2_mouseover_boxes[i].rect.top + virtscr[2].topline;
+		_string[1].xpos = v2_mouseover_boxes[i].rect.left;
 
+		_string[1].color = v2_mouseover_boxes[i].color;
 		_messagePtr = getObjOrActorName(obj);
 		assert(_messagePtr);
 
@@ -214,18 +231,18 @@
 
 	// If necessary, draw "up" arrow
 	if (_inventoryOffset > 0) {
-		_string[1].xpos = v2_mouseover_boxes[kInventoryUpArrow].left;
-		_string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].top + virtscr[2].topline;
-	        _string[1].color = 1;
+		_string[1].xpos = v2_mouseover_boxes[kInventoryUpArrow].rect.left;
+		_string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].rect.top + virtscr[2].topline;
+	        _string[1].color = v2_mouseover_boxes[kInventoryUpArrow].color;
 		_messagePtr = (const byte *)" \1\2";
 		drawString(1);
 	}
 
 	// If necessary, draw "down" arrow
 	if (_inventoryOffset + 4 < getInventoryCount(_scummVars[VAR_EGO])) {
-		_string[1].xpos = v2_mouseover_boxes[kInventoryDownArrow].left;
-		_string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].top + virtscr[2].topline;
-	        _string[1].color = 1;
+		_string[1].xpos = v2_mouseover_boxes[kInventoryDownArrow].rect.left;
+		_string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].rect.top + virtscr[2].topline;
+	        _string[1].color = v2_mouseover_boxes[kInventoryDownArrow].color;
 		_messagePtr = (const byte *)" \3\4";
 		drawString(1);
 	}





More information about the Scummvm-git-logs mailing list