XEEN: Fix loading saves from main menus and launcher

This commit is contained in:
Paul Gilbert 2018-03-03 22:15:50 -05:00
parent 92c49a8571
commit 50630efde6
11 changed files with 484 additions and 248 deletions

View File

@ -60,7 +60,42 @@ enum MagicSpell {
NO_SPELL = 76
};
const char *const CREDITS =
const char *const CLOUDS_CREDITS =
"\v012\t000\x3""c\f35Designed and Directed By:\n"
"\f17Jon Van Caneghem\x3""l\n"
"\n"
"\t025\f35Programming:\n"
"\t035\f17Mark Caldwell\n"
"\t035Dave Hathaway\n"
"\n"
"\t025\f35Sound System & FX:\n"
"\t035\f17Todd Hendrix\n"
"\n"
"\t025\f35Music & Speech:\n"
"\t035\f17Tim Tully\n"
"\n"
"\t025\f35Writing:\n"
"\t035\f17Paul Rattner\n"
"\t035Debbie Murphy\n"
"\t035Jon Van Caneghem\v012\n"
"\n"
"\n"
"\t180\f35Graphics:\n"
"\t190\f17Louis Johnson\n"
"\t190Jonathan P. Gwyn\n"
"\t190Bonita Long-Hemsath\n"
"\t190Julia Ulano\n"
"\t190Ricardo Barrera\n"
"\n"
"\t180\f35Testing:\n"
"\t190\f17Benjamin Bent\n"
"\t190Mario Escamilla\n"
"\t190Richard Espy\n"
"\t190Scott McDaniel\n"
"\t190Clayton Retzer\n"
"\t190Michael Suarez\x3""c";
const char *const DARK_SIDE_CREDITS =
"\013""012\010""000\003""c\014""35Designed and Directed By:\n"
"\014""17Jon Van Caneghem\003""l\n"
"\n"
@ -94,10 +129,47 @@ const char *const CREDITS =
"\t190Robert J. Lupo\n"
"\t190Clayton Retzer\n"
"\t190David Vela\003""c";
const char *const SWORDS_CREDITS1 =
"\v012\x3""c35Published By New World Computing, Inc.\f17\n"
"Developed By CATware, Inc.\x3l\n"
"\f01Design and Direction\t180Series Created by\n"
"\t020Bill Fawcett\t190John Van Caneghem\n"
"\n"
"\t010Story Contributions\t180Producer & Manual\n"
"\t020Ellen Guon\t190Dean Rettig\n"
"\n"
"\t010Programming & Ideas\t180Original Programming\n"
"\t020David Potter\t190Mark Caldwell\n"
"\t020Rod Retterath\t190Dave Hathaway\n"
"\n"
"\t010Manual Illustrations\t180Graphic Artists\n"
"\t020Todd Cameron Hamilton\t190Jonathan P. Gwyn\n"
"\t020James Clouse\t190Bonnie Long-Hemsath\n"
"\t190Julia Ulano\n"
"\t190Ricardo Barrera\n";
const char *const SWORDS_CREDITS2 =
"\f05v012\t000\x3l\n"
"\t100Sound Programming\n"
"\t110Todd Hendrix\n"
"\n"
"\t100Music\n"
"\t110Tim Tully\n"
"\t110Quality Assurance Manager\n"
"\t110Peter Ryu\n"
"\t100Testers\n"
"\t110Walter Johnson\n"
"\t110Bryan Farina\n"
"\t110David Baton\n"
"\t110Jack Nalls\n";
const char *const OPTIONS_TITLE =
"\x0D\x01\003""c\014""dMight and Magic Options\n"
"World of Xeen\x02\n"
const char *const CLOUDS_MAIN_MENU =
"\r\x1\x3""c\fdMight and Magic Options\n"
"Clouds of Xeen\x2\n"
"\v%03dCopyright (c) 1992 NWC, Inc.\n"
"All Rights Reserved\x1";
const char *const WORLD_MAIN_MENU =
"\r\x1\x3""c\fdMight and Magic Options\n"
"World of Xeen\x2\n"
"\v117Copyright (c) 1993 NWC, Inc.\n"
"All Rights Reserved\x01";
@ -1771,8 +1843,12 @@ const char *const DIFFICULTY_TEXT = "\v000\t000\x3""cSelect Game Preference";
void writeConstants(CCArchive &cc) {
Common::MemFile file;
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);

