Skip to content

Commit

Permalink
Minor game lobby improvements / fixes
Browse files Browse the repository at this point in the history
- Parse attributes for map list sort button from INI
- Do not apply map list sorting if map list sort button is disabled
- Correctly re-enable pick random map button when re-showing map list
- Always correctly hide map list related controls when hiding map list if they are explicitly enabled in INI
  • Loading branch information
Starkku committed May 25, 2022
1 parent e9b17fa commit f6b8b39
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
22 changes: 15 additions & 7 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ private void InitBtnMapSort()
btnMapSortAlphabetically.SetToolTipText("Sort Maps Alphabetically".L10N("UI:Main:MapSortAlphabeticallyToolTip"));
RefreshMapSortAlphabeticallyBtn();
AddChild(btnMapSortAlphabetically);

// Allow repositioning / disabling in INI.
ReadINIForControl(btnMapSortAlphabetically);
}

private void InitializeGameOptionPresetUI()
Expand Down Expand Up @@ -479,14 +482,19 @@ private void AddPlayerExtraOptionForcedNotice(bool disabled, string type)
private List<GameModeMap> GetSortedGameModeMaps()
{
var gameModeMaps = gameModeMapFilter.GetGameModeMaps();
switch ((SortDirection)UserINISettings.Instance.MapSortState.Value)

// Only apply sort if the map list sort button is available.
if (btnMapSortAlphabetically.Enabled && btnMapSortAlphabetically.Visible)
{
case SortDirection.Asc:
gameModeMaps = gameModeMaps.OrderBy(gmm => gmm.Map.Name).ToList();
break;
case SortDirection.Desc:
gameModeMaps = gameModeMaps.OrderByDescending(gmm => gmm.Map.Name).ToList();
break;
switch ((SortDirection)UserINISettings.Instance.MapSortState.Value)
{
case SortDirection.Asc:
gameModeMaps = gameModeMaps.OrderBy(gmm => gmm.Map.Name).ToList();
break;
case SortDirection.Desc:
gameModeMaps = gameModeMaps.OrderByDescending(gmm => gmm.Map.Name).ToList();
break;
}
}

return gameModeMaps;
Expand Down
17 changes: 10 additions & 7 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/MultiplayerGameLobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,6 @@ private void HideMapList()
lblGameMode.Name = "lblGameMode";
lblMapSize.Name = "lblMapSize";

ddGameModeMapFilter.Disable();
lblGameModeSelect.Disable();
lbGameModeMapList.Disable();
tbMapSearch.Disable();
btnPickRandomMap.Disable();
btnMapSortAlphabetically.Disable();

ReadINIForControl(btnPickRandomMap);
ReadINIForControl(lbChatMessages);
ReadINIForControl(tbChatInput);
Expand All @@ -651,6 +644,14 @@ private void HideMapList()
ReadINIForControl(lblMapAuthor);
ReadINIForControl(lblGameMode);
ReadINIForControl(lblMapSize);
ReadINIForControl(btnMapSortAlphabetically);

ddGameModeMapFilter.Disable();
lblGameModeSelect.Disable();
lbGameModeMapList.Disable();
tbMapSearch.Disable();
btnPickRandomMap.Disable();
btnMapSortAlphabetically.Disable();
}

private void ShowMapList()
Expand All @@ -667,6 +668,7 @@ private void ShowMapList()
lblGameModeSelect.Enable();
lbGameModeMapList.Enable();
tbMapSearch.Enable();
btnPickRandomMap.Enable();
btnMapSortAlphabetically.Enable();

ReadINIForControl(btnPickRandomMap);
Expand All @@ -677,6 +679,7 @@ private void ShowMapList()
ReadINIForControl(lblMapAuthor);
ReadINIForControl(lblGameMode);
ReadINIForControl(lblMapSize);
ReadINIForControl(btnMapSortAlphabetically);
}

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

0 comments on commit f6b8b39

Please sign in to comment.