[Scummvm-cvs-logs] SF.net SVN: scummvm: [29532] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sat Nov 17 10:39:20 CET 2007
Revision: 29532
http://scummvm.svn.sourceforge.net/scummvm/?rev=29532&view=rev
Author: peres001
Date: 2007-11-17 01:39:20 -0800 (Sat, 17 Nov 2007)
Log Message:
-----------
Refactored main input code.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/callables_ns.cpp
scummvm/trunk/engines/parallaction/dialogue.cpp
scummvm/trunk/engines/parallaction/gui_ns.cpp
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/parallaction_br.cpp
Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp 2007-11-17 08:58:31 UTC (rev 29531)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp 2007-11-17 09:39:20 UTC (rev 29532)
@@ -511,7 +511,7 @@
for (uint16 v2 = 0; v2 < 100; v2++) {
_mouseButtons = kMouseNone;
- updateInput();
+ readInput();
if (_mouseButtons == kMouseLeftUp)
break;
Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp 2007-11-17 08:58:31 UTC (rev 29531)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp 2007-11-17 09:39:20 UTC (rev 29532)
@@ -122,7 +122,7 @@
Common::Event e;
while (e.kbd.ascii != Common::KEYCODE_RETURN && passwordLen < MAX_PASSWORD_LENGTH) {
- // FIXME: see comment for updateInput()
+ // FIXME: see comment for readInput()
if (!g_system->getEventManager()->pollEvent(e)) continue;
if (e.type == Common::EVENT_QUIT) {
// TODO: don't quit() here, just have caller routines to check
@@ -311,7 +311,7 @@
_mouseButtons = kMouseNone;
while (_mouseButtons != kMouseLeftUp) {
- _vm->updateInput();
+ _vm->readInput();
_si = getHoverAnswer(_vm->_mousePos.x, _vm->_mousePos.y);
if (_si != v2) {
Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp 2007-11-17 08:58:31 UTC (rev 29531)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp 2007-11-17 09:39:20 UTC (rev 29532)
@@ -205,7 +205,7 @@
_mouseButtons = kMouseNone;
do {
- updateInput();
+ readInput();
} while (_mouseButtons != kMouseLeftUp && _mouseButtons != kMouseRightUp);
showCursor(true);
@@ -284,7 +284,7 @@
_mouseButtons = kMouseNone;
while (_mouseButtons != kMouseLeftUp) {
- updateInput();
+ readInput();
_si = (_mousePos.x > 160) ? 1 : 0;
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2007-11-17 08:58:31 UTC (rev 29531)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2007-11-17 09:39:20 UTC (rev 29532)
@@ -197,7 +197,7 @@
// loops which could possibly be merged into this one with some effort in changing
// caller code, i.e. adding condition checks.
//
-uint16 Parallaction::updateInput() {
+uint16 Parallaction::readInput() {
Common::Event e;
uint16 KeyDown = 0;
@@ -257,11 +257,11 @@
}
-// FIXME: see comment for updateInput()
+// FIXME: see comment for readInput()
void waitUntilLeftClick() {
do {
- _vm->updateInput();
+ _vm->readInput();
_vm->_gfx->updateScreen();
g_system->delayMillis(30);
} while (_mouseButtons != kMouseLeftUp);
@@ -273,11 +273,7 @@
void Parallaction::runGame() {
while ((_engineFlags & kEngineQuit) == 0) {
- _keyDown = updateInput();
- InputData *v8 = translateInput();
- if (v8) {
- processInput(v8);
- }
+ updateInput();
if (_activeZone) {
Zone *z = _activeZone; // speak Zone or sound
@@ -417,8 +413,16 @@
-Parallaction::InputData *Parallaction::translateInput() {
+
+
+
+
+
+void Parallaction::updateInput() {
+
+ _keyDown = readInput();
+
debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
!_mouseHidden,
(_engineFlags & kEngineBlockInput) == 0,
@@ -431,100 +435,115 @@
(_engineFlags & kEngineWalking) ||
(_engineFlags & kEngineChangeLocation)) {
- return NULL;
+ return;
}
-
if (_keyDown == kEvQuitGame) {
_input._event = kEvQuitGame;
- return &_input;
- }
-
+ } else
if (_keyDown == kEvSaveGame) {
_input._event = kEvSaveGame;
- return &_input;
- }
-
+ } else
if (_keyDown == kEvLoadGame) {
_input._event = kEvLoadGame;
- return &_input;
+ } else {
+ _input._mousePos = _mousePos;
+ _input._event = kEvNone;
+ if (!translateGameInput()) {
+ translateInventoryInput();
+ }
}
- _input._mousePos = _mousePos;
+ if (_input._event != kEvNone)
+ processInput(&_input);
- if (((_engineFlags & kEnginePauseJobs) == 0) && ((_engineFlags & kEngineInventory) == 0)) {
+ return;
+}
- if (_actionAfterWalk == true) {
- // if walking is over, then take programmed action
- _input._event = kEvAction;
- _actionAfterWalk = false;
- return &_input;
- }
+bool Parallaction::translateGameInput() {
- Zone *z = hitZone(_activeItem._id, _mousePos.x, _mousePos.y);
+ if ((_engineFlags & kEnginePauseJobs) || (_engineFlags & kEngineInventory)) {
+ return false;
+ }
- if (_mouseButtons == kMouseRightDown) {
- // right button down shows inventory
+ if (_actionAfterWalk) {
+ // if walking is over, then take programmed action
+ _input._event = kEvAction;
+ _actionAfterWalk = false;
+ return true;
+ }
- if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) && (_activeItem._id != 0)) {
- _activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
- _engineFlags |= kEngineDragging;
- }
+ if (_mouseButtons == kMouseRightDown) {
+ // right button down shows inventory
- _input._event = kEvOpenInventory;
- _transCurrentHoverItem = -1;
- return &_input;
+ if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) && (_activeItem._id != 0)) {
+ _activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
+ _engineFlags |= kEngineDragging;
}
- if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((z == NULL) || ((z->_type & 0xFFFF) != kZoneCommand))) {
- _input._event = kEvWalk;
- return &_input;
- }
+ _input._event = kEvOpenInventory;
+ _transCurrentHoverItem = -1;
+ return true;
+ }
- if ((z != _hoverZone) && (_hoverZone != NULL)) {
- _hoverZone = NULL;
- _input._event = kEvExitZone;
-// _input._data= &z->_name;
- return &_input;
- }
+ // test if mouse is hovering on an interactive zone for the currently selected inventory item
+ Zone *z = hitZone(_activeItem._id, _mousePos.x, _mousePos.y);
- if (z == NULL) {
- return NULL;
- }
+ if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((z == NULL) || ((z->_type & 0xFFFF) != kZoneCommand))) {
+ _input._event = kEvWalk;
+ return true;
+ }
- if ((_hoverZone == NULL) && ((z->_flags & kFlagsNoName) == 0)) {
- _hoverZone = z;
- _input._event = kEvEnterZone;
- _input._label = &z->_label;
- return &_input;
- }
+ if ((z != _hoverZone) && (_hoverZone != NULL)) {
+ _hoverZone = NULL;
+ _input._event = kEvExitZone;
+ return true;
+ }
- if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || ((z->_type & 0xFFFF) == kZoneCommand))) {
+ if (z == NULL) {
+ _input._event = kEvNone;
+ return true;
+ }
- _input._zone = z;
- if (z->_flags & kFlagsNoWalk) {
- // character doesn't need to walk to take specified action
- _input._event = kEvAction;
+ if ((_hoverZone == NULL) && ((z->_flags & kFlagsNoName) == 0)) {
+ _hoverZone = z;
+ _input._event = kEvEnterZone;
+ _input._label = &z->_label;
+ return true;
+ }
- } else {
- // action delayed: if Zone defined a moveto position the character is programmed to move there,
- // else it will move to the mouse position
- _input._event = kEvWalk;
- _actionAfterWalk = true;
- if (z->_moveTo.y != 0) {
- _input._mousePos = z->_moveTo;
- }
+ if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || ((z->_type & 0xFFFF) == kZoneCommand))) {
+
+ _input._zone = z;
+ if (z->_flags & kFlagsNoWalk) {
+ // character doesn't need to walk to take specified action
+ _input._event = kEvAction;
+
+ } else {
+ // action delayed: if Zone defined a moveto position the character is programmed to move there,
+ // else it will move to the mouse position
+ _input._event = kEvWalk;
+ _actionAfterWalk = true;
+ if (z->_moveTo.y != 0) {
+ _input._mousePos = z->_moveTo;
}
-
- beep();
- setArrowCursor();
- return &_input;
}
+ beep();
+ setArrowCursor();
+ return true;
}
- if ((_engineFlags & kEngineInventory) == 0) return NULL;
+ return true;
+}
+
+bool Parallaction::translateInventoryInput() {
+
+ if ((_engineFlags & kEngineInventory) == 0) {
+ return false;
+ }
+
// in inventory
int16 _si = getHoverInventoryItem(_mousePos.x, _mousePos.y);
@@ -535,7 +554,9 @@
_input._inventoryIndex = getHoverInventoryItem(_mousePos.x, _mousePos.y);
highlightInventoryItem(_transCurrentHoverItem, 12); // disable
- if ((_engineFlags & kEngineDragging) == 0) return &_input;
+ if ((_engineFlags & kEngineDragging) == 0) {
+ return true;
+ }
_engineFlags &= ~kEngineDragging;
Zone *z = hitZone(kZoneMerge, _activeItem._index, getInventoryItemIndex(_input._inventoryIndex));
@@ -547,18 +568,22 @@
runCommands(z->_commands);
}
- return &_input;
+ return true;
}
- if (_si == _transCurrentHoverItem) return NULL;
+ if (_si == _transCurrentHoverItem) {
+ _input._event = kEvNone;
+ return true;
+ }
_transCurrentHoverItem = _si;
_input._event = kEvHoverInventory;
_input._inventoryIndex = _si;
- return &_input;
+ return true;
}
+
uint32 Parallaction::getElapsedTime() {
return g_system->getMillis() - _baseTime;
}
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2007-11-17 08:58:31 UTC (rev 29531)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2007-11-17 09:39:20 UTC (rev 29532)
@@ -371,7 +371,8 @@
virtual bool loadGame() = 0;
virtual bool saveGame() = 0;
- uint16 updateInput();
+ uint16 readInput();
+ void updateInput();
void waitTime(uint32 t);
@@ -541,6 +542,8 @@
void resetTimer();
InputData *translateInput();
+ bool translateGameInput();
+ bool translateInventoryInput();
void processInput(InputData*);
Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp 2007-11-17 08:58:31 UTC (rev 29531)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp 2007-11-17 09:39:20 UTC (rev 29532)
@@ -236,7 +236,7 @@
if ((_mouseButtons == kMouseLeftUp) && selectedItem >= 0)
break;
- updateInput();
+ readInput();
if ((_mousePos.x > MENUITEMS_X) && (_mousePos.x < (MENUITEMS_X+MENUITEM_WIDTH)) && (_mousePos.y > MENUITEMS_Y)) {
selectedItem = (_mousePos.y - MENUITEMS_Y) / MENUITEM_HEIGHT;
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