* Cleanup of input code.

* Removed old timer routines.

svn-id: r32135
This commit is contained in:
Nicola Mettifogo 2008-05-15 01:18:26 +00:00
parent e4c11fa635
commit 765f976008
7 changed files with 49 additions and 78 deletions

View File

@ -468,7 +468,6 @@ void Parallaction_ns::_c_endIntro(void *parm) {
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);
@ -479,14 +478,7 @@ void Parallaction_ns::_c_endIntro(void *parm) {
_gfx->updateScreen();
for (uint16 v2 = 0; v2 < 100; v2++) {
_input->readInput();
event = _input->getLastButtonEvent();
if (event == kMouseLeftUp)
break;
waitTime( 1 );
}
_input->waitForButtonEvent(kMouseLeftUp, 5500);
_gfx->freeLabels();
}

View File

@ -213,11 +213,7 @@ int Parallaction_ns::guiNewGame() {
_input->waitForButtonEvent(kMouseLeftUp | kMouseRightUp);
uint32 event = _input->getLastButtonEvent();
/*
do {
_input->readInput();
} while (_mouseButtons != kMouseLeftUp && _mouseButtons != kMouseRightUp);
*/
_input->showCursor(true);
_gfx->freeLabels();

View File

@ -83,7 +83,7 @@ uint16 Input::readInput() {
// 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();
_vm->_system->quit();
break;
default:
@ -101,17 +101,26 @@ uint16 Input::readInput() {
}
// FIXME: see comment for readInput()
void Input::waitForButtonEvent(uint32 buttonEventMask) {
void Input::waitForButtonEvent(uint32 buttonEventMask, int32 timeout) {
if (buttonEventMask == kMouseNone) {
_mouseButtons = kMouseNone; // don't wait on nothing
return;
}
do {
readInput();
g_system->delayMillis(30);
} while ((_mouseButtons & buttonEventMask) == 0);
const int32 LOOP_RESOLUTION = 30;
if (timeout <= 0) {
do {
readInput();
_vm->_system->delayMillis(LOOP_RESOLUTION);
} while ((_mouseButtons & buttonEventMask) == 0);
} else {
do {
readInput();
_vm->_system->delayMillis(LOOP_RESOLUTION);
timeout -= LOOP_RESOLUTION;
} while ((timeout > 0) && (_mouseButtons & buttonEventMask) == 0);
}
}
@ -121,38 +130,12 @@ void Input::waitUntilLeftClick() {
do {
readInput();
_vm->_gfx->updateScreen();
g_system->delayMillis(30);
_vm->_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() {

View File

@ -68,6 +68,7 @@ class Input {
uint16 _mouseButtons;
bool _mouseHidden;
ZonePtr _hoverZone;
public:
enum {
@ -94,13 +95,12 @@ public:
}
int _inputMode;
ZonePtr _hoverZone;
InventoryItem _activeItem;
uint16 readInput();
InputData* updateInput();
void waitUntilLeftClick();
void waitForButtonEvent(uint32 buttonEventMask);
void waitForButtonEvent(uint32 buttonEventMask, int32 timeout = -1);
uint32 getLastButtonEvent() { return _mouseButtons; }
void stopHovering() {

View File

@ -153,29 +153,6 @@ void Parallaction::updateView() {
}
uint32 Parallaction::getElapsedTime() {
return g_system->getMillis() - _baseTime;
}
void Parallaction::resetTimer() {
_baseTime = g_system->getMillis();
return;
}
void Parallaction::waitTime(uint32 t) {
uint32 v4 = 0;
while (v4 < t * (1000 / 18.2)) {
v4 = getElapsedTime();
}
resetTimer();
return;
}
void Parallaction::freeCharacter() {
debugC(1, kDebugExec, "freeCharacter()");
@ -370,6 +347,33 @@ void Parallaction::processInput(InputData *data) {
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();
}
@ -409,8 +413,8 @@ void Parallaction::doLocationEnterTransition() {
for (uint16 _si = 0; _si<6; _si++) {
pal.fadeTo(_gfx->_palette, 4);
_gfx->setPalette(pal);
waitTime( 1 );
_gfx->updateScreen();
g_system->delayMillis(20);
}
_gfx->setPalette(_gfx->_palette);

View File

@ -259,8 +259,6 @@ public:
Input *_input;
void waitTime(uint32 t);
OpcodeSet _commandOpcodes;
struct ParallactionStruct1 {
@ -368,8 +366,6 @@ protected: // members
void initGlobals();
void runGame();
void updateView();
uint32 getElapsedTime();
void resetTimer();
void scheduleLocationSwitch(const char *location);
void doLocationEnterTransition();

View File

@ -299,7 +299,7 @@ void Parallaction_ns::changeLocation(char *location) {
_gfx->setFloatingLabel(0);
_gfx->freeLabels();
_input->_hoverZone = nullZonePtr;
_input->stopHovering();
if (_engineFlags & kEngineBlockInput) {
setArrowCursor();
}