[Scummvm-cvs-logs] SF.net SVN: scummvm: [32115] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Wed May 14 16:34:01 CEST 2008


Revision: 32115
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32115&view=rev
Author:   peres001
Date:     2008-05-14 07:34:01 -0700 (Wed, 14 May 2008)

Log Message:
-----------
- Moved input code to its own class.
- Slightly simplified inventory highlight code thanks to changes in input code.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/dialogue.cpp
    scummvm/trunk/engines/parallaction/exec_br.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/gui_br.cpp
    scummvm/trunk/engines/parallaction/gui_ns.cpp
    scummvm/trunk/engines/parallaction/inventory.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp

Added Paths:
-----------
    scummvm/trunk/engines/parallaction/input.cpp
    scummvm/trunk/engines/parallaction/input.h

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -30,6 +30,7 @@
 
 #include "graphics/primitives.h"			// for Graphics::drawLine
 
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 #include "parallaction/sound.h"
 
@@ -303,14 +304,14 @@
 }
 
 void Parallaction_ns::_c_offMouse(void *parm) {
-	showCursor(false);
+	_input->showCursor(false);
 	_engineFlags |= kEngineBlockInput;
 	return;
 }
 
 void Parallaction_ns::_c_onMouse(void *parm) {
 	_engineFlags &= ~kEngineBlockInput;
-	showCursor(true);
+	_input->showCursor(true);
 	return;
 }
 
@@ -339,7 +340,7 @@
 		g_system->delayMillis(20);
 	}
 
-	waitUntilLeftClick();
+	_input->waitUntilLeftClick();
 	_gfx->freeBalloons();
 
 	return;
@@ -395,7 +396,7 @@
 	_gfx->showLabel(id[1], CENTER_LABEL_HORIZONTAL, 100);
 	_gfx->showLabel(id[2], CENTER_LABEL_HORIZONTAL, 130);
 	_gfx->showLabel(id[3], CENTER_LABEL_HORIZONTAL, 160);
-	waitUntilLeftClick();
+	_input->waitUntilLeftClick();
 
 	_gfx->freeLabels();
 
@@ -467,6 +468,7 @@
 
 	debugC(1, kDebugExec, "endIntro()");
 
