[Scummvm-cvs-logs] SF.net SVN: scummvm:[33225] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Wed Jul 23 09:31:36 CEST 2008
Revision: 33225
http://scummvm.svn.sourceforge.net/scummvm/?rev=33225&view=rev
Author: peres001
Date: 2008-07-23 07:31:35 +0000 (Wed, 23 Jul 2008)
Log Message:
-----------
Removed useless event management code and made readInput() more general.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/input.cpp
scummvm/trunk/engines/parallaction/input.h
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
Modified: scummvm/trunk/engines/parallaction/input.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/input.cpp 2008-07-23 02:45:09 UTC (rev 33224)
+++ scummvm/trunk/engines/parallaction/input.cpp 2008-07-23 07:31:35 UTC (rev 33225)
@@ -36,25 +36,23 @@
// loops which could possibly be merged into this one with some effort in changing
// caller code, i.e. adding condition checks.
//
-uint16 Input::readInput() {
+void Input::readInput() {
Common::Event e;
- uint16 KeyDown = 0;
_mouseButtons = kMouseNone;
- _lastKeyDownAscii = -1;
+ _hasKeyPressEvent = false;
Common::EventManager *eventMan = _vm->_system->getEventManager();
while (eventMan->pollEvent(e)) {
switch (e.type) {
case Common::EVENT_KEYDOWN:
- _lastKeyDownAscii = e.kbd.ascii;
+ _hasKeyPressEvent = true;
+ _keyPressed = e.kbd;
+
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:
@@ -83,7 +81,7 @@
case Common::EVENT_QUIT:
_engineFlags |= kEngineQuit;
- return KeyDown;
+ return;
default:
break;
@@ -95,13 +93,13 @@
if (_vm->_debugger->isAttached())
_vm->_debugger->onFrame();
- return KeyDown;
+ return;
}
bool Input::getLastKeyDown(uint16 &ascii) {
- ascii = _lastKeyDownAscii;
- return (_lastKeyDownAscii != -1);
+ ascii = _keyPressed.ascii;
+ return (_hasKeyPressEvent);
}
// FIXME: see comment for readInput()
@@ -143,7 +141,7 @@
void Input::updateGameInput() {
- int16 keyDown = readInput();
+ readInput();
debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
!_mouseHidden,
@@ -160,17 +158,13 @@
return;
}
- if (keyDown == kEvQuitGame) {
- _inputData._event = kEvQuitGame;
- } else
- if (keyDown == kEvSaveGame) {
- _inputData._event = kEvSaveGame;
- } else
- if (keyDown == kEvLoadGame) {
- _inputData._event = kEvLoadGame;
- } else {
+ if (_hasKeyPressEvent && (_vm->getFeatures() & GF_DEMO) == 0) {
+ if (_keyPressed.keycode == Common::KEYCODE_l) _inputData._event = kEvLoadGame;
+ if (_keyPressed.keycode == Common::KEYCODE_s) _inputData._event = kEvSaveGame;
+ }
+
+ if (_inputData._event == kEvNone) {
_inputData._mousePos = _mousePos;
- _inputData._event = kEvNone;
translateGameInput();
}
Modified: scummvm/trunk/engines/parallaction/input.h
===================================================================
--- scummvm/trunk/engines/parallaction/input.h 2008-07-23 02:45:09 UTC (rev 33224)
+++ scummvm/trunk/engines/parallaction/input.h 2008-07-23 07:31:35 UTC (rev 33225)
@@ -26,6 +26,8 @@
#ifndef PARALLACTION_INPUT_H
#define PARALLACTION_INPUT_H
+#include "common/keyboard.h"
+
#include "parallaction/objects.h"
#include "parallaction/inventory.h"
@@ -53,6 +55,9 @@
// input-only
InputData _inputData;
+ bool _hasKeyPressEvent;
+ Common::KeyState _keyPressed;
+
bool _hasDelayedAction; // actived when the character needs to move before taking an action
ZonePtr _delayedActionZone;
@@ -68,7 +73,6 @@
Common::Point _mousePos;
uint16 _mouseButtons;
- int32 _lastKeyDownAscii;
bool _mouseHidden;
ZonePtr _hoverZone;
@@ -106,7 +110,7 @@
int _inputMode;
InventoryItem _activeItem;
- uint16 readInput();
+ void readInput();
InputData* updateInput();
void trackMouse(ZonePtr z);
void waitUntilLeftClick();
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2008-07-23 02:45:09 UTC (rev 33224)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2008-07-23 07:31:35 UTC (rev 33225)
@@ -297,6 +297,9 @@
void Parallaction::processInput(InputData *data) {
+ if (!data) {
+ return;
+ }
switch (data->_event) {
case kEvSaveGame:
@@ -326,13 +329,7 @@
runCommentFrame();
if (_input->_inputMode == Input::kInputModeGame) {
- if (data->_event != kEvNone) {
- processInput(data);
- }
-
- if (_engineFlags & kEngineQuit)
- return;
-
+ processInput(data);
runPendingZones();
if (_engineFlags & kEngineQuit)
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2008-07-23 02:45:09 UTC (rev 33224)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2008-07-23 07:31:35 UTC (rev 33225)
@@ -114,12 +114,6 @@
enum {
kEvNone = 0,
- kEvAction = 3,
- kEvOpenInventory = 4,
- kEvCloseInventory = 5,
- kEvHoverInventory = 6,
- kEvWalk = 7,
- kEvQuitGame = 1000,
kEvSaveGame = 2000,
kEvLoadGame = 4000
};
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