diff --git a/base/main.cpp b/base/main.cpp
index e2cb980e0c5..af5326dd495 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -298,6 +298,8 @@ static Common::Error runGame(const Plugin *plugin, OSystem &system, const Common
keymapper->addGameKeymap(gameKeymaps[i]);
}
+ system.applyBackendSettings();
+
// Inform backend that the engine is about to be run
system.engineInit();
@@ -353,6 +355,8 @@ static void setupGraphics(OSystem &system) {
system.setShader(ConfMan.get("shader").c_str());
system.endGFXTransaction();
+ system.applyBackendSettings();
+
// When starting up launcher for the first time, the user might have specified
// a --gui-theme option, to allow that option to be working, we need to initialize
// GUI here.
@@ -400,6 +404,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// Register config manager defaults
Base::registerDefaults();
+ system.registerDefaultSettings(Common::ConfigManager::kApplicationDomain);
// Parse the command line
Common::StringMap settings;
diff --git a/common/system.h b/common/system.h
index e1e55481b42..288697ff1ca 100644
--- a/common/system.h
+++ b/common/system.h
@@ -40,6 +40,11 @@ namespace Graphics {
struct Surface;
}
+namespace GUI {
+class GuiObject;
+class OptionsContainerWidget;
+}
+
namespace Common {
class EventManager;
struct Rect;
@@ -1622,6 +1627,36 @@ public:
*/
virtual Common::String getDefaultConfigFileName();
+ /**
+ * Register the default values for the settings the backend uses into the
+ * configuration manager.
+ *
+ * @param target name of a config manager target
+ */
+ virtual void registerDefaultSettings(const Common::String &target) const {}
+
+ /**
+ * Return a GUI widget container for configuring the specified target options.
+ *
+ * The returned widget is shown in the Backend tab in the options dialog.
+ * Backends can build custom options dialogs.
+ *
+ * Backends that don't want to have a Backend tab in the options dialog
+ * can return nullptr.
+ *
+ * @param boss the widget / dialog the returned widget is a child of
+ * @param name the name the returned widget must use
+ * @param target name of a config manager target
+ */
+ virtual GUI::OptionsContainerWidget *buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const { return nullptr; }
+
+ /**
+ * Notify the backend that the settings editable from the game tab in the
+ * options dialog may have changed and that they need to be applied if
+ * necessary.
+ */
+ virtual void applyBackendSettings() {}
+
/**
* Log the given message.
*
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp
index ffb89641d85..f332f673efc 100644
--- a/engines/dialogs.cpp
+++ b/engines/dialogs.cpp
@@ -327,6 +327,19 @@ ConfigDialog::ConfigDialog() :
addKeyMapperControls(tab, "GlobalConfig_KeyMapper.", keymaps, gameDomain);
}
+ //
+ // The backend tab (shown only if the backend implements one)
+ //
+ int backendTabId = tab->addTab(_("Backend"), "GlobalConfig_Backend");
+
+ _backendOptions = g_system->buildBackendOptionsWidget(tab, "GlobalConfig_Backend.Container", _domain);
+
+ if (_backendOptions) {
+ _backendOptions->setParentDialog(this);
+ } else {
+ tab->removeTab(backendTabId);
+ }
+
//
// The Achievements tab
//
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 197eb64c58a..073dacd0ffa 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -639,6 +639,7 @@ void Engine::openMainMenuDialog() {
ttsMan->popState();
#endif
+ g_system->applyBackendSettings();
applyGameSettings();
syncSoundSettings();
}
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index f7a1d712283..4d534eead14 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -38,7 +38,7 @@
#include "graphics/pixelformat.h"
-#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.39"
+#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.40"
class OSystem;
diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp
index ae8cfd82e7b..3974620a500 100644
--- a/gui/editgamedialog.cpp
+++ b/gui/editgamedialog.cpp
@@ -240,6 +240,20 @@ EditGameDialog::EditGameDialog(const String &domain)
addKeyMapperControls(tab, "GameOptions_KeyMapper.", keymaps, domain);
}
+ //
+ // The backend tab (shown only if the backend implements one)
+ //
+ int backendTabId = tab->addTab(_("Backend"), "GameOptions_Backend");
+
+ g_system->registerDefaultSettings(_domain);
+ _backendOptions = g_system->buildBackendOptionsWidget(tab, "GameOptions_Backend.Container", _domain);
+
+ if (_backendOptions) {
+ _backendOptions->setParentDialog(this);
+ } else {
+ tab->removeTab(backendTabId);
+ }
+
//
// 4) The audio tab
//
diff --git a/gui/options.cpp b/gui/options.cpp
index a99927cebf9..f9ba3e5dea2 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -168,6 +168,7 @@ void OptionsDialog::init() {
_joystickDeadzoneSlider = nullptr;
_joystickDeadzoneLabel = nullptr;
_keymapperWidget = nullptr;
+ _backendOptions = nullptr;
_enableGraphicSettings = false;
_gfxPopUp = nullptr;
_gfxPopUpDesc = nullptr;
@@ -285,6 +286,11 @@ void OptionsDialog::build() {
_keymapperWidget->load();
}
+ // Backend options
+ if (_backendOptions) {
+ _backendOptions->load();
+ }
+
// Graphic options
if (_fullscreenCheckbox) {
_gfxPopUp->setSelected(0);
@@ -710,6 +716,12 @@ void OptionsDialog::apply() {
}
}
+ if (_backendOptions) {
+ bool changes = _backendOptions->save();
+ if (changes && _domain == Common::ConfigManager::kApplicationDomain)
+ g_system->applyBackendSettings();
+ }
+
// Control options
if (_enableControlSettings) {
if (g_system->hasFeature(OSystem::kFeatureOnScreenControl)) {
@@ -1815,6 +1827,20 @@ void GlobalOptionsDialog::build() {
addKeyMapperControls(tab, "GlobalOptions_KeyMapper.", keymaps, Common::ConfigManager::kKeymapperDomain);
}
+ //
+ // The backend tab (shown only if the backend implements one)
+ //
+ int backendTabId = tab->addTab(_("Backend"), "GlobalOptions_Backend");
+
+ g_system->registerDefaultSettings(_domain);
+ _backendOptions = g_system->buildBackendOptionsWidget(tab, "GlobalOptions_Backend.Container", _domain);
+
+ if (_backendOptions) {
+ _backendOptions->setParentDialog(this);
+ } else {
+ tab->removeTab(backendTabId);
+ }
+
//
// 2) The audio tab
//
diff --git a/gui/options.h b/gui/options.h
index 93e5ce625f8..00ba6d8bf92 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -59,6 +59,7 @@ class CommandSender;
class GuiObject;
class RadiobuttonGroup;
class RadiobuttonWidget;
+class OptionsContainerWidget;
class OptionsDialog : public Dialog {
public:
@@ -246,6 +247,11 @@ protected:
//
Common::String _guioptions;
Common::String _guioptionsString;
+
+ //
+ // Backend controls
+ //
+ OptionsContainerWidget *_backendOptions;
};
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index b72ca06dfbb..d1b05045d87 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -1666,6 +1666,11 @@ const char *defaultXML1 = ""
""
""
""
+""
""
+""
""
+""
""
+""
""
+""
""
+""
"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+