[Scummvm-cvs-logs] CVS: scummvm/sword2 mouse.cpp,1.69,1.70 mouse.h,1.18,1.19

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Mon Feb 28 06:05:06 CET 2005


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

Modified Files:
	mouse.cpp mouse.h 
Log Message:
And, finally, the change I meant to before I got side-tracked: Use
ScummVM's "Rect" data type in the mouse list. The benefit of this is that
we can then use the contains() function in checkMouseList(), which makes
the code a bit less eye-watering.


Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- mouse.cpp	28 Feb 2005 13:28:02 -0000	1.69
+++ mouse.cpp	28 Feb 2005 14:03:52 -0000	1.70
@@ -132,20 +132,27 @@
 	assert(_curMouse < TOTAL_mouse_list);
 
 	if (build_unit) {
-		_mouseList[_curMouse].x1 = build_unit->x;
-		_mouseList[_curMouse].y1 = build_unit->y;
-		_mouseList[_curMouse].x2 = build_unit->x + build_unit->scaled_width;
-		_mouseList[_curMouse].y2 = build_unit->y + build_unit->scaled_height;
+		_mouseList[_curMouse].rect.left = build_unit->x;
+		_mouseList[_curMouse].rect.top = build_unit->y;
+		_mouseList[_curMouse].rect.right = 1 + build_unit->x + build_unit->scaled_width;
+		_mouseList[_curMouse].rect.bottom = 1 + build_unit->y + build_unit->scaled_height;
 	} else {
-		_mouseList[_curMouse].x1 = ob_mouse->x1;
-		_mouseList[_curMouse].y1 = ob_mouse->y1;
-		_mouseList[_curMouse].x2 = ob_mouse->x2;
-		_mouseList[_curMouse].y2 = ob_mouse->y2;
+		_mouseList[_curMouse].rect.left = ob_mouse->x1;
+		_mouseList[_curMouse].rect.top = ob_mouse->y1;
+		_mouseList[_curMouse].rect.right = 1 + ob_mouse->x2;
+		_mouseList[_curMouse].rect.bottom = 1 + ob_mouse->y2;
 	}
 
 	_mouseList[_curMouse].priority = ob_mouse->priority;
 	_mouseList[_curMouse].pointer = ob_mouse->pointer;
 
+	// Change all COGS pointers to CROSHAIR. I'm guessing that this was a
+	// design decision made in mid-development and they didn't want to go
+	// back and re-generate the resource files.
+
+	if (_mouseList[_curMouse].pointer == USE)
+		_mouseList[_curMouse].pointer = CROSHAIR;
+
 	// Check if pointer text field is set due to previous object using this
 	// slot (ie. not correct for this one)
 
@@ -158,11 +165,6 @@
 	// Get id from system variable 'id' which is correct for current object
 	_mouseList[_curMouse].id = Logic::_scriptVars[ID];
 
-	// Not using sprite as detection mask - this is only done from
-	// fnRegisterFrame()
-	_mouseList[_curMouse].anim_resource = 0;
-	_mouseList[_curMouse].anim_pc = 0;
-
 	_curMouse++;
 }
 
@@ -966,24 +968,18 @@
 uint32 Mouse::checkMouseList() {
 	ScreenInfo *screenInfo = _vm->_screen->getScreenInfo();
 
+	Common::Point mousePos(_pos.x + screenInfo->scroll_offset_x, _pos.y + screenInfo->scroll_offset_y);
+
 	// Number of priorities subject to implementation needs
 	for (int priority = 0; priority < 10; priority++) {
 		for (uint i = 0; i < _curMouse; i++) {
 			// If the mouse pointer is over this
 			// mouse-detection-box
 
-			if (_mouseList[i].priority == priority &&
-			    _pos.x + screenInfo->scroll_offset_x >= _mouseList[i].x1 &&
-			    _pos.x + screenInfo->scroll_offset_x <= _mouseList[i].x2 &&
-			    _pos.y + screenInfo->scroll_offset_y >= _mouseList[i].y1 &&
-			    _pos.y + screenInfo->scroll_offset_y <= _mouseList[i].y2) {
+			if (_mouseList[i].priority == priority && _mouseList[i].rect.contains(mousePos)) {
 				// Record id
 				_mouseTouching = _mouseList[i].id;
 
-				// Change all COGS pointers to CROSHAIR
-				if (_mouseList[i].pointer == USE)
-					_mouseList[i].pointer = CROSHAIR;
-
 				createPointerText(_mouseList[i].pointer_text, _mouseList[i].pointer);
 
 				// Return pointer type

Index: mouse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mouse.h	27 Feb 2005 16:11:17 -0000	1.18
+++ mouse.h	28 Feb 2005 14:03:53 -0000	1.19
@@ -85,31 +85,17 @@
 // sprite is to act as mouse detection mask)
 
 struct MouseUnit {
-	// Top-left and bottom-right of mouse area. These coords are inclusive
-	int32 x1;
-	int32 y1;
-	int32 x2;
-	int32 y2;
+	// Basically the same information as in ObjectMouse, except the
+	// coordinates are adjusted to conform to standard ScummVM usage.
 
+	Common::Rect rect;
 	int32 priority;
-
-	// type (or resource id?) of pointer used over this area
 	int32 pointer;
 
-	// up to here, this is basically a copy of the ObjectMouse
-	// structure, but then we have...
+	// In addition, we need an id when checking the mouse list, and a
+	// text id for mouse-overs.
 
-	// object id, used when checking mouse list
 	int32 id;
-
-	// resource id of animation file (if sprite to be used as mask) -
-	// otherwise 0
-	int32 anim_resource;
-
-	// current frame number of animation
-	int32 anim_pc;
-
-	// local id of text line to print when pointer highlights an object
 	int32 pointer_text;
 };
 





More information about the Scummvm-git-logs mailing list