[Scummvm-cvs-logs] CVS: scummvm/sword1 logic.cpp,1.26,1.27 menu.cpp,1.11,1.12 mouse.cpp,1.13,1.14 mouse.h,1.8,1.9

Robert G?ffringmann lavosspawn at users.sourceforge.net
Tue Dec 30 13:33:09 CET 2003


Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1:/tmp/cvs-serv28695/sword1

Modified Files:
	logic.cpp menu.cpp mouse.cpp mouse.h 
Log Message:
implemented mouse luggage stuff

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/logic.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- logic.cpp	30 Dec 2003 16:19:30 -0000	1.26
+++ logic.cpp	30 Dec 2003 21:32:49 -0000	1.27
@@ -1049,7 +1049,6 @@
 		cdt = GEOSTDLCDT; // workaround for missing animation when examining
 		spr = GEOSTDL;    // the conductor on the train roof
 	}
-	_mouse->flushEvents(); // prevent player from accidently clicking text away within first three frames
 	cpt->o_logic = LOGIC_speech;
 
 	// first setup the talk animation
@@ -1348,7 +1347,6 @@
 		cpt->o_down_flag = 1; // 1 means okay.
 		// if both mouse buttons were pressed on an exit => skip george's walk
 		if ((id == GEORGE) && (_mouse->testEvent() == MOUSE_BOTH_BUTTONS)) {
-			_mouse->flushEvents();
 			int32 target = _scriptVars[CLICK_ID];
 			// exceptions: compacts that use hand pointers but are not actually exits
 			if ((target != LEFT_SCROLL_POINTER) && (target != RIGHT_SCROLL_POINTER) &&

Index: menu.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/menu.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- menu.cpp	28 Dec 2003 18:10:18 -0000	1.11
+++ menu.cpp	30 Dec 2003 21:32:50 -0000	1.12
@@ -127,9 +127,10 @@
 			if (_objects[cnt]->wasClicked(x, y))
 				if (mouseEvent & BS1L_BUTTON_DOWN) {
 					if (SwordLogic::_scriptVars[OBJECT_HELD]) {
-						if (SwordLogic::_scriptVars[OBJECT_HELD] == _menuList[cnt])
+						if (SwordLogic::_scriptVars[OBJECT_HELD] == _menuList[cnt]) {
+							_mouse->setLuggage(0, 0);
 							SwordLogic::_scriptVars[OBJECT_HELD] = 0; // reselected => deselect it
-						else { // the player is clicking another item on this one.
+						} else { // the player is clicking another item on this one.
 							   // run its use-script, if there is one
 							SwordLogic::_scriptVars[SECOND_ITEM] = _menuList[cnt];
 						}
@@ -138,8 +139,10 @@
 					refreshMenus = true;
 				} else if (mouseEvent & BS1L_BUTTON_UP) {
 					if (SwordLogic::_scriptVars[OBJECT_HELD] == _menuList[cnt]) {
+						_mouse->setLuggage(_objectDefs[_menuList[cnt]].luggageIconRes, 0);
 						return cnt + 1;
 					} else {
+						_mouse->setLuggage(0, 0);
 						SwordLogic::_scriptVars[OBJECT_HELD] = 0;
 						refreshMenus = true;
 					}

Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/mouse.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- mouse.cpp	28 Dec 2003 23:24:02 -0000	1.13
+++ mouse.cpp	30 Dec 2003 21:32:50 -0000	1.14
@@ -35,35 +35,35 @@
 	_resMan = pResMan;
 	_objMan = pObjMan;
 	_system = system;
+	_currentPtr = NULL;
 }
 
 void SwordMouse::initialize(void) {
 	_numObjs = 0;
 	SwordLogic::_scriptVars[MOUSE_STATUS] = 0; // mouse off and unlocked
 	_getOff = 0;
-	_specialPtrId = 0;
 	_inTopMenu = false;
 	_mouseOverride = false;
+	_currentPtrId = _currentLuggageId = 0;
 
-	for (uint8 cnt = 0; cnt < 17; cnt++)
-		_pointers[cnt] = (MousePtr*)_resMan->mouseResOpen(MSE_POINTER + cnt);
+	for (uint8 cnt = 0; cnt < 17; cnt++)	 // force res manager to keep mouse 
+		_resMan->resOpen(MSE_POINTER + cnt); // cursors in memory all the time
+	
+	createPointer(0, 0);
 }
 
 void SwordMouse::controlPanel(bool on) { // true on entering cpanel, false when leaving
-	static uint32 savedPtrId = 0, savedSpecialId = 0;
+	static uint32 savedPtrId = 0;
 	if (on) {
 		savedPtrId = _currentPtrId;
-		savedSpecialId = _specialPtrId;
 		_mouseOverride = true;
+		setLuggage(0, 0);
 		setPointer(MSE_POINTER, 0);
 	} else {
 		_currentPtrId = savedPtrId;
-		_specialPtrId = savedSpecialId;
 		_mouseOverride = false;
-		if (_specialPtrId)
-			setPointer(_specialPtrId, 0);
-		else
-			setPointer(_currentPtrId + MSE_POINTER, 0);
+		setLuggage(_currentLuggageId, 0);
+		setPointer(_currentPtrId, 0);
 	}
 }
 
@@ -78,10 +78,6 @@
 	_numObjs++;
 }
 
-void SwordMouse::flushEvents(void) {
-	_lastState = _state = 0;
-}
-
 void SwordMouse::engine(uint16 x, uint16 y, uint16 eventFlags) {
 	_state = 0; // all mouse events are flushed after one cycle.
 	if (_lastState) { // delay all events by one cycle to notice L_button + R_button clicks correctly.
@@ -100,13 +96,6 @@
 	_mouseX = x;
 	_mouseY = y;
 	if (!(SwordLogic::_scriptVars[MOUSE_STATUS] & 1)) {  // no human?
-		// if the mouse is turned off, I want the menu automatically removed,
-		// except while in conversation, while examining a menu object or while combining two menu objects!
-		/*if ((!subject_status)&&(!menu_looking)&&(!second_icon))
-		{
-			HideMenu(TOP_MENU);
-			menu_status=0;
-		}*/
 		_numObjs = 0;
 		return;	// no human, so we don't want the mouse engine
 	}
@@ -177,44 +166,88 @@
 	return _state;
 }
 
-void SwordMouse::setLuggage(uint32 resId, uint32 rate) {
-	warning("stub: SwordMouse::setLuggage(%d, %d)", resId, rate);
+void SwordMouse::createPointer(uint32 ptrId, uint32 luggageId) {
+	if (_currentPtr) {
+		free(_currentPtr);
+		_currentPtr = NULL;
+	}
+	if (ptrId) {
+		MousePtr *lugg = NULL;
+		MousePtr *ptr = (MousePtr*)_resMan->openFetchRes(ptrId);
+		uint16 resSizeX = FROM_LE_16(ptr->sizeX);
+		uint16 resSizeY = FROM_LE_16(ptr->sizeY);
+		uint16 noFrames = FROM_LE_16(ptr->numFrames);
+		if (luggageId) {
+			lugg = (MousePtr*)_resMan->openFetchRes(luggageId);
+			resSizeX = MAX(resSizeX, (uint16)((resSizeX / 2) + FROM_LE_16(lugg->sizeX)));
+			resSizeY = MAX(resSizeY, (uint16)((resSizeY / 2) + FROM_LE_16(lugg->sizeY)));
+		}
+		_currentPtr = (MousePtr*)malloc(sizeof(MousePtr) + resSizeX * resSizeY * noFrames);
+		_currentPtr->hotSpotX = FROM_LE_16(ptr->hotSpotX);
+		_currentPtr->hotSpotY = FROM_LE_16(ptr->hotSpotY);
+		_currentPtr->numFrames = noFrames;
+		_currentPtr->sizeX = resSizeX;
+		_currentPtr->sizeY = resSizeY;
+		uint8 *ptrData = (uint8*)_currentPtr + sizeof(MousePtr);
+		memset(ptrData, 255, resSizeX * resSizeY * noFrames);
+		uint8 *dstData = ptrData;
+		uint8 *srcData = (uint8*)ptr + sizeof(MousePtr);
+		for (uint32 frameCnt = 0; frameCnt < noFrames; frameCnt++) {
+			for (uint32 cnty = 0; cnty < FROM_LE_16(ptr->sizeY); cnty++) {
+				for (uint32 cntx = 0; cntx < FROM_LE_16(ptr->sizeX); cntx++)
+					if (srcData[cntx])
+						dstData[cntx] = srcData[cntx];
+				srcData += FROM_LE_16(ptr->sizeX);
+				dstData += resSizeX;
+			}
+			dstData += (resSizeY - FROM_LE_16(ptr->sizeY)) * resSizeX;
+		}
+		if (luggageId) {
+			dstData = ptrData + resSizeX - FROM_LE_16(lugg->sizeX);
+			for (uint32 frameCnt = 0; frameCnt < noFrames; frameCnt++) {
+				uint8 *luggSrc = (uint8*)lugg + sizeof(MousePtr);
+				dstData += (resSizeY - FROM_LE_16(lugg->sizeY)) * resSizeX;
+				for (uint32 cnty = 0; cnty < FROM_LE_16(lugg->sizeY); cnty++) {
+					for (uint32 cntx = 0; cntx < FROM_LE_16(lugg->sizeX); cntx++)
+						if (luggSrc[cntx])
+							dstData[cntx] = luggSrc[cntx];
+					dstData += resSizeX;
+					luggSrc += FROM_LE_16(lugg->sizeX);
+				}
+			}
+			_resMan->resClose(luggageId);
+		}
+		_resMan->resClose(ptrId);
+	}
 }
 
 void SwordMouse::setPointer(uint32 resId, uint32 rate) {
-	if (_specialPtrId) {
-		_resMan->resClose(_specialPtrId);
-		_specialPtrId = 0;
-	}
+	_currentPtrId = resId;
 	_frame = 0;
 
+	createPointer(resId, _currentLuggageId);
+
 	if ((resId == 0) || (!(SwordLogic::_scriptVars[MOUSE_STATUS] & 1) && (!_mouseOverride))) {
 		_system->set_mouse_cursor(NULL, 0, 0, 0, 0);
 		_system->show_mouse(false);
 	} else {
-		if (resId <= MSE_ARROW9)
-			_currentPtrId = resId - MSE_POINTER;
-		else {
-			_currentPtrId = 0;
-			_specialPtrId = resId;
-			_specialPtr = (MousePtr*)_resMan->mouseResOpen(resId);
-		}
 		animate();
 		_system->show_mouse(true);
 	}
 }
 
+void SwordMouse::setLuggage(uint32 resId, uint32 rate) {
+	_currentLuggageId = resId;
+	_frame = 0;
+	createPointer(_currentPtrId, resId);
+}
+
 void SwordMouse::animate(void) {
-	MousePtr *currentPtr;
 	if ((SwordLogic::_scriptVars[MOUSE_STATUS] == 1) || _mouseOverride) {
-		if (_specialPtrId)
-			currentPtr = _specialPtr;
-		else
-			currentPtr = _pointers[_currentPtrId];
-
-		_frame = (_frame + 1) % currentPtr->numFrames;
-		uint16 size = currentPtr->sizeX * currentPtr->sizeY;
-		_system->set_mouse_cursor(currentPtr->data + 0x30 + _frame * size, currentPtr->sizeX, currentPtr->sizeY, currentPtr->hotSpotX, currentPtr->hotSpotY);
+		_frame = (_frame + 1) % _currentPtr->numFrames;
+		uint8 *ptrData = (uint8*)_currentPtr + sizeof(MousePtr);
+		ptrData += _frame * _currentPtr->sizeX * _currentPtr->sizeY;
+		_system->set_mouse_cursor(ptrData, _currentPtr->sizeX, _currentPtr->sizeY, _currentPtr->hotSpotX, _currentPtr->hotSpotY);
 	}
 }
 
@@ -230,11 +263,9 @@
 	if (SwordLogic::_scriptVars[MOUSE_STATUS] & 2) // locked, can't do anything
 		return ;
 	SwordLogic::_scriptVars[MOUSE_STATUS] = 1;
-	SwordLogic::_scriptVars[SPECIAL_ITEM] = 0; // _scriptVars is unsigned...
+	SwordLogic::_scriptVars[SPECIAL_ITEM] = 0;
 	_getOff = SCR_std_off;
 	setPointer(MSE_POINTER, 0);
-	_mouseCount = 3;
-
 }
 
 void SwordMouse::fnBlankMouse(void) {

Index: mouse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/mouse.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mouse.h	21 Dec 2003 18:50:05 -0000	1.8
+++ mouse.h	30 Dec 2003 21:32:50 -0000	1.9
@@ -51,7 +51,7 @@
 	uint16 sizeY;
 	uint16 hotSpotX;
 	uint16 hotSpotY;
-	uint8  data[2]; // arbitrary number.
+	uint8  dummyData[0x30];
 } GCC_PACK;
 
 #if !defined(__GNUC__)
@@ -75,7 +75,7 @@
 	void animate(void);
 	void engine(uint16 x, uint16 y, uint16 eventFlags);
 	uint16 testEvent(void);
-	void flushEvents(void);
+	//void flushEvents(void);
 	void giveCoords(uint16 *x, uint16 *y);
 	void fnNoHuman(void);
 	void fnAddHuman(void);
@@ -85,7 +85,7 @@
 	void fnUnlockMouse(void);
 	void controlPanel(bool on);
 private:
-	MousePtr *_pointers[17];
+	void createPointer(uint32 ptrId, uint32 luggageId);
 	OSystem *_system;
 	SwordLogic *_logic;
 	SwordMenu *_menu;
@@ -94,13 +94,15 @@
 	ObjectMan *_objMan;
 	uint16 _mouseX, _mouseY;
 
-	uint32 _currentPtrId, _frame;
-	uint8 _mouseCount;
+	uint32 _currentPtrId, _currentLuggageId, _frame;
+	MousePtr *_currentPtr;
+	//uint8 _mouseCount;
 	uint16 _numObjs;
 	uint16 _lastState, _state;
 	uint32 _getOff;
-	uint32 _specialPtrId; // for special mouse cursors which aren't in the _pointers[] array.
-	MousePtr *_specialPtr;
+	//uint32 _specialPtrId; // for special mouse cursors which aren't in the _pointers[] array.
+	//MousePtr *_specialPtr;
+	//MousePtr *_pointers[17];
 	bool _inTopMenu, _mouseOverride;
 };
 





More information about the Scummvm-git-logs mailing list