mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-10 21:03:31 +00:00
STARK: Move event processing to the end of the game loop
Previously, clicking before a location was loaded would crash
This commit is contained in:
parent
8f81e7e6f0
commit
01fda9348b
@ -176,42 +176,6 @@ void StarkEngine::setStartupLocation() {
|
||||
|
||||
void StarkEngine::mainLoop() {
|
||||
while (!shouldQuit()) {
|
||||
// Process events
|
||||
Common::Event e;
|
||||
while (g_system->getEventManager()->pollEvent(e)) {
|
||||
// Handle any buttons, keys and joystick operations
|
||||
if (e.type == Common::EVENT_KEYDOWN) {
|
||||
if (e.kbd.ascii == 'q') {
|
||||
quitGame();
|
||||
break;
|
||||
} else if (e.kbd.keycode == Common::KEYCODE_d) {
|
||||
if (e.kbd.flags & Common::KBD_CTRL) {
|
||||
_console->attach();
|
||||
_console->onFrame();
|
||||
}
|
||||
} else if (e.kbd.keycode == Common::KEYCODE_ESCAPE) {
|
||||
_gameInterface->skipCurrentSpeeches();
|
||||
// Quick-hack for now.
|
||||
_userInterface->skipFMV();
|
||||
} else {
|
||||
//handleChars(event.type, event.kbd.keycode, event.kbd.flags, event.kbd.ascii);
|
||||
}
|
||||
|
||||
} else if (e.type == Common::EVENT_LBUTTONUP) {
|
||||
// Do nothing for now
|
||||
} else if (e.type == Common::EVENT_MOUSEMOVE) {
|
||||
_userInterface->handleMouseMove(e.mouse);
|
||||
} else if (e.type == Common::EVENT_LBUTTONDOWN) {
|
||||
_userInterface->handleClick();
|
||||
if (_system->getMillis() - _lastClickTime < _doubleClickDelay) {
|
||||
_userInterface->handleDoubleClick();
|
||||
}
|
||||
_lastClickTime = _system->getMillis();
|
||||
} else if (e.type == Common::EVENT_RBUTTONDOWN) {
|
||||
_userInterface->handleRightClick();
|
||||
}
|
||||
}
|
||||
|
||||
if (_resourceProvider->hasLocationChangeRequest()) {
|
||||
_resourceProvider->performLocationChange();
|
||||
}
|
||||
@ -219,6 +183,8 @@ void StarkEngine::mainLoop() {
|
||||
updateDisplayScene();
|
||||
g_system->delayMillis(10);
|
||||
|
||||
processEvents();
|
||||
|
||||
if (_userInterface->shouldExit()) {
|
||||
quitGame();
|
||||
break;
|
||||
@ -226,6 +192,38 @@ void StarkEngine::mainLoop() {
|
||||
}
|
||||
}
|
||||
|
||||
void StarkEngine::processEvents() {
|
||||
Common::Event e;
|
||||
while (g_system->getEventManager()->pollEvent(e)) {
|
||||
// Handle any buttons, keys and joystick operations
|
||||
if (e.type == Common::EVENT_KEYDOWN) {
|
||||
if (e.kbd.keycode == Common::KEYCODE_d) {
|
||||
if (e.kbd.flags & Common::KBD_CTRL) {
|
||||
_console->attach();
|
||||
_console->onFrame();
|
||||
}
|
||||
} else if (e.kbd.keycode == Common::KEYCODE_ESCAPE) {
|
||||
_gameInterface->skipCurrentSpeeches();
|
||||
// Quick-hack for now.
|
||||
_userInterface->skipFMV();
|
||||
}
|
||||
|
||||
} else if (e.type == Common::EVENT_LBUTTONUP) {
|
||||
// Do nothing for now
|
||||
} else if (e.type == Common::EVENT_MOUSEMOVE) {
|
||||
_userInterface->handleMouseMove(e.mouse);
|
||||
} else if (e.type == Common::EVENT_LBUTTONDOWN) {
|
||||
_userInterface->handleClick();
|
||||
if (_system->getMillis() - _lastClickTime < _doubleClickDelay) {
|
||||
_userInterface->handleDoubleClick();
|
||||
}
|
||||
_lastClickTime = _system->getMillis();
|
||||
} else if (e.type == Common::EVENT_RBUTTONDOWN) {
|
||||
_userInterface->handleRightClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StarkEngine::updateDisplayScene() {
|
||||
// Get frame delay
|
||||
static uint32 lastFrame = g_system->getMillis();
|
||||
|
@ -73,6 +73,7 @@ protected:
|
||||
private:
|
||||
void mainLoop();
|
||||
void updateDisplayScene();
|
||||
void processEvents();
|
||||
void setStartupLocation();
|
||||
bool isDemo();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user