polish serverbrowser filters
This commit is contained in:
@@ -14,6 +14,7 @@ using System.Linq;
|
||||
using System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Server;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
@@ -31,8 +32,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
bool showWaiting = true;
|
||||
bool showEmpty = true;
|
||||
bool showStarted = true;
|
||||
bool showCompatibleVersionsOnly = false;
|
||||
bool showThisModOnly = false;
|
||||
|
||||
public string ProgressLabelText()
|
||||
{
|
||||
@@ -103,20 +102,6 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
showAlreadyStartedCheckbox.OnClick = () => { showStarted ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
|
||||
}
|
||||
|
||||
var showCompatibleVersionsOnlyCheckbox = panel.GetOrNull<CheckboxWidget>("COMPATIBLE_VERSION");
|
||||
if (showCompatibleVersionsOnlyCheckbox != null)
|
||||
{
|
||||
showCompatibleVersionsOnlyCheckbox.IsChecked = () => showCompatibleVersionsOnly;
|
||||
showCompatibleVersionsOnlyCheckbox.OnClick = () => { showCompatibleVersionsOnly ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
|
||||
}
|
||||
|
||||
var showThisModOnlyCheckbox = panel.GetOrNull<CheckboxWidget>("THIS_MOD");
|
||||
if (showThisModOnlyCheckbox != null)
|
||||
{
|
||||
showThisModOnlyCheckbox.IsChecked = () => showThisModOnly;
|
||||
showThisModOnlyCheckbox.OnClick = () => { showThisModOnly ^= true; ServerList.Query(games => RefreshServerList(panel, games)); };
|
||||
}
|
||||
|
||||
ServerList.Query(games => RefreshServerList(panel, games));
|
||||
}
|
||||
|
||||
@@ -148,9 +133,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (game == null)
|
||||
return "";
|
||||
|
||||
if (game.State == 1) return "Waiting for players";
|
||||
if (game.State == 2) return "Playing";
|
||||
else return "Unknown";
|
||||
if (game.State == (int)ServerState.WaitingPlayers)
|
||||
return "Waiting for players";
|
||||
if (game.State == (int)ServerState.GameStarted)
|
||||
return "Playing";
|
||||
if (game.State == (int)ServerState.ShuttingDown)
|
||||
return "Server shutting down";
|
||||
|
||||
return "Unknown server state";
|
||||
}
|
||||
|
||||
Map GetMapPreview(GameServer game)
|
||||
@@ -171,7 +161,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
return s.UsefulMods.Select(m => GenerateModLabel(m)).JoinWith("\n");
|
||||
}
|
||||
|
||||
public static string GetPing(GameServer s)
|
||||
static string GetPing(GameServer s)
|
||||
{
|
||||
if (s.Latency > -1)
|
||||
return "Ping: {0} ms".F(s.Latency);
|
||||
@@ -179,7 +169,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
return "Ping: ? ms";
|
||||
}
|
||||
|
||||
public void PingServerList(Widget panel, IEnumerable<GameServer> games)
|
||||
void PingServerList(Widget panel, IEnumerable<GameServer> games)
|
||||
{
|
||||
searchStatus = SearchStatus.Pinging;
|
||||
|
||||
@@ -198,6 +188,20 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
RefreshServerList(panel, games);
|
||||
}
|
||||
|
||||
bool Filtered(GameServer game)
|
||||
{
|
||||
if ((game.State == (int)ServerState.GameStarted) && !showStarted)
|
||||
return true;
|
||||
|
||||
if ((game.State == (int)ServerState.WaitingPlayers) && !showWaiting)
|
||||
return true;
|
||||
|
||||
if ((game.Players == 0) && !showEmpty)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RefreshServerList(Widget panel, IEnumerable<GameServer> games)
|
||||
{
|
||||
var sl = panel.Get<ScrollPanelWidget>("SERVER_LIST");
|
||||
@@ -226,27 +230,6 @@ 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));
|
||||
@@ -297,9 +280,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
state.GetColor = () => Color.Gray;
|
||||
ip.GetColor = () => Color.Gray;
|
||||
version.GetColor = () => Color.Gray;
|
||||
if (ping != null)
|
||||
ping.GetColor = () => Color.Gray;
|
||||
}
|
||||
|
||||
sl.AddChild(item);
|
||||
if (!Filtered(game))
|
||||
sl.AddChild(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,33 +23,45 @@ Background@JOINSERVER_BG:
|
||||
Checkbox@WAITING_FOR_PLAYERS:
|
||||
X:80
|
||||
Y:50
|
||||
Width:300
|
||||
Width:170
|
||||
Height:20
|
||||
Text:waiting for players
|
||||
Text:Waiting For Players
|
||||
Checkbox@EMPTY:
|
||||
X:250
|
||||
Y:50
|
||||
Width:300
|
||||
Width:100
|
||||
Height:20
|
||||
Text:empty
|
||||
Text:Empty
|
||||
Checkbox@ALREADY_STARTED:
|
||||
X:350
|
||||
Y:50
|
||||
Width:300
|
||||
Width:100
|
||||
Height:20
|
||||
Text:already started
|
||||
Checkbox@COMPATIBLE_VERSION:
|
||||
X:80
|
||||
Text:Already Started
|
||||
DropDownButton@VERSIONS:
|
||||
X:20
|
||||
Y:80
|
||||
Width:300
|
||||
Height:20
|
||||
Text:compatible versions only
|
||||
Checkbox@THIS_MOD:
|
||||
X:300
|
||||
Width:150
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:All Versions
|
||||
Disabled: yes
|
||||
DropDownButton@MODS:
|
||||
X:190
|
||||
Y:80
|
||||
Width:300
|
||||
Height:20
|
||||
Text:this mod only
|
||||
Width:150
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:All Mods
|
||||
Disabled: yes
|
||||
DropDownButton@MAPS:
|
||||
X:360
|
||||
Y:80
|
||||
Width:150
|
||||
Height:25
|
||||
Font:Bold
|
||||
Text:All Maps
|
||||
Disabled: yes
|
||||
ScrollPanel@SERVER_LIST:
|
||||
X:20
|
||||
Y:110
|
||||
|
||||
Reference in New Issue
Block a user