Show all mods in the server browser.
This commit is contained in:
@@ -30,6 +30,7 @@ namespace OpenRA.Network
|
|||||||
public readonly bool IsJoinable = false;
|
public readonly bool IsJoinable = false;
|
||||||
|
|
||||||
public readonly string ModLabel = "";
|
public readonly string ModLabel = "";
|
||||||
|
public readonly string ModId = "";
|
||||||
public readonly string ModVersion = "";
|
public readonly string ModVersion = "";
|
||||||
|
|
||||||
public GameServer(MiniYaml yaml)
|
public GameServer(MiniYaml yaml)
|
||||||
@@ -40,10 +41,10 @@ namespace OpenRA.Network
|
|||||||
var modVersion = Mods.Split('@');
|
var modVersion = Mods.Split('@');
|
||||||
if (modVersion.Length == 2 && ModMetadata.AllMods.TryGetValue(modVersion[0], out mod))
|
if (modVersion.Length == 2 && ModMetadata.AllMods.TryGetValue(modVersion[0], out mod))
|
||||||
{
|
{
|
||||||
ModLabel = "{0} ({1})".F(mod.Title, modVersion[1]);
|
ModId = modVersion[0];
|
||||||
ModVersion = modVersion[1];
|
ModVersion = modVersion[1];
|
||||||
|
ModLabel = "{0} ({1})".F(mod.Title, modVersion[1]);
|
||||||
IsCompatible = Game.Settings.Debug.IgnoreVersionMismatch || (mod.Id == Game.modData.Manifest.Mod.Id && ModVersion == Game.modData.Manifest.Mod.Version);
|
IsCompatible = Game.Settings.Debug.IgnoreVersionMismatch || ModVersion == mod.Version;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ModLabel = "Unknown mod: {0}".F(Mods);
|
ModLabel = "Unknown mod: {0}".F(Mods);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
GameServer currentServer;
|
GameServer currentServer;
|
||||||
ScrollItemWidget serverTemplate;
|
ScrollItemWidget serverTemplate;
|
||||||
|
ScrollItemWidget headerTemplate;
|
||||||
|
|
||||||
Action onStart;
|
Action onStart;
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
this.onStart = onStart;
|
this.onStart = onStart;
|
||||||
|
|
||||||
serverList = panel.Get<ScrollPanelWidget>("SERVER_LIST");
|
serverList = panel.Get<ScrollPanelWidget>("SERVER_LIST");
|
||||||
|
headerTemplate = serverList.Get<ScrollItemWidget>("HEADER_TEMPLATE");
|
||||||
serverTemplate = serverList.Get<ScrollItemWidget>("SERVER_TEMPLATE");
|
serverTemplate = serverList.Get<ScrollItemWidget>("SERVER_TEMPLATE");
|
||||||
|
|
||||||
// Menu buttons
|
// Menu buttons
|
||||||
@@ -154,24 +156,51 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
var games = yaml.Select(a => new GameServer(a.Value))
|
var games = yaml.Select(a => new GameServer(a.Value))
|
||||||
.Where(gs => gs.Address != null);
|
.Where(gs => gs.Address != null);
|
||||||
|
|
||||||
RefreshServerListInner(games);
|
|
||||||
Game.RunAfterTick(() => RefreshServerListInner(games));
|
Game.RunAfterTick(() => RefreshServerListInner(games));
|
||||||
};
|
};
|
||||||
|
|
||||||
currentQuery = new Download(Game.Settings.Server.MasterServer + "games", _ => {}, onComplete);
|
currentQuery = new Download(Game.Settings.Server.MasterServer + "games", _ => {}, onComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GroupSortOrder(GameServer testEntry)
|
||||||
|
{
|
||||||
|
// Games that we can't join are sorted last
|
||||||
|
if (!testEntry.IsCompatible)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Games for the current mod+version are sorted first
|
||||||
|
if (testEntry.ModId == Game.modData.Manifest.Mod.Id)
|
||||||
|
return 2;
|
||||||
|
|
||||||
|
// Followed by games for different mods that are joinable
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void RefreshServerListInner(IEnumerable<GameServer> games)
|
void RefreshServerListInner(IEnumerable<GameServer> games)
|
||||||
{
|
{
|
||||||
if (games == null)
|
if (games == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var rows = new List<Widget>();
|
var mods = games.GroupBy(g => g.Mods)
|
||||||
|
.OrderByDescending(g => GroupSortOrder(g.First()))
|
||||||
|
.ThenByDescending(g => g.Count());
|
||||||
|
|
||||||
foreach (var loop in games.OrderByDescending(g => g.IsJoinable).ThenByDescending(g => g.Players))
|
var rows = new List<Widget>();
|
||||||
|
foreach (var modGames in mods)
|
||||||
|
{
|
||||||
|
if (modGames.All(Filtered))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var header = ScrollItemWidget.Setup(headerTemplate, () => true, () => {});
|
||||||
|
|
||||||
|
var headerTitle = modGames.First().ModLabel;
|
||||||
|
header.Get<LabelWidget>("LABEL").GetText = () => headerTitle;
|
||||||
|
rows.Add(header);
|
||||||
|
|
||||||
|
foreach (var loop in modGames.OrderByDescending(g => g.IsJoinable).ThenByDescending(g => g.Players))
|
||||||
{
|
{
|
||||||
var game = loop;
|
var game = loop;
|
||||||
if (game == null)
|
if (game == null || Filtered(game))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var canJoin = game.IsJoinable;
|
var canJoin = game.IsJoinable;
|
||||||
@@ -220,26 +249,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
ip.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : ip.TextColor;
|
ip.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : ip.TextColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
var version = item.GetOrNull<LabelWidget>("VERSION");
|
|
||||||
if (version != null)
|
|
||||||
{
|
|
||||||
version.GetText = () => game.ModLabel;
|
|
||||||
version.IsVisible = () => !compatible;
|
|
||||||
version.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : version.TextColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
var location = item.GetOrNull<LabelWidget>("LOCATION");
|
var location = item.GetOrNull<LabelWidget>("LOCATION");
|
||||||
if (location != null)
|
if (location != null)
|
||||||
{
|
{
|
||||||
var cachedServerLocation = LobbyUtils.LookupCountry(game.Address.Split(':')[0]);
|
var cachedServerLocation = LobbyUtils.LookupCountry(game.Address.Split(':')[0]);
|
||||||
location.GetText = () => cachedServerLocation;
|
location.GetText = () => cachedServerLocation;
|
||||||
location.IsVisible = () => compatible;
|
|
||||||
location.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : location.TextColor;
|
location.GetColor = () => !compatible ? Color.DarkGray : !canJoin ? Color.LightGray : location.TextColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Filtered(game))
|
|
||||||
rows.Add(item);
|
rows.Add(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Game.RunAfterTick(() =>
|
Game.RunAfterTick(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,40 +26,40 @@ Container@SERVERBROWSER_PANEL:
|
|||||||
Font: Bold
|
Font: Bold
|
||||||
Checkbox@WAITING_FOR_PLAYERS:
|
Checkbox@WAITING_FOR_PLAYERS:
|
||||||
X: 80
|
X: 80
|
||||||
Y: 468
|
Y: 467
|
||||||
Width: 100
|
Width: 100
|
||||||
Height: 20
|
Height: 20
|
||||||
Text: Waiting
|
Text: Waiting
|
||||||
TextColor: 50,205,50
|
TextColor: 50,205,50
|
||||||
Checkbox@EMPTY:
|
Checkbox@EMPTY:
|
||||||
X: 180
|
X: 180
|
||||||
Y: 468
|
Y: 467
|
||||||
Width: 100
|
Width: 100
|
||||||
Height: 20
|
Height: 20
|
||||||
Text: Empty
|
Text: Empty
|
||||||
Checkbox@ALREADY_STARTED:
|
|
||||||
X: 270
|
|
||||||
Y: 468
|
|
||||||
Width: 100
|
|
||||||
Height: 20
|
|
||||||
Text: Started
|
|
||||||
TextColor: 255,165,0
|
|
||||||
Checkbox@PASSWORD_PROTECTED:
|
Checkbox@PASSWORD_PROTECTED:
|
||||||
X: 370
|
X: 270
|
||||||
Y: 468
|
Y: 467
|
||||||
Width: 100
|
Width: 100
|
||||||
Height: 20
|
Height: 20
|
||||||
Text: Protected
|
Text: Protected
|
||||||
TextColor: 255,0,0
|
TextColor: 255,0,0
|
||||||
|
Checkbox@ALREADY_STARTED:
|
||||||
|
X: 385
|
||||||
|
Y: 467
|
||||||
|
Width: 100
|
||||||
|
Height: 20
|
||||||
|
Text: Started
|
||||||
|
TextColor: 255,165,0
|
||||||
Checkbox@INCOMPATIBLE_VERSION:
|
Checkbox@INCOMPATIBLE_VERSION:
|
||||||
X: 480
|
X: 480
|
||||||
Y: 468
|
Y: 467
|
||||||
Width: 100
|
Width: 100
|
||||||
Height: 20
|
Height: 20
|
||||||
Text: Incompatible
|
Text: Incompatible
|
||||||
TextColor: 190,190,190
|
TextColor: 190,190,190
|
||||||
Button@REFRESH_BUTTON:
|
Button@REFRESH_BUTTON:
|
||||||
X: PARENT_RIGHT - WIDTH - 20
|
X: PARENT_RIGHT - WIDTH - 15
|
||||||
Y: 465
|
Y: 465
|
||||||
Width: 100
|
Width: 100
|
||||||
Height: 25
|
Height: 25
|
||||||
@@ -70,6 +70,18 @@ Container@SERVERBROWSER_PANEL:
|
|||||||
Width: 700
|
Width: 700
|
||||||
Height: 440
|
Height: 440
|
||||||
Children:
|
Children:
|
||||||
|
ScrollItem@HEADER_TEMPLATE:
|
||||||
|
Width: PARENT_RIGHT-27
|
||||||
|
Height: 25
|
||||||
|
X: 2
|
||||||
|
Visible: false
|
||||||
|
Children:
|
||||||
|
Label@LABEL:
|
||||||
|
Y: 0-1
|
||||||
|
Font: Bold
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 25
|
||||||
|
Align: Center
|
||||||
ScrollItem@SERVER_TEMPLATE:
|
ScrollItem@SERVER_TEMPLATE:
|
||||||
Width: PARENT_RIGHT-27
|
Width: PARENT_RIGHT-27
|
||||||
Height: 68
|
Height: 68
|
||||||
@@ -109,12 +121,6 @@ Container@SERVERBROWSER_PANEL:
|
|||||||
Y: 20
|
Y: 20
|
||||||
Align: Right
|
Align: Right
|
||||||
Height: 25
|
Height: 25
|
||||||
Label@VERSION:
|
|
||||||
Width: 140
|
|
||||||
X: PARENT_RIGHT-150
|
|
||||||
Y: 40
|
|
||||||
Align: Right
|
|
||||||
Height: 25
|
|
||||||
Label@LOCATION:
|
Label@LOCATION:
|
||||||
Width: 140
|
Width: 140
|
||||||
X: PARENT_RIGHT-150
|
X: PARENT_RIGHT-150
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Background@SERVERBROWSER_PANEL:
|
|||||||
Font: Bold
|
Font: Bold
|
||||||
Label@SHOW_LABEL_TITLE:
|
Label@SHOW_LABEL_TITLE:
|
||||||
X: 20
|
X: 20
|
||||||
Y: 45
|
Y: 48
|
||||||
Width: 20
|
Width: 20
|
||||||
Height: 25
|
Height: 25
|
||||||
Text: Show:
|
Text: Show:
|
||||||
@@ -33,20 +33,20 @@ Background@SERVERBROWSER_PANEL:
|
|||||||
Width: 100
|
Width: 100
|
||||||
Height: 20
|
Height: 20
|
||||||
Text: Empty
|
Text: Empty
|
||||||
Checkbox@ALREADY_STARTED:
|
|
||||||
X: 280
|
|
||||||
Y: 50
|
|
||||||
Width: 100
|
|
||||||
Height: 20
|
|
||||||
Text: Started
|
|
||||||
TextColor: 255,165,0
|
|
||||||
Checkbox@PASSWORD_PROTECTED:
|
Checkbox@PASSWORD_PROTECTED:
|
||||||
X: 380
|
X: 270
|
||||||
Y: 50
|
Y: 50
|
||||||
Width: 100
|
Width: 100
|
||||||
Height: 20
|
Height: 20
|
||||||
Text: Protected
|
Text: Protected
|
||||||
TextColor: 255,0,0
|
TextColor: 255,0,0
|
||||||
|
Checkbox@ALREADY_STARTED:
|
||||||
|
X: 385
|
||||||
|
Y: 50
|
||||||
|
Width: 100
|
||||||
|
Height: 20
|
||||||
|
Text: Started
|
||||||
|
TextColor: 255,165,0
|
||||||
Checkbox@INCOMPATIBLE_VERSION:
|
Checkbox@INCOMPATIBLE_VERSION:
|
||||||
X: 480
|
X: 480
|
||||||
Y: 50
|
Y: 50
|
||||||
@@ -60,6 +60,19 @@ Background@SERVERBROWSER_PANEL:
|
|||||||
Width: 700
|
Width: 700
|
||||||
Height: 360
|
Height: 360
|
||||||
Children:
|
Children:
|
||||||
|
ScrollItem@HEADER_TEMPLATE:
|
||||||
|
BaseName: scrollheader
|
||||||
|
Width: PARENT_RIGHT-27
|
||||||
|
Height: 25
|
||||||
|
X: 2
|
||||||
|
Visible: false
|
||||||
|
Children:
|
||||||
|
Label@LABEL:
|
||||||
|
Y: 0-1
|
||||||
|
Font: Bold
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 25
|
||||||
|
Align: Center
|
||||||
ScrollItem@SERVER_TEMPLATE:
|
ScrollItem@SERVER_TEMPLATE:
|
||||||
Width: PARENT_RIGHT-27
|
Width: PARENT_RIGHT-27
|
||||||
Height: 68
|
Height: 68
|
||||||
@@ -99,12 +112,6 @@ Background@SERVERBROWSER_PANEL:
|
|||||||
Y: 20
|
Y: 20
|
||||||
Align: Right
|
Align: Right
|
||||||
Height: 25
|
Height: 25
|
||||||
Label@VERSION:
|
|
||||||
Width: 140
|
|
||||||
X: PARENT_RIGHT-150
|
|
||||||
Y: 40
|
|
||||||
Align: Right
|
|
||||||
Height: 25
|
|
||||||
Label@LOCATION:
|
Label@LOCATION:
|
||||||
Width: 140
|
Width: 140
|
||||||
X: PARENT_RIGHT-150
|
X: PARENT_RIGHT-150
|
||||||
|
|||||||
Reference in New Issue
Block a user