Add a total player count to the MP browser.

This commit is contained in:
Paul Chote
2017-12-31 16:55:49 +00:00
committed by reaperrr
parent cd6dfd2185
commit 3353215b66
3 changed files with 25 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
GameServer currentServer;
MapPreview currentMap;
bool showNotices;
int playerCount;
enum SearchStatus { Fetching, Failed, NoGames, Hidden }
@@ -218,6 +219,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}
}
var playersLabel = widget.GetOrNull<LabelWidget>("PLAYER_COUNT");
if (playersLabel != null)
{
var playersText = new CachedTransform<int, string>(c => c == 1 ? "1 Player Online" : c.ToString() + " Players Online");
playersLabel.IsVisible = () => playerCount != 0;
playersLabel.GetText = () => playersText.Update(playerCount);
}
mapPreview = widget.GetOrNull<MapPreviewWidget>("SELECTED_MAP_PREVIEW");
if (mapPreview != null)
mapPreview.Preview = () => currentMap;
@@ -512,6 +521,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (nextServerRow != null)
nextServerRow.OnClick();
playerCount = games.Sum(g => g.Players);
});
}