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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Mar 18 19:27:53 CET 2007


Revision: 26221
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26221&view=rev
Author:   fingolfin
Date:     2007-03-18 11:27:52 -0700 (Sun, 18 Mar 2007)

Log Message:
-----------
KYRA: Changed to use EventManager::getMousePos (should improve some things: the old code did not properly track the mouse upon click events, and KyraEngine::waitForEvent ignored _flags.useHiResOverlay)

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/animator.cpp
    scummvm/trunk/engines/kyra/gui.cpp
    scummvm/trunk/engines/kyra/items.cpp
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/saveload.cpp
    scummvm/trunk/engines/kyra/scene.cpp
    scummvm/trunk/engines/kyra/script_v1.cpp

Modified: scummvm/trunk/engines/kyra/animator.cpp
===================================================================
--- scummvm/trunk/engines/kyra/animator.cpp	2007-03-18 18:10:34 UTC (rev 26220)
+++ scummvm/trunk/engines/kyra/animator.cpp	2007-03-18 18:27:52 UTC (rev 26221)
@@ -575,7 +575,8 @@
 
 void ScreenAnimator::makeBrandonFaceMouse() {
 	debugC(9, kDebugLevelAnimator, "ScreenAnimator::makeBrandonFaceMouse()");
-	if (_vm->mouseX() >= _vm->_currentCharacter->x1) {
+	Common::Point mouse = _vm->getMousePos();
+	if (mouse.x >= _vm->_currentCharacter->x1) {
 		_vm->_currentCharacter->facing = 3;
 	} else {
 		_vm->_currentCharacter->facing = 5;

Modified: scummvm/trunk/engines/kyra/gui.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui.cpp	2007-03-18 18:10:34 UTC (rev 26220)
+++ scummvm/trunk/engines/kyra/gui.cpp	2007-03-18 18:27:52 UTC (rev 26221)
@@ -316,7 +316,8 @@
 		}
 		y += _screen->_screenDimTable[list->dimTableIndex].sy;
 		
-		if (_mouseX >= x && _mouseY >= y && x + list->width >= _mouseX && y + list->height >= _mouseY) {
+		Common::Point mouse = getMousePos();
+		if (mouse.x >= x && mouse.y >= y && x + list->width >= mouse.x && y + list->height >= mouse.y) {
 			int processMouseClick = 0;
 			if (list->flags & 0x400) {
 				if (_mousePressFlag) {
@@ -820,12 +821,6 @@
 			_mousePressFlag = false;
 			break;
 		case Common::EVENT_MOUSEMOVE:
-			_mouseX = event.mouse.x;
-			_mouseY = event.mouse.y;
-			if (_flags.useHiResOverlay) {
-				_mouseX >>= 1;
-				_mouseY >>= 1;
-			}
 			_system->updateScreen();
 			lastScreenUpdate = now;
 			break;
@@ -1378,6 +1373,7 @@
 void KyraEngine::gui_processHighlights(Menu &menu) {
 	int x1, y1, x2, y2;
 
+	Common::Point mouse = getMousePos();
 	for (int i = 0; i < menu.nrOfItems; i++) {
 		if (!menu.item[i].enabled)
 			continue;
@@ -1388,8 +1384,8 @@
 		x2 = x1 + menu.item[i].width;
 		y2 = y1 + menu.item[i].height;
 
-		if (_mouseX > x1 && _mouseX < x2 &&
-			_mouseY > y1 && _mouseY < y2) {
+		if (mouse.x > x1 && mouse.x < x2 &&
+			mouse.y > y1 && mouse.y < y2) {
 			
 			if (menu.highlightedItem != i) {
 				if (menu.item[menu.highlightedItem].enabled )
@@ -1481,14 +1477,6 @@
 		case Common::EVENT_QUIT:
 			quitGame();
 			break;
-		case Common::EVENT_MOUSEMOVE:
-			_mouseX = event.mouse.x;
-			_mouseY = event.mouse.y;
-			if (_flags.useHiResOverlay) {
-				_mouseX >>= 1;
-				_mouseY >>= 1;
-			}
-			break;
 		case Common::EVENT_LBUTTONUP:
 			return true;
 		default:
@@ -1541,8 +1529,9 @@
 		gui_updateMainMenuAnimation();
 		bool mousePressed = gui_mainMenuGetInput();
 
-		if (menuRect.contains(mouseX(), mouseY())) {
-			int item = (mouseY() - menuRect.top) / fh;
+		Common::Point mouse = getMousePos();
+		if (menuRect.contains(mouse)) {
+			int item = (mouse.y - menuRect.top) / fh;
 
 			if (item != selected) {
 				gui_printString(strings[selected], textPos, menuRect.top + selected * fh, 0x80, 0, 5);

Modified: scummvm/trunk/engines/kyra/items.cpp
===================================================================
--- scummvm/trunk/engines/kyra/items.cpp	2007-03-18 18:10:34 UTC (rev 26220)
+++ scummvm/trunk/engines/kyra/items.cpp	2007-03-18 18:27:52 UTC (rev 26221)
@@ -694,8 +694,9 @@
 	_screen->_curPage = 0;
 	int x = 0, y = 0;
 	if (itemPos == -1) {
-		x = _mouseX - 12;
-		y = _mouseY - 18;
+		Common::Point mouse = getMousePos();
+		x = mouse.x - 12;
+		y = mouse.y - 18;
 	} else {
 		x = _itemPosX[itemPos] - 4;
 		y = _itemPosY[itemPos] - 3;
@@ -781,8 +782,9 @@
 	_screen->_curPage = 0;
 	int x = 0, y = 0;
 	if (itemPos == -1) {
-		x = _mouseX - 12;
-		y = _mouseY - 18;
+		Common::Point mouse = getMousePos();
+		x = mouse.x - 12;
+		y = mouse.y - 18;
 	} else {
 		x = _itemPosX[itemPos] - 4;
 		y = _itemPosX[itemPos] - 3;

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2007-03-18 18:10:34 UTC (rev 26220)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2007-03-18 18:27:52 UTC (rev 26221)
@@ -265,7 +265,6 @@
 	_abortWalkFlag2 = false;
 	_talkingCharNum = -1;
 	_charSayUnk3 = -1;
-	_mouseX = _mouseY = -1;
 	memset(_currSentenceColor, 0, 3);
 	_startSentencePalIndex = -1;
 	_fadeText = false;
@@ -636,12 +635,6 @@
 
 				break;
 			case Common::EVENT_MOUSEMOVE:
-				_mouseX = event.mouse.x;
-				_mouseY = event.mouse.y;
-				if (_flags.useHiResOverlay) {
-					_mouseX >>= 1;
-					_mouseY >>= 1;
-				}
 				_animator->_updateScreen = true;
 				break;
 			case Common::EVENT_QUIT:
@@ -653,19 +646,12 @@
 			case Common::EVENT_LBUTTONUP:
 				_mousePressFlag = false;
 
-				_mouseX = event.mouse.x;
-				_mouseY = event.mouse.y;
-				if (_flags.useHiResOverlay) {
-					_mouseX >>= 1;
-					_mouseY >>= 1;
-				}
-
 				if (_abortWalkFlag2) 
 					_abortWalkFlag = true;
 
 				if (_handleInput) {
 					_handleInput = false;
-					processInput(_mouseX, _mouseY);
+					processInput();
 					_handleInput = true;
 				} else
 					_skipFlag = true;
@@ -703,6 +689,15 @@
 	
 }
 
+Common::Point KyraEngine::getMousePos() const {
+	Common::Point mouse = g_system->getEventManager()->getMousePos();
+	if (_flags.useHiResOverlay) {
+		mouse.x >>= 1;
+		mouse.y >>= 1;
+	}
+	return mouse;
+}
+
 void KyraEngine::waitForEvent() {
 	bool finished = false;
 	Common::Event event;
@@ -713,10 +708,6 @@
 			case Common::EVENT_KEYDOWN:
 				finished = true;
 				break;
-			case Common::EVENT_MOUSEMOVE:
-				_mouseX = event.mouse.x;
-				_mouseY = event.mouse.y;
-				break;
 			case Common::EVENT_QUIT:
 				quitGame();
 				break;
@@ -843,7 +834,11 @@
 #pragma mark - Input
 #pragma mark -
 
-void KyraEngine::processInput(int xpos, int ypos) {
+void KyraEngine::processInput() {
+	Common::Point mouse = getMousePos();
+	int xpos = mouse.x;
+	int ypos = mouse.y;
+
 	debugC(9, kDebugLevelMain, "KyraEngine::processInput(%d, %d)", xpos, ypos);
 	_abortWalkFlag2 = false;
 
@@ -952,9 +947,10 @@
 	int newMouseState = 0;
 	int newX = 0;
 	int newY = 0;
-	if (_mouseY <= 158) {
-		if (_mouseX >= 12) {
-			if (_mouseX >= 308) {
+	Common::Point mouse = getMousePos();
+	if (mouse.y <= 158) {
+		if (mouse.x >= 12) {
+			if (mouse.x >= 308) {
 				if (_walkBlockEast == 0xFFFF) {
 					newMouseState = -2;
 				} else {
@@ -963,7 +959,7 @@
 					newX = 7;
 					newY = 5;
 				}
-			} else if (_mouseY >= 136) {
+			} else if (mouse.y >= 136) {
 				if (_walkBlockSouth == 0xFFFF) {
 					newMouseState = -2;
 				} else {
@@ -972,7 +968,7 @@
 					newX = 5;
 					newY = 7;
 				}
-			} else if (_mouseY < 12) {
+			} else if (mouse.y < 12) {
 				if (_walkBlockNorth == 0xFFFF) {
 					newMouseState = -2;
 				} else {
@@ -993,8 +989,8 @@
 		}
 	}
 	
-	if (_mouseX >= _entranceMouseCursorTracks[0] && _mouseY >= _entranceMouseCursorTracks[1]
-		&& _mouseX <= _entranceMouseCursorTracks[2] && _mouseY <= _entranceMouseCursorTracks[3]) {
+	if (mouse.x >= _entranceMouseCursorTracks[0] && mouse.y >= _entranceMouseCursorTracks[1]
+		&& mouse.x <= _entranceMouseCursorTracks[2] && mouse.y <= _entranceMouseCursorTracks[3]) {
 		switch (_entranceMouseCursorTracks[4]) {
 		case 0:
 			newMouseState = -6;
@@ -1044,7 +1040,7 @@
 	
 	if (!newMouseState) {
 		if (_mouseState != _itemInHand || forceUpdate) {
-			if (_mouseY > 158 || (_mouseX >= 12 && _mouseX < 308 && _mouseY < 136 && _mouseY >= 12) || forceUpdate) {
+			if (mouse.y > 158 || (mouse.x >= 12 && mouse.x < 308 && mouse.y < 136 && mouse.y >= 12) || forceUpdate) {
 				_mouseState = _itemInHand;
 				_screen->hideMouse();
 				if (_itemInHand == -1) {
@@ -1073,10 +1069,13 @@
 
 void KyraEngine::clickEventHandler2() {
 	debugC(9, kDebugLevelMain, "KyraEngine::clickEventHandler2()");
+
+	Common::Point mouse = getMousePos();
+
 	_scriptInterpreter->initScript(_scriptClick, _scriptClickData);
 	_scriptClick->variables[0] = _currentCharacter->sceneId;
-	_scriptClick->variables[1] = _mouseX;
-	_scriptClick->variables[2] = _mouseY;
+	_scriptClick->variables[1] = mouse.x;
+	_scriptClick->variables[2] = mouse.y;
 	_scriptClick->variables[4] = _itemInHand;
 	_scriptInterpreter->startScript(_scriptClick, 6);
 	

Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2007-03-18 18:10:34 UTC (rev 26220)
+++ scummvm/trunk/engines/kyra/kyra.h	2007-03-18 18:27:52 UTC (rev 26221)
@@ -305,13 +305,12 @@
 	void disableTimer(uint8 timer);
 
 	void delayWithTicks(int ticks);
-	
+
 	void saveGame(const char *fileName, const char *saveName);
 	void loadGame(const char *fileName);
 
-	int mouseX() { return _mouseX; }
-	int mouseY() { return _mouseY; }
-	
+	Common::Point getMousePos() const;
+
 	int setGameFlag(int flag);
 	int queryGameFlag(int flag);
 	int resetGameFlag(int flag);
@@ -531,7 +530,7 @@
 	void setBrandonPoisonFlags(int reset);
 	void resetBrandonPoisonFlags();
 
-	void processInput(int xpos, int ypos);
+	void processInput();
 	int processInputHelper(int xpos, int ypos);
 	int clickEventHandler(int xpos, int ypos);
 	void clickEventHandler2();
@@ -707,7 +706,6 @@
 	uint16 _gameSpeed;
 	uint16 _tickLength;
 	int _lang;
-	int _mouseX, _mouseY;
 	int8 _itemInHand;
 	int _mouseState;
 	bool _handleInput;

Modified: scummvm/trunk/engines/kyra/saveload.cpp
===================================================================
--- scummvm/trunk/engines/kyra/saveload.cpp	2007-03-18 18:10:34 UTC (rev 26220)
+++ scummvm/trunk/engines/kyra/saveload.cpp	2007-03-18 18:27:52 UTC (rev 26221)
@@ -255,8 +255,6 @@
 	_abortWalkFlag = true;
 	_abortWalkFlag2 = false;
 	_mousePressFlag = false;
-	_mouseX = brandonX;
-	_mouseY = brandonY;
 	_system->warpMouse(brandonX, brandonY);
 
 	if (in->ioFailed())

Modified: scummvm/trunk/engines/kyra/scene.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene.cpp	2007-03-18 18:10:34 UTC (rev 26220)
+++ scummvm/trunk/engines/kyra/scene.cpp	2007-03-18 18:27:52 UTC (rev 26221)
@@ -958,7 +958,7 @@
 			_currentCharacter->currentAnimFrame = 7;
 			_animator->animRefreshNPC(0);
 			_animator->updateAllObjectShapes();
-			processInput(_mouseX, _mouseY);
+			processInput();
 			return 0;
 		}
 		bool forceContinue = false;

Modified: scummvm/trunk/engines/kyra/script_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_v1.cpp	2007-03-18 18:10:34 UTC (rev 26220)
+++ scummvm/trunk/engines/kyra/script_v1.cpp	2007-03-18 18:27:52 UTC (rev 26221)
@@ -1377,8 +1377,9 @@
 	// }
 	processButtonList(_buttonList);
 	_skipFlag = false;
-	script->variables[1] = _mouseX;
-	script->variables[2] = _mouseY;
+	Common::Point mouse = getMousePos();
+	script->variables[1] = mouse.x;
+	script->variables[2] = mouse.y;
 	return 0;
 }
 
@@ -1514,8 +1515,6 @@
 int KyraEngine::o1_setMousePos(ScriptState *script) {
 	debugC(3, kDebugLevelScriptFuncs, "o1_setMousePos(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
 	_system->warpMouse(stackPos(0), stackPos(1));
-	_mouseX = stackPos(0);
-	_mouseY = stackPos(1);
 	return 0;
 }
 


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