diff options
author | Christopher Page | 2008-06-25 00:55:18 +0000 |
---|---|---|
committer | Christopher Page | 2008-06-25 00:55:18 +0000 |
commit | 6e3474896cec0e42c2f5ac7ccb5783981d746fcc (patch) | |
tree | 60d70df6441d3d1084853fbe18e7bccc8bad29db /engines/lure | |
parent | c14804e22f5171e6aa7b2cf5d383a4e28180aa7a (diff) | |
download | scummvm-rg350-6e3474896cec0e42c2f5ac7ccb5783981d746fcc.tar.gz scummvm-rg350-6e3474896cec0e42c2f5ac7ccb5783981d746fcc.tar.bz2 scummvm-rg350-6e3474896cec0e42c2f5ac7ccb5783981d746fcc.zip |
Kyra and Lure are now using the new _quit flag
svn-id: r32772
Diffstat (limited to 'engines/lure')
-rw-r--r-- | engines/lure/events.cpp | 14 | ||||
-rw-r--r-- | engines/lure/events.h | 2 | ||||
-rw-r--r-- | engines/lure/fights.cpp | 7 | ||||
-rw-r--r-- | engines/lure/game.cpp | 14 | ||||
-rw-r--r-- | engines/lure/intro.cpp | 2 | ||||
-rw-r--r-- | engines/lure/lure.cpp | 8 | ||||
-rw-r--r-- | engines/lure/menu.cpp | 6 | ||||
-rw-r--r-- | engines/lure/scripts.cpp | 6 | ||||
-rw-r--r-- | engines/lure/surface.cpp | 14 |
9 files changed, 43 insertions, 30 deletions
diff --git a/engines/lure/events.cpp b/engines/lure/events.cpp index 30e0e571b7..3d093365f6 100644 --- a/engines/lure/events.cpp +++ b/engines/lure/events.cpp @@ -29,6 +29,7 @@ #include "graphics/cursorman.h" #include "lure/events.h" +#include "lure/lure.h" #include "lure/res.h" namespace Lure { @@ -137,11 +138,12 @@ void Mouse::setPosition(int newX, int newY) { void Mouse::waitForRelease() { Events &e = Events::getReference(); + LureEngine &engine = LureEngine::getReference(); do { - while (e.pollEvent() && !e.quitFlag) ; + while (e.pollEvent() && !engine._quit) ; g_system->delayMillis(20); - } while (!e.quitFlag && (lButton() || rButton() || mButton())); + } while (!engine._quit && (lButton() || rButton() || mButton())); } /*--------------------------------------------------------------------------*/ @@ -150,7 +152,6 @@ static Events *int_events = NULL; Events::Events() { int_events = this; - quitFlag = false; } Events &Events::getReference() { @@ -159,12 +160,14 @@ Events &Events::getReference() { bool Events::pollEvent() { + LureEngine &engine = LureEngine::getReference(); + if (!g_system->getEventManager()->pollEvent(_event)) return false; // Handle keypress switch (_event.type) { case Common::EVENT_QUIT: - quitFlag = true; + engine._quit = true; break; case Common::EVENT_LBUTTONDOWN: @@ -210,10 +213,11 @@ void Events::waitForPress() { bool Events::interruptableDelay(uint32 milliseconds) { Events &events = Events::getReference(); + LureEngine &engine = LureEngine::getReference(); uint32 delayCtr = g_system->getMillis() + milliseconds; while (g_system->getMillis() < delayCtr) { - if (events.quitFlag) return true; + if (engine._quit) return true; if (events.pollEvent()) { if (((events.type() == Common::EVENT_KEYDOWN) && (events.event().kbd.ascii != 0)) || diff --git a/engines/lure/events.h b/engines/lure/events.h index d1246f95d8..f04072aa0f 100644 --- a/engines/lure/events.h +++ b/engines/lure/events.h @@ -66,8 +66,6 @@ class Events { private: Common::Event _event; public: - bool quitFlag; - Events(); static Events &getReference(); diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp index dcf09ba50d..5323122fa6 100644 --- a/engines/lure/fights.cpp +++ b/engines/lure/fights.cpp @@ -22,6 +22,7 @@ #include "lure/fights.h" #include "lure/luredefs.h" #include "lure/game.h" +#include "lure/lure.h" #include "lure/res.h" #include "lure/room.h" #include "lure/sound.h" @@ -108,6 +109,7 @@ bool FightsManager::isFighting() { } void FightsManager::fightLoop() { + LureEngine &engine = LureEngine::getReference(); Resources &res = Resources::getReference(); Game &game = Game::getReference(); Room &room = Room::getReference(); @@ -116,7 +118,7 @@ void FightsManager::fightLoop() { uint32 timerVal = g_system->getMillis(); // Loop for the duration of the battle - while (!events.quitFlag && (playerFight.fwhits != GENERAL_MAGIC_ID)) { + while (!engine._quit && (playerFight.fwhits != GENERAL_MAGIC_ID)) { checkEvents(); if (g_system->getMillis() > timerVal + GAME_FRAME_DELAY) { @@ -184,6 +186,7 @@ const KeyMapping keyList[] = { {Common::KEYCODE_INVALID, 0}}; void FightsManager::checkEvents() { + LureEngine &engine = LureEngine::getReference(); Game &game = Game::getReference(); Events &events = Events::getReference(); Mouse &mouse = Mouse::getReference(); @@ -196,7 +199,7 @@ void FightsManager::checkEvents() { if (events.type() == Common::EVENT_KEYDOWN) { switch (events.event().kbd.keycode) { case Common::KEYCODE_ESCAPE: - events.quitFlag = true; + engine._quit = true; return; case Common::KEYCODE_d: diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp index f9b31c21c5..e8ac2ead88 100644 --- a/engines/lure/game.cpp +++ b/engines/lure/game.cpp @@ -23,10 +23,10 @@ * */ -#include "lure/lure.h" #include "lure/game.h" #include "lure/animseq.h" #include "lure/fights.h" +#include "lure/lure.h" #include "lure/res_struct.h" #include "lure/room.h" #include "lure/scripts.h" @@ -125,6 +125,7 @@ void Game::nextFrame() { void Game::execute() { OSystem &system = *g_system; + LureEngine &engine = LureEngine::getReference(); Room &room = Room::getReference(); Resources &res = Resources::getReference(); Events &events = Events::getReference(); @@ -142,7 +143,7 @@ void Game::execute() { setState(GS_RESTART); bool initialRestart = true; - while (!events.quitFlag) { + while (!engine._quit) { if ((_state & GS_RESTART) != 0) { res.reset(); @@ -162,7 +163,7 @@ void Game::execute() { mouse.cursorOn(); // Main game loop - while (!events.quitFlag && ((_state & GS_RESTART) == 0)) { + while (!engine._quit && ((_state & GS_RESTART) == 0)) { // If time for next frame, allow everything to update if (system.getMillis() > timerVal + GAME_FRAME_DELAY) { timerVal = system.getMillis(); @@ -294,7 +295,7 @@ void Game::execute() { } else if ((_state & GS_RESTART) == 0) // Exiting game - events.quitFlag = true; + engine._quit = true; } } @@ -892,7 +893,7 @@ void Game::doShowCredits() { void Game::doQuit() { Sound.pause(); if (getYN()) - Events::getReference().quitFlag = true; + LureEngine::getReference()._quit = true; Sound.resume(); } @@ -977,6 +978,7 @@ bool Game::getYN() { Events &events = Events::getReference(); Screen &screen = Screen::getReference(); Resources &res = Resources::getReference(); + LureEngine &engine = LureEngine::getReference(); Common::Language l = LureEngine::getReference().getLanguage(); Common::KeyCode y = Common::KEYCODE_y; @@ -1018,7 +1020,7 @@ bool Game::getYN() { } g_system->delayMillis(10); - } while (!events.quitFlag && !breakFlag); + } while (!engine._quit && !breakFlag); screen.update(); if (!vKbdFlag) diff --git a/engines/lure/intro.cpp b/engines/lure/intro.cpp index 4d3e172dc5..a21ac27266 100644 --- a/engines/lure/intro.cpp +++ b/engines/lure/intro.cpp @@ -65,7 +65,7 @@ bool Introduction::showScreen(uint16 screenId, uint16 paletteId, uint16 delaySiz else screen.paletteFadeIn(&p); bool result = interruptableDelay(delaySize); - if (events.quitFlag) return true; + if (LureEngine::getReference()._quit) return true; if (!isEGA) screen.paletteFadeOut(); diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index ea760ddb4f..d20071691f 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -126,8 +126,8 @@ int LureEngine::go() { CopyProtectionDialog *dialog = new CopyProtectionDialog(); bool result = dialog->show(); delete dialog; - if (_events->quitFlag) - return 0; + if (_quit) + return _rtl; if (!result) error("Sorry - copy protection failed"); @@ -145,14 +145,14 @@ int LureEngine::go() { } // Play the game - if (!_events->quitFlag) { + if (!_quit) { // Play the game Sound.loadSection(Sound.isRoland() ? ROLAND_MAIN_SOUND_RESOURCE_ID : ADLIB_MAIN_SOUND_RESOURCE_ID); gameInstance->execute(); } delete gameInstance; - return 0; + return _rtl; } void LureEngine::pauseEngineIntern(bool pause) { diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp index 0b4ef06081..3468e49582 100644 --- a/engines/lure/menu.cpp +++ b/engines/lure/menu.cpp @@ -116,6 +116,7 @@ Menu &Menu::getReference() { uint8 Menu::execute() { OSystem &system = *g_system; + LureEngine &engine = LureEngine::getReference(); Mouse &mouse = Mouse::getReference(); Events &events = Events::getReference(); Screen &screen = Screen::getReference(); @@ -130,7 +131,7 @@ uint8 Menu::execute() { while (mouse.lButton() || mouse.rButton()) { while (events.pollEvent()) { - if (events.quitFlag) return MENUITEM_NONE; + if (engine._quit) return MENUITEM_NONE; if (mouse.y() < MENUBAR_Y_SIZE) { MenuRecord *p = getMenuAt(mouse.x()); @@ -467,6 +468,7 @@ Action PopupMenu::Show(int numEntries, Action *actions) { uint16 PopupMenu::Show(int numEntries, const char *actions[]) { if (numEntries == 0) return 0xffff; + LureEngine &engine = LureEngine::getReference(); Events &e = Events::getReference(); Mouse &mouse = Mouse::getReference(); OSystem &system = *g_system; @@ -545,7 +547,7 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { } while (e.pollEvent()) { - if (e.quitFlag) { + if (engine._quit) { selectedIndex = 0xffff; goto bail_out; diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp index 7490f05b24..9a459616ed 100644 --- a/engines/lure/scripts.cpp +++ b/engines/lure/scripts.cpp @@ -26,6 +26,7 @@ #include "lure/animseq.h" #include "lure/fights.h" #include "lure/game.h" +#include "lure/lure.h" #include "lure/res.h" #include "lure/room.h" #include "lure/screen.h" @@ -190,6 +191,7 @@ void Script::addSound(uint16 soundIndex, uint16 v2, uint16 v3) { } void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) { + LureEngine &engine = LureEngine::getReference(); Screen &screen = Screen::getReference(); Mouse &mouse = Mouse::getReference(); Events &events = Events::getReference(); @@ -219,7 +221,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) { anim->show(); if (!events.interruptableDelay(30000)) { // No key yet pressed, so keep waiting - while (Sound.musicInterface_CheckPlaying(6) && !events.quitFlag) { + while (Sound.musicInterface_CheckPlaying(6) && !engine._quit) { if (events.interruptableDelay(20)) break; } @@ -227,7 +229,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) { delete anim; screen.paletteFadeOut(); - events.quitFlag = true; + engine._quit = true; } // Setup the pig fight in the cave diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp index 64394545d1..1d18344358 100644 --- a/engines/lure/surface.cpp +++ b/engines/lure/surface.cpp @@ -506,6 +506,7 @@ Surface *Surface::getScreen(uint16 resourceId) { bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool varLength, int16 x, int16 y) { OSystem &system = *g_system; + LureEngine &engine = LureEngine::getReference(); Mouse &mouse = Mouse::getReference(); Events &events = Events::getReference(); Screen &screen = Screen::getReference(); @@ -533,7 +534,7 @@ bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool // Loop until the input string changes refreshFlag = false; while (!refreshFlag && !abortFlag) { - abortFlag = events.quitFlag; + abortFlag = engine._quit; if (abortFlag) break; while (events.pollEvent()) { @@ -975,7 +976,7 @@ bool SaveRestoreDialog::show(bool saveDialog) { // Provide highlighting of lines to select a save slot while (!abortFlag && !(mouse.lButton() && (selectedLine != -1)) && !mouse.rButton() && !mouse.mButton()) { - abortFlag = events.quitFlag; + abortFlag = engine._quit; if (abortFlag) break; while (events.pollEvent()) { @@ -1178,7 +1179,7 @@ bool RestartRestoreDialog::show() { // Event loop for making selection bool buttonPressed = false; - while (!events.quitFlag) { + while (!engine._quit) { // Handle events while (events.pollEvent()) { if ((events.type() == Common::EVENT_LBUTTONDOWN) && (highlightedButton != -1)) { @@ -1230,7 +1231,7 @@ bool RestartRestoreDialog::show() { Sound.killSounds(); - if (!restartFlag && !events.quitFlag) { + if (!restartFlag && !engine._quit) { // Need to show Restore game dialog if (!SaveRestoreDialog::show(false)) // User cancelled, so fall back on Restart @@ -1299,6 +1300,7 @@ bool CopyProtectionDialog::show() { Screen &screen = Screen::getReference(); Events &events = Events::getReference(); Common::RandomSource rnd; + LureEngine &engine = LureEngine::getReference(); screen.setPaletteEmpty(); Palette p(COPY_PROTECTION_RESOURCE_ID - 1); @@ -1349,7 +1351,7 @@ bool CopyProtectionDialog::show() { // Clear any prior try _charIndex = 0; - while (!events.quitFlag) { + while (!engine._quit) { while (events.pollEvent() && (_charIndex < 4)) { if (events.type() == Common::EVENT_KEYDOWN) { if ((events.event().kbd.keycode == Common::KEYCODE_BACKSPACE) && (_charIndex > 0)) { @@ -1383,7 +1385,7 @@ bool CopyProtectionDialog::show() { break; } - if (events.quitFlag) + if (engine._quit) return false; // At this point, two page numbers have been entered - validate them |