aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/game.cpp
diff options
context:
space:
mode:
authorRobert Špalek2009-11-12 09:27:41 +0000
committerRobert Špalek2009-11-12 09:27:41 +0000
commit44afaf9bf1fb8a0c4c77bdf033324a7bea82a151 (patch)
tree822b6b04d3e00ed73b6a40fdc05f2105d2eae79f /engines/draci/game.cpp
parent226f0bd23d40f4c807c33ee32f77d449a4f06837 (diff)
downloadscummvm-rg350-44afaf9bf1fb8a0c4c77bdf033324a7bea82a151.tar.gz
scummvm-rg350-44afaf9bf1fb8a0c4c77bdf033324a7bea82a151.tar.bz2
scummvm-rg350-44afaf9bf1fb8a0c4c77bdf033324a7bea82a151.zip
Display/remove the inventory based on mouse "gestures"
svn-id: r45855
Diffstat (limited to 'engines/draci/game.cpp')
-rw-r--r--engines/draci/game.cpp57
1 files changed, 49 insertions, 8 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp
index e8bebdc2b5..4f7f191f84 100644
--- a/engines/draci/game.cpp
+++ b/engines/draci/game.cpp
@@ -304,9 +304,6 @@ void Game::handleInventoryLoop() {
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 @@ void Game::loop(LoopSubstatus substatus, bool shouldExit) {
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 @@ void Game::loop(LoopSubstatus substatus, bool shouldExit) {
case kStatusGate: ;
// cannot happen when isCursonOn; added for completeness
}
-
- // TODO: Handle main menu
}
advanceAnimationsAndTestLoopExit();
@@ -541,6 +538,48 @@ void Game::loop(LoopSubstatus substatus, bool shouldExit) {
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 @@ void Game::inventoryInit() {
// 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 @@ void Game::inventoryDone() {
// 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() {