From 7df7566d7cb6d1c1d6d77d691156334c842d20c3 Mon Sep 17 00:00:00 2001 From: wraitii Date: Fri, 23 Jun 2023 07:19:16 +0000 Subject: [PATCH] Fix 'Options' asking for confirmation without changes during a game. Since 281bb0b2ec, opening the 'Options' menu in-game will show that there are pending changes, even if the user has done nothing. Unfortunately the cinematic logic to hide silhouettes, which comes from cfd08bbf28, is broken following those changes. We use the configuration to hide them, which results in us, indeed, changing the configuration. There isn't really a good short term fix. This change only attemps to reset the setting if we changed it for a cinematic, which fixes the issue, but has drawbacks. Ideally, we would use a superior config level, but we need to be careful about exposing that to JS. Reported by: langbart Fixes #6821 Differential Revision: https://code.wildfiregames.com/D5040 This was SVN commit r27730. --- binaries/data/mods/public/gui/session/session.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js index 023cbfccb9..a3a047e1c7 100644 --- a/binaries/data/mods/public/gui/session/session.js +++ b/binaries/data/mods/public/gui/session/session.js @@ -686,13 +686,26 @@ function toggleGUI() updateCinemaPath(); } +var g_HasHiddenSilhouettes = false; function updateCinemaPath() { let isPlayingCinemaPath = GetSimState().cinemaPlaying && !g_Disconnected; Engine.GetGUIObjectByName("session").hidden = !g_ShowGUI || isPlayingCinemaPath; Engine.GetGUIObjectByName("cinemaOverlay").hidden = !isPlayingCinemaPath; - Engine.ConfigDB_CreateValue("user", "silhouettes", !isPlayingCinemaPath && Engine.ConfigDB_GetValue("user", "silhouettes") == "true" ? "true" : "false"); + // TODO: This isn't great and should use a different system. + if (isPlayingCinemaPath && Engine.ConfigDB_GetValue("user", "silhouettes") == "true") + { + Engine.ConfigDB_CreateValue("user", "silhouettes", "false"); + g_HasHiddenSilhouettes = true; + } + else if (!isPlayingCinemaPath && g_HasHiddenSilhouettes) + { + // TODO: Keyboard shortcuts can still try to toggle silhouettes + // which would behave incorrectly on reset. + Engine.ConfigDB_Reload(); + g_HasHiddenSilhouettes = false; + } } function updateCinemaOverlay()