diff options
author | Max Horn | 2010-05-26 19:54:50 +0000 |
---|---|---|
committer | Max Horn | 2010-05-26 19:54:50 +0000 |
commit | 947edd08c3b60ec873fcc6c922ef4ebb34ba2305 (patch) | |
tree | cdd32b9f1a079f3da714e0b64204cf901c685d1e /engines | |
parent | db475d1501452490ab4e95ecbd181380b0bec414 (diff) | |
download | scummvm-rg350-947edd08c3b60ec873fcc6c922ef4ebb34ba2305.tar.gz scummvm-rg350-947edd08c3b60ec873fcc6c922ef4ebb34ba2305.tar.bz2 scummvm-rg350-947edd08c3b60ec873fcc6c922ef4ebb34ba2305.zip |
Replace SCUMM F5 dialog by GMM & add help button to GMM
The new "Help" button in the GMM is currently only used by SCUMM.
To use it, an engine currently needs to subclass MainMenuDialog.
svn-id: r49249
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dialogs.cpp | 45 | ||||
-rw-r--r-- | engines/dialogs.h | 43 | ||||
-rw-r--r-- | engines/scumm/dialogs.cpp | 213 | ||||
-rw-r--r-- | engines/scumm/dialogs.h | 24 | ||||
-rw-r--r-- | engines/scumm/input.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 18 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 2 |
7 files changed, 67 insertions, 280 deletions
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 73ba591b4b..954bc81470 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -35,8 +35,9 @@ #include "gui/GuiManager.h" #include "gui/launcher.h" #include "gui/ListWidget.h" -#include "gui/ThemeEval.h" +#include "gui/options.h" #include "gui/saveload.h" +#include "gui/ThemeEval.h" #include "engines/dialogs.h" #include "engines/engine.h" @@ -49,16 +50,17 @@ using GUI::CommandSender; using GUI::StaticTextWidget; -enum { - kSaveCmd = 'SAVE', - kLoadCmd = 'LOAD', - kPlayCmd = 'PLAY', - kOptionsCmd = 'OPTN', - kHelpCmd = 'HELP', - kAboutCmd = 'ABOU', - kQuitCmd = 'QUIT', - kRTLCmd = 'RTL ', - kChooseCmd = 'CHOS' +class ConfigDialog : public GUI::OptionsDialog { +protected: +#ifdef SMALL_SCREEN_DEVICE + GUI::Dialog *_keysDialog; +#endif + +public: + ConfigDialog(bool subtitleControls); + ~ConfigDialog(); + + virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); }; MainMenuDialog::MainMenuDialog(Engine *engine) @@ -95,6 +97,12 @@ MainMenuDialog::MainMenuDialog(Engine *engine) new GUI::ButtonWidget(this, "GlobalMenu.Options", "Options", kOptionsCmd, 'O'); + // The help button is disabled by default. + // To enable "Help", an engine needs to use a subclass of MainMenuDialog + // (at least for now, we might change how this works in the future). + _helpButton = new GUI::ButtonWidget(this, "GlobalMenu.Help", "Help", kHelpCmd, 'H'); + _helpButton->setEnabled(false); + new GUI::ButtonWidget(this, "GlobalMenu.About", "About", kAboutCmd, 'A'); _rtlButton = new GUI::ButtonWidget(this, "GlobalMenu.RTL", "Return to Launcher", kRTLCmd, 'R'); @@ -135,6 +143,9 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat case kAboutCmd: _aboutDialog->runModal(); break; + case kHelpCmd: + // Not handled here -- needs to be handled by a subclass (for now) + break; case kRTLCmd: { Common::Event eventRTL; eventRTL.type = Common::EVENT_RTL; @@ -263,13 +274,13 @@ enum { // "" as value for the domain, and in fact provide a somewhat better user // experience at the same time. ConfigDialog::ConfigDialog(bool subtitleControls) - : GUI::OptionsDialog("", "ScummConfig") { + : GUI::OptionsDialog("", "GlobalConfig") { // // Sound controllers // - addVolumeControls(this, "ScummConfig."); + addVolumeControls(this, "GlobalConfig."); setVolumeSettingsState(true); // could disable controls by GUI options // @@ -278,7 +289,7 @@ ConfigDialog::ConfigDialog(bool subtitleControls) if (subtitleControls) { // Global talkspeed range of 0-255 - addSubtitleControls(this, "ScummConfig.", 255); + addSubtitleControls(this, "GlobalConfig.", 255); setSubtitleSettingsState(true); // could disable controls by GUI options } @@ -286,11 +297,11 @@ ConfigDialog::ConfigDialog(bool subtitleControls) // Add the buttons // - new GUI::ButtonWidget(this, "ScummConfig.Ok", "OK", GUI::kOKCmd, 'O'); - new GUI::ButtonWidget(this, "ScummConfig.Cancel", "Cancel", GUI::kCloseCmd, 'C'); + new GUI::ButtonWidget(this, "GlobalConfig.Ok", "OK", GUI::kOKCmd, 'O'); + new GUI::ButtonWidget(this, "GlobalConfig.Cancel", "Cancel", GUI::kCloseCmd, 'C'); #ifdef SMALL_SCREEN_DEVICE - new GUI::ButtonWidget(this, "ScummConfig.Keys", "Keys", kKeysCmd, 'K'); + new GUI::ButtonWidget(this, "GlobalConfig.Keys", "Keys", kKeysCmd, 'K'); _keysDialog = NULL; #endif } diff --git a/engines/dialogs.h b/engines/dialogs.h index 6bee7c5fb1..6e5338b317 100644 --- a/engines/dialogs.h +++ b/engines/dialogs.h @@ -27,7 +27,6 @@ #include "common/str.h" #include "gui/dialog.h" -#include "gui/options.h" class Engine; @@ -39,6 +38,19 @@ namespace GUI { class MainMenuDialog : public GUI::Dialog { public: + enum { + kSaveCmd = 'SAVE', + kLoadCmd = 'LOAD', + kPlayCmd = 'PLAY', + kOptionsCmd = 'OPTN', + kHelpCmd = 'HELP', + kAboutCmd = 'ABOU', + kQuitCmd = 'QUIT', + kRTLCmd = 'RTL ', + kChooseCmd = 'CHOS' + }; + +public: MainMenuDialog(Engine *engine); ~MainMenuDialog(); @@ -51,29 +63,20 @@ protected: void load(); protected: - Engine *_engine; + Engine *_engine; - GUI::GraphicsWidget *_logo; - GUI::ButtonWidget *_rtlButton; - GUI::ButtonWidget *_loadButton; - GUI::ButtonWidget *_saveButton; - GUI::Dialog *_aboutDialog; - GUI::Dialog *_optionsDialog; - GUI::SaveLoadChooser *_loadDialog; - GUI::SaveLoadChooser *_saveDialog; -}; + GUI::GraphicsWidget *_logo; -class ConfigDialog : public GUI::OptionsDialog { -protected: -#ifdef SMALL_SCREEN_DEVICE - GUI::Dialog *_keysDialog; -#endif + GUI::ButtonWidget *_rtlButton; + GUI::ButtonWidget *_loadButton; + GUI::ButtonWidget *_saveButton; + GUI::ButtonWidget *_helpButton; -public: - ConfigDialog(bool subtitleControls); - ~ConfigDialog(); + GUI::Dialog *_aboutDialog; + GUI::Dialog *_optionsDialog; - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); + GUI::SaveLoadChooser *_loadDialog; + GUI::SaveLoadChooser *_saveDialog; }; #endif diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 1f153094c1..d9c24ddca2 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -233,19 +233,6 @@ protected: #endif -class ConfigDialog : public GUI::OptionsDialog { -protected: -#ifdef SMALL_SCREEN_DEVICE - GUI::Dialog *_keysDialog; -#endif - -public: - ConfigDialog(); - ~ConfigDialog(); - - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); -}; - #pragma mark - ScummDialog::ScummDialog(int x, int y, int w, int h) : GUI::Dialog(x, y, w, h) { @@ -258,223 +245,31 @@ ScummDialog::ScummDialog(String name) : GUI::Dialog(name) { #pragma mark - -enum { - kSaveCmd = 'SAVE', - kLoadCmd = 'LOAD', - kPlayCmd = 'PLAY', - kOptionsCmd = 'OPTN', - kHelpCmd = 'HELP', - kAboutCmd = 'ABOU', - kQuitCmd = 'QUIT', - kChooseCmd = 'CHOS' -}; - -ScummMenuDialog::ScummMenuDialog(ScummEngine *scumm) - : ScummDialog("ScummMain"), _vm(scumm) { - - new GUI::ButtonWidget(this, "ScummMain.Resume", "Resume", kPlayCmd, 'P'); - - _loadButton = new GUI::ButtonWidget(this, "ScummMain.Load", "Load", kLoadCmd, 'L'); - _saveButton = new GUI::ButtonWidget(this, "ScummMain.Save", "Save", kSaveCmd, 'S'); - - new GUI::ButtonWidget(this, "ScummMain.Options", "Options", kOptionsCmd, 'O'); #ifndef DISABLE_HELP - new GUI::ButtonWidget(this, "ScummMain.Help", "Help", kHelpCmd, 'H'); -#endif - new GUI::ButtonWidget(this, "ScummMain.About", "About", kAboutCmd, 'A'); - - new GUI::ButtonWidget(this, "ScummMain.Quit", "Quit", kQuitCmd, 'Q'); - // - // Create the sub dialog(s) - // - _aboutDialog = new GUI::AboutDialog(); - _optionsDialog = new ConfigDialog(); -#ifndef DISABLE_HELP +ScummMenuDialog::ScummMenuDialog(ScummEngine *scumm) + : MainMenuDialog(scumm) { _helpDialog = new HelpDialog(scumm->_game); -#endif - _saveDialog = new GUI::SaveLoadChooser("Save game:", "Save"); - _saveDialog->setSaveMode(true); - _loadDialog = new GUI::SaveLoadChooser("Load game:", "Load"); - _loadDialog->setSaveMode(false); + _helpButton->setEnabled(true); } ScummMenuDialog::~ScummMenuDialog() { - delete _aboutDialog; - delete _optionsDialog; -#ifndef DISABLE_HELP delete _helpDialog; -#endif - delete _saveDialog; - delete _loadDialog; -} - -int ScummMenuDialog::runModal() { - _loadButton->setEnabled(_vm->canLoadGameStateCurrently()); - _saveButton->setEnabled(_vm->canSaveGameStateCurrently()); - return ScummDialog::runModal(); -} - -void ScummMenuDialog::reflowLayout() { - _loadButton->setEnabled(_vm->canLoadGameStateCurrently()); - _saveButton->setEnabled(_vm->canSaveGameStateCurrently()); - Dialog::reflowLayout(); } void ScummMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { - case kSaveCmd: - save(); - break; - case kLoadCmd: - load(); - break; - case kPlayCmd: - close(); - break; - case kOptionsCmd: - _optionsDialog->runModal(); - break; - case kAboutCmd: - _aboutDialog->runModal(); - break; -#ifndef DISABLE_HELP case kHelpCmd: _helpDialog->runModal(); break; -#endif - case kQuitCmd: - _vm->quitGame(); - close(); - break; default: - ScummDialog::handleCommand(sender, cmd, data); - } -} - -void ScummMenuDialog::save() { - Common::String gameId = ConfMan.get("gameid"); - - const EnginePlugin *plugin = 0; - EngineMan.findGame(gameId, &plugin); - - int idx = _saveDialog->runModal(plugin, ConfMan.getActiveDomainName()); - if (idx >= 0) { - String result(_saveDialog->getResultString()); - char buffer[20]; - const char *str; - if (result.empty()) { - // If the user was lazy and entered no save name, come up with a default name. - sprintf(buffer, "Save %d", idx); - str = buffer; - } else - str = result.c_str(); - _vm->requestSave(idx, str); - close(); - } -} - -void ScummMenuDialog::load() { - Common::String gameId = ConfMan.get("gameid"); - - const EnginePlugin *plugin = 0; - EngineMan.findGame(gameId, &plugin); - - int idx = _loadDialog->runModal(plugin, ConfMan.getActiveDomainName()); - if (idx >= 0) { - _vm->requestLoad(idx); - close(); + MainMenuDialog::handleCommand(sender, cmd, data); } } #pragma mark - enum { - kKeysCmd = 'KEYS' -}; - -// FIXME: We use the empty string as domain name here. This tells the -// ConfigManager to use the 'default' domain for all its actions. We do that -// to get as close as possible to editing the 'active' settings. -// -// However, that requires bad & evil hacks in the ConfigManager code, -// and even then still doesn't work quite correctly. -// For example, if the transient domain contains 'false' for the 'fullscreen' -// flag, but the user used a hotkey to switch to windowed mode, then the dialog -// will display the wrong value anyway. -// -// Proposed solution consisting of multiple steps: -// 1) Add special code to the open() code that reads out everything stored -// in the transient domain that is controlled by this dialog, and updates -// the dialog accordingly. -// 2) Even more code is added to query the backend for current settings, like -// the fullscreen mode flag etc., and also updates the dialog accordingly. -// 3) The domain being edited is set to the active game domain. -// 4) If the dialog is closed with the "OK" button, then we remove everything -// stored in the transient domain (or at least everything corresponding to -// switches in this dialog. -// If OTOH the dialog is closed with "Cancel" we do no such thing. -// -// These changes will achieve two things at once: Allow us to get rid of using -// "" as value for the domain, and in fact provide a somewhat better user -// experience at the same time. -ConfigDialog::ConfigDialog() - : GUI::OptionsDialog("", "ScummConfig") { - - // - // Sound controllers - // - - addVolumeControls(this, "ScummConfig."); - - // - // Some misc options - // - - // SCUMM has a talkspeed range of 0-9 - addSubtitleControls(this, "ScummConfig.", 9); - - // - // Add the buttons - // - - new GUI::ButtonWidget(this, "ScummConfig.Ok", "OK", GUI::kOKCmd, 'O'); - new GUI::ButtonWidget(this, "ScummConfig.Cancel", "Cancel", GUI::kCloseCmd, 'C'); -#ifdef SMALL_SCREEN_DEVICE - new GUI::ButtonWidget(this, "ScummConfig.Keys", "Keys", kKeysCmd, 'K'); - _keysDialog = NULL; -#endif -} - -ConfigDialog::~ConfigDialog() { -#ifdef SMALL_SCREEN_DEVICE - delete _keysDialog; -#endif -} - -void ConfigDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { - switch (cmd) { - case kKeysCmd: -#ifdef SMALL_SCREEN_DEVICE - // - // Create the sub dialog(s) - // - _keysDialog = new GUI::KeysDialog(); - _keysDialog->runModal(); - delete _keysDialog; - _keysDialog = NULL; -#endif - break; - default: - GUI::OptionsDialog::handleCommand (sender, cmd, data); - } -} - -#ifndef DISABLE_HELP - -#pragma mark - - -enum { kNextCmd = 'NEXT', kPrevCmd = 'PREV' }; diff --git a/engines/scumm/dialogs.h b/engines/scumm/dialogs.h index 7889027dcf..41a8ec83c1 100644 --- a/engines/scumm/dialogs.h +++ b/engines/scumm/dialogs.h @@ -27,9 +27,8 @@ #include "common/str.h" #include "gui/dialog.h" -#include "gui/options.h" #include "gui/widget.h" -#include "gui/saveload.h" +#include "engines/dialogs.h" #include "scumm/detection.h" @@ -52,32 +51,17 @@ protected: typedef Common::String String; }; -class ScummMenuDialog : public ScummDialog { +#ifndef DISABLE_HELP +class ScummMenuDialog : public MainMenuDialog { public: ScummMenuDialog(ScummEngine *scumm); ~ScummMenuDialog(); virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); - virtual void reflowLayout(); - - int runModal(); protected: - ScummEngine *_vm; - - GUI::Dialog *_aboutDialog; - GUI::Dialog *_optionsDialog; -#ifndef DISABLE_HELP GUI::Dialog *_helpDialog; -#endif - GUI::SaveLoadChooser *_saveDialog; - GUI::SaveLoadChooser *_loadDialog; - - GUI::ButtonWidget *_loadButton; - GUI::ButtonWidget *_saveButton; - - void save(); - void load(); }; +#endif /** * A dialog which displays an arbitrary message to the user and returns diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 8a9570f534..dc3a5d26b3 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -508,7 +508,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) { if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0); - scummMenuDialog(); // Display GUI + openMainMenuDialog(); // Display global main menu if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0) runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, 0); diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 2359d4a04f..bb50ce7bb2 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -108,7 +108,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _language(dr.language), _debugger(0), _currentScript(0xFF), // Let debug() work on init stage - _messageDialog(0), _pauseDialog(0), _scummMenuDialog(0), _versionDialog(0) { + _messageDialog(0), _pauseDialog(0), _versionDialog(0) { if (_game.platform == Common::kPlatformNES) { _gdi = new GdiNES(this); @@ -140,7 +140,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _fileHandle = 0; - // Init all vars _v0ObjectIndex = false; _v0ObjectInInventory = false; @@ -152,7 +151,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _sound = NULL; memset(&vm, 0, sizeof(vm)); _pauseDialog = NULL; - _scummMenuDialog = NULL; _versionDialog = NULL; _fastMode = 0; _actors = NULL; @@ -552,6 +550,12 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) for (int i = 0; i < ARRAYSIZE(debugChannels); ++i) DebugMan.addDebugChannel(debugChannels[i].flag, debugChannels[i].channel, debugChannels[i].desc); +#ifndef DISABLE_HELP + // Create custom GMM dialog providing a help subdialog + assert(!_mainMenuDialog); + _mainMenuDialog = new ScummMenuDialog(this); +#endif + g_eventRec.registerRandomSource(_rnd, "scumm"); } @@ -572,7 +576,6 @@ ScummEngine::~ScummEngine() { delete _charset; delete _messageDialog; delete _pauseDialog; - delete _scummMenuDialog; delete _versionDialog; delete _fileHandle; @@ -2437,13 +2440,6 @@ void ScummEngine::versionDialog() { runDialog(*_versionDialog); } -void ScummEngine::scummMenuDialog() { - if (!_scummMenuDialog) - _scummMenuDialog = new ScummMenuDialog(this); - runDialog(*_scummMenuDialog); - syncSoundSettings(); -} - void ScummEngine::confirmExitDialog() { ConfirmDialog d(this, 6); diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 885ab790de..42322ba5a2 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -530,7 +530,6 @@ protected: Dialog *_pauseDialog; Dialog *_messageDialog; Dialog *_versionDialog; - Dialog *_scummMenuDialog; virtual int runDialog(Dialog &dialog); void confirmExitDialog(); @@ -538,7 +537,6 @@ protected: void pauseDialog(); void messageDialog(const char *message); void versionDialog(); - void scummMenuDialog(); char displayMessage(const char *altButton, const char *message, ...) GCC_PRINTF(3, 4); |