added serverbrowser filters
This commit is contained in:
@@ -28,6 +28,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
enum SearchStatus { Fetching, Failed, NoGames, Hidden }
|
enum SearchStatus { Fetching, Failed, NoGames, Hidden }
|
||||||
SearchStatus searchStatus = SearchStatus.Fetching;
|
SearchStatus searchStatus = SearchStatus.Fetching;
|
||||||
|
|
||||||
|
bool showWaiting = true;
|
||||||
|
bool showEmpty = true;
|
||||||
|
bool showStarted = false;
|
||||||
|
bool showCompatibleVersionsOnly = false;
|
||||||
|
bool showThisModOnly = false;
|
||||||
|
|
||||||
public string ProgressLabelText()
|
public string ProgressLabelText()
|
||||||
{
|
{
|
||||||
switch (searchStatus)
|
switch (searchStatus)
|
||||||
@@ -50,13 +56,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
// Menu buttons
|
// Menu buttons
|
||||||
var refreshButton = panel.Get<ButtonWidget>("REFRESH_BUTTON");
|
var refreshButton = panel.Get<ButtonWidget>("REFRESH_BUTTON");
|
||||||
refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
|
refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
|
||||||
refreshButton.OnClick = () =>
|
refreshButton.OnClick = () => ServerList.Query(games => RefreshServerList(panel, games));
|
||||||
{
|
|
||||||
searchStatus = SearchStatus.Fetching;
|
|
||||||
sl.RemoveChildren();
|
|
||||||
currentServer = null;
|
|
||||||
ServerList.Query(games => RefreshServerList(panel, games));
|
|
||||||
};
|
|
||||||
|
|
||||||
var join = panel.Get<ButtonWidget>("JOIN_BUTTON");
|
var join = panel.Get<ButtonWidget>("JOIN_BUTTON");
|
||||||
join.IsDisabled = () => currentServer == null || !currentServer.CanJoin();
|
join.IsDisabled = () => currentServer == null || !currentServer.CanJoin();
|
||||||
@@ -73,6 +73,26 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
|
progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
|
||||||
progressText.GetText = ProgressLabelText;
|
progressText.GetText = ProgressLabelText;
|
||||||
|
|
||||||
|
var showWaitingCheckbox = panel.Get<CheckboxWidget>("WAITING_FOR_PLAYERS");
|
||||||
|
showWaitingCheckbox.IsChecked = () => showWaiting;
|
||||||
|
showWaitingCheckbox.OnClick = () => { showWaiting ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
|
||||||
|
|
||||||
|
var showEmptyCheckbox = panel.Get<CheckboxWidget>("EMPTY");
|
||||||
|
showEmptyCheckbox.IsChecked = () => showEmpty;
|
||||||
|
showEmptyCheckbox.OnClick = () => { showEmpty ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
|
||||||
|
|
||||||
|
var showAlreadyStartedCheckbox = panel.Get<CheckboxWidget>("ALREADY_STARTED");
|
||||||
|
showAlreadyStartedCheckbox.IsChecked = () => showStarted;
|
||||||
|
showAlreadyStartedCheckbox.OnClick = () => { showStarted ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
|
||||||
|
|
||||||
|
var showCompatibleVersionsOnlyCheckbox = panel.Get<CheckboxWidget>("COMPATIBLE_VERSION");
|
||||||
|
showCompatibleVersionsOnlyCheckbox.IsChecked = () => showCompatibleVersionsOnly;
|
||||||
|
showCompatibleVersionsOnlyCheckbox.OnClick = () => { showCompatibleVersionsOnly ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
|
||||||
|
|
||||||
|
var showThisModOnlyCheckbox = panel.Get<CheckboxWidget>("THIS_MOD");
|
||||||
|
showThisModOnlyCheckbox.IsChecked = () => showThisModOnly;
|
||||||
|
showThisModOnlyCheckbox.OnClick = () => { showThisModOnly ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
|
||||||
|
|
||||||
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<ScrollPanelWidget>("SERVER_LIST");
|
var sl = panel.Get<ScrollPanelWidget>("SERVER_LIST");
|
||||||
|
|
||||||
|
searchStatus = SearchStatus.Fetching;
|
||||||
|
|
||||||
sl.RemoveChildren();
|
sl.RemoveChildren();
|
||||||
currentServer = null;
|
currentServer = null;
|
||||||
|
|
||||||
@@ -153,6 +175,27 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
var game = loop;
|
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 canJoin = game.CanJoin();
|
||||||
|
|
||||||
var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game, () => Join(game));
|
var item = ScrollItemWidget.Setup(serverTemplate, () => currentServer == game, () => currentServer = game, () => Join(game));
|
||||||
|
|||||||
@@ -7,17 +7,54 @@ Background@JOINSERVER_BG:
|
|||||||
Children:
|
Children:
|
||||||
Label@JOINSERVER_LABEL_TITLE:
|
Label@JOINSERVER_LABEL_TITLE:
|
||||||
X:0
|
X:0
|
||||||
Y:20
|
Y:15
|
||||||
Width:PARENT_RIGHT
|
Width:PARENT_RIGHT
|
||||||
Height:25
|
Height:25
|
||||||
Text:Join Server
|
Text:Join Server
|
||||||
Align:Center
|
Align:Center
|
||||||
Font:Bold
|
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:
|
ScrollPanel@SERVER_LIST:
|
||||||
X:20
|
X:20
|
||||||
Y:50
|
Y:110
|
||||||
Width:500
|
Width:500
|
||||||
Height:425
|
Height:355
|
||||||
Children:
|
Children:
|
||||||
ScrollItem@SERVER_TEMPLATE:
|
ScrollItem@SERVER_TEMPLATE:
|
||||||
Width:PARENT_RIGHT-27
|
Width:PARENT_RIGHT-27
|
||||||
|
|||||||
Reference in New Issue
Block a user