[Scummvm-cvs-logs] SF.net SVN: scummvm:[45855] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Thu Nov 12 10:27:42 CET 2009


Revision: 45855
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45855&view=rev
Author:   spalek
Date:     2009-11-12 09:27:41 +0000 (Thu, 12 Nov 2009)

Log Message:
-----------
Display/remove the inventory based on mouse "gestures"

Modified Paths:
--------------
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/game.h

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-11-12 09:24:46 UTC (rev 45854)
+++ scummvm/trunk/engines/draci/game.cpp	2009-11-12 09:27:41 UTC (rev 45855)
@@ -304,9 +304,6 @@
 	if (_loopSubstatus != kOuterLoop) {
 		return;
 	}
-	if (_inventoryExit) {
-		inventoryDone();
-	}
 
 	// If we are in inventory mode, all the animations except game items'
 	// images will necessarily be paused so we can safely assume that any
@@ -517,11 +514,13 @@
 				updateOrdinaryCursor();
 				updateTitle(x, y);
 				handleOrdinaryLoop(x, y);
+				handleStatusChangeByMouse();
 				break;
 			case kStatusInventory:
 				updateInventoryCursor();
 				updateTitle(x, y);
 				handleInventoryLoop();
+				handleStatusChangeByMouse();
 				break;
 			case kStatusDialogue:
 				handleDialogueLoop();
@@ -529,8 +528,6 @@
 			case kStatusGate: ;
 				// cannot happen when isCursonOn; added for completeness
 			}
-
-			// TODO: Handle main menu
 		}
 
 		advanceAnimationsAndTestLoopExit();
@@ -541,6 +538,48 @@
 	setExitLoop(false);
 }
 
+void Game::handleStatusChangeByMouse() {
+	bool wantsChange = false;
+	if (_loopStatus == kStatusOrdinary) {
+		wantsChange = _vm->_mouse->getPosY() == 0;
+	} else if (_loopStatus == kStatusInventory) {
+		wantsChange = _animUnderCursor != _inventoryAnim && !_itemUnderCursor && _vm->_mouse->getPosY() != 0;
+	}
+
+	if (!wantsChange) {
+		// Disable the timer.
+		_mouseChangeTick = -1;
+	} else {
+		if (_mouseChangeTick == -1) {
+			// If the timer is currently disabled, this is the
+			// first time when the mouse left the region.  Start
+			// counting.
+			_mouseChangeTick = _vm->_system->getMillis();
+		} else if (_mouseChangeTick == -2) {
+			// Do nothing.  This exception is good when the
+			// inventory visibility flag is flipped by the key 'I'
+			// instead of by moving the mouse.  Even if the mouse
+			// starts in the outside region, the timeout won't kick
+			// in until it moves into the inside region for the
+			// first time.
+		} else if (_vm->_system->getMillis() - _mouseChangeTick >= kStatusChangeTimeout) {
+			if (_loopStatus == kStatusOrdinary) {
+				inventoryInit();
+			} else {
+				inventoryDone();
+			}
+		}
+	}
+
+	// We don't implement the original game player's main
+	// menu that pops up when the mouse gets to the bottom
+	// of the screen.  It contains icons for displaying the map,
+	// loading/saving the game, quiting the game, and displaying the
+	// credits.  The essential options are implemented in ScummVM's main
+	// menu, I don't wanna implement the credits, and for map we key the
+	// key 'M'.
+}
+
 void Game::updateOrdinaryCursor() {
 	// Fetch mouse coordinates
 	bool mouseChanged = false;
@@ -732,9 +771,8 @@
 	// Set the appropriate loop status
 	setLoopStatus(kStatusInventory);
 
-	// TODO: This will be used for exiting the inventory automatically when the mouse
-	// is outside it for some time
-	_inventoryExit = false;
+	// Don't return from the inventory mode immediately if the mouse is out.
+	_mouseChangeTick = -2;
 }
 
 void Game::inventoryDone() {
@@ -753,6 +791,9 @@
 
 	// Reset item under cursor
 	_itemUnderCursor = NULL;
+
+	// Don't start the inventory mode again if the mouse is on the top.
+	_mouseChangeTick = -2;
 }
 
 void Game::inventoryDraw() {

Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h	2009-11-12 09:24:46 UTC (rev 45854)
+++ scummvm/trunk/engines/draci/game.h	2009-11-12 09:27:41 UTC (rev 45855)
@@ -72,7 +72,8 @@
   kInventoryLines = 5,
   kInventoryX = 70, ///< Used for positioning of the inventory sprite on the X axis
   kInventoryY = 30, ///< Used for positioning of the inventory sprite on the Y axis
-  kInventorySlots = kInventoryLines * kInventoryColumns
+  kInventorySlots = kInventoryLines * kInventoryColumns,
+  kStatusChangeTimeout = 500
 };
 
 class GameObject {
@@ -333,6 +334,7 @@
 	void updateTitle(int x, int y);
 	void updateCursor();
 	void advanceAnimationsAndTestLoopExit();
+	void handleStatusChangeByMouse();
 
 	bool enterNewRoom();	// Returns false if another room change has been triggered and therefore loop() shouldn't be called yet.
 	void initWalkingOverlays();
@@ -355,7 +357,6 @@
 	GameItem *_itemUnderCursor;
 
 	GameItem *_inventory[kInventorySlots];
-	bool _inventoryExit;
 
 	Room _currentRoom;
 	int _newRoom;
@@ -397,6 +398,7 @@
 	int _fadePhases;
 	int _fadePhase;
 	uint _fadeTick;
+	int _mouseChangeTick;
 
 	bool _enableQuickHero;
 	bool _wantQuickHero;


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