From c5d2ace30ce9dc3d32dfd51029cb1c534ea072f2 Mon Sep 17 00:00:00 2001 From: phosit Date: Fri, 27 Dec 2024 11:33:09 +0100 Subject: [PATCH] Make MapPreview always listen to map changes When loading a saved game the user can't change the maps but when receiving the initAttributes from the host the map is "changed". Defect introduced in b90280855f. (cherry picked from commit 96aa283e6a755df7386a6ed447c027aaf33ab04a) Signed-off-by: Itms --- .../Pages/GameSetupPage/Panels/MapPreview.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/MapPreview.js b/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/MapPreview.js index 99c1ceaba1..f441a5ff46 100644 --- a/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/MapPreview.js +++ b/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/Panels/MapPreview.js @@ -9,19 +9,19 @@ class MapPreview this.mapInfoName = Engine.GetGUIObjectByName("mapInfoName"); this.mapPreview = Engine.GetGUIObjectByName("mapPreview"); - if (isSavedGame) - { - // Delay the settings registration handler until we have the map cache. - setupWindow.controls.gameSettingsController.registerSettingsLoadedHandler(() => { - this.renderName(); - this.renderPreview(); - }); - return; - } + // Delay the settings registration handler until we have the map cache. + setupWindow.controls.gameSettingsController.registerSettingsLoadedHandler( + this.onSettingsLoaded.bind(this)); // TODO: Why does onPress not work? CGUI.cpp seems to support it. this.mapPreview.onMouseLeftPress = this.onPress.bind(this, isSavedGame); this.mapPreview.tooltip = this.Tooltip; + } + + onSettingsLoaded() + { + this.renderName(); + this.renderPreview(); g_GameSettings.map.watch(() => this.renderName(), ["map"]); g_GameSettings.mapPreview.watch(() => this.renderPreview(), ["value"]); }