[Scummvm-cvs-logs] SF.net SVN: scummvm: [31537] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Apr 17 17:29:11 CEST 2008


Revision: 31537
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31537&view=rev
Author:   lordhoto
Date:     2008-04-17 08:29:10 -0700 (Thu, 17 Apr 2008)

Log Message:
-----------
Added partial implementation of updateMouse cursor.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/items_v3.cpp
    scummvm/trunk/engines/kyra/kyra_v3.cpp
    scummvm/trunk/engines/kyra/kyra_v3.h
    scummvm/trunk/engines/kyra/scene_v3.cpp

Modified: scummvm/trunk/engines/kyra/items_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items_v3.cpp	2008-04-17 14:26:50 UTC (rev 31536)
+++ scummvm/trunk/engines/kyra/items_v3.cpp	2008-04-17 15:29:10 UTC (rev 31537)
@@ -51,4 +51,43 @@
 	return -1;
 }
 
+int KyraEngine_v3::checkItemCollision(int x, int y) {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::checkItemCollision(%d, %d)", x, y);
+	int itemIndex = -1;
+	int maxItemY = -1;
+
+	for (int i = 0; i < 50; ++i) {
+		if (_itemList[i].id == 0xFFFF || _itemList[i].sceneId != _mainCharacter.sceneId)
+			continue;
+
+		const int x1 = _itemList[i].x - 11;
+		const int x2 = _itemList[i].x + 10;
+
+		if (x < x1 || x > x2)
+			continue;
+
+		const int y1 = _itemList[i].y - _itemBuffer1[_itemList[i].id] - 3;
+		const int y2 = _itemList[i].y + 3;
+
+		if (y < y1 || y > y2)
+			continue;
+
+		if (_itemList[i].y >= maxItemY) {
+			itemIndex = i;
+			maxItemY = _itemList[i].y;
+		}
+	}
+
+	return itemIndex;
+}
+
+void KyraEngine_v3::setItemMouseCursor() {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::setItemMouseCursor()");
+	_handItemSet = _itemInHand;
+	if (_itemInHand == -1)
+		_screen->setMouseCursor(0, 0, _gameShapes[0]);
+	else
+		_screen->setMouseCursor(0xC, 0x13, _gameShapes[_itemInHand+248]);
+}
+
 } // end of namespace Kyra

Modified: scummvm/trunk/engines/kyra/kyra_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.cpp	2008-04-17 14:26:50 UTC (rev 31536)
+++ scummvm/trunk/engines/kyra/kyra_v3.cpp	2008-04-17 15:29:10 UTC (rev 31537)
@@ -916,7 +916,7 @@
 	musicUpdate(0);
 	refreshAnimObjectsIfNeed();
 	musicUpdate(0);
-	//XXX
+	updateMouse();
 	updateSpecialSceneScripts();
 	updateCommandLine();
 	//XXX
@@ -925,6 +925,125 @@
 	_screen->updateScreen();
 }
 
