diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs index 8b738d2283..10cc1e79bc 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs @@ -28,6 +28,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic enum SearchStatus { Fetching, Failed, NoGames, Hidden } SearchStatus searchStatus = SearchStatus.Fetching; + bool showWaiting = true; + bool showEmpty = true; + bool showStarted = false; + bool showCompatibleVersionsOnly = false; + bool showThisModOnly = false; + public string ProgressLabelText() { switch (searchStatus) @@ -50,13 +56,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic // Menu buttons var refreshButton = panel.Get("REFRESH_BUTTON"); refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching; - refreshButton.OnClick = () => - { - searchStatus = SearchStatus.Fetching; - sl.RemoveChildren(); - currentServer = null; - ServerList.Query(games => RefreshServerList(panel, games)); - }; + refreshButton.OnClick = () => ServerList.Query(games => RefreshServerList(panel, games)); var join = panel.Get("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !currentServer.CanJoin(); @@ -73,6 +73,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic progressText.IsVisible = () => searchStatus != SearchStatus.Hidden; progressText.GetText = ProgressLabelText; + var showWaitingCheckbox = panel.Get("WAITING_FOR_PLAYERS"); + showWaitingCheckbox.IsChecked = () => showWaiting; + showWaitingCheckbox.OnClick = () => { showWaiting ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; + + var showEmptyCheckbox = panel.Get("EMPTY"); + showEmptyCheckbox.IsChecked = () => showEmpty; + showEmptyCheckbox.OnClick = () => { showEmpty ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; + + var showAlreadyStartedCheckbox = panel.Get("ALREADY_STARTED"); + showAlreadyStartedCheckbox.IsChecked = () => showStarted; + showAlreadyStartedCheckbox.OnClick = () => { showStarted ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; + + var showCompatibleVersionsOnlyCheckbox = panel.Get("COMPATIBLE_VERSION"); + showCompatibleVersionsOnlyCheckbox.IsChecked = () => showCompatibleVersionsOnly; + showCompatibleVersionsOnlyCheckbox.OnClick = () => { showCompatibleVersionsOnly ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; + + var showThisModOnlyCheckbox = panel.Get("THIS_MOD"); + showThisModOnlyCheckbox.IsChecked = () => showThisModOnly; + showThisModOnlyCheckbox.OnClick = () => { showThisModOnly ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; + ServerList.Query(games => RefreshServerList(panel, games)); } @@ -131,6 +151,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var sl = panel.Get("SERVER_LIST"); + searchStatus = SearchStatus.Fetching; + sl.RemoveChildren(); currentServer = null; @@ -153,6 +175,27 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var game = loop; + if (game == null) + continue; + + if (game.State == 3) // server shutting down + continue; + + if ((game.State == 2) && !showStarted) + continue; + + if ((game.State == 1) && !showWaiting) + continue; + + if ((game.Players == 0) && !showEmpty) + continue; + + if (!game.CompatibleVersion() && showCompatibleVersionsOnly) + continue; + + if (!game.UsefulMods.Any(m => Game.CurrentMods.ContainsKey(m.Key)) && showThisModOnly) + continue; + var canJoin = game.CanJoin(); var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game, () => Join(game)); diff --git a/mods/ra/chrome/serverbrowser.yaml b/mods/ra/chrome/serverbrowser.yaml index 8e96dc2d90..2c5efdc514 100644 --- a/mods/ra/chrome/serverbrowser.yaml +++ b/mods/ra/chrome/serverbrowser.yaml @@ -7,17 +7,54 @@ Background@JOINSERVER_BG: Children: Label@JOINSERVER_LABEL_TITLE: X:0 - Y:20 + Y:15 Width:PARENT_RIGHT Height:25 Text:Join Server Align:Center Font:Bold + Label@SHOW_LABEL_TITLE: + X:20 + Y:45 + Width:20 + Height:25 + Text:Show: + Font:Bold + Checkbox@WAITING_FOR_PLAYERS: + X:80 + Y:50 + Width:300 + Height:20 + Text:waiting for players + Checkbox@EMPTY: + X:250 + Y:50 + Width:300 + Height:20 + Text:empty + Checkbox@ALREADY_STARTED: + X:350 + Y:50 + Width:300 + Height:20 + Text:already started + Checkbox@COMPATIBLE_VERSION: + X:80 + Y:80 + Width:300 + Height:20 + Text:compatible versions only + Checkbox@THIS_MOD: + X:300 + Y:80 + Width:300 + Height:20 + Text:this mod only ScrollPanel@SERVER_LIST: X:20 - Y:50 + Y:110 Width:500 - Height:425 + Height:355 Children: ScrollItem@SERVER_TEMPLATE: Width:PARENT_RIGHT-27