diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs index 2ef848bf17..114f823c0e 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs @@ -37,6 +37,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic bool showWaiting = true; bool showEmpty = true; bool showStarted = true; + bool showProtected = true; bool showIncompatible = false; public string ProgressLabelText() @@ -100,6 +101,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic showAlreadyStartedCheckbox.OnClick = () => { showStarted ^= true; RefreshServerList(); }; } + var showProtectedCheckbox = panel.GetOrNull("PASSWORD_PROTECTED"); + if (showProtectedCheckbox != null) + { + showProtectedCheckbox.IsChecked = () => showProtected; + showProtectedCheckbox.OnClick = () => { showProtected ^= true; RefreshServerList(); }; + } + var showIncompatibleCheckbox = panel.GetOrNull("INCOMPATIBLE_VERSION"); if (showIncompatibleCheckbox != null) { @@ -155,6 +163,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic continue; var canJoin = game.CanJoin(); + var compatible = game.CompatibleVersion(); var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game, () => Join(game)); @@ -166,15 +175,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic var title = item.GetOrNull("TITLE"); if (title != null) { - title.GetText = () => game.Protected ? ("(Password) " + game.Name) : game.Name; - title.GetColor = () => canJoin ? title.TextColor : Color.Gray; + title.GetText = () => game.Name; + title.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : title.TextColor; } var maptitle = item.GetOrNull("MAP"); if (title != null) { maptitle.GetText = () => map.Title; - maptitle.GetColor = () => canJoin ? maptitle.TextColor : Color.Gray; + maptitle.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : maptitle.TextColor; } var players = item.GetOrNull("PLAYERS"); @@ -182,29 +191,29 @@ namespace OpenRA.Mods.RA.Widgets.Logic { players.GetText = () => "{0} / {1}".F(game.Players, game.MaxPlayers) + (game.Spectators > 0 ? " ({0} Spectator{1})".F(game.Spectators, game.Spectators > 1 ? "s" : "") : ""); - players.GetColor = () => canJoin ? players.TextColor : Color.Gray; + players.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : players.TextColor; } var state = item.GetOrNull("STATE"); if (state != null) { state.GetText = () => GetStateLabel(game); - state.GetColor = () => canJoin ? state.TextColor : Color.Gray; + state.GetColor = () => GetStateColor(game, state, !compatible || !canJoin); } var ip = item.GetOrNull("IP"); if (ip != null) { ip.GetText = () => game.Address; - ip.GetColor = () => canJoin ? ip.TextColor : Color.Gray; + ip.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : ip.TextColor; } var version = item.GetOrNull("VERSION"); if (version != null) { version.GetText = () => GenerateModLabel(game); - version.IsVisible = () => !game.CompatibleVersion(); - version.GetColor = () => canJoin ? version.TextColor : Color.Gray; + version.IsVisible = () => !compatible; + version.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : version.TextColor; } var location = item.GetOrNull("LOCATION"); @@ -212,8 +221,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var cachedServerLocation = LobbyUtils.LookupCountry(game.Address.Split(':')[0]); location.GetText = () => cachedServerLocation; - location.IsVisible = () => game.CompatibleVersion(); - location.GetColor = () => canJoin ? location.TextColor : Color.Gray; + location.IsVisible = () => compatible; + location.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : location.TextColor; } if (!Filtered(game)) @@ -293,8 +302,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (game == null) return ""; - if (game.State == (int)ServerState.WaitingPlayers) - return "Waiting for players"; if (game.State == (int)ServerState.GameStarted) { try @@ -307,12 +314,33 @@ namespace OpenRA.Mods.RA.Widgets.Logic return "In progress"; } } + + if (game.Protected) + return "Password protected"; + + if (game.State == (int)ServerState.WaitingPlayers) + return "Waiting for players"; + if (game.State == (int)ServerState.ShuttingDown) return "Server shutting down"; return "Unknown server state"; } + static Color GetStateColor(GameServer game, LabelWidget label, bool darkened) + { + if (game.Protected && game.State == (int)ServerState.WaitingPlayers) + return darkened ? Color.DarkRed : Color.Red; + + if (game.State == (int)ServerState.WaitingPlayers) + return darkened ? Color.LimeGreen : Color.Lime; + + if (game.State == (int)ServerState.GameStarted) + return darkened ? Color.Chocolate : Color.Orange; + + return label.TextColor; + } + public static string GenerateModLabel(GameServer s) { ModMetadata mod; @@ -338,6 +366,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic if (!game.CompatibleVersion() && !showIncompatible) return true; + if (game.Protected && !showProtected) + return true; + return false; } } diff --git a/mods/cnc/chrome/serverbrowser.yaml b/mods/cnc/chrome/serverbrowser.yaml index 3c4ddb3a3a..6b8683ccdc 100644 --- a/mods/cnc/chrome/serverbrowser.yaml +++ b/mods/cnc/chrome/serverbrowser.yaml @@ -30,6 +30,7 @@ Container@SERVERBROWSER_PANEL: Width: 100 Height: 20 Text: Waiting + TextColor: 50,205,50 Checkbox@EMPTY: X: 180 Y: 468 @@ -37,17 +38,26 @@ Container@SERVERBROWSER_PANEL: Height: 20 Text: Empty Checkbox@ALREADY_STARTED: - X: 280 + X: 270 Y: 468 Width: 100 Height: 20 Text: Started + TextColor: 255,165,0 + Checkbox@PASSWORD_PROTECTED: + X: 370 + Y: 468 + Width: 100 + Height: 20 + Text: Protected + TextColor: 255,0,0 Checkbox@INCOMPATIBLE_VERSION: - X: 380 + X: 480 Y: 468 Width: 100 Height: 20 Text: Incompatible + TextColor: 190,190,190 Button@REFRESH_BUTTON: X: PARENT_RIGHT - WIDTH - 20 Y: 465 diff --git a/mods/ra/chrome/serverbrowser.yaml b/mods/ra/chrome/serverbrowser.yaml index 664f8f4bb3..34846bafd4 100644 --- a/mods/ra/chrome/serverbrowser.yaml +++ b/mods/ra/chrome/serverbrowser.yaml @@ -26,6 +26,7 @@ Background@SERVERBROWSER_PANEL: Width: 100 Height: 20 Text: Waiting + TextColor: 50,205,50 Checkbox@EMPTY: X: 180 Y: 50 @@ -38,12 +39,21 @@ Background@SERVERBROWSER_PANEL: Width: 100 Height: 20 Text: Started - Checkbox@INCOMPATIBLE_VERSION: + TextColor: 255,165,0 + Checkbox@PASSWORD_PROTECTED: X: 380 Y: 50 Width: 100 Height: 20 + Text: Protected + TextColor: 255,0,0 + Checkbox@INCOMPATIBLE_VERSION: + X: 480 + Y: 50 + Width: 100 + Height: 20 Text: Incompatible + TextColor: 190,190,190 ScrollPanel@SERVER_LIST: X: 20 Y: 80