View File

@ -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);

View File

@ -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);
};

View File

@ -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);

View File

@ -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;

View File

@ -1084,6 +1084,10 @@ bool Scripts::cmdCutsceneEndClouds(ParamsIterator &params) {
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 &params) {
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;
}

View File

@ -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

View File

@ -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;
MainMenuContainer::MainMenuContainer(const Common::String &spritesName) : _animateCtr(0), _dialog(nullptr) {
_backgroundSprites.load(spritesName);
}
File newBright("newbrigh.m");
_vm->_sound->playSong(newBright);
MainMenuContainer::~MainMenuContainer() {
delete _dialog;
g_vm->_windows->closeAll();
g_vm->_sound->stopAllAudio();
g_vm->_events->clearEvents();
}
windows[GAME_WINDOW].setBounds(Common::Rect(72, 25, 248, 175));
void MainMenuContainer::draw() {
g_vm->_screen->restoreBackground();
_animateCtr = (_animateCtr + 1) % 9;
_backgroundSprites.draw(0, _animateCtr);
}
Common::String title1, title2;
startup(title1, title2);
SpriteResource title1Sprites(title1), title2Sprites(title2);
void MainMenuContainer::execute() {
EventsManager &events = *g_vm->_events;
bool showFlag = false;
bool firstTime = true, doFade = true;
while (!_vm->shouldExit()) {
setBackground(doFade);
// Show the cursor
events.clearEvents();
events.setCursor(0);
events.showCursor();
if (firstTime) {
firstTime = false;
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();
// 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();
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;
// 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();
while (!_vm->shouldExit() && events.timeElapsed() < 2)
events.pollEventsAndWait();
}
screen.restoreBackground();
windows[0].update();
}
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 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 CloudsMainMenuContainer::showMenuDialog() {
setOwner(new CloudsMenuDialog(this));
}
/*------------------------------------------------------------------------*/
void CloudsOptionsMenu::startup(Common::String &title1, Common::String &title2) {
title1 = "title1.int";
title2 = "title1a.int";
DarkSideMainMenuContainer::DarkSideMainMenuContainer() : MainMenuContainer("intro.vga") {
g_vm->_sound->playSong("inn.m");
}
void DarkSideMainMenuContainer::loadBackground() {
Screen &screen = *g_vm->_screen;
screen.loadPalette("mm4.pal");
screen.loadBackground("intro.raw");
screen.saveBackground();
}
void DarkSideMainMenuContainer::showMenuDialog() {
setOwner(new CloudsMenuDialog(this));
}
/*------------------------------------------------------------------------*/
void DarkSideOptionsMenu::startup(Common::String &title1, Common::String &title2) {
title1 = "title2.int";
title2 = "title2a.int";
WorldOfXeenMainMenuContainer::WorldOfXeenMainMenuContainer() : MainMenuContainer("intro.vga") {
g_vm->_sound->playSong("inn.m");
}
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();
}
void WorldOptionsMenu::setBackground(bool doFade) {
Screen &screen = *_vm->_screen;
screen.loadBackground("world.raw");
void WorldOfXeenMainMenuContainer::loadBackground() {
Screen &screen = *g_vm->_screen;
screen.loadPalette("mm4.pal");
screen.loadBackground("intro.raw");
screen.saveBackground();
if (doFade)
screen.fadeIn();
}
void WorldOptionsMenu::openWindow() {
Windows &windows = *_vm->_windows;
windows[GAME_WINDOW].open();
void WorldOfXeenMainMenuContainer::showMenuDialog() {
setOwner(new CloudsMenuDialog(this));
}
void WorldOptionsMenu::closeWindow() {
Windows &windows = *_vm->_windows;
windows[GAME_WINDOW].close();
/*------------------------------------------------------------------------*/
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;
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 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::showContents(SpriteResource &title1, bool waitFlag) {
EventsManager &events = *_vm->_events;
Screen &screen = *_vm->_screen;
Windows &windows = *_vm->_windows;
events.updateGameCounter();
/*------------------------------------------------------------------------*/
// Draw the background frame in a continous cycle
_bgFrame = (_bgFrame + 1) % 5;
title1.draw(windows[0], _bgFrame);
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();
// Draw the basic frame for the optitons menu and title text
windows[GAME_WINDOW].frame();
windows[GAME_WINDOW].writeString(Res.OPTIONS_TITLE);
loadButtons();
}
drawButtons(&windows[0]);
screen.update();
CloudsMenuDialog::~CloudsMenuDialog() {
Windows &windows = *g_vm->_windows;
Window &w = windows[GAME_WINDOW];
w.close();
}
if (waitFlag) {
while (!_vm->shouldExit() && !_buttonValue && events.timeElapsed() < 3) {
events.pollEventsAndWait();
checkEvents(_vm);
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);
}
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);
}
bool CloudsMenuDialog::handleEvents() {
if (MainMenuDialog::handleEvents())
return true;
switch (_buttonValue) {
case Common::KEYCODE_e:
if (g_vm->_gameWon[0]) {
// Close the window
delete this;
// 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

View File

@ -29,82 +29,181 @@
namespace Xeen {
namespace WorldOfXeen {
class WorldOfXeenMenu : public SettingsBaseDialog {
class MainMenuDialog;
class MainMenuContainer {
private:
int _animateCtr;
SpriteResource _backgroundSprites;
MainMenuDialog *_dialog;
protected:
/**
* Draws the main menu background
*/
void draw();
/**
* Load the background
*/
virtual void loadBackground() = 0;
/**
* 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);
/**
* Destructor
*/
virtual ~MainMenuContainer();
/**
* Execute the menu
*/
void execute();
protected:
WorldOfXeenMenu(XeenEngine *vm) : SettingsBaseDialog(vm) {}
protected:
virtual void startup(Common::String &title1, Common::String &title2) = 0;
virtual void setBackground(bool doFade) {}
virtual void showTitles1(SpriteResource &sprites);
virtual void showTitles2();
virtual void setupButtons(SpriteResource *buttons);
/**
* 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:
/**
* Load the background
*/
virtual void loadBackground();
/**
* Closes the menu window
* Shows the main menu dialog
*/
virtual void closeWindow() {}
virtual void showMenuDialog();
public:
virtual ~WorldOfXeenMenu() {}
static void show(XeenEngine *vm);
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);
virtual void setBackground(bool doFade);
virtual void showTitles2() {}
virtual void setupButtons(SpriteResource *buttons);
/**
* Opens the menu window
*/
virtual void openWindow();
/**
* Closes the menu window
*/
virtual void closeWindow();
virtual void showContents(SpriteResource &title1, bool mode);
MainMenuContainer *_owner;
public:
WorldOptionsMenu(XeenEngine *vm) : DarkSideOptionsMenu(vm), _bgFrame(0) {}
/**
* Constructor
*/
MenuContainerDialog(MainMenuContainer *owner) : ButtonContainer(g_vm), _owner(owner) {}
virtual ~WorldOptionsMenu() {}
/**
* Destructor
*/
virtual ~MenuContainerDialog() {
_owner->setOwner(nullptr);
}
/**
* Draws the dialog
*/
virtual void draw() = 0;
/**
* Handles events
*/
virtual bool handleEvents() = 0;
};
class MainMenuDialog : public MenuContainerDialog {
public:
/**
* Constructor
*/
MainMenuDialog(MainMenuContainer *owner) : MenuContainerDialog(owner) {}
/**
* Destructor
*/
virtual ~MainMenuDialog() {}
/**
* Draws the dialog
*/
virtual void draw() = 0;
/**
* Handles events
*/
virtual bool handleEvents();
};
class CloudsMenuDialog : public MainMenuDialog {
private:
SpriteResource _buttonSprites;
private:
/**
* Loads buttons for the dialog
*/
void loadButtons();
public:
/**
* Constructor
*/
CloudsMenuDialog(MainMenuContainer *owner);
/**
* Destructor
*/
virtual ~CloudsMenuDialog();
/**
* Draws the dialog
*/
virtual void draw();
/**
* Handles events
*/
virtual bool handleEvents();
};
} // End of namespace WorldOfXeen

View File

@ -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

View File

@ -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;