[Scummvm-git-logs] scummvm master -> 05bd770ea9593cb718a83ae2864e30716d86b5d0

criezy criezy at scummvm.org
Sun Apr 9 22:09:14 CEST 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
7ff4641d5d GUI: Restore settings if GUI cannot be rendered
05bd770ea9 Merge pull request #921 from Joefish/PR_9711


Commit: 7ff4641d5dbb93e4c4cab16a738aa1a2b196f40c
    https://github.com/scummvm/scummvm/commit/7ff4641d5dbb93e4c4cab16a738aa1a2b196f40c
Author: Joseph-Eugene Winzer (m999 at openmailbox.org)
Date: 2017-04-06T23:08:28+02:00

Commit Message:
GUI: Restore settings if GUI cannot be rendered

PR#921 changes the behavior of the client that if the GUI fails to be
rendered the previously applied settings in the misc category are
restored. Error messages were altered according to the changes.

Bug: #9717 GUI: Indirectly changing 'GUI Language' can produce
                inconsistent behaviour when changing some options.

Changed paths:
    gui/ThemeEngine.cpp
    gui/options.cpp


diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index c27d36d..ecea945 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -722,7 +722,9 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &file, const Com
 #ifdef USE_TRANSLATION
 			TransMan.setLanguage("C");
 #endif
-			warning("Failed to load localized font '%s'. Using non-localized font and default GUI language instead", localized.c_str());
+			warning("Failed to load localized font '%s'.", localized.c_str());
+
+			return false;
 		}
 	}
 
