mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 12:09:15 +00:00
ENGINES: Allow showing the engine options in the in-game options dialog
This commit is contained in:
parent
bcfb7145fa
commit
0d895ec2f9
@ -121,7 +121,7 @@ void MainMenuDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint3
|
||||
save();
|
||||
break;
|
||||
case kOptionsCmd: {
|
||||
GUI::ConfigDialog configDialog(_engine->hasFeature(Engine::kSupportsSubtitleOptions));
|
||||
GUI::ConfigDialog configDialog;
|
||||
configDialog.runModal();
|
||||
break;
|
||||
}
|
||||
@ -270,18 +270,37 @@ namespace GUI {
|
||||
// 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(bool subtitleControls) : GUI::OptionsDialog("", "GlobalConfig") {
|
||||
init(subtitleControls);
|
||||
}
|
||||
ConfigDialog::ConfigDialog() :
|
||||
GUI::OptionsDialog("", "GlobalConfig"),
|
||||
_engineOptions(nullptr) {
|
||||
assert(g_engine);
|
||||
|
||||
ConfigDialog::ConfigDialog() : GUI::OptionsDialog("", "GlobalConfig") {
|
||||
init(g_engine->hasFeature(Engine::kSupportsSubtitleOptions));
|
||||
}
|
||||
const Common::String &gameDomain = ConfMan.getActiveDomainName();
|
||||
const MetaEngine &metaEngine = g_engine->getMetaEngine();
|
||||
|
||||
void ConfigDialog::init(bool subtitleControls) {
|
||||
// GUI: Add tab widget
|
||||
GUI::TabWidget *tab = new GUI::TabWidget(this, "GlobalConfig.TabWidget");
|
||||
|
||||
//
|
||||
// The game specific options tab
|
||||
//
|
||||
|
||||
int tabId = tab->addTab(_("Game"), "GlobalConfig_Engine");
|
||||
|
||||
if (g_engine->hasFeature(Engine::kSupportsChangingOptionsDuringRuntime)) {
|
||||
_engineOptions = metaEngine.buildEngineOptionsWidget(tab, "GlobalConfig_Engine.Container", gameDomain);
|
||||
}
|
||||
|
||||
if (_engineOptions) {
|
||||
_engineOptions->setParentDialog(this);
|
||||
} else {
|
||||
tab->removeTab(tabId);
|
||||
}
|
||||
|
||||
//
|
||||
// The Audio / Subtitles tab
|
||||
//
|
||||
|
||||
tab->addTab(_("Audio"), "GlobalConfig_Audio");
|
||||
|
||||
//
|
||||
@ -295,7 +314,7 @@ void ConfigDialog::init(bool subtitleControls) {
|
||||
// Subtitle speed and toggle controllers
|
||||
//
|
||||
|
||||
if (subtitleControls) {
|
||||
if (g_engine->hasFeature(Engine::kSupportsSubtitleOptions)) {
|
||||
// Global talkspeed range of 0-255
|
||||
addSubtitleControls(tab, "GlobalConfig_Audio.", 255);
|
||||
setSubtitleSettingsState(true); // could disable controls by GUI options
|
||||
@ -304,14 +323,8 @@ void ConfigDialog::init(bool subtitleControls) {
|
||||
//
|
||||
// The Keymap tab
|
||||
//
|
||||
const Common::String &gameDomain = ConfMan.getActiveDomainName();
|
||||
const Plugin *plugin = EngineMan.findPlugin(ConfMan.get("engineid"));
|
||||
|
||||
Common::KeymapArray keymaps;
|
||||
if (plugin) {
|
||||
keymaps = plugin->get<MetaEngine>().initKeymaps(gameDomain.c_str());
|
||||
}
|
||||
|
||||
Common::KeymapArray keymaps = metaEngine.initKeymaps(gameDomain.c_str());
|
||||
if (!keymaps.empty()) {
|
||||
tab->addTab(_("Keymaps"), "GlobalConfig_KeyMapper");
|
||||
addKeyMapperControls(tab, "GlobalConfig_KeyMapper.", keymaps, gameDomain);
|
||||
@ -339,6 +352,23 @@ ConfigDialog::~ConfigDialog() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void ConfigDialog::build() {
|
||||
OptionsDialog::build();
|
||||
|
||||
// Engine options
|
||||
if (_engineOptions) {
|
||||
_engineOptions->load();
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigDialog::apply() {
|
||||
if (_engineOptions) {
|
||||
_engineOptions->save();
|
||||
}
|
||||
|
||||
OptionsDialog::apply();
|
||||
}
|
||||
|
||||
void ConfigDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
switch (cmd) {
|
||||
case kKeysCmd:
|
||||
|
@ -81,19 +81,22 @@ protected:
|
||||
namespace GUI {
|
||||
|
||||
class ConfigDialog : public OptionsDialog {
|
||||
private:
|
||||
void init(bool subtitleControls);
|
||||
protected:
|
||||
#ifdef GUI_ENABLE_KEYSDIALOG
|
||||
Dialog *_keysDialog;
|
||||
#endif
|
||||
|
||||
public:
|
||||
ConfigDialog(bool subtitleControls);
|
||||
ConfigDialog();
|
||||
~ConfigDialog() override;
|
||||
|
||||
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data) override;
|
||||
|
||||
// OptionsDialog API
|
||||
void build() override;
|
||||
void apply() override;
|
||||
|
||||
private:
|
||||
OptionsContainerWidget *_engineOptions;
|
||||
|
||||
#ifdef GUI_ENABLE_KEYSDIALOG
|
||||
Dialog *_keysDialog;
|
||||
#endif
|
||||
};
|
||||
|
||||
class ExtraGuiOptionsWidget : public OptionsContainerWidget {
|
||||
|
@ -580,6 +580,7 @@ void Engine::openMainMenuDialog() {
|
||||
}
|
||||
}
|
||||
|
||||
applyGameSettings();
|
||||
syncSoundSettings();
|
||||
#ifdef USE_TTS
|
||||
ttsMan->popState();
|
||||
|
@ -149,7 +149,14 @@ public:
|
||||
* If this feature is supported, then the corresponding MetaEngine *must*
|
||||
* support the kSupportsListSaves feature.
|
||||
*/
|
||||
kSupportsSavingDuringRuntime
|
||||
kSupportsSavingDuringRuntime,
|
||||
|
||||
/**
|
||||
* Changing the game settings during runtime is supported. This enables
|
||||
* showing the engine options tab in the config dialog accessed through
|
||||
* the Global Main Menu.
|
||||
*/
|
||||
kSupportsChangingOptionsDuringRuntime
|
||||
};
|
||||
|
||||
|
||||
@ -209,8 +216,6 @@ public:
|
||||
*/
|
||||
virtual bool hasFeature(EngineFeature f) const { return false; }
|
||||
|
||||
// virtual EnginePlugin *getMetaEnginePlugin() const;
|
||||
|
||||
/**
|
||||
* Notify the engine that the sound settings in the config manager may have
|
||||
* changed and that it hence should adjust any internal volume etc. values
|
||||
@ -228,6 +233,13 @@ public:
|
||||
*/
|
||||
virtual void syncSoundSettings();
|
||||
|
||||
/**
|
||||
* Notify the engine that the settings editable from the game tab in the
|
||||
* in-game options dialog may have changed and that they need to be applied
|
||||
* if necessary.
|
||||
*/
|
||||
virtual void applyGameSettings() {}
|
||||
|
||||
/**
|
||||
* Flip mute all sound option.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user