[Scummvm-git-logs] scummvm master -> 1f00706bfba81d42db00ef141205748bedaff451
somaen
noreply at scummvm.org
Sun Feb 12 08:45:25 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1f00706bfb BASE: Filter out old graphics modes when passed to -g
Commit: 1f00706bfba81d42db00ef141205748bedaff451
https://github.com/scummvm/scummvm/commit/1f00706bfba81d42db00ef141205748bedaff451
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-02-12T09:44:51+01:00
Commit Message:
BASE: Filter out old graphics modes when passed to -g
Fix #12775
Changed paths:
base/main.cpp
base/plugins.cpp
graphics/scalerplugin.h
diff --git a/base/main.cpp b/base/main.cpp
index 6e2b78c997a..4b57bddb292 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -84,6 +84,7 @@
#if defined(__DC__)
#include "backends/platform/dc/DCLauncherDialog.h"
#else
+#include "graphics/scalerplugin.h"
#include "gui/launcher.h"
#endif
@@ -587,6 +588,19 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
}
#endif
+ // If we received an old style graphics mode parameter via command line
+ // override it to default at this stage, so that the backend init won't
+ // pass it onto updateOldSettings(). If it happened to be a valid new
+ // graphics mode, we'll put it back after initBackend().
+ Common::String gfxModeSetting;
+ if (settings.contains("gfx-mode")) {
+ gfxModeSetting = settings["gfx-mode"];
+ if (ScalerMan.isOldGraphicsSetting(gfxModeSetting)) {
+ settings["gfx-mode"] = "default";
+ ConfMan.set("gfx_mode", settings["gfx-mode"], Common::ConfigManager::kSessionDomain);
+ }
+ }
+
// Init the backend. Must take place after all config data (including
// the command line params) was read.
system.initBackend();
@@ -595,19 +609,22 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// we check this here. We can't do it until after the backend is inited,
// or there won't be a graphics manager to ask for the supported modes.
- if (settings.contains("gfx-mode")) {
+ if (!gfxModeSetting.empty()) {
const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
- Common::String option = settings["gfx-mode"];
bool isValid = false;
while (gm->name && !isValid) {
- isValid = !scumm_stricmp(gm->name, option.c_str());
+ isValid = !scumm_stricmp(gm->name, gfxModeSetting.c_str());
gm++;
}
if (!isValid) {
- warning("Unrecognized graphics mode '%s'. Switching to default mode", option.c_str());
- settings["gfx-mode"] = "default";
+ // We will actually already have switched to default, but couldn't be sure that it was right until now.
+ warning("Unrecognized graphics mode '%s'. Switching to default mode", gfxModeSetting.c_str());
+ } else {
+ settings["gfx-mode"] = gfxModeSetting;
+ system.setGraphicsMode(gfxModeSetting.c_str());
}
+ ConfMan.set("gfx_mode", gfxModeSetting, Common::ConfigManager::kSessionDomain);
}
if (settings.contains("disable-display")) {
ConfMan.setInt("disable-display", 1, Common::ConfigManager::kTransientDomain);
diff --git a/base/plugins.cpp b/base/plugins.cpp
index cefe7401168..ee807aac4b8 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -1081,6 +1081,15 @@ static const LegacyGraphicsMode s_legacyGraphicsModes[] = {
{ "tv2x", "tv", 2 }
};
+bool ScalerManager::isOldGraphicsSetting(const Common::String &gfxMode) {
+ for (uint i = 0; i < ARRAYSIZE(s_legacyGraphicsModes); ++i) {
+ if (gfxMode == s_legacyGraphicsModes[i].oldName) {
+ return true;
+ }
+ }
+ return false;
+}
+
void ScalerManager::updateOldSettings() {
// Search for legacy gfx_mode and replace it
if (ConfMan.hasKey("gfx_mode")) {
diff --git a/graphics/scalerplugin.h b/graphics/scalerplugin.h
index a268fd49673..bc1425322a2 100644
--- a/graphics/scalerplugin.h
+++ b/graphics/scalerplugin.h
@@ -234,6 +234,11 @@ public:
* Update scaler settings from older versions of ScummVM.
*/
void updateOldSettings();
+
+ /**
+ * Returns whether the supplied mode is one of the old gfx-modes.
+ */
+ bool isOldGraphicsSetting(const Common::String &gfxMode);
};
/** Convenience shortcut for accessing singleton */
More information about the Scummvm-git-logs
mailing list