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

Add a total player count to the MP browser. #14610

Merged
merged 1 commit into from Jan 1, 2018
Jump to file or symbol
Failed to load files and symbols.
+25 −0
Diff settings

Always

Just for now

@@ -53,6 +53,7 @@ public class ServerListLogic : ChromeLogic
GameServer currentServer;
MapPreview currentMap;
bool showNotices;
int playerCount;
enum SearchStatus { Fetching, Failed, NoGames, Hidden }
@@ -218,6 +219,14 @@ public ServerListLogic(Widget widget, ModData modData, Action<GameServer> onJoin
}
}
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 @@ void RefreshServerListInner(List<GameServer> games)
if (nextServerRow != null)
nextServerRow.OnClick();
playerCount = games.Sum(g => g.Players);
});
}
@@ -220,6 +220,13 @@ Container@MULTIPLAYER_PANEL:
IgnoreMouseOver: True
Children:
LogicTicker@ANIMATION:
Label@PLAYER_COUNT:
X: 198
Y: PARENT_BOTTOM - 40
Width: 189
Height: 25
Align: Center
Font: Bold
Button@DIRECTCONNECT_BUTTON:
X: 387
Y: PARENT_BOTTOM - 40
@@ -214,6 +214,13 @@ Background@MULTIPLAYER_PANEL:
IgnoreMouseOver: True
Children:
LogicTicker@ANIMATION:
Label@PLAYER_COUNT:
X: 208
Y: PARENT_BOTTOM - HEIGHT - 20
Width: 190
Height: 25
Align: Center
Font: Bold
Button@DIRECTCONNECT_BUTTON:
X: 398
Y: PARENT_BOTTOM - HEIGHT - 20
ProTip! Use n and p to navigate between commits in a pull request.