diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs index 5301818b52..8385afe51b 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic bool showWaiting = true; bool showEmpty = true; - bool showStarted = false; + bool showStarted = true; bool showCompatibleVersionsOnly = false; bool showThisModOnly = false; @@ -59,10 +59,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching; refreshButton.OnClick = () => ServerList.Query(games => RefreshServerList(panel, games)); - var pingButton = panel.Get("PING_BUTTON"); - pingButton.IsDisabled = () => searchStatus == SearchStatus.Pinging || - searchStatus == SearchStatus.Fetching || searchStatus == SearchStatus.Failed; - pingButton.OnClick = () => ServerList.Query(games => PingServerList(panel, games)); + var pingButton = panel.GetOrNull("PING_BUTTON"); + if (pingButton != null) + { + pingButton.IsDisabled = () => searchStatus == SearchStatus.Pinging || + searchStatus == SearchStatus.Fetching || searchStatus == SearchStatus.Failed; + pingButton.OnClick = () => ServerList.Query(games => PingServerList(panel, games)); + } var join = panel.Get("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !currentServer.CanJoin(); @@ -79,25 +82,40 @@ 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 showWaitingCheckbox = panel.GetOrNull("WAITING_FOR_PLAYERS"); + if (showWaitingCheckbox != null) + { + 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 showEmptyCheckbox = panel.GetOrNull("EMPTY"); + if (showEmptyCheckbox != null) + { + 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 showAlreadyStartedCheckbox = panel.GetOrNull("ALREADY_STARTED"); + if (showAlreadyStartedCheckbox != null) + { + 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 showCompatibleVersionsOnlyCheckbox = panel.GetOrNull("COMPATIBLE_VERSION"); + if (showCompatibleVersionsOnlyCheckbox != null) + { + 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)); }; + var showThisModOnlyCheckbox = panel.GetOrNull("THIS_MOD"); + if (showThisModOnlyCheckbox != null) + { + showThisModOnlyCheckbox.IsChecked = () => showThisModOnly; + showThisModOnlyCheckbox.OnClick = () => { showThisModOnly ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; + } ServerList.Query(games => RefreshServerList(panel, games)); } @@ -262,9 +280,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic version.GetText = () => GenerateModsLabel(game); version.IsVisible = () => !game.CompatibleVersion(); - var ping = item.Get("PING"); - ping.GetText = () => GetPing(game); - ping.IsVisible = () => game.CompatibleVersion(); + var ping = item.GetOrNull("PING"); + if (ping != null) + { + ping.GetText = () => GetPing(game); + ping.IsVisible = () => game.CompatibleVersion(); + } // TODO: Display game.Location once https://github.com/OpenRA/OpenRAMasterServer/pull/12 is merged