+	uint32 event;
 	uint id[2];
 	for (uint16 _si = 0; _si < 6; _si++) {
 		id[0] = _gfx->createLabel(_menuFont, _credits[_si]._role, 1);
@@ -478,9 +480,9 @@
 		_gfx->updateScreen();
 
 		for (uint16 v2 = 0; v2 < 100; v2++) {
-			_mouseButtons = kMouseNone;
-			readInput();
-			if (_mouseButtons == kMouseLeftUp)
+			_input->readInput();
+			event = _input->getLastButtonEvent();
+			if (event == kMouseLeftUp)
 				break;
 
 			waitTime( 1 );
@@ -497,7 +499,7 @@
 		id[0] = _gfx->createLabel(_menuFont, "CLICK MOUSE BUTTON TO START", 1);
 		_gfx->showLabel(id[0], CENTER_LABEL_HORIZONTAL, 80);
 
-		waitUntilLeftClick();
+		_input->waitUntilLeftClick();
 
 		_gfx->freeLabels();
 
@@ -507,7 +509,7 @@
 		cleanupGame();
 
 	} else {
-		waitUntilLeftClick();
+		_input->waitUntilLeftClick();
 	}
 
 	return;

Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -24,6 +24,8 @@
  */
 
 #include "common/events.h"
+
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 
 
@@ -195,7 +197,7 @@
 	_vm->_gfx->setItemFrame(id, _q->_mood & 0xF);
 
 	_vm->_gfx->updateScreen();
-	waitUntilLeftClick();
+	_vm->_input->waitUntilLeftClick();
 	_vm->_gfx->hideDialogueStuff();
 
 	return;
@@ -254,7 +256,7 @@
 
 	if (numAvailableAnswers == 1) {
 		_vm->_gfx->setBalloonText(0, _q->_answers[0]->_text, 0);
-		waitUntilLeftClick();
+		_vm->_input->waitUntilLeftClick();
 		_vm->_gfx->hideDialogueStuff();
 		return 0;
 	}
@@ -262,10 +264,14 @@
 	int oldSelection = -1;
 	int selection;
 
+	uint32 event;
+	Common::Point p;
 	while (true) {
 
-		_vm->readInput();
-		selection = _vm->_gfx->hitTestDialogueBalloon(_vm->_mousePos.x, _vm->_mousePos.y);
+		_vm->_input->readInput();
+		_vm->_input->getCursorPos(p);
+		event = _vm->_input->getLastButtonEvent();
+		selection = _vm->_gfx->hitTestDialogueBalloon(p.x, p.y);
 
 		if (selection != oldSelection) {
 			if (oldSelection != -1) {
@@ -278,7 +284,7 @@
 			}
 		}
 
-		if ((selection != -1) && (_mouseButtons == kMouseLeftUp)) {
+		if ((selection != -1) && (event == kMouseLeftUp)) {
 			break;
 		}
 

Modified: scummvm/trunk/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_br.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/exec_br.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -23,7 +23,7 @@
  *
  */
 
-
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 
 namespace Parallaction {
@@ -184,12 +184,12 @@
 
 
 DECLARE_COMMAND_OPCODE(onmouse) {
-	showCursor(true);
+	_input->showCursor(true);
 }
 
 
 DECLARE_COMMAND_OPCODE(offmouse) {
-	showCursor(false);
+	_input->showCursor(false);
 }
 
 

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -23,6 +23,7 @@
  *
  */
 
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 #include "parallaction/sound.h"
 
@@ -480,7 +481,7 @@
 		_gfx->setItemFrame(id, 0);
 	}
 
-	_inputMode = kInputModeComment;
+	_input->_inputMode = Input::kInputModeComment;
 }
 
 

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -27,6 +27,7 @@
 #include "common/file.h"
 #include "graphics/primitives.h"
 
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 
 
@@ -781,9 +782,9 @@
 	int16 _si, _di;
 
 	Common::Point	cursor;
-	_vm->getCursorPos(cursor);
+	_vm->_input->getCursorPos(cursor);
 
-	if (_vm->_activeItem._id != 0) {
+	if (_vm->_input->_activeItem._id != 0) {
 		_si = cursor.x + 16 - _floatingLabel->_cnv.w/2;
 		_di = cursor.y + 34;
 	} else {

Modified: scummvm/trunk/engines/parallaction/gui_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_br.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/gui_br.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -25,6 +25,8 @@
 
 #include "common/system.h"
 
+
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 
 namespace Parallaction {
@@ -164,15 +166,20 @@
 
 	setMousePointer(0);
 
+	uint32 event;
+	Common::Point p;
 	while (true) {
 
-		if ((_mouseButtons == kMouseLeftUp) && selectedItem >= 0)
+		_input->readInput();
+
+		event = _input->getLastButtonEvent();
+		if ((event == kMouseLeftUp) && selectedItem >= 0)
 			break;
 
-		readInput();
+		_input->getCursorPos(p);
 
-		if ((_mousePos.x > MENUITEMS_X) && (_mousePos.x < (MENUITEMS_X+MENUITEM_WIDTH)) && (_mousePos.y > MENUITEMS_Y)) {
-			selectedItem = (_mousePos.y - MENUITEMS_Y) / MENUITEM_HEIGHT;
+		if ((p.x > MENUITEMS_X) && (p.x < (MENUITEMS_X+MENUITEM_WIDTH)) && (p.y > MENUITEMS_Y)) {
+			selectedItem = (p.y - MENUITEMS_Y) / MENUITEM_HEIGHT;
 
 			if (!(selectedItem < availItems))
 				selectedItem = -1;

Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -25,6 +25,7 @@
 
 #include "common/system.h"
 
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 #include "parallaction/sound.h"
 
@@ -206,20 +207,22 @@
 	_gfx->showLabel(id[2], CENTER_LABEL_HORIZONTAL, 100);
 	_gfx->showLabel(id[3], CENTER_LABEL_HORIZONTAL, 120);
 
-	showCursor(false);
+	_input->showCursor(false);
 
 	_gfx->updateScreen();
 
-	_mouseButtons = kMouseNone;
+	_input->waitForButtonEvent(kMouseLeftUp | kMouseRightUp);
+	uint32 event = _input->getLastButtonEvent();
+/*
 	do {
-		readInput();
+		_input->readInput();
 	} while (_mouseButtons != kMouseLeftUp && _mouseButtons != kMouseRightUp);
+*/
+	_input->showCursor(true);
 
-	showCursor(true);
-
 	_gfx->freeLabels();
 
-	if (_mouseButtons != kMouseRightUp) {
+	if (event != kMouseRightUp) {
 		return START_INTRO;
 	}
 
@@ -267,11 +270,14 @@
 
 	setArrowCursor();
 
+	Common::Point p;
+
 	int selection = -1;
 	while (selection == -1) {
-		waitUntilLeftClick();
+		_input->waitUntilLeftClick();
+		_input->getCursorPos(p);
 		for (uint16 i = 0; i < 4; i++) {
-			if (blocks[i].contains(_mousePos)) {
+			if (blocks[i].contains(p)) {
 				selection = i;
 				break;
 			}
@@ -299,13 +305,19 @@
 	id0 = _gfx->createLabel(_introFont, loadGameMsg[_language], 1);
 	id1 = _gfx->createLabel(_introFont, newGameMsg[_language], 1);
 
-	_mouseButtons = kMouseNone;
-	while (_mouseButtons != kMouseLeftUp) {
+	Common::Point p;
 
-		readInput();
+	_input->readInput();
+	uint32 event = _input->getLastButtonEvent();
 
-		_si = (_mousePos.x > 160) ? 1 : 0;
+	while (event != kMouseLeftUp) {
 
+		_input->readInput();
+		_input->getCursorPos(p);
+		event = _input->getLastButtonEvent();
+
+		_si = (p.x > 160) ? 1 : 0;
+
 		if (_si != _di) {
 			if (_si != 0) {
 				// load a game
@@ -409,6 +421,8 @@
 	Graphics::Surface block;
 	block.create(BLOCK_WIDTH, BLOCK_HEIGHT, 1);
 
+	Common::Point p;
+
 	while (true) {
 
 		points[0] = 0;
@@ -422,9 +436,11 @@
 		_di = 0;
 		while (_di < PASSWORD_LEN) {
 
-			waitUntilLeftClick();
-			int _si = guiGetSelectedBlock(_mousePos);
+			_input->waitUntilLeftClick();
+			_input->getCursorPos(p);
 
+			int _si = guiGetSelectedBlock(p);
+
 			if (_si != -1) {
 				_gfx->grabBackground(codeTrueBlocks[_si], block);
 				_gfx->patchBackground(block, _di * SLOT_WIDTH + SLOT_X, SLOT_Y, false);

Added: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp	                        (rev 0)
+++ scummvm/trunk/engines/parallaction/input.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -0,0 +1,349 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/events.h"
+
+#include "parallaction/input.h"
+#include "parallaction/parallaction.h"
+#include "parallaction/debug.h"
+
+namespace Parallaction {
+
+// FIXME: the engine has 3 event loops. The following routine hosts the main one,
+// and it's called from 8 different places in the code. There exist 2 more specialised
+// loops which could possibly be merged into this one with some effort in changing
+// caller code, i.e. adding condition checks.
+//
+uint16 Input::readInput() {
+
+	Common::Event e;
+	uint16 KeyDown = 0;
+
+	_mouseButtons = kMouseNone;
+
+	Common::EventManager *eventMan = _vm->_system->getEventManager();
+	while (eventMan->pollEvent(e)) {
+
+		switch (e.type) {
+		case Common::EVENT_KEYDOWN:
+			if (e.kbd.flags == Common::KBD_CTRL && e.kbd.keycode == 'd')
+				_vm->_debugger->attach();
+			if (_vm->getFeatures() & GF_DEMO) break;
+			if (e.kbd.keycode == Common::KEYCODE_l) KeyDown = kEvLoadGame;
+			if (e.kbd.keycode == Common::KEYCODE_s) KeyDown = kEvSaveGame;
+			break;
+
+		case Common::EVENT_LBUTTONDOWN:
+			_mouseButtons = kMouseLeftDown;
+			_mousePos = e.mouse;
+			break;
+
+		case Common::EVENT_LBUTTONUP:
+			_mouseButtons = kMouseLeftUp;
+			_mousePos = e.mouse;
+			break;
+
+		case Common::EVENT_RBUTTONDOWN:
+			_mouseButtons = kMouseRightDown;
+			_mousePos = e.mouse;
+			break;
+
+		case Common::EVENT_RBUTTONUP:
+			_mouseButtons = kMouseRightUp;
+			_mousePos = e.mouse;
+			break;
+
+		case Common::EVENT_MOUSEMOVE:
+			_mousePos = e.mouse;
+			break;
+
+		case Common::EVENT_QUIT:
+			// TODO: don't quit() here, just have caller routines to check
+			// on kEngineQuit and exit gracefully to allow the engine to shut down
+			_engineFlags |= kEngineQuit;
+			g_system->quit();
+			break;
+
+		default:
+			break;
+
+		}
+
+	}
+
+	if (_vm->_debugger->isAttached())
+		_vm->_debugger->onFrame();
+
+	return KeyDown;
+
+}
+
+// FIXME: see comment for readInput()
+void Input::waitForButtonEvent(uint32 buttonEventMask) {
+
+	if (buttonEventMask == kMouseNone) {
+		_mouseButtons = kMouseNone;	// don't wait on nothing
+		return;
+	}
+
+	do {
+		readInput();
+		g_system->delayMillis(30);
+	} while ((_mouseButtons & buttonEventMask) == 0);
+
+}
+
+// FIXME: see comment for readInput()
+void Input::waitUntilLeftClick() {
+
+	do {
+		readInput();
+		_vm->_gfx->updateScreen();
+		g_system->delayMillis(30);
+	} while (_mouseButtons != kMouseLeftUp);
+
+	return;
+}
+
+void Parallaction::runGame() {
+
+	InputData *data = _input->updateInput();
+	if (data->_event != kEvNone) {
+		processInput(data);
+	}
+
+	runPendingZones();
+
+	if (_engineFlags & kEngineChangeLocation) {
+		changeLocation(_location._name);
+	}
+
+
+	_gfx->beginFrame();
+
+	if (_input->_inputMode == Input::kInputModeGame) {
+		runScripts();
+		walk();
+		drawAnimations();
+	}
+
+	// change this to endFrame?
+	updateView();
+
+}
+
+void Input::updateGameInput() {
+
+	int16 keyDown = readInput();
+
+	debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
+		!_mouseHidden,
+		(_engineFlags & kEngineBlockInput) == 0,
+		(_engineFlags & kEngineWalking) == 0,
+		(_engineFlags & kEngineChangeLocation) == 0
+	);
+
+	if ((_mouseHidden) ||
+		(_engineFlags & kEngineBlockInput) ||
+		(_engineFlags & kEngineWalking) ||
+		(_engineFlags & kEngineChangeLocation)) {
+
+		return;
+	}
+
+	if (keyDown == kEvQuitGame) {
+		_inputData._event = kEvQuitGame;
+	} else
+	if (keyDown == kEvSaveGame) {
+		_inputData._event = kEvSaveGame;
+	} else
+	if (keyDown == kEvLoadGame) {
+		_inputData._event = kEvLoadGame;
+	} else {
+		_inputData._mousePos = _mousePos;
+		_inputData._event = kEvNone;
+		if (!translateGameInput()) {
+			translateInventoryInput();
+		}
+	}
+
+}
+
+void Input::updateCommentInput() {
+	waitUntilLeftClick();
+
+	_vm->_gfx->hideDialogueStuff();
+	_vm->_gfx->setHalfbriteMode(false);
+
+	_inputMode = kInputModeGame;
+}
+
+InputData* Input::updateInput() {
+
+	_inputData._event = kEvNone;
+
+	switch (_inputMode) {
+	case kInputModeComment:
+		updateCommentInput();
+		break;
+
+	case kInputModeGame:
+		updateGameInput();
+		break;
+	}
+
+	return &_inputData;
+}
+
+bool Input::translateGameInput() {
+
+	if ((_engineFlags & kEnginePauseJobs) || (_engineFlags & kEngineInventory)) {
+		return false;
+	}
+
+	if (_actionAfterWalk) {
+		// if walking is over, then take programmed action
+		_inputData._event = kEvAction;
+		_actionAfterWalk = false;
+		return true;
+	}
+
+	if (_mouseButtons == kMouseRightDown) {
+		// right button down shows inventory
+
+		if (_vm->hitZone(kZoneYou, _mousePos.x, _mousePos.y) && (_activeItem._id != 0)) {
+			_activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
+			_engineFlags |= kEngineDragging;
+		}
+
+		_inputData._event = kEvOpenInventory;
+		_transCurrentHoverItem = -1;
+		return true;
+	}
+
+	// test if mouse is hovering on an interactive zone for the currently selected inventory item
+	ZonePtr z = _vm->hitZone(_activeItem._id, _mousePos.x, _mousePos.y);
+
+	if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((!z) || ((z->_type & 0xFFFF) != kZoneCommand))) {
+		_inputData._event = kEvWalk;
+		return true;
+	}
+
+	if ((z != _hoverZone) && (_hoverZone)) {
+		_hoverZone = nullZonePtr;
+		_inputData._event = kEvExitZone;
+		return true;
+	}
+
+	if (!z) {
+		_inputData._event = kEvNone;
+		return true;
+	}
+
+	if ((!_hoverZone) && ((z->_flags & kFlagsNoName) == 0)) {
+		_hoverZone = z;
+		_inputData._event = kEvEnterZone;
+		_inputData._label = z->_label;
+		return true;
+	}
+
+	if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || ((z->_type & 0xFFFF) == kZoneCommand))) {
+
+		_inputData._zone = z;
+		if (z->_flags & kFlagsNoWalk) {
+			// character doesn't need to walk to take specified action
+			_inputData._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
+			_inputData._event = kEvWalk;
+			_actionAfterWalk = true;
+			if (z->_moveTo.y != 0) {
+				_inputData._mousePos = z->_moveTo;
+			}
+		}
+
+		_vm->beep();
+		_vm->setArrowCursor();
+		return true;
+	}
+
+	return true;
+
+}
+
+bool Input::translateInventoryInput() {
+
+	if ((_engineFlags & kEngineInventory) == 0) {
+		return false;
+	}
+
+	// in inventory
+	int16 _si = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
+
+	if (_mouseButtons == kMouseRightUp) {
+		// right up hides inventory
+
+		_inputData._event = kEvCloseInventory;
+		_inputData._inventoryIndex = _vm->getHoverInventoryItem(_mousePos.x, _mousePos.y);
+		_vm->highlightInventoryItem(-1);			// disable
+
+		if ((_engineFlags & kEngineDragging) == 0) {
+			return true;
+		}
+
+		_engineFlags &= ~kEngineDragging;
+		ZonePtr z = _vm->hitZone(kZoneMerge, _activeItem._index, _vm->getInventoryItemIndex(_inputData._inventoryIndex));
+
+		if (z) {
+			_vm->dropItem(z->u.merge->_obj1);
+			_vm->dropItem(z->u.merge->_obj2);
+			_vm->addInventoryItem(z->u.merge->_obj3);
+			_vm->runCommands(z->_commands);
+		}
+
+		return true;
+	}
+
+	if (_si == _transCurrentHoverItem) {
+		_inputData._event = kEvNone;
+		return true;
+	}
+
+	_transCurrentHoverItem = _si;
+	_inputData._event = kEvHoverInventory;
+	_inputData._inventoryIndex = _si;
+	return true;
+
+}
+
+void Input::showCursor(bool visible) {
+	_mouseHidden = !visible;
+	_vm->_system->showMouse(visible);
+}
+
+
+} // namespace Parallaction


Property changes on: scummvm/trunk/engines/parallaction/input.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/trunk/engines/parallaction/input.h
===================================================================
--- scummvm/trunk/engines/parallaction/input.h	                        (rev 0)
+++ scummvm/trunk/engines/parallaction/input.h	2008-05-14 14:34:01 UTC (rev 32115)
@@ -0,0 +1,114 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef PARALLACTION_INPUT_H
+#define PARALLACTION_INPUT_H
+
+#include "parallaction/objects.h"
+#include "parallaction/inventory.h"
+
+namespace Parallaction {
+
+enum {
+	kMouseNone			= 0,
+	kMouseLeftUp		= 1,
+	kMouseLeftDown		= 2,
+	kMouseRightUp		= 4,
+	kMouseRightDown		= 8
+};
+
+struct InputData {
+	uint16			_event;
+	Common::Point	_mousePos;
+	int16		_inventoryIndex;
+	ZonePtr		_zone;
+	Label*			_label;
+};
+
+class Input {
+	void updateGameInput();
+	void updateCommentInput();
+
+	// input-only
+	InputData	_inputData;
+	bool		_actionAfterWalk;  // actived when the character needs to move before taking an action
+	// these two could/should be merged as they carry on the same duty in two member functions,
+	// respectively processInput and translateInput
+	int16		_transCurrentHoverItem;
+
+	InputData	*translateInput();
+	bool		translateGameInput();
+	bool		translateInventoryInput();
+
+	Parallaction	*_vm;
+
+	Common::Point	_mousePos;
+	uint16	_mouseButtons;
+
+	bool		_mouseHidden;
+
+public:
+	enum {
+		kInputModeGame = 0,
+		kInputModeComment = 1
+	};
+
+
+	Input(Parallaction *vm) : _vm(vm) {
+		_transCurrentHoverItem = 0;
+		_actionAfterWalk = false;  // actived when the character needs to move before taking an action
+		_mouseHidden = false;
+		_activeItem._index = 0;
+		_activeItem._id = 0;
+		_mouseButtons = 0;
+	}
+
+	virtual ~Input() { }
+
+
+	void		showCursor(bool visible);
+	void			getCursorPos(Common::Point& p) {
+		p = _mousePos;
+	}
+
+	int				_inputMode;
+	ZonePtr			_hoverZone;
+	InventoryItem	_activeItem;
+
+	uint16	readInput();
+	InputData* 	updateInput();
+	void 	waitUntilLeftClick();
+	void	waitForButtonEvent(uint32 buttonEventMask);
+	uint32	getLastButtonEvent() { return _mouseButtons; }
+
+	void Input::stopHovering() {
+		_hoverZone = nullZonePtr;
+	}
+
+};
+
+} // namespace Parallaction
+
+#endif


Property changes on: scummvm/trunk/engines/parallaction/input.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/parallaction/inventory.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/inventory.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -23,7 +23,7 @@
  *
  */
 
-
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 
 
@@ -52,8 +52,18 @@
 	return _inventoryRenderer->hitTest(Common::Point(x,y));
 }
 
-void Parallaction::highlightInventoryItem(ItemPosition pos, byte color) {
-	_inventoryRenderer->highlightItem(pos, color);
+void Parallaction::highlightInventoryItem(ItemPosition pos) {
+	static ItemPosition lastHighlightedPos = -1;
+
+	if (lastHighlightedPos != -1) {
+		_inventoryRenderer->highlightItem(lastHighlightedPos, 12);
+	}
+
+	if (pos != -1) {
+		_inventoryRenderer->highlightItem(pos, 19);
+	}
+
+	lastHighlightedPos = pos;
 }
 
 int Parallaction::addInventoryItem(ItemName item) {
@@ -125,9 +135,12 @@
 
 	uint16 lines = getNumLines();
 
-	_pos.x = CLIP(_vm->_mousePos.x - (INVENTORY_WIDTH / 2), 0, (int)(_vm->_screenWidth - INVENTORY_WIDTH));
-	_pos.y = CLIP(_vm->_mousePos.y - 2 - (lines * INVENTORYITEM_HEIGHT), 0, (int)(_vm->_screenHeight - lines * INVENTORYITEM_HEIGHT));
+	Common::Point p;
+	_vm->_input->getCursorPos(p);
 
+	_pos.x = CLIP(p.x - (INVENTORY_WIDTH / 2), 0, (int)(_vm->_screenWidth - INVENTORY_WIDTH));
+	_pos.y = CLIP(p.y - 2 - (lines * INVENTORYITEM_HEIGHT), 0, (int)(_vm->_screenHeight - lines * INVENTORYITEM_HEIGHT));
+
 	refresh();
 }
 

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -31,6 +31,8 @@
 #include "sound/mididrv.h"
 #include "sound/mixer.h"
 
+
+#include "parallaction/input.h"
 #include "parallaction/parallaction.h"
 #include "parallaction/debug.h"
 #include "parallaction/sound.h"
@@ -44,9 +46,6 @@
 
 // public stuff
 
-uint16	_mouseButtons = 0;
-
-
 char		_saveData1[30] = { '\0' };
 uint16		_language = 0;
 uint32		_engineFlags = 0;
@@ -67,8 +66,6 @@
 	// FIXME
 	_vm = this;
 
-	_mouseHidden = false;
-
 	Common::File::addDefaultDirectory( _gameDataPath );
 
 	Common::addSpecialDebugLevel(kDebugDialogue, "dialogue", "Dialogues debug level");
@@ -111,11 +108,6 @@
 	_objectsNames = NULL;
 	_globalTable = NULL;
 	_location._hasSound = false;
-	_transCurrentHoverItem = 0;
-	_actionAfterWalk = false;  // actived when the character needs to move before taking an action
-	_activeItem._index = 0;
-	_activeItem._id = 0;
-	_procCurrentHoverItem = -1;
 	_baseTime = 0;
 	_numLocations = 0;
 	_location._startPosition.x = -1000;
@@ -134,6 +126,8 @@
 
 	initInventory();	// needs to be pushed into subclass
 
+	_input = new Input(this);
+
 	_gfx = new Gfx(this);
 
 	_debugger = new Debugger(this);
@@ -147,111 +141,6 @@
 
 
 
-// FIXME: the engine has 3 event loops. The following routine hosts the main one,
-// and it's called from 8 different places in the code. There exist 2 more specialised
-// loops which could possibly be merged into this one with some effort in changing
-// caller code, i.e. adding condition checks.
-//
-uint16 Parallaction::readInput() {
-
-	Common::Event e;
-	uint16 KeyDown = 0;
-
-	_mouseButtons = kMouseNone;
-
-	Common::EventManager *eventMan = _system->getEventManager();
-	while (eventMan->pollEvent(e)) {
-
-		switch (e.type) {
-		case Common::EVENT_KEYDOWN:
-			if (e.kbd.flags == Common::KBD_CTRL && e.kbd.keycode == 'd')
-				_debugger->attach();
-			if (getFeatures() & GF_DEMO) break;
-			if (e.kbd.keycode == Common::KEYCODE_l) KeyDown = kEvLoadGame;
-			if (e.kbd.keycode == Common::KEYCODE_s) KeyDown = kEvSaveGame;
-			break;
-
-		case Common::EVENT_LBUTTONDOWN:
-			_mouseButtons = kMouseLeftDown;
-			_mousePos = e.mouse;
-			break;
-
-		case Common::EVENT_LBUTTONUP:
-			_mouseButtons = kMouseLeftUp;
-			_mousePos = e.mouse;
-			break;
-
-		case Common::EVENT_RBUTTONDOWN:
-			_mouseButtons = kMouseRightDown;
-			_mousePos = e.mouse;
-			break;
-
-		case Common::EVENT_RBUTTONUP:
-			_mouseButtons = kMouseRightUp;
-			_mousePos = e.mouse;
-			break;
-
-		case Common::EVENT_MOUSEMOVE:
-			_mousePos = e.mouse;
-			break;
-
-		case Common::EVENT_QUIT:
-			// TODO: don't quit() here, just have caller routines to check
-			// on kEngineQuit and exit gracefully to allow the engine to shut down
-			_engineFlags |= kEngineQuit;
-			g_system->quit();
-			break;
-
-		default:
-			break;
-
-		}
-
-	}
-
-	if (_debugger->isAttached())
-		_debugger->onFrame();
-
-	return KeyDown;
-
-}
-
-// FIXME: see comment for readInput()
-void waitUntilLeftClick() {
-
-	do {
-		_vm->readInput();
-		_vm->_gfx->updateScreen();
-		g_system->delayMillis(30);
-	} while (_mouseButtons != kMouseLeftUp);
-
-	return;
-}
-
-void Parallaction::runGame() {
-
-	updateInput();
-
-	runPendingZones();
-
-	if (_engineFlags & kEngineChangeLocation) {
-		changeLocation(_location._name);
-	}
-
-
-	_gfx->beginFrame();
-
-	if (_inputMode == kInputModeGame) {
-		runScripts();
-		walk();
-		drawAnimations();
-	}
-
-	// change this to endFrame?
-	updateView();
-
-}
-
 void Parallaction::updateView() {
 
 	if ((_engineFlags & kEnginePauseJobs) && (_engineFlags & kEngineInventory) == 0) {
@@ -264,271 +153,6 @@
 }
 
 
-void Parallaction::processInput(InputData *data) {
-
-	switch (data->_event) {
-	case kEvEnterZone:
-		debugC(2, kDebugInput, "processInput: kEvEnterZone");
-		_gfx->setFloatingLabel(data->_label);
-		break;
-
-	case kEvExitZone:
-		debugC(2, kDebugInput, "processInput: kEvExitZone");
-		_gfx->setFloatingLabel(0);
-		break;
-
-	case kEvAction:
-		debugC(2, kDebugInput, "processInput: kEvAction");
-		_procCurrentHoverItem = -1;
-		_hoverZone = nullZonePtr;
-		pauseJobs();
-		runZone(data->_zone);
-		resumeJobs();
-		break;
-
-	case kEvOpenInventory:
-		_procCurrentHoverItem = -1;
-		_hoverZone = nullZonePtr;
-		_gfx->setFloatingLabel(0);
-		if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) == 0) {
-			setArrowCursor();
-		}
-		pauseJobs();
-		openInventory();
-		break;
-
-	case kEvCloseInventory: // closes inventory and possibly select item
-		closeInventory();
-		setInventoryCursor(data->_inventoryIndex);
-		resumeJobs();
-		break;
-
-	case kEvHoverInventory:
-		highlightInventoryItem(_procCurrentHoverItem, 12);	// disable
-		highlightInventoryItem(data->_inventoryIndex, 19);						// enable
-		_procCurrentHoverItem = data->_inventoryIndex;
-		break;
-
-	case kEvWalk:
-		debugC(2, kDebugInput, "processInput: kEvWalk");
-		_hoverZone = nullZonePtr;
-		setArrowCursor();
-		_char.scheduleWalk(data->_mousePos.x, data->_mousePos.y);
-		break;
-
-	case kEvQuitGame:
-		_engineFlags |= kEngineQuit;
-		break;
-
-	case kEvSaveGame:
-		_hoverZone = nullZonePtr;
-		saveGame();
-		setArrowCursor();
-		break;
-
-	case kEvLoadGame:
-		_hoverZone = nullZonePtr;
-		loadGame();
-		setArrowCursor();
-		break;
-
-	}
-
-	return;
-}
-
-
-
-
-
-void Parallaction::updateGameInput() {
-
-	int16 keyDown = readInput();
-
-	debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
-		!_mouseHidden,
-		(_engineFlags & kEngineBlockInput) == 0,
-		(_engineFlags & kEngineWalking) == 0,
-		(_engineFlags & kEngineChangeLocation) == 0
-	);
-
-	if ((_mouseHidden) ||
-		(_engineFlags & kEngineBlockInput) ||
-		(_engineFlags & kEngineWalking) ||
-		(_engineFlags & kEngineChangeLocation)) {
-
-		return;
-	}
-
-	if (keyDown == kEvQuitGame) {
-		_input._event = kEvQuitGame;
-	} else
-	if (keyDown == kEvSaveGame) {
-		_input._event = kEvSaveGame;
-	} else
-	if (keyDown == kEvLoadGame) {
-		_input._event = kEvLoadGame;
-	} else {
-		_input._mousePos = _mousePos;
-		_input._event = kEvNone;
-		if (!translateGameInput()) {
-			translateInventoryInput();
-		}
-	}
-
-	if (_input._event != kEvNone)
-		processInput(&_input);
-
-}
-
-void Parallaction::updateCommentInput() {
-	waitUntilLeftClick();
-
-	_gfx->hideDialogueStuff();
-	_gfx->setHalfbriteMode(false);
-
-	_inputMode = kInputModeGame;
-}
-
-void Parallaction::updateInput() {
-
-	switch (_inputMode) {
-	case kInputModeComment:
-		updateCommentInput();
-		break;
-
-	case kInputModeGame:
-		updateGameInput();
-		break;
-	}
-
-	return;
-}
-
-bool Parallaction::translateGameInput() {
-
-	if ((_engineFlags & kEnginePauseJobs) || (_engineFlags & kEngineInventory)) {
-		return false;
-	}
-
-	if (_actionAfterWalk) {
-		// if walking is over, then take programmed action
-		_input._event = kEvAction;
-		_actionAfterWalk = false;
-		return true;
-	}
-
-	if (_mouseButtons == kMouseRightDown) {
-		// right button down shows inventory
-
-		if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) && (_activeItem._id != 0)) {
-			_activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
-			_engineFlags |= kEngineDragging;
-		}
-
-		_input._event = kEvOpenInventory;
-		_transCurrentHoverItem = -1;
-		return true;
-	}
-
-	// test if mouse is hovering on an interactive zone for the currently selected inventory item
-	ZonePtr z = hitZone(_activeItem._id, _mousePos.x, _mousePos.y);
-
-	if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((!z) || ((z->_type & 0xFFFF) != kZoneCommand))) {
-		_input._event = kEvWalk;
-		return true;
-	}
-
-	if ((z != _hoverZone) && (_hoverZone)) {
-		_hoverZone = nullZonePtr;
-		_input._event = kEvExitZone;
-		return true;
-	}
-
-	if (!z) {
-		_input._event = kEvNone;
-		return true;
-	}
-
-	if ((!_hoverZone) && ((z->_flags & kFlagsNoName) == 0)) {
-		_hoverZone = z;
-		_input._event = kEvEnterZone;
-		_input._label = z->_label;
-		return true;
-	}
-
-	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 true;
-	}
-
-	return true;
-
-}
-
-bool Parallaction::translateInventoryInput() {
-
-	if ((_engineFlags & kEngineInventory) == 0) {
-		return false;
-	}
-
-	// in inventory
-	int16 _si = getHoverInventoryItem(_mousePos.x, _mousePos.y);
-
-	if (_mouseButtons == kMouseRightUp) {
-		// right up hides inventory
-
-		_input._event = kEvCloseInventory;
-		_input._inventoryIndex = getHoverInventoryItem(_mousePos.x, _mousePos.y);
-		highlightInventoryItem(_transCurrentHoverItem, 12);			// disable
-
-		if ((_engineFlags & kEngineDragging) == 0) {
-			return true;
-		}
-
-		_engineFlags &= ~kEngineDragging;
-		ZonePtr z = hitZone(kZoneMerge, _activeItem._index, getInventoryItemIndex(_input._inventoryIndex));
-
-		if (z) {
-			dropItem(z->u.merge->_obj1);
-			dropItem(z->u.merge->_obj2);
-			addInventoryItem(z->u.merge->_obj3);
-			runCommands(z->_commands);
-		}
-
-		return true;
-	}
-
-	if (_si == _transCurrentHoverItem) {
-		_input._event = kEvNone;
-		return true;
-	}
-
-	_transCurrentHoverItem = _si;
-	_input._event = kEvHoverInventory;
-	_input._inventoryIndex = _si;
-	return true;
-
-}
-
-
 uint32 Parallaction::getElapsedTime() {
 	return g_system->getMillis() - _baseTime;
 }
@@ -553,13 +177,6 @@
 }
 
 
-void Parallaction::showCursor(bool visible) {
-	_mouseHidden = !visible;
-	g_system->showMouse(visible);
-}
-
-
-
 void Parallaction::freeCharacter() {
 	debugC(1, kDebugExec, "freeCharacter()");
 
@@ -684,9 +301,78 @@
 }
 
 
+void Parallaction::processInput(InputData *data) {
 
+	switch (data->_event) {
+	case kEvEnterZone:
+		debugC(2, kDebugInput, "processInput: kEvEnterZone");
+		_gfx->setFloatingLabel(data->_label);
+		break;
 
+	case kEvExitZone:
+		debugC(2, kDebugInput, "processInput: kEvExitZone");
+		_gfx->setFloatingLabel(0);
+		break;
 
+	case kEvAction:
+		debugC(2, kDebugInput, "processInput: kEvAction");
+		_input->stopHovering();
+		pauseJobs();
+		runZone(data->_zone);
+		resumeJobs();
+		break;
+
+	case kEvOpenInventory:
+		_input->stopHovering();
+		_gfx->setFloatingLabel(0);
+		if (hitZone(kZoneYou, data->_mousePos.x, data->_mousePos.y) == 0) {
+			setArrowCursor();
+		}
+		pauseJobs();
+		openInventory();
+		break;
+
+	case kEvCloseInventory: // closes inventory and possibly select item
+		closeInventory();
+		setInventoryCursor(data->_inventoryIndex);
+		resumeJobs();
+		break;
+
+	case kEvHoverInventory:
+		highlightInventoryItem(data->_inventoryIndex);						// enable
+		break;
+
+	case kEvWalk:
+		debugC(2, kDebugInput, "processInput: kEvWalk");
+		_input->stopHovering();
+		setArrowCursor();
+		_char.scheduleWalk(data->_mousePos.x, data->_mousePos.y);
+		break;
+
+	case kEvQuitGame:
+		_engineFlags |= kEngineQuit;
+		break;
+
+	case kEvSaveGame:
+		_input->stopHovering();
+		saveGame();
+		setArrowCursor();
+		break;
+
+	case kEvLoadGame:
+		_input->stopHovering();
+		loadGame();
+		setArrowCursor();
+		break;
+
+	}
+
+	return;
+}
+
+
+
+
 //	displays transition before a new location
 //
 //	clears screen (in white??)
@@ -716,7 +402,7 @@
 	_gfx->updateScreen();
 
 	showLocationComment(_location._comment, false);
-	waitUntilLeftClick();
+	_input->waitUntilLeftClick();
 	_gfx->freeBalloons();
 
 	// fades maximum intensity palette towards approximation of main palette

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-05-14 14:34:01 UTC (rev 32115)
@@ -33,6 +33,7 @@
 
 #include "engines/engine.h"
 
+#include "parallaction/input.h"
 #include "parallaction/inventory.h"
 #include "parallaction/parser.h"
 #include "parallaction/objects.h"
@@ -96,14 +97,6 @@
 	kPriority21 = 21
 };
 
-enum {
-	kMouseNone			= 0,
-	kMouseLeftUp		= 1,
-	kMouseLeftDown		= 2,
-	kMouseRightUp		= 3,
-	kMouseRightDown		= 4
-};
-
 enum EngineFlags {
 	kEngineQuit			= (1 << 0),
 	kEnginePauseJobs	= (1 << 1),
@@ -163,7 +156,6 @@
 extern const char	*_minidrkiName;
 
 
-void waitUntilLeftClick();
 
 
 
@@ -171,8 +163,8 @@
 class Debugger;
 class Gfx;
 class SoundMan;
+class Input;
 
-
 struct Location {
 
 	Common::Point	_startPosition;
@@ -246,7 +238,6 @@
 
 
 
-
 #define DECLARE_UNQUALIFIED_COMMAND_OPCODE(op) void cmdOp_##op()
 #define DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(op) void instOp_##op()
 
@@ -266,21 +257,10 @@
 	virtual bool loadGame() = 0;
 	virtual bool saveGame() = 0;
 
-	uint16		readInput();
-	void		updateInput();
+	Input	*_input;
 
 	void		waitTime(uint32 t);
 
-	enum {
-		kInputModeGame = 0,
-		kInputModeComment = 1
-	};
-
-	int		_inputMode;
-
-	void updateGameInput();
-	void updateCommentInput();
-
 	OpcodeSet	_commandOpcodes;
 
 	struct ParallactionStruct1 {
@@ -298,9 +278,8 @@
 		bool		suspend;
 	} _instRunCtxt;
 
+	void		processInput(InputData* data);
 
-	void		showCursor(bool visible);
-
 	void		pauseJobs();
 	void		resumeJobs();
 
@@ -363,13 +342,6 @@
 	uint16			_numLocations;
 	Location		_location;
 
-	InventoryItem	_activeItem;
-
-	Common::Point	_mousePos;
-	void			getCursorPos(Common::Point& p) {
-		p = _mousePos;
-	}
-
 	ZonePtr			_activeZone;
 
 
@@ -380,38 +352,16 @@
 
 	Common::RandomSource _rnd;
 
-protected:		// data
-
 	Debugger	*_debugger;
 
-	struct InputData {
-		uint16			_event;
-		Common::Point	_mousePos;
-		int16		_inventoryIndex;
-		ZonePtr		_zone;
-		Label*			_label;
-	};
 
-	bool		_mouseHidden;
-
-	// input-only
-	InputData	_input;
-	bool		_actionAfterWalk;  // actived when the character needs to move before taking an action
-
-	// these two could/should be merged as they carry on the same duty in two member functions,
-	// respectively processInput and translateInput
-	int16		_procCurrentHoverItem;
-	int16		_transCurrentHoverItem;
-
+protected:		// data
 	uint32		_baseTime;
 	char		_characterName1[50];	// only used in changeCharacter
 
 	Common::String	_saveFileName;
 
 
-	ZonePtr		_hoverZone;
-
-
 protected:		// members
 	bool detectGame(void);
 
@@ -421,12 +371,6 @@
 	uint32		getElapsedTime();
 	void		resetTimer();
 
-	InputData	*translateInput();
-	bool		translateGameInput();
-	bool		translateInventoryInput();
-	void		processInput(InputData*);
-
-
 	void		scheduleLocationSwitch(const char *location);
 	void		doLocationEnterTransition();
 	virtual void changeLocation(char *location) = 0;
@@ -468,7 +412,7 @@
 	const char **_callableNamesRes;
 	const char **_instructionNamesRes;
 
-	void highlightInventoryItem(ItemPosition pos, byte color);
+	void highlightInventoryItem(ItemPosition pos);
 	int16 getHoverInventoryItem(int16 x, int16 y);
 	int addInventoryItem(ItemName item);
 	int addInventoryItem(ItemName item, uint32 value);

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -27,6 +27,7 @@
 #include "common/util.h"
 
 #include "parallaction/parallaction.h"
+#include "parallaction/input.h"
 #include "parallaction/sound.h"
 
 namespace Parallaction {
@@ -108,7 +109,7 @@
 
 //		initCharacter();
 
-		_inputMode = kInputModeGame;
+		_input->_inputMode = Input::kInputModeGame;
 		while ((_engineFlags & (kEngineReturn | kEngineQuit)) == 0) {
 			runGame();
 		}

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-05-14 14:07:56 UTC (rev 32114)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-05-14 14:34:01 UTC (rev 32115)
@@ -28,6 +28,7 @@
 #include "common/config-manager.h"
 
 #include "parallaction/parallaction.h"
+#include "parallaction/input.h"
 #include "parallaction/sound.h"
 
 
@@ -191,7 +192,7 @@
 
 	// this stuff is needed to avoid artifacts with labels and selected items when switching cursors
 	_gfx->setFloatingLabel(0);
-	_activeItem._id = 0;
+	_input->_activeItem._id = 0;
 
 	_system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0);
 	_system->showMouse(true);
@@ -207,7 +208,7 @@
 	if (item->_index == 0)
 		return;
 
-	_activeItem._id = item->_id;
+	_input->_activeItem._id = item->_id;
 
 	byte *v8 = _mouseComposedArrow->getData(0);
 
@@ -243,7 +244,7 @@
 
 	changeLocation(_location._name);
 
-	_inputMode = kInputModeGame;
+	_input->_inputMode = Input::kInputModeGame;
 	while ((_engineFlags & kEngineQuit) == 0) {
 		runGame();
 	}
@@ -298,7 +299,7 @@
 	_gfx->setFloatingLabel(0);
 	_gfx->freeLabels();
 
-	_hoverZone = nullZonePtr;
+	_input->_hoverZone = nullZonePtr;
 	if (_engineFlags & kEngineBlockInput) {
 		setArrowCursor();
 	}
@@ -314,7 +315,7 @@
 		showSlide(locname.slide());
 		uint id = _gfx->createLabel(_menuFont, _location._slideText[0], 1);
 		_gfx->showLabel(id, CENTER_LABEL_HORIZONTAL, 14);
-		waitUntilLeftClick();
+		_input->waitUntilLeftClick();
 		_gfx->freeLabels();
 		freeBackground();
 	}


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