From 41ae38700d327710dbd0210aeab88c3f5dd0ea70 Mon Sep 17 00:00:00 2001 From: "[EJ]" Date: Sat, 11 Jan 2025 08:43:16 +1300 Subject: [PATCH] Fix map information labels (name, author, etc) not being updated when a game is first created or Show/Hide Maps is called - issue #597 --- .../Multiplayer/GameLobby/GameLobbyBase.cs | 34 ++++++++++++------- .../GameLobby/MultiplayerGameLobby.cs | 4 +++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs b/DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs index 169f9b95d..425d576fc 100644 --- a/DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs +++ b/DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs @@ -2086,26 +2086,16 @@ protected virtual void BanPlayer(int playerIndex) } /// - /// Changes the current map and game mode. + /// Updates the map information labels such as name and author. /// - /// The new game mode map. - protected virtual void ChangeMap(GameModeMap gameModeMap) + protected virtual void SetMapLabels() { - GameModeMap = gameModeMap; - - _ = UpdateLaunchGameButtonStatus(); - if (GameMode == null || Map == null) { lblMapName.Text = "Map: Unknown".L10N("Client:Main:MapUnknown"); lblMapAuthor.Text = "By Unknown Author".L10N("Client:Main:AuthorByUnknown"); lblGameMode.Text = "Game mode: Unknown".L10N("Client:Main:GameModeUnknown"); lblMapSize.Text = "Size: Not available".L10N("Client:Main:MapSizeUnknown"); - - MapPreviewBox.GameModeMap = null; - - OnGameOptionChanged(); - return; } @@ -2113,6 +2103,26 @@ protected virtual void ChangeMap(GameModeMap gameModeMap) lblMapAuthor.Text = "By".L10N("Client:Main:AuthorBy") + " " + Renderer.GetSafeString(Map.Author, lblMapAuthor.FontIndex); lblGameMode.Text = "Game mode:".L10N("Client:Main:GameModeLabel") + " " + GameMode.UIName; lblMapSize.Text = "Size:".L10N("Client:Main:MapSize") + " " + Map.GetSizeString(); + } + + /// + /// Changes the current map and game mode. + /// + /// The new game mode map. + protected virtual void ChangeMap(GameModeMap gameModeMap) + { + GameModeMap = gameModeMap; + + _ = UpdateLaunchGameButtonStatus(); + + SetMapLabels(); + + if (GameMode == null || Map == null) + { + MapPreviewBox.GameModeMap = null; + OnGameOptionChanged(); + return; + } disableGameOptionUpdateBroadcast = true; diff --git a/DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs b/DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs index c317f2e0d..def4595e5 100644 --- a/DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs +++ b/DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs @@ -700,6 +700,8 @@ private void HideMapList() tbMapSearch.Disable(); btnPickRandomMap.Disable(); btnMapSortAlphabetically.Disable(); + + SetMapLabels(); } private void ShowMapList() @@ -728,6 +730,8 @@ private void ShowMapList() ReadINIForControl(lblGameMode); ReadINIForControl(lblMapSize); ReadINIForControl(btnMapSortAlphabetically); + + SetMapLabels(); } private void MapPreviewBox_LocalStartingLocationSelected(object sender, LocalStartingLocationEventArgs e)