Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix map information labels not being updated in certain cases #636

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@
protected void AddSideToDropDown(XNADropDown dd, string name, string? uiName = null, Texture2D? texture = null)
{
XNADropDownItem item = new()
{

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (Ares)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (Ares)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (TS)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (TS)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (YR)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 783 in DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

View workflow job for this annotation

GitHub Actions / build-clients (YR)

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
Text = uiName ?? name.L10N($"INI:Sides:{name}"),
Tag = name,
Texture = texture ?? LoadTextureOrNull(name + "icon.png"),
Expand Down Expand Up @@ -2086,33 +2086,43 @@
}

/// <summary>
/// Changes the current map and game mode.
/// Updates the map information labels such as name and author.
/// </summary>
/// <param name="gameModeMap">The new game mode map.</param>
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;
}

lblMapName.Text = "Map:".L10N("Client:Main:Map") + " " + Renderer.GetSafeString(Map.Name, lblMapName.FontIndex);
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();
}

/// <summary>
/// Changes the current map and game mode.
/// </summary>
/// <param name="gameModeMap">The new game mode map.</param>
protected virtual void ChangeMap(GameModeMap gameModeMap)
{
GameModeMap = gameModeMap;

_ = UpdateLaunchGameButtonStatus();

SetMapLabels();

if (GameMode == null || Map == null)
{
MapPreviewBox.GameModeMap = null;
OnGameOptionChanged();
return;
}

disableGameOptionUpdateBroadcast = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@ private void HideMapList()
tbMapSearch.Disable();
btnPickRandomMap.Disable();
btnMapSortAlphabetically.Disable();

SetMapLabels();
}

private void ShowMapList()
Expand Down Expand Up @@ -728,6 +730,8 @@ private void ShowMapList()
ReadINIForControl(lblGameMode);
ReadINIForControl(lblMapSize);
ReadINIForControl(btnMapSortAlphabetically);

SetMapLabels();
}

private void MapPreviewBox_LocalStartingLocationSelected(object sender, LocalStartingLocationEventArgs e)
Expand Down
Loading