From 50630efde6d0f42f4d5f371d6818afac64ba86f5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 3 Mar 2018 22:15:50 -0500 Subject: XEEN: Fix loading saves from main menus and launcher --- engines/xeen/dialogs.cpp | 19 +- engines/xeen/dialogs.h | 2 +- engines/xeen/resources.cpp | 8 +- engines/xeen/resources.h | 8 +- engines/xeen/scripts.cpp | 8 + engines/xeen/worldofxeen/worldofxeen.cpp | 9 +- engines/xeen/worldofxeen/worldofxeen_menu.cpp | 351 +++++++++++++------------- engines/xeen/worldofxeen/worldofxeen_menu.h | 179 ++++++++++--- engines/xeen/xeen.cpp | 19 ++ engines/xeen/xeen.h | 7 + 10 files changed, 385 insertions(+), 225 deletions(-) (limited to 'engines') diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp index 276d9a7b3b..4ca69ec4cb 100644 --- a/engines/xeen/dialogs.cpp +++ b/engines/xeen/dialogs.cpp @@ -191,11 +191,24 @@ void SettingsBaseDialog::showContents(SpriteResource &title1, bool waitFlag) { void CreditsScreen::show(XeenEngine *vm) { CreditsScreen *dlg = new CreditsScreen(vm); - dlg->execute(); + + switch (vm->getGameID()) { + case GType_Clouds: + dlg->execute(Res.CLOUDS_CREDITS); + break; + case GType_Swords: + dlg->execute(Res.SWORDS_CREDITS1); + dlg->execute(Res.SWORDS_CREDITS2); + break; + default: + dlg->execute(Res.DARK_SIDE_CREDITS); + break; + } + delete dlg; } -void CreditsScreen::execute() { +void CreditsScreen::execute(const char *content) { Screen &screen = *_vm->_screen; Windows &windows = *_vm->_windows; EventsManager &events = *_vm->_events; @@ -205,7 +218,7 @@ void CreditsScreen::execute() { windows[GAME_WINDOW].close(); screen.loadBackground("marb.raw"); - windows[0].writeString(Res.CREDITS); + windows[0].writeString(content); doScroll(false, false); events.setCursor(0); diff --git a/engines/xeen/dialogs.h b/engines/xeen/dialogs.h index b4ad77232b..cabc921536 100644 --- a/engines/xeen/dialogs.h +++ b/engines/xeen/dialogs.h @@ -117,7 +117,7 @@ class CreditsScreen: public ButtonContainer { private: CreditsScreen(XeenEngine *vm) : ButtonContainer(vm) {} - void execute(); + void execute(const char *content); public: static void show(XeenEngine *vm); }; diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 0aa7d8ac83..6ea4252999 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -62,8 +62,12 @@ Resources::Resources() { void Resources::loadData() { ResFile file(_buffer); - file.syncString(CREDITS); - file.syncString(OPTIONS_TITLE); + file.syncString(CLOUDS_CREDITS); + file.syncString(DARK_SIDE_CREDITS); + file.syncString(SWORDS_CREDITS1); + file.syncString(SWORDS_CREDITS2); + file.syncString(CLOUDS_MAIN_MENU); + file.syncString(WORLD_MAIN_MENU); file.syncString(THE_PARTY_NEEDS_REST); file.syncString(WHO_WILL); file.syncString(HOW_MUCH); diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index 67ac992ad3..b14b9f5273 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -116,8 +116,12 @@ public: const char **ITEM_NAMES[4]; // Data loaded from xeen.ccs - const char *CREDITS; - const char *OPTIONS_TITLE; + const char *CLOUDS_CREDITS; + const char *DARK_SIDE_CREDITS; + const char *SWORDS_CREDITS1; + const char *SWORDS_CREDITS2; + const char *CLOUDS_MAIN_MENU; + const char *WORLD_MAIN_MENU; const char *THE_PARTY_NEEDS_REST; const char *WHO_WILL; const char *HOW_MUCH; diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index e08fd1b5c0..679e48c5b0 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -1084,6 +1084,10 @@ bool Scripts::cmdCutsceneEndClouds(ParamsIterator ¶ms) { party._mazeId = 28; party._mazePosition = Common::Point(18, 4); + g_vm->_gameWon[0] = true; + g_vm->_finalScore[0] = party.getScore(); + g_vm->saveSettings(); + doCloudsEnding(); return false; } @@ -1416,6 +1420,10 @@ bool Scripts::cmdCutsceneEndDarkside(ParamsIterator ¶ms) { party._mazeDirection = DIR_NORTH; party._mazePosition = Common::Point(25, 21); + g_vm->_gameWon[1] = true; + g_vm->_finalScore[1] = party.getScore(); + g_vm->saveSettings(); + doDarkSideEnding(); return false; } diff --git a/engines/xeen/worldofxeen/worldofxeen.cpp b/engines/xeen/worldofxeen/worldofxeen.cpp index 20fa7be44a..962bdfec6a 100644 --- a/engines/xeen/worldofxeen/worldofxeen.cpp +++ b/engines/xeen/worldofxeen/worldofxeen.cpp @@ -186,14 +186,7 @@ void WorldOfXeenEngine::showStartup() { } void WorldOfXeenEngine::showMainMenu() { - // TODO: Remove this as the game main menus are properly implemented - if (getGameID() == GType_Clouds) { - _saves->newGame(); - _gameMode = GMODE_PLAY_GAME; - return; - } - - WorldOfXeenMenu::show(this); + WorldOfXeenMainMenuContainer::show(); } } // End of namespace WorldOfXeen diff --git a/engines/xeen/worldofxeen/worldofxeen_menu.cpp b/engines/xeen/worldofxeen/worldofxeen_menu.cpp index 7f5e7f35c1..a91a711a67 100644 --- a/engines/xeen/worldofxeen/worldofxeen_menu.cpp +++ b/engines/xeen/worldofxeen/worldofxeen_menu.cpp @@ -29,236 +29,249 @@ namespace Xeen { namespace WorldOfXeen { -void WorldOfXeenMenu::show(XeenEngine *vm) { - WorldOfXeenMenu *menu; +void MainMenuContainer::show() { + MainMenuContainer *menu; - switch (vm->getGameID()) { + switch (g_vm->getGameID()) { case GType_Clouds: - menu = new CloudsOptionsMenu(vm); + menu = new CloudsMainMenuContainer(); break; case GType_DarkSide: - menu = new DarkSideOptionsMenu(vm); + menu = new DarkSideMainMenuContainer(); break; case GType_WorldOfXeen: - menu = new WorldOptionsMenu(vm); + menu = new WorldOfXeenMainMenuContainer(); break; default: - error("Unsupported game"); - break; + error("Invalid game"); } menu->execute(); delete menu; } -void WorldOfXeenMenu::execute() { - _vm->_files->setGameCc(1); - SpriteResource special("special.icn"); - Windows &windows = *_vm->_windows; - EventsManager &events = *_vm->_events; - - File newBright("newbrigh.m"); - _vm->_sound->playSong(newBright); - - windows[GAME_WINDOW].setBounds(Common::Rect(72, 25, 248, 175)); +MainMenuContainer::MainMenuContainer(const Common::String &spritesName) : _animateCtr(0), _dialog(nullptr) { + _backgroundSprites.load(spritesName); +} - Common::String title1, title2; - startup(title1, title2); - SpriteResource title1Sprites(title1), title2Sprites(title2); +MainMenuContainer::~MainMenuContainer() { + delete _dialog; + g_vm->_windows->closeAll(); + g_vm->_sound->stopAllAudio(); + g_vm->_events->clearEvents(); +} - bool firstTime = true, doFade = true; - while (!_vm->shouldExit()) { - setBackground(doFade); +void MainMenuContainer::draw() { + g_vm->_screen->restoreBackground(); + _animateCtr = (_animateCtr + 1) % 9; + _backgroundSprites.draw(0, _animateCtr); +} - if (firstTime) { - firstTime = false; - events.setCursor(0); - events.showCursor(); +void MainMenuContainer::execute() { + EventsManager &events = *g_vm->_events; + bool showFlag = false; + + // Show the cursor + events.clearEvents(); + events.setCursor(0); + events.showCursor(); + + while (!g_vm->shouldExit() && g_vm->_gameMode == GMODE_NONE) { + // Draw the menu + draw(); + if (_dialog) + _dialog->draw(); + + // Fade/scroll in screen if first frame + if (!showFlag) { + loadBackground(); + // TODO: doScroll(false, false); + showFlag = true; } - showTitles1(title1Sprites); - showTitles2(); - - clearButtons(); - setupButtons(&title2Sprites); - openWindow(); - - while (!_vm->shouldExit()) { - // Show the dialog with a continually animating background - while (!_vm->shouldExit() && !_buttonValue) - showContents(title1Sprites, true); - if (_vm->shouldExit()) - return; - - // Handle keypress - int key = toupper(_buttonValue); - _buttonValue = 0; - - if (key == Common::KEYCODE_ESCAPE) { - // Hide the options menu - closeWindow(); - break; - } else if (key == 'C' || key == 'V') { - // Show credits - closeWindow(); - CreditsScreen::show(_vm); - break; - } else if (key == 'S') { - // Start new game - int result = DifficultyDialog::show(_vm); - if (result == -1) - break; - - // Load a new game state and set the difficulty - _vm->_saves->newGame(); - _vm->_party->_difficulty = (Difficulty)result; - _vm->_gameMode = GMODE_PLAY_GAME; - closeWindow(); - return; - } else if (key == 'L') { - _vm->_saves->newGame(); - if (_vm->_saves->loadGame()) { - _vm->_gameMode = GMODE_PLAY_GAME; - break; + // Check for events + events.updateGameCounter(); + + if (events.wait(4, true)) { + if (_dialog) { + // There's a dialog active, so let it handle the event + _dialog->handleEvents(); + + // If dialog was removed as a result of the event, flag screen for re-showing + // if the menu screen isn't being left + if (!_dialog) + showFlag = false; + } else { + // No active dialog. If Escape pressed, exit game entirely. Otherwise, + // open up the main menu dialog + if (events.isKeyPending()) { + Common::KeyState key; + if (events.getKey(key) && key.keycode == Common::KEYCODE_ESCAPE) + g_vm->_gameMode = GMODE_QUIT; } + + events.clearEvents(); + showMenuDialog(); } } } } -void WorldOfXeenMenu::showTitles1(SpriteResource &sprites) { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - - int frameNum = 0; - while (!_vm->shouldExit() && !events.isKeyMousePressed()) { - events.updateGameCounter(); - - frameNum = (frameNum + 1) % (_vm->getGameID() == GType_WorldOfXeen ? 5 : 10); - screen.restoreBackground(); - sprites.draw(0, frameNum); +/*------------------------------------------------------------------------*/ - events.wait(4); - } +CloudsMainMenuContainer::CloudsMainMenuContainer() : MainMenuContainer("intro.vga") { + g_vm->_sound->playSong("inn.m"); } -void WorldOfXeenMenu::showTitles2() { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - Sound &sound = *_vm->_sound; - Windows &windows = *_vm->_windows; - - SpriteResource titleSprites("title2b.raw"); - SpriteResource kludgeSprites("kludge.int"); - SpriteResource title2Sprites[8] = { - SpriteResource("title2b.int"), SpriteResource("title2c.int"), - SpriteResource("title2d.int"), SpriteResource("title2e.int"), - SpriteResource("title2f.int"), SpriteResource("title2g.int"), - SpriteResource("title2h.int"), SpriteResource("title2i.int"), - }; - - kludgeSprites.draw(0, 0); +void CloudsMainMenuContainer::loadBackground() { + Screen &screen = *g_vm->_screen; + screen.loadPalette("mm4.pal"); + screen.loadBackground("intro.raw"); screen.saveBackground(); - sound.playSound("elect.voc"); - - for (int i = 0; i < 30 && !_vm->shouldExit(); ++i) { - events.updateGameCounter(); - screen.restoreBackground(); - title2Sprites[i / 4].draw(0, i % 4); - windows[0].update(); +} - if (i == 19) - sound.stopSound(); +void CloudsMainMenuContainer::showMenuDialog() { + setOwner(new CloudsMenuDialog(this)); +} - while (!_vm->shouldExit() && events.timeElapsed() < 2) - events.pollEventsAndWait(); - } +/*------------------------------------------------------------------------*/ - screen.restoreBackground(); - windows[0].update(); +DarkSideMainMenuContainer::DarkSideMainMenuContainer() : MainMenuContainer("intro.vga") { + g_vm->_sound->playSong("inn.m"); } -void WorldOfXeenMenu::setupButtons(SpriteResource *buttons) { - addButton(Common::Rect(124, 87, 124 + 53, 87 + 10), 'S'); - addButton(Common::Rect(126, 98, 126 + 47, 98 + 10), 'L'); - addButton(Common::Rect(91, 110, 91 + 118, 110 + 10), 'C'); - addButton(Common::Rect(85, 121, 85 + 131, 121 + 10), 'O'); +void DarkSideMainMenuContainer::loadBackground() { + Screen &screen = *g_vm->_screen; + screen.loadPalette("mm4.pal"); + screen.loadBackground("intro.raw"); + screen.saveBackground(); } -void WorldOptionsMenu::setupButtons(SpriteResource *buttons) { - addButton(Common::Rect(93, 53, 93 + 134, 53 + 20), 'S', buttons); - addButton(Common::Rect(93, 78, 93 + 134, 78 + 20), 'L', buttons); - addButton(Common::Rect(93, 103, 93 + 134, 103 + 20), 'C', buttons); - addButton(Common::Rect(93, 128, 93 + 134, 128 + 20), 'O', buttons); +void DarkSideMainMenuContainer::showMenuDialog() { + setOwner(new CloudsMenuDialog(this)); } /*------------------------------------------------------------------------*/ -void CloudsOptionsMenu::startup(Common::String &title1, Common::String &title2) { - title1 = "title1.int"; - title2 = "title1a.int"; +WorldOfXeenMainMenuContainer::WorldOfXeenMainMenuContainer() : MainMenuContainer("intro.vga") { + g_vm->_sound->playSong("inn.m"); } -/*------------------------------------------------------------------------*/ +void WorldOfXeenMainMenuContainer::loadBackground() { + Screen &screen = *g_vm->_screen; + screen.loadPalette("mm4.pal"); + screen.loadBackground("intro.raw"); + screen.saveBackground(); +} -void DarkSideOptionsMenu::startup(Common::String &title1, Common::String &title2) { - title1 = "title2.int"; - title2 = "title2a.int"; +void WorldOfXeenMainMenuContainer::showMenuDialog() { + setOwner(new CloudsMenuDialog(this)); } -void WorldOptionsMenu::startup(Common::String &title1, Common::String &title2) { - title1 = "world.int"; - title2 = "start.icn"; +/*------------------------------------------------------------------------*/ - Screen &screen = *_vm->_screen; - screen.fadeOut(); - screen.loadPalette("dark.pal"); - _vm->_events->clearEvents(); -} +bool MainMenuDialog::handleEvents() { + checkEvents(g_vm); + int difficulty; + + switch (_buttonValue) { + case Common::KEYCODE_s: + // Start new game + difficulty = DifficultyDialog::show(g_vm); + if (difficulty == -1) + return true; + + // Load a new game state and set the difficulty + g_vm->_saves->newGame(); + g_vm->_party->_difficulty = (Difficulty)difficulty; + g_vm->_gameMode = GMODE_PLAY_GAME; + break; -void WorldOptionsMenu::setBackground(bool doFade) { - Screen &screen = *_vm->_screen; - screen.loadBackground("world.raw"); - screen.saveBackground(); + case Common::KEYCODE_l: + // Load existing game + g_vm->_saves->newGame(); + if (!g_vm->_saves->loadGame()) + return true; + + g_vm->_gameMode = GMODE_PLAY_GAME; + break; + + case Common::KEYCODE_c: + case Common::KEYCODE_v: + // Show credits + CreditsScreen::show(g_vm); + break; + + default: + return false; + } - if (doFade) - screen.fadeIn(); + // If this point is reached, delete the dialog itself, which will return the main menu + // to it's default "No dialog showing" state + delete this; + return true; } -void WorldOptionsMenu::openWindow() { - Windows &windows = *_vm->_windows; - windows[GAME_WINDOW].open(); +/*------------------------------------------------------------------------*/ + +CloudsMenuDialog::CloudsMenuDialog(MainMenuContainer *owner) : MainMenuDialog(owner) { + Windows &windows = *g_vm->_windows; + Window &w = windows[GAME_WINDOW]; + w.setBounds(Common::Rect(72, 25, 248, g_vm->_gameWon[0] ? 175 : 150)); + w.open(); + + loadButtons(); } -void WorldOptionsMenu::closeWindow() { - Windows &windows = *_vm->_windows; - windows[GAME_WINDOW].close(); +CloudsMenuDialog::~CloudsMenuDialog() { + Windows &windows = *g_vm->_windows; + Window &w = windows[GAME_WINDOW]; + w.close(); } -void WorldOptionsMenu::showContents(SpriteResource &title1, bool waitFlag) { - EventsManager &events = *_vm->_events; - Screen &screen = *_vm->_screen; - Windows &windows = *_vm->_windows; - events.updateGameCounter(); +void CloudsMenuDialog::loadButtons() { + _buttonSprites.load("start.icn"); + addButton(Common::Rect(93, 53, 227, 73), Common::KEYCODE_s, &_buttonSprites); + addButton(Common::Rect(93, 78, 227, 98), Common::KEYCODE_l, &_buttonSprites); + addButton(Common::Rect(93, 103, 227, 123), Common::KEYCODE_c, &_buttonSprites); + if (g_vm->_gameWon[0]) + addButton(Common::Rect(93, 128, 227, 148), Common::KEYCODE_e, &_buttonSprites); +} - // Draw the background frame in a continous cycle - _bgFrame = (_bgFrame + 1) % 5; - title1.draw(windows[0], _bgFrame); +void CloudsMenuDialog::draw() { + Windows &windows = *g_vm->_windows; + Window &w = windows[GAME_WINDOW]; + + w.frame(); + w.writeString(Common::String::format(Res.CLOUDS_MAIN_MENU, g_vm->_gameWon[0] ? 117 : 92)); + drawButtons(&w); +} - // Draw the basic frame for the optitons menu and title text - windows[GAME_WINDOW].frame(); - windows[GAME_WINDOW].writeString(Res.OPTIONS_TITLE); +bool CloudsMenuDialog::handleEvents() { + if (MainMenuDialog::handleEvents()) + return true; - drawButtons(&windows[0]); - screen.update(); + switch (_buttonValue) { + case Common::KEYCODE_e: + if (g_vm->_gameWon[0]) { + // Close the window + delete this; - if (waitFlag) { - while (!_vm->shouldExit() && !_buttonValue && events.timeElapsed() < 3) { - events.pollEventsAndWait(); - checkEvents(_vm); + // Show clouds ending + WOX_VM.showCloudsEnding(g_vm->_finalScore[0]); + return true; } + break; + + default: + break; } + + return false; } +/*------------------------------------------------------------------------*/ + + } // End of namespace WorldOfXeen } // End of namespace Xeen diff --git a/engines/xeen/worldofxeen/worldofxeen_menu.h b/engines/xeen/worldofxeen/worldofxeen_menu.h index 39d309c751..3495f08923 100644 --- a/engines/xeen/worldofxeen/worldofxeen_menu.h +++ b/engines/xeen/worldofxeen/worldofxeen_menu.h @@ -29,82 +29,181 @@ namespace Xeen { namespace WorldOfXeen { -class WorldOfXeenMenu : public SettingsBaseDialog { +class MainMenuDialog; + +class MainMenuContainer { private: - void execute(); -protected: - WorldOfXeenMenu(XeenEngine *vm) : SettingsBaseDialog(vm) {} + int _animateCtr; + SpriteResource _backgroundSprites; + MainMenuDialog *_dialog; protected: - virtual void startup(Common::String &title1, Common::String &title2) = 0; + /** + * Draws the main menu background + */ + void draw(); - virtual void setBackground(bool doFade) {} + /** + * Load the background + */ + virtual void loadBackground() = 0; - virtual void showTitles1(SpriteResource &sprites); + /** + * Shows the main menu dialog + */ + virtual void showMenuDialog() = 0; +public: + /** + * Show the main menu for the correct game + */ + static void show(); +public: + /** + * Constructor + */ + MainMenuContainer(const Common::String &spritesName); - virtual void showTitles2(); + /** + * Destructor + */ + virtual ~MainMenuContainer(); - virtual void setupButtons(SpriteResource *buttons); + /** + * Execute the menu + */ + void execute(); /** - * Opens the menu window + * Sets the dialog being displayed in the menu */ - virtual void openWindow() {} + void setOwner(MainMenuDialog *dlalog) { + _dialog = dlalog; + } +}; +class CloudsMainMenuContainer : public MainMenuContainer { +protected: /** - * Closes the menu window + * Load the background */ - virtual void closeWindow() {} -public: - virtual ~WorldOfXeenMenu() {} + virtual void loadBackground(); - static void show(XeenEngine *vm); + /** + * Shows the main menu dialog + */ + virtual void showMenuDialog(); +public: + CloudsMainMenuContainer(); }; -class CloudsOptionsMenu : public WorldOfXeenMenu { +class DarkSideMainMenuContainer : public MainMenuContainer { protected: - virtual void startup(Common::String &title1, Common::String &title2); -public: - CloudsOptionsMenu(XeenEngine *vm) : WorldOfXeenMenu(vm) {} + /** + * Load the background + */ + virtual void loadBackground(); - virtual ~CloudsOptionsMenu() {} + /** + * Shows the main menu dialog + */ + virtual void showMenuDialog(); +public: + DarkSideMainMenuContainer(); }; -class DarkSideOptionsMenu : public WorldOfXeenMenu { +class WorldOfXeenMainMenuContainer : public MainMenuContainer { protected: - virtual void startup(Common::String &title1, Common::String &title2); -public: - DarkSideOptionsMenu(XeenEngine *vm) : WorldOfXeenMenu(vm) {} + /** + * Load the background + */ + virtual void loadBackground(); - virtual ~DarkSideOptionsMenu() {} + /** + * Shows the main menu dialog + */ + virtual void showMenuDialog(); +public: + WorldOfXeenMainMenuContainer(); }; -class WorldOptionsMenu : public DarkSideOptionsMenu { +class MenuContainerDialog : public ButtonContainer { private: - int _bgFrame; -protected: - virtual void startup(Common::String &title1, Common::String &title2); + MainMenuContainer *_owner; +public: + /** + * Constructor + */ + MenuContainerDialog(MainMenuContainer *owner) : ButtonContainer(g_vm), _owner(owner) {} - virtual void setBackground(bool doFade); + /** + * Destructor + */ + virtual ~MenuContainerDialog() { + _owner->setOwner(nullptr); + } + + /** + * Draws the dialog + */ + virtual void draw() = 0; - virtual void showTitles2() {} + /** + * Handles events + */ + virtual bool handleEvents() = 0; +}; - virtual void setupButtons(SpriteResource *buttons); +class MainMenuDialog : public MenuContainerDialog { +public: + /** + * Constructor + */ + MainMenuDialog(MainMenuContainer *owner) : MenuContainerDialog(owner) {} /** - * Opens the menu window + * Destructor */ - virtual void openWindow(); + virtual ~MainMenuDialog() {} /** - * Closes the menu window + * Draws the dialog */ - virtual void closeWindow(); + virtual void draw() = 0; - virtual void showContents(SpriteResource &title1, bool mode); + /** + * Handles events + */ + virtual bool handleEvents(); + +}; + +class CloudsMenuDialog : public MainMenuDialog { +private: + SpriteResource _buttonSprites; +private: + /** + * Loads buttons for the dialog + */ + void loadButtons(); public: - WorldOptionsMenu(XeenEngine *vm) : DarkSideOptionsMenu(vm), _bgFrame(0) {} + /** + * Constructor + */ + CloudsMenuDialog(MainMenuContainer *owner); - virtual ~WorldOptionsMenu() {} + /** + * Destructor + */ + virtual ~CloudsMenuDialog(); + + /** + * Draws the dialog + */ + virtual void draw(); + + /** + * Handles events + */ + virtual bool handleEvents(); }; } // End of namespace WorldOfXeen diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 21db8b270f..6122f4deea 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -62,6 +62,8 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _mode = MODE_0; _endingScore = 0; _loadSaveSlot = -1; + _gameWon[0] = _gameWon[1] = false; + _finalScore[0] = _finalScore[1] = 0; g_vm = this; } @@ -111,6 +113,12 @@ bool XeenEngine::initialize() { // Setup mixer syncSoundSettings(); + // Load settings + _gameWon[0] = ConfMan.hasKey("game_won") && ConfMan.getBool("game_won"); + _gameWon[1] = ConfMan.hasKey("game_won2") && ConfMan.getBool("game_won2"); + _finalScore[0] = ConfMan.hasKey("final_score") ? ConfMan.getInt("final_score") : 0; + _finalScore[1] = ConfMan.hasKey("final_score2") ? ConfMan.getInt("final_score2") : 0; + // If requested, load a savegame instead of showing the intro if (ConfMan.hasKey("save_slot")) { int saveSlot = ConfMan.getInt("save_slot"); @@ -294,4 +302,15 @@ void XeenEngine::GUIError(const char *msg, ...) { GUIErrorMessage(buffer); } +void XeenEngine::saveSettings() { + if (_gameWon[0]) + ConfMan.setBool("game_won", true); + if (_gameWon[1]) + ConfMan.setBool("game_won2", true); + + ConfMan.setInt("final_score", _finalScore[0]); + ConfMan.setInt("final_score2", _finalScore[1]); + ConfMan.flushToDisk(); +} + } // End of namespace Xeen diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index 5031f1fea3..98ba00bf52 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -183,6 +183,8 @@ public: bool _noDirectionSense; bool _startupWindowActive; uint _endingScore; + bool _gameWon[2]; + uint _finalScore[2]; public: XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc); virtual ~XeenEngine(); @@ -251,6 +253,11 @@ public: static Common::String printK(uint value); static Common::String printK2(uint value); + + /** + * Saves engine settings + */ + void saveSettings(); }; extern XeenEngine *g_vm; -- cgit v1.2.3