From cfd08bbf28ad50ba609694bf33bb953addd4c7f1 Mon Sep 17 00:00:00 2001 From: elexis Date: Sat, 17 Jun 2017 14:17:30 +0000 Subject: [PATCH] Cinema Path GUI hiding and silhouettes fixes. Let the JS GUI take care of hiding the GUI and silhouettes and remove the according hardcoding in the engine following 89aef0b6eb. Thereby fix some bugs (like not having hid the GUI if there was a message box or different page shown while playing a path) and fix these two hotkeys broken by 5d49e6c456. Differential Revision: https://code.wildfiregames.com/D631 Fixes #4633 Reviewed By: Vladislav This was SVN commit r19797. --- .../mods/public/gui/session/hotkeys/misc.xml | 9 +++--- .../data/mods/public/gui/session/session.js | 32 ++++++++++++++++--- .../data/mods/public/gui/session/session.xml | 2 +- .../simulation/components/GuiInterface.js | 5 +++ source/graphics/CinemaManager.cpp | 30 ----------------- source/graphics/CinemaManager.h | 3 -- .../components/ICmpCinemaManager.cpp | 1 + 7 files changed, 40 insertions(+), 42 deletions(-) diff --git a/binaries/data/mods/public/gui/session/hotkeys/misc.xml b/binaries/data/mods/public/gui/session/hotkeys/misc.xml index 7f1510f232..46d84dbfbb 100644 --- a/binaries/data/mods/public/gui/session/hotkeys/misc.xml +++ b/binaries/data/mods/public/gui/session/hotkeys/misc.xml @@ -16,6 +16,10 @@ openChat(g_LastChatAddressee); + + g_ShowGUI = !g_ShowGUI; + + toggleMenu(); @@ -25,10 +29,7 @@ - - var newSetting = !Engine.Renderer_GetSilhouettesEnabled(); - Engine.Renderer_SetSilhouettesEnabled(newSetting); - + toggleConfigBool("silhouettes"); diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js index 2e1e1d7af3..dc9f762b8c 100644 --- a/binaries/data/mods/public/gui/session/session.js +++ b/binaries/data/mods/public/gui/session/session.js @@ -128,6 +128,12 @@ var g_DevSettings = { "controlAll": false }; +/** + * Whether the entire UI should be hidden (useful for promotional screenshots). + * Can be toggled with a hotkey. + */ +var g_ShowGUI = true; + /** * Whether status bars should be shown for all of the player's units. */ @@ -801,6 +807,7 @@ function onSimulationUpdate() if (!g_SimState) return; + updateCinemaPath(); handleNotifications(); updateGUIObjects(); @@ -848,6 +855,14 @@ function confirmExit() g_ConfirmExit = false; } +function updateCinemaPath() +{ + let isPlayingCinemaPath = GetSimState().cinemaPlaying; + + Engine.GetGUIObjectByName("sn").hidden = !g_ShowGUI || isPlayingCinemaPath; + Engine.Renderer_SetSilhouettesEnabled(!isPlayingCinemaPath && Engine.ConfigDB_GetValue("user", "silhouettes") == "true"); +} + function updateGUIObjects() { g_Selection.update(); @@ -1268,16 +1283,25 @@ function recalculateStatusBarDisplay(remove = false) }); } +/** + * Inverts the given configuration boolean and returns the current state. + * For example "silhouettes". + */ +function toggleConfigBool(configName) +{ + let enabled = Engine.ConfigDB_GetValue("user", configName) != "true"; + Engine.ConfigDB_CreateValue("user", configName, String(enabled)); + Engine.ConfigDB_WriteValueToFile("user", configName, String(enabled), "config/user.cfg"); + return enabled; +} + /** * Toggles the display of range overlays of selected entities for the given range type. * @param {string} type - for example "Aura" */ function toggleRangeOverlay(type) { - let configString = "gui.session." + type.toLowerCase() + "range"; - let enabled = Engine.ConfigDB_GetValue("user", configString) != "true"; - Engine.ConfigDB_CreateValue("user", configString, String(enabled)); - Engine.ConfigDB_WriteValueToFile("user", configString, String(enabled), "config/user.cfg"); + let enabled = toggleConfigBool("gui.session." + type.toLowerCase() + "range"); Engine.GuiInterfaceCall("EnableVisualRangeOverlayType", { "type": type, diff --git a/binaries/data/mods/public/gui/session/session.xml b/binaries/data/mods/public/gui/session/session.xml index eafd6f0665..b4d2e31c49 100644 --- a/binaries/data/mods/public/gui/session/session.xml +++ b/binaries/data/mods/public/gui/session/session.xml @@ -16,7 +16,7 @@