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 96aa283e6a)
Signed-off-by: Itms <itms@wildfiregames.com>
This commit is contained in:
phosit
2024-12-27 11:33:09 +01:00
committed by Itms
parent cd34f75f03
commit c5d2ace30c
@@ -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"]);
}