aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/dialogs.cpp63
-rw-r--r--engines/mohawk/dialogs.h15
2 files changed, 73 insertions, 5 deletions
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index 73b1a15300..f8aaf0f4af 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -24,6 +24,7 @@
#include "mohawk/dialogs.h"
#include "gui/gui-manager.h"
+#include "gui/saveload.h"
#include "gui/ThemeEngine.h"
#include "gui/widget.h"
#include "common/system.h"
@@ -82,35 +83,47 @@ enum {
kWaterCmd = 'WATR',
kDropCmd = 'DROP',
kMapCmd = 'SMAP',
- kMenuCmd = 'MENU'
+ kMenuCmd = 'MENU',
+ kSaveCmd = 'SAVE',
+ kLoadCmd = 'LOAD',
+ kQuitCmd = 'QUIT'
};
#ifdef ENABLE_MYST
MystOptionsDialog::MystOptionsDialog(MohawkEngine_Myst* vm) : GUI::Dialog(0, 0, 360, 200), _vm(vm) {
// I18N: Option for fast scene switching
- _zipModeCheckbox = new GUI::CheckboxWidget(this, 15, 10, 300, 15, _("~Z~ip Mode Activated"), 0, kZipCmd);
- _transitionsCheckbox = new GUI::CheckboxWidget(this, 15, 30, 300, 15, _("~T~ransitions Enabled"), 0, kTransCmd);
+ _zipModeCheckbox = new GUI::CheckboxWidget(this, 15, 10, 220, 15, _("~Z~ip Mode Activated"), 0, kZipCmd);
+ _transitionsCheckbox = new GUI::CheckboxWidget(this, 15, 30, 220, 15, _("~T~ransitions Enabled"), 0, kTransCmd);
// I18N: Drop book page
_dropPageButton = new GUI::ButtonWidget(this, 15, 60, 100, 25, _("~D~rop Page"), 0, kDropCmd);
// Myst ME only has maps
if (_vm->getFeatures() & GF_ME)
- _showMapButton = new GUI::ButtonWidget(this, 15, 95, 100, 25, _("~S~how Map"), 0, kMapCmd);
+ _showMapButton = new GUI::ButtonWidget(this, 15, 95, 100, 25, _("Show ~M~ap"), 0, kMapCmd);
else
_showMapButton = 0;
// Myst demo only has a menu
if (_vm->getFeatures() & GF_DEMO)
- _returnToMenuButton = new GUI::ButtonWidget(this, 15, 95, 100, 25, _("~M~ain Menu"), 0, kMenuCmd);
+ _returnToMenuButton = new GUI::ButtonWidget(this, 15, 95, 100, 25, _("Main Men~u~"), 0, kMenuCmd);
else
_returnToMenuButton = 0;
+ _loadButton = new GUI::ButtonWidget(this, 245, 25, 100, 25, _("~L~oad"), 0, kLoadCmd);
+ _saveButton = new GUI::ButtonWidget(this, 245, 60, 100, 25, _("~S~ave"), 0, kSaveCmd);
+ new GUI::ButtonWidget(this, 245, 95, 100, 25, _("~Q~uit"), 0, kQuitCmd);
+
new GUI::ButtonWidget(this, 95, 160, 120, 25, _("~O~K"), 0, GUI::kOKCmd);
new GUI::ButtonWidget(this, 225, 160, 120, 25, _("~C~ancel"), 0, GUI::kCloseCmd);
+
+ _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false);
+ _saveDialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
}
MystOptionsDialog::~MystOptionsDialog() {
+ delete _loadDialog;
+ delete _saveDialog;
}
void MystOptionsDialog::open() {
@@ -133,6 +146,33 @@ void MystOptionsDialog::open() {
_zipModeCheckbox->setState(_vm->_gameState->_globals.zipMode);
_transitionsCheckbox->setState(_vm->_gameState->_globals.transitions);
+
+ _loadButton->setEnabled(_vm->canLoadGameStateCurrently());
+ _saveButton->setEnabled(_vm->canSaveGameStateCurrently());
+}
+
+void MystOptionsDialog::save() {
+ int slot = _saveDialog->runModalWithCurrentTarget();
+
+ if (slot >= 0) {
+ Common::String result(_saveDialog->getResultString());
+ if (result.empty()) {
+ // If the user was lazy and entered no save name, come up with a default name.
+ result = _saveDialog->createDefaultSaveDescription(slot);
+ }
+
+ _vm->saveGameState(slot, result);
+ close();
+ }
+}
+
+void MystOptionsDialog::load() {
+ int slot = _loadDialog->runModalWithCurrentTarget();
+
+ if (slot >= 0) {
+ _vm->loadGameState(slot);
+ close();
+ }
}
void MystOptionsDialog::reflowLayout() {
@@ -160,6 +200,19 @@ void MystOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, ui
_vm->_needsShowDemoMenu = true;
close();
break;
+ case kLoadCmd:
+ load();
+ break;
+ case kSaveCmd:
+ save();
+ break;
+ case kQuitCmd: {
+ Common::Event eventQ;
+ eventQ.type = Common::EVENT_QUIT;
+ g_system->getEventManager()->pushEvent(eventQ);
+ close();
+ }
+ break;
case GUI::kOKCmd:
_vm->_gameState->_globals.zipMode = _zipModeCheckbox->getState();
_vm->_gameState->_globals.transitions = _transitionsCheckbox->getState();
diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h
index da8909061f..bc25c72a43 100644
--- a/engines/mohawk/dialogs.h
+++ b/engines/mohawk/dialogs.h
@@ -32,6 +32,10 @@
#include "gui/widget.h"
#include "gui/widgets/list.h"
+namespace GUI {
+class SaveLoadChooser;
+}
+
namespace Mohawk {
class MohawkEngine;
@@ -80,11 +84,22 @@ public:
virtual void handleCommand(GUI::CommandSender*, uint32, uint32);
private:
MohawkEngine_Myst *_vm;
+
GUI::CheckboxWidget *_zipModeCheckbox;
GUI::CheckboxWidget *_transitionsCheckbox;
+
GUI::ButtonWidget *_dropPageButton;
GUI::ButtonWidget *_showMapButton;
GUI::ButtonWidget *_returnToMenuButton;
+
+ GUI::ButtonWidget *_loadButton;
+ GUI::ButtonWidget *_saveButton;
+
+ GUI::SaveLoadChooser *_loadDialog;
+ GUI::SaveLoadChooser *_saveDialog;
+
+ void save();
+ void load();
};
#endif