GUI: Add per-engine and per-game options

This commit is contained in:
Filippos Karapetis 2012-02-27 22:50:01 +02:00 committed by Johannes Schickel
parent be8c557645
commit c84cd8dee8
17 changed files with 267 additions and 13 deletions

View file

@ -145,11 +145,28 @@ protected:
CheckboxWidget *_globalMIDIOverride;
CheckboxWidget *_globalMT32Override;
CheckboxWidget *_globalVolumeOverride;
ExtraGuiOptions _engineOptions;
};
EditGameDialog::EditGameDialog(const String &domain, const String &desc)
: OptionsDialog(domain, "GameOptions") {
// Retrieve all game specific options.
const EnginePlugin *plugin = 0;
// To allow for game domains without a gameid.
// TODO: Is it intentional that this is still supported?
String gameId(ConfMan.get("gameid", domain));
if (gameId.empty())
gameId = domain;
// Retrieve the plugin, since we need to access the engine's MetaEngine
// implementation.
EngineMan.findGame(gameId, &plugin);
if (plugin) {
_engineOptions = (*plugin)->getExtraGuiOptions(domain);
} else {
warning("Plugin for target \"%s\" not found! Game specific settings might be missing", domain.c_str());
}
// GAME: Path to game data (r/o), extra data (r/o), and save data (r/w)
String gamePath(ConfMan.get("path", _domain));
String extraPath(ConfMan.get("extrapath", _domain));
@ -208,7 +225,16 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
}
//
// 2) The graphics tab
// 2) The engine tab (shown only if there are custom engine options)
//
if (_engineOptions.size() > 0) {
tab->addTab(_("Engine"));
addEngineControls(tab, "GameOptions_Engine.", _engineOptions);
}
//
// 3) The graphics tab
//
_graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX"));
@ -220,7 +246,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
addGraphicControls(tab, "GameOptions_Graphics.");
//
// 3) The audio tab
// 4) The audio tab
//
tab->addTab(_("Audio"));
@ -233,7 +259,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
addSubtitleControls(tab, "GameOptions_Audio.");
//
// 4) The volume tab
// 5) The volume tab
//
if (g_system->getOverlayWidth() > 320)
tab->addTab(_("Volume"));
@ -248,7 +274,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
addVolumeControls(tab, "GameOptions_Volume.");
//
// 5) The MIDI tab
// 6) The MIDI tab
//
if (!_guioptions.contains(GUIO_NOMIDI)) {
tab->addTab(_("MIDI"));
@ -262,7 +288,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
}
//
// 6) The MT-32 tab
// 7) The MT-32 tab
//
if (!_guioptions.contains(GUIO_NOMIDI)) {
tab->addTab(_("MT-32"));
@ -276,7 +302,7 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
}
//
// 7) The Paths tab
// 8) The Paths tab
//
if (g_system->getOverlayWidth() > 320)
tab->addTab(_("Paths"));
@ -311,7 +337,6 @@ EditGameDialog::EditGameDialog(const String &domain, const String &desc)
_savePathClearButton = addClearButton(tab, "GameOptions_Paths.SavePathClearButton", kCmdSavePathClear);
// Activate the first tab
tab->setActiveTab(0);
_tabWidget = tab;
@ -386,6 +411,19 @@ void EditGameDialog::open() {
_langPopUp->setEnabled(false);
}
// Set the state of engine-specific checkboxes
for (uint j = 0; j < _engineOptions.size(); ++j) {
// The default values for engine-specific checkboxes are not set when
// ScummVM starts, as this would require us to load and poll all of the
// engine plugins on startup. Thus, we set the state of each custom
// option checkbox to what is specified by the engine plugin, and
// update it only if a value has been set in the configuration of the
// currently selected game.
bool isChecked = _engineOptions[j].defaultState;
if (ConfMan.hasKey(_engineOptions[j].configOption, _domain))
isChecked = ConfMan.getBool(_engineOptions[j].configOption, _domain);
_engineCheckboxes[j]->setState(isChecked);
}
const Common::PlatformDescription *p = Common::g_platforms;
const Common::Platform platform = Common::parsePlatform(ConfMan.get("platform", _domain));
@ -429,6 +467,11 @@ void EditGameDialog::close() {
ConfMan.removeKey("platform", _domain);
else
ConfMan.set("platform", Common::getPlatformCode(platform), _domain);
// Set the state of engine-specific checkboxes
for (uint i = 0; i < _engineOptions.size(); i++) {
ConfMan.setBool(_engineOptions[i].configOption, _engineCheckboxes[i]->getState(), _domain);
}
}
OptionsDialog::close();
}