diff --git a/gui/options.cpp b/gui/options.cpp
index 179fa65..20191e7 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -1619,7 +1619,7 @@ void GlobalOptionsDialog::build() {
 
 	// Select the currently configured language or default/English if
 	// nothing is specified.
-	if (ConfMan.hasKey("gui_language"))
+	if (ConfMan.hasKey("gui_language") && !ConfMan.get("gui_language").empty())
 		_guiLanguagePopUp->setSelectedTag(TransMan.parseLanguage(ConfMan.get("gui_language")));
 	else
 #ifdef USE_DETECTLANG
@@ -1797,6 +1797,10 @@ void GlobalOptionsDialog::clean() {
 }
 
 void GlobalOptionsDialog::apply() {
+	OptionsDialog::apply();
+
+	bool isRebuildNeeded = false;
+
 	Common::String savePath(_savePath->getLabel());
 	if (!savePath.empty() && (savePath != _("Default")))
 		ConfMan.set("savepath", savePath, _domain);
@@ -1833,15 +1837,6 @@ void GlobalOptionsDialog::apply() {
 
 	ConfMan.setInt("autosave_period", _autosavePeriodPopUp->getSelectedTag(), _domain);
 
-	GUI::ThemeEngine::GraphicsMode selected = (GUI::ThemeEngine::GraphicsMode)_rendererPopUp->getSelectedTag();
-	const char *cfg = GUI::ThemeEngine::findModeConfigName(selected);
-	if (!ConfMan.get("gui_renderer").equalsIgnoreCase(cfg)) {
-		// FIXME: Actually, any changes (including the theme change) should
-		// only become active *after* the options dialog has closed.
-		g_gui.loadNewTheme(g_gui.theme()->getThemeId(), selected);
-		ConfMan.set("gui_renderer", cfg, _domain);
-	}
-
 #ifdef USE_UPDATES
 	ConfMan.setInt("updates_check", _updatesPopUp->getSelectedTag());
 
@@ -1885,52 +1880,73 @@ void GlobalOptionsDialog::apply() {
 #endif // USE_SDL_NET
 #endif // USE_CLOUD
 
+	Common::String oldThemeId = g_gui.theme()->getThemeId();
+	Common::String oldThemeName = g_gui.theme()->getThemeName();
 	if (!_newTheme.empty()) {
+		ConfMan.set("gui_theme", _newTheme);
+	}
+
 #ifdef USE_TRANSLATION
-		Common::String lang = TransMan.getCurrentLanguage();
-#endif
-		Common::String oldTheme = g_gui.theme()->getThemeId();
-		if (g_gui.loadNewTheme(_newTheme)) {
-#ifdef USE_TRANSLATION
-			// If the charset has changed, it means the font were not found for the
-			// new theme. Since for the moment we do not support change of translation
-			// language without restarting, we let the user know about this.
-			if (lang != TransMan.getCurrentLanguage()) {
-				TransMan.setLanguage(lang.c_str());
-				g_gui.loadNewTheme(oldTheme);
-				_curTheme->setLabel(g_gui.theme()->getThemeName());
-				MessageDialog error(_("The theme you selected does not support your current language. If you want to use this theme you need to switch to another language first."));
-				error.runModal();
-			} else {
-#endif
-				ConfMan.set("gui_theme", _newTheme);
-#ifdef USE_TRANSLATION
-			}
+	int selectedLang = _guiLanguagePopUp->getSelectedTag();
+	Common::String oldLang = ConfMan.get("gui_language");
+	Common::String newLang = TransMan.getLangById(selectedLang);
+	Common::String newCharset;
+	if (newLang != oldLang) {
+		TransMan.setLanguage(newLang);
+		ConfMan.set("gui_language", newLang);
+		newCharset = TransMan.getCurrentCharset();
+		isRebuildNeeded = true;
+	}
 #endif
-		}
-		draw();
-		_newTheme.clear();
+
+	GUI::ThemeEngine::GraphicsMode gfxMode = (GUI::ThemeEngine::GraphicsMode)_rendererPopUp->getSelectedTag();
+	Common::String oldGfxConfig = ConfMan.get("gui_renderer");
+	Common::String newGfxConfig = GUI::ThemeEngine::findModeConfigName(gfxMode);
+	if (newGfxConfig != oldGfxConfig) {
+		ConfMan.set("gui_renderer", newGfxConfig, _domain);
 	}
+
+	if (_newTheme.empty())
+		_newTheme = oldThemeId;
+
+	if (!g_gui.loadNewTheme(_newTheme, gfxMode, true)) {
+		Common::String errorMessage;
+
+		_curTheme->setLabel(oldThemeName);
+		_newTheme = oldThemeId;
+		ConfMan.set("gui_theme", _newTheme);
+		gfxMode = GUI::ThemeEngine::findMode(oldGfxConfig);
+		_rendererPopUp->setSelectedTag(gfxMode);
+		newGfxConfig = oldGfxConfig;
+		ConfMan.set("gui_renderer", newGfxConfig, _domain);
 #ifdef USE_TRANSLATION
-	Common::String oldLang = ConfMan.get("gui_language");
-	int selLang = _guiLanguagePopUp->getSelectedTag();
+		bool isCharsetEqual = (newCharset == TransMan.getCurrentCharset());
+		TransMan.setLanguage(oldLang);
+		_guiLanguagePopUp->setSelectedTag(selectedLang);
+		ConfMan.set("gui_language", oldLang);
 
-	ConfMan.set("gui_language", TransMan.getLangById(selLang));
+		if (!isCharsetEqual)
+			errorMessage = _("Theme does not support selected language!");
+		else
+#endif
+			errorMessage = _("Theme cannot be loaded!");
 
-	Common::String newLang = ConfMan.get("gui_language").c_str();
-	if (newLang != oldLang) {
-		// Activate the selected language
-		TransMan.setLanguage(selLang);
+		g_gui.loadNewTheme(_newTheme, gfxMode, true);
+		errorMessage += _("\nMisc settings will be restored.");
+		MessageDialog error(errorMessage);
+		error.runModal();
+	}
 
-		// Rebuild the Launcher and Options dialogs
-		g_gui.loadNewTheme(g_gui.theme()->getThemeId(), ThemeEngine::kGfxDisabled, true);
+	if (isRebuildNeeded) {
 		rebuild();
 		if (_launcher != 0)
 			_launcher->rebuild();
 	}
-#endif // USE_TRANSLATION
 
-	OptionsDialog::apply();
+	_newTheme.clear();
+
+	// Save config file
+	ConfMan.flushToDisk();
 }
 
 void GlobalOptionsDialog::close() {


Commit: 05bd770ea9593cb718a83ae2864e30716d86b5d0
    https://github.com/scummvm/scummvm/commit/05bd770ea9593cb718a83ae2864e30716d86b5d0
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-04-09T21:09:10+01:00

Commit Message:
Merge pull request #921 from Joefish/PR_9711

GUI: Restore previous settings if GUI cannot be rendered

Changed paths:
    gui/ThemeEngine.cpp
    gui/options.cpp







More information about the Scummvm-git-logs mailing list