+void KyraEngine_v3::updateMouse() {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::updateMouse()");
+	int shape = 0, offsetX = 0, offsetY = 0;
+	Common::Point mouse = getMousePos();
+	bool hasItemCollision = checkItemCollision(mouse.x, mouse.y) != -1;
+
+	if (mouse.y > 187) {
+		bool setItemCursor = false;
+		if (_handItemSet == -6) {
+			if (mouse.x < 311)
+				setItemCursor = true;
+		} else if (_handItemSet == -5) {
+			if (mouse.x < _sceneMinX || mouse.x > _sceneMaxX)
+				setItemCursor = true;
+		} else if (_handItemSet == -4) {
+			if (mouse.x > 8)
+				setItemCursor = true;
+		}
+
+		if (setItemCursor) {
+			setItemMouseCursor();
+			return;
+		}
+	}
+
+	if (_inventoryState) {
+		if (mouse.y >= 144)
+			return;
+		//hideInventory();
+	}
+
+	if (hasItemCollision && _handItemSet < -1 && _itemInHand < 0) {
+		_handItemSet = -1;
+		_itemInHand = -1;
+		_screen->setMouseCursor(0, 0, _gameShapes[0]);
+	}
+
+	int type = 0;
+	if (mouse.y <= 199) {
+		if (mouse.x <= 8) {
+			if (_sceneExit4 != 0xFFFF) {
+				type = -4;
+				shape = 4;
+				offsetX = 0;
+				offsetY = 0;
+			}
+		} else if (mouse.x >= 311) {
+			if (_sceneExit2 != 0xFFFF) {
+				type = -6;
+				shape = 2;
+				offsetX = 13;
+				offsetY = 8;
+			}
+		} else if (mouse.y >= 171) {
+			if (_sceneExit3 != 0xFFFF) {
+				if (mouse.x >= _sceneMinX && mouse.x <= _sceneMaxX) {
+					type = -5;
+					shape = 3;
+					offsetX = 8;
+					offsetY = 13;
+				}
+			}
+		} else if (mouse.y <= 8) {
+			if (_sceneExit1 != 0xFFFF) {
+				type = -7;
+				shape = 1;
+				offsetX = 8;
+				offsetY = 0;
+			}
+		}
+	}
+
+	for (int i = 0; i < _specialExitCount; ++i) {
+		if (checkSpecialSceneExit(i, mouse.x, mouse.y)) {
+			switch (_specialExitTable[20+i]) {
+			case 0:
+				type = -7;
+				shape = 1;
+				offsetX = 8;
+				offsetY = 0;
+				break;
+
+			case 2:
+				type = -6;
+				shape = 2;
+				offsetX = 13;
+				offsetY = 8;
+				break;
+
+			case 4:
+				type = -5;
+				shape = 3;
+				offsetX = 8;
+				offsetY = 13;
+				break;
+
+			case 6:
+				type = -4;
+				shape = 4;
+				offsetX = 0;
+				offsetY = 8;
+				break;
+
+			default:
+				break;
+			}
+		}
+	}
+
+	if (type != 0 && type != _handItemSet && !hasItemCollision) {
+		_handItemSet = type;
+		_screen->setMouseCursor(offsetX, offsetY, _gameShapes[shape]);
+	} else if (type == 0 && _handItemSet != _itemInHand && mouse.x > 8 && mouse.x < 311 && mouse.y < 171 && mouse.y > 8) {
+		setItemMouseCursor();
+	} else if (mouse.y > 187 && _handItemSet > -4 && type == 0 && !_inventoryState) {
+		//showInventory();
+	}
+}
+
 void KyraEngine_v3::delay(uint32 millis, bool doUpdate, bool isMainLoop) {
 	debugC(9, kDebugLevelMain, "KyraEngine_v3::delay(%d, %d, %d)", millis, doUpdate, isMainLoop);
 	uint32 endTime = _system->getMillis() + millis;

Modified: scummvm/trunk/engines/kyra/kyra_v3.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v3.h	2008-04-17 14:26:50 UTC (rev 31536)
+++ scummvm/trunk/engines/kyra/kyra_v3.h	2008-04-17 15:29:10 UTC (rev 31537)
@@ -74,6 +74,7 @@
 	void handleInput(int x, int y);
 
 	void update();
+	void updateMouse();
 
 	void delay(uint32 millis, bool update = false, bool isMainLoop = false);
 
@@ -225,10 +226,28 @@
 	// items
 	uint8 *_itemBuffer1;
 	uint8 *_itemBuffer2;
+	struct Item {
+		uint16 id;
+		uint16 sceneId;
+		int16 x, y;
+		uint16 unk8;
+	};
+
+	Item *_itemList;
+	uint16 _hiddenItems[100];
+
+	void resetItem(int index);
+	void resetItemList();
+
+	int findFreeItem();
 	
 	void initItems();
 
+	int checkItemCollision(int x, int y);
+
 	// -> hand item
+	void setItemMouseCursor();
+
 	int _itemInHand;
 	int _handItemSet;
 
@@ -293,8 +312,10 @@
 	int _sceneEnterX2, _sceneEnterY2;
 	int _sceneEnterX3, _sceneEnterY3;
 	int _sceneEnterX4, _sceneEnterY4;
+
 	int _specialExitCount;
 	uint16 _specialExitTable[25];
+	bool checkSpecialSceneExit(int index, int x, int y);
 
 	bool _noScriptEnter;
 	void enterNewScene(uint16 scene, int facing, int unk1, int unk2, int unk3);
@@ -314,7 +335,7 @@
 	void runSceneScript4(int unk1);
 	void runSceneScript8();
 
-	int _sceneMinY, _sceneMaxY;
+	int _sceneMinX, _sceneMaxX;
 	int _maskPageMinY, _maskPageMaxY;
 
 	ScriptState _sceneScriptState;
@@ -339,22 +360,6 @@
 
 	bool _unkSceneScreenFlag1;
 
-	// items
-	struct Item {
-		uint16 id;
-		uint16 sceneId;
-		int16 x, y;
-		uint16 unk8;
-	};
-
-	Item *_itemList;
-	uint16 _hiddenItems[100];
-
-	void resetItem(int index);
-	void resetItemList();
-
-	int findFreeItem();
-
 	// character
 	struct Character {
 		uint16 sceneId;

Modified: scummvm/trunk/engines/kyra/scene_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v3.cpp	2008-04-17 14:26:50 UTC (rev 31536)
+++ scummvm/trunk/engines/kyra/scene_v3.cpp	2008-04-17 15:29:10 UTC (rev 31537)
@@ -429,8 +429,8 @@
 	_sceneEnterY3 = 171;
 	_sceneEnterX4 = 24;
 	_sceneEnterY4 = 93;
-	_sceneMinY = 0;
-	_sceneMaxY = 319;
+	_sceneMinX = 0;
+	_sceneMaxX = 319;
 
 	_scriptInterpreter->initScript(&_sceneScriptState, &_sceneScriptData);
 	strcpy(filename, scene.filename2);
@@ -679,4 +679,13 @@
 	}
 }
 
+bool KyraEngine_v3::checkSpecialSceneExit(int index, int x, int y) {
+	debugC(9, kDebugLevelMain, "KyraEngine_v3::checkSpecialSceneExit(%d, %d, %d)", index, x, y);
+	if (_specialExitTable[index] < x && _specialExitTable[5+index] < y &&
+		_specialExitTable[10+index] > x && _specialExitTable[15+index] > y)
+		return true;
+
+	return false;
+}
+
 } // end of namespace Kyra


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list