diff options
author | Paul Gilbert | 2018-02-26 19:15:00 -0500 |
---|---|---|
committer | Paul Gilbert | 2018-02-26 19:15:00 -0500 |
commit | 0fc11aef63d2abbc695d64ed41053b4163aac69c (patch) | |
tree | 5c3da450b0112529f48e909a81cb58609052f1ba | |
parent | 724c4e57add58362395ad6b6e79bcdaed1ff073b (diff) | |
download | scummvm-rg350-0fc11aef63d2abbc695d64ed41053b4163aac69c.tar.gz scummvm-rg350-0fc11aef63d2abbc695d64ed41053b4163aac69c.tar.bz2 scummvm-rg350-0fc11aef63d2abbc695d64ed41053b4163aac69c.zip |
XEEN: Cleanup of the game title, intro, and menu launching code
-rw-r--r-- | engines/xeen/dialogs_control_panel.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/interface.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/swordsofxeen/swordsofxeen.cpp | 10 | ||||
-rw-r--r-- | engines/xeen/swordsofxeen/swordsofxeen.h | 13 | ||||
-rw-r--r-- | engines/xeen/worldofxeen/worldofxeen.cpp | 91 | ||||
-rw-r--r-- | engines/xeen/worldofxeen/worldofxeen.h | 21 | ||||
-rw-r--r-- | engines/xeen/worldofxeen/worldofxeen_menu.cpp | 3 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 37 | ||||
-rw-r--r-- | engines/xeen/xeen.h | 43 |
10 files changed, 124 insertions, 100 deletions
diff --git a/engines/xeen/dialogs_control_panel.cpp b/engines/xeen/dialogs_control_panel.cpp index 5a7f593e68..d2129e46c2 100644 --- a/engines/xeen/dialogs_control_panel.cpp +++ b/engines/xeen/dialogs_control_panel.cpp @@ -85,7 +85,7 @@ int ControlPanel::execute() { switch (_buttonValue) { case Common::KEYCODE_q: if (Confirm::show(g_vm, Res.CONFIRM_QUIT)) { - g_vm->_quitMode = QMODE_QUIT; + g_vm->_gameMode = GMODE_QUIT; result = 1; } break; diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index fa06fa7afc..f646eb8ac5 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -320,7 +320,7 @@ void Interface::perform() { // Show control panel combat._moveMonsters = false; ControlPanel::show(_vm); - if (!g_vm->shouldExit() && !g_vm->_quitMode) + if (!g_vm->shouldExit() && !g_vm->_gameMode) combat._moveMonsters = true; break; diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 13b0cb3bb8..e08fd1b5c0 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -1466,7 +1466,7 @@ void Scripts::doEnding(const Common::String &endStr) { uint finalScore = party.getScore(); g_vm->showCutscene(endStr, state, finalScore); - g_vm->_quitMode = QMODE_MENU; + g_vm->_gameMode = GMODE_MENU; } bool Scripts::ifProc(int action, uint32 val, int mode, int charIndex) { diff --git a/engines/xeen/swordsofxeen/swordsofxeen.cpp b/engines/xeen/swordsofxeen/swordsofxeen.cpp index ebe6f74858..386136770a 100644 --- a/engines/xeen/swordsofxeen/swordsofxeen.cpp +++ b/engines/xeen/swordsofxeen/swordsofxeen.cpp @@ -29,10 +29,10 @@ SwordsOfXeenEngine::SwordsOfXeenEngine(OSystem *syst, const XeenGameDescription : XeenEngine(syst, gameDesc) { } -void SwordsOfXeenEngine::outerGameLoop() { - // TODO: Implement Swords of Xeen main menu - - playGame(); +void SwordsOfXeenEngine::showMainMenu() { + // TODO: Implement Swords of Xeen main menu. For now, skip to playing game + _saves->newGame(); + _gameMode = GMODE_PLAY_GAME; } void SwordsOfXeenEngine::death() { @@ -88,7 +88,7 @@ void SwordsOfXeenEngine::dream() { } void SwordsOfXeenEngine::showCutscene(const Common::String &name, int status, uint score) { - _quitMode = QMODE_MENU; + _gameMode = GMODE_MENU; } } // End of namespace SwordsOfXeen diff --git a/engines/xeen/swordsofxeen/swordsofxeen.h b/engines/xeen/swordsofxeen/swordsofxeen.h index 2eda3dec29..d301423287 100644 --- a/engines/xeen/swordsofxeen/swordsofxeen.h +++ b/engines/xeen/swordsofxeen/swordsofxeen.h @@ -36,10 +36,17 @@ namespace SwordsOfXeen { class SwordsOfXeenEngine: public XeenEngine { protected: /** - * Outer gameplay loop responsible for dispatching control to game-specific - * intros, main menus, or to play the actual game + * Show the starting sequence/intro */ - virtual void outerGameLoop(); + virtual void showStartup() { + // Swords of Xeen doesn't have a starting title or intro + _gameMode = GMODE_MENU; + } + + /** + * Show the startup menu + */ + virtual void showMainMenu(); /** * Death cutscene diff --git a/engines/xeen/worldofxeen/worldofxeen.cpp b/engines/xeen/worldofxeen/worldofxeen.cpp index 54d3b482fc..9403b94bc2 100644 --- a/engines/xeen/worldofxeen/worldofxeen.cpp +++ b/engines/xeen/worldofxeen/worldofxeen.cpp @@ -32,63 +32,7 @@ namespace WorldOfXeen { WorldOfXeenEngine::WorldOfXeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) : XeenEngine(syst, gameDesc), WorldOfXeenCutscenes(this) { _seenDarkSideIntro = false; - _pendingAction = WOX_PLAY_GAME; -} - -void WorldOfXeenEngine::outerGameLoop() { - //_pendingAction = getGameID() == GType_DarkSide ? WOX_DARKSIDE_INTRO : WOX_CLOUDS_INTRO; - _pendingAction = WOX_MENU; - - if (_loadSaveSlot != -1) - // Loading savegame from launcher, so Skip menu and go straight to game - _pendingAction = WOX_PLAY_GAME; - - while (!shouldQuit() && _pendingAction != WOX_QUIT) { - // TODO: Remove this once proper startup menus are added for Clouds & Dark Side - if (g_vm->getGameID() != GType_WorldOfXeen) { - _saves->newGame(); - _pendingAction = WOX_PLAY_GAME; - } - - WOXGameAction action = _pendingAction; - _pendingAction = WOX_MENU; - _quitMode = QMODE_NONE; - - switch (action) { - case WOX_CLOUDS_INTRO: - if (showCloudsTitle()) - showCloudsIntro(); - break; - - case WOX_CLOUDS_ENDING: - //showCloudsEnding(); - break; - - case WOX_DARKSIDE_INTRO: - if (showDarkSideTitle()) - showDarkSideIntro(); - break; - - case WOX_DARKSIDE_ENDING: - //showDarkSideEnding(); - break; - - case WOX_WORLD_ENDING: - // TODO - return; - - case WOX_MENU: - WorldOfXeenMenu::show(this); - break; - - case WOX_PLAY_GAME: - playGame(); - break; - - default: - break; - } - } + _gameMode = GMODE_STARTUP; } void WorldOfXeenEngine::death() { @@ -218,11 +162,42 @@ void WorldOfXeenEngine::showCutscene(const Common::String &name, int status, uin showDarkSideEnding(score); else if (name == "WORLDEND") showWorldOfXeenEnding((GooberState)status, score); + else if (name == "CLOUDS_TITLE") + showCloudsTitle(); + else if (name == "CLOUDS_INTRO") + showCloudsIntro(); + else if (name == "DARKSIDE_TITLE") + showDarkSideTitle(); + else if (name == "DARKSIDE_INTRO") + showDarkSideIntro(); _screen->freePages(); _sound->stopAllAudio(); _events->clearEvents(); - _quitMode = QMODE_MENU; + _gameMode = GMODE_MENU; +} + +void WorldOfXeenEngine::showStartup() { + if (getGameID() == GType_Clouds) { + if (showCloudsTitle()) + showCloudsIntro(); + } else { + if (showDarkSideTitle()) + showDarkSideIntro(); + } + + _gameMode = GMODE_MENU; +} + +void WorldOfXeenEngine::showMainMenu() { + if (getGameID() != GType_WorldOfXeen) { + // TODO: Implement menus for Clouds and Dark Side of Xeen + _saves->newGame(); + _gameMode = GMODE_PLAY_GAME; + return; + } + + WorldOfXeenMenu::show(this); } } // End of namespace WorldOfXeen diff --git a/engines/xeen/worldofxeen/worldofxeen.h b/engines/xeen/worldofxeen/worldofxeen.h index f985947af4..08c2e25ace 100644 --- a/engines/xeen/worldofxeen/worldofxeen.h +++ b/engines/xeen/worldofxeen/worldofxeen.h @@ -29,11 +29,6 @@ namespace Xeen { namespace WorldOfXeen { -enum WOXGameAction { - WOX_QUIT, WOX_CLOUDS_INTRO, WOX_CLOUDS_ENDING, WOX_DARKSIDE_INTRO, - WOX_DARKSIDE_ENDING, WOX_WORLD_ENDING, WOX_MENU, WOX_PLAY_GAME -}; - /** * Implements a descendant of the base Xeen engine to handle * Clouds of Xeen, Dark Side of Xeen, and Worlds of Xeen specific @@ -42,10 +37,14 @@ enum WOXGameAction { class WorldOfXeenEngine: public XeenEngine, public WorldOfXeenCutscenes { protected: /** - * Outer gameplay loop responsible for dispatching control to game-specific - * intros, main menus, or to play the actual game + * Show the starting sequence/intro + */ + virtual void showStartup(); + + /** + * Show the startup menu */ - virtual void outerGameLoop(); + virtual void showMainMenu(); /** * Death cutscene @@ -53,7 +52,6 @@ protected: virtual void death(); public: bool _seenDarkSideIntro; - WOXGameAction _pendingAction; public: WorldOfXeenEngine(OSystem *syst, const XeenGameDescription *gameDesc); virtual ~WorldOfXeenEngine() {} @@ -67,11 +65,6 @@ public: * Dream sequence */ virtual void dream(); - - /** - * Set the next overall game action to do - */ - void setPendingAction(WOXGameAction action) { _pendingAction = action; } }; #define WOX_VM (*(::Xeen::WorldOfXeen::WorldOfXeenEngine *)g_vm) diff --git a/engines/xeen/worldofxeen/worldofxeen_menu.cpp b/engines/xeen/worldofxeen/worldofxeen_menu.cpp index f43b00f027..42a55885a0 100644 --- a/engines/xeen/worldofxeen/worldofxeen_menu.cpp +++ b/engines/xeen/worldofxeen/worldofxeen_menu.cpp @@ -112,8 +112,7 @@ void WorldOfXeenMenu::execute() { // Load a new game state and set the difficulty _vm->_saves->newGame(); _vm->_party->_difficulty = (Difficulty)result; - - WOX_VM._pendingAction = WOX_PLAY_GAME; + _vm->_gameMode = GMODE_PLAY_GAME; closeWindow(); return; } diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 9acf2c51b4..e9e27c455c 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -58,7 +58,7 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _windows = nullptr; _noDirectionSense = false; _startupWindowActive = false; - _quitMode = QMODE_NONE; + _gameMode = GMODE_STARTUP; _mode = MODE_0; _endingScore = 0; _loadSaveSlot = -1; @@ -128,6 +128,35 @@ Common::Error XeenEngine::run() { return Common::kNoError; } +void XeenEngine::outerGameLoop() { + if (_loadSaveSlot != -1) + // Loading savegame from launcher, so Skip menu and go straight to game + _gameMode = GMODE_PLAY_GAME; + + while (!shouldQuit() && _gameMode != GMODE_QUIT) { + GameMode mode = _gameMode; + _gameMode = GMODE_NONE; + assert(mode != GMODE_NONE); + + switch (mode) { + case GMODE_STARTUP: + showStartup(); + break; + + case GMODE_MENU: + showMainMenu(); + break; + + case GMODE_PLAY_GAME: + playGame(); + break; + + default: + break; + } + } +} + int XeenEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } @@ -161,7 +190,7 @@ void XeenEngine::playGame() { } void XeenEngine::play() { - _quitMode = QMODE_NONE; + _gameMode = GMODE_NONE; _interface->setup(); _screen->loadBackground("back.raw"); @@ -218,8 +247,8 @@ void XeenEngine::gameLoop() { _map->cellFlagLookup(_party->_mazePosition); if (_map->_currentIsEvent) { - _quitMode = (QuitMode)_scripts->checkEvents(); - if (shouldExit() || _quitMode) + _gameMode = (GameMode)_scripts->checkEvents(); + if (shouldExit() || _gameMode) return; } _party->giveTreasure(); diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index 561d928158..5031f1fea3 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -93,10 +93,12 @@ enum Mode { MODE_86 = 86 }; -enum QuitMode { - QMODE_NONE = 0, - QMODE_QUIT = 1, - QMODE_MENU = 2 +enum GameMode { + GMODE_NONE = 0, + GMODE_STARTUP = 1, + GMODE_MENU = 2, + GMODE_PLAY_GAME = 3, + GMODE_QUIT = 4 }; struct XeenGameDescription; @@ -117,19 +119,38 @@ private: virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; + /** + * Outer gameplay loop responsible for dispatching control to game-specific + * intros, main menus, or to play the actual game + */ + void outerGameLoop(); + + /** + * Inner game loop + */ + void gameLoop(); + + /** + * Plays the actual game + */ void play(); + /** + * Shows a please wait dialog + */ void pleaseWait(); - - void gameLoop(); protected: int _loadSaveSlot; protected: /** - * Outer gameplay loop responsible for dispatching control to game-specific - * intros, main menus, or to play the actual game + * Show the starting sequence/intro + */ + virtual void showStartup() = 0; + + /** + * Show the startup menu */ - virtual void outerGameLoop() = 0; + virtual void showMainMenu() = 0; /** * Play the game @@ -158,7 +179,7 @@ public: Windows *_windows; Mode _mode; GameEvent _gameEvent; - QuitMode _quitMode; + GameMode _gameMode; bool _noDirectionSense; bool _startupWindowActive; uint _endingScore; @@ -185,7 +206,7 @@ public: /** * Returns true if the game should be exited (and likely return to game menu) */ - bool shouldExit() const { return _quitMode != QMODE_NONE || shouldQuit(); } + bool shouldExit() const { return _gameMode != GMODE_NONE || shouldQuit(); } /** * Load a savegame |