Show mod info in server browser
This commit is contained in:
@@ -44,7 +44,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
preview.IsVisible = () => CurrentMap() != null;
|
||||
|
||||
bg.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
|
||||
bg.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => string.Join(",", currentServer.Mods);
|
||||
bg.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => GenerateModsLabel();
|
||||
bg.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
|
||||
bg.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () =>
|
||||
{
|
||||
@@ -120,6 +120,13 @@ namespace OpenRA.Widgets.Delegates
|
||||
return (currentServer == null || !Game.modData.AvailableMaps.ContainsKey(currentServer.Map))
|
||||
? null : Game.modData.AvailableMaps[currentServer.Map];
|
||||
}
|
||||
|
||||
string GenerateModsLabel()
|
||||
{
|
||||
return string.Join("\n", currentServer.Mods.Select(m =>
|
||||
ModData.AllMods.ContainsKey(m) ? string.Format("{0} ({1})", ModData.AllMods[m].Title, ModData.AllMods[m].Version)
|
||||
: string.Format("Unknown Mod: {0}",m)).ToArray());
|
||||
}
|
||||
|
||||
void RefreshServerList(IEnumerable<GameServer> games)
|
||||
{
|
||||
|
||||
@@ -16,10 +16,12 @@ namespace OpenRA.Widgets
|
||||
public class LabelWidget : Widget
|
||||
{
|
||||
public enum TextAlign { Left, Center, Right }
|
||||
public enum TextVAlign { Top, Middle, Bottom }
|
||||
|
||||
public string Text = null;
|
||||
public string Background = null;
|
||||
public TextAlign Align = TextAlign.Left;
|
||||
public TextVAlign VAlign = TextVAlign.Middle;
|
||||
public bool Bold = false;
|
||||
public Func<string> GetText;
|
||||
public Func<string> GetBackground;
|
||||
@@ -54,8 +56,14 @@ namespace OpenRA.Widgets
|
||||
return;
|
||||
|
||||
int2 textSize = font.Measure(text);
|
||||
int2 position = RenderOrigin + new int2(0, (Bounds.Height - textSize.Y)/2);
|
||||
|
||||
int2 position = RenderOrigin;
|
||||
|
||||
if (VAlign == TextVAlign.Middle)
|
||||
position += new int2(0, (Bounds.Height - textSize.Y)/2);
|
||||
|
||||
if (VAlign == TextVAlign.Bottom)
|
||||
position += new int2(0, Bounds.Height - textSize.Y);
|
||||
|
||||
if (Align == TextAlign.Center)
|
||||
position += new int2((Bounds.Width - textSize.X)/2, 0);
|
||||
|
||||
|
||||
@@ -141,10 +141,16 @@ Background@JOINSERVER_BG:
|
||||
Height:PARENT_BOTTOM
|
||||
Visible:false
|
||||
Children:
|
||||
MapPreview@MAP_PREVIEW:
|
||||
Id:MAP_PREVIEW
|
||||
X:PARENT_RIGHT-241
|
||||
Y:30
|
||||
Width:192
|
||||
Height:192
|
||||
Label@SERVER_IP_LABEL:
|
||||
Id:SERVER_IP_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:50
|
||||
Y:230
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
@@ -153,46 +159,14 @@ Background@JOINSERVER_BG:
|
||||
Label@SERVER_IP:
|
||||
Id:SERVER_IP
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:50
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
Label@SERVER_MODS_LABEL:
|
||||
Id:SERVER_MODS_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:70
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
Text:Mods:
|
||||
Bold:True
|
||||
Label@SERVER_MODS:
|
||||
Id:SERVER_MODS
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:70
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
Label@MAP_TITLE_LABEL:
|
||||
Id:MAP_TITLE_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:90
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
Text:Map:
|
||||
Bold:True
|
||||
Label@MAP_TITLE:
|
||||
Id:MAP_TITLE
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:90
|
||||
Y:230
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
Label@MAP_PLAYERS_LABEL:
|
||||
Id:MAP_PLAYERS_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:110
|
||||
Y:250
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
@@ -201,16 +175,43 @@ Background@JOINSERVER_BG:
|
||||
Label@MAP_PLAYERS:
|
||||
Id:MAP_PLAYERS
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:110
|
||||
Y:250
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
MapPreview@MAP_PREVIEW:
|
||||
Id:MAP_PREVIEW
|
||||
X:PARENT_RIGHT-241
|
||||
Y:140
|
||||
Width:192
|
||||
Height:192
|
||||
Label@MAP_TITLE_LABEL:
|
||||
Id:MAP_TITLE_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:270
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
Text:Map:
|
||||
Bold:True
|
||||
Label@MAP_TITLE:
|
||||
Id:MAP_TITLE
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:270
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
Label@SERVER_MODS_LABEL:
|
||||
Id:SERVER_MODS_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:290
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
Text:Mods:
|
||||
Bold:True
|
||||
Label@SERVER_MODS:
|
||||
Id:SERVER_MODS
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:293
|
||||
Align:Left
|
||||
VAlign:Top
|
||||
Width:70
|
||||
Height:20
|
||||
Button@DIRECTCONNECT_BUTTON:
|
||||
Id:DIRECTCONNECT_BUTTON
|
||||
X:20
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Metadata:
|
||||
Title: Command & Conquer
|
||||
Title: C&C
|
||||
Description: OpenRA Reimagining of the classic game
|
||||
Version: a0001
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ Background@CREATESERVER_BG:
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:400
|
||||
Height:240
|
||||
Visible:true
|
||||
Children:
|
||||
Label@LABEL_TITLE:
|
||||
Id:LABEL_TITLE
|
||||
@@ -100,7 +99,6 @@ Background@JOINSERVER_BG:
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:700
|
||||
Height:410
|
||||
Visible:true
|
||||
Children:
|
||||
Label@JOINSERVER_LABEL_TITLE:
|
||||
Id:JOINSERVER_LABEL_TITLE
|
||||
@@ -143,10 +141,16 @@ Background@JOINSERVER_BG:
|
||||
Height:PARENT_BOTTOM
|
||||
Visible:false
|
||||
Children:
|
||||
MapPreview@MAP_PREVIEW:
|
||||
Id:MAP_PREVIEW
|
||||
X:PARENT_RIGHT-241
|
||||
Y:30
|
||||
Width:192
|
||||
Height:192
|
||||
Label@SERVER_IP_LABEL:
|
||||
Id:SERVER_IP_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:50
|
||||
Y:230
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
@@ -155,46 +159,14 @@ Background@JOINSERVER_BG:
|
||||
Label@SERVER_IP:
|
||||
Id:SERVER_IP
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:50
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
Label@SERVER_MODS_LABEL:
|
||||
Id:SERVER_MODS_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:70
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
Text:Mods:
|
||||
Bold:True
|
||||
Label@SERVER_MODS:
|
||||
Id:SERVER_MODS
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:70
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
Label@MAP_TITLE_LABEL:
|
||||
Id:MAP_TITLE_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:90
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
Text:Map:
|
||||
Bold:True
|
||||
Label@MAP_TITLE:
|
||||
Id:MAP_TITLE
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:90
|
||||
Y:230
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
Label@MAP_PLAYERS_LABEL:
|
||||
Id:MAP_PLAYERS_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:110
|
||||
Y:250
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
@@ -203,16 +175,43 @@ Background@JOINSERVER_BG:
|
||||
Label@MAP_PLAYERS:
|
||||
Id:MAP_PLAYERS
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:110
|
||||
Y:250
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
MapPreview@MAP_PREVIEW:
|
||||
Id:MAP_PREVIEW
|
||||
X:PARENT_RIGHT-241
|
||||
Y:140
|
||||
Width:192
|
||||
Height:192
|
||||
Label@MAP_TITLE_LABEL:
|
||||
Id:MAP_TITLE_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:270
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
Text:Map:
|
||||
Bold:True
|
||||
Label@MAP_TITLE:
|
||||
Id:MAP_TITLE
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:270
|
||||
Align:Left
|
||||
Width:70
|
||||
Height:20
|
||||
Label@SERVER_MODS_LABEL:
|
||||
Id:SERVER_MODS_LABEL
|
||||
X:PARENT_RIGHT - 200 - WIDTH
|
||||
Y:290
|
||||
Align:Right
|
||||
Width:70
|
||||
Height:20
|
||||
Text:Mods:
|
||||
Bold:True
|
||||
Label@SERVER_MODS:
|
||||
Id:SERVER_MODS
|
||||
X:PARENT_RIGHT - 195
|
||||
Y:293
|
||||
Align:Left
|
||||
VAlign:Top
|
||||
Width:70
|
||||
Height:20
|
||||
Button@DIRECTCONNECT_BUTTON:
|
||||
Id:DIRECTCONNECT_BUTTON
|
||||
X:20
|
||||
@@ -252,7 +251,6 @@ Background@DIRECTCONNECT_BG:
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:400
|
||||
Height:155
|
||||
Visible:true
|
||||
Children:
|
||||
Label@DIRECTCONNECT_LABEL_TITLE:
|
||||
Id:DIRECTCONNECT_LABEL_TITLE
|
||||
@@ -301,7 +299,6 @@ Background@CONNECTION_FAILED_BG:
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:450
|
||||
Height:150
|
||||
Visible:true
|
||||
Children:
|
||||
Label@CONNECTION_FAILED_TITLE:
|
||||
Id:CONNECTION_FAILED_TITLE
|
||||
@@ -343,7 +340,6 @@ Background@CONNECTING_BG:
|
||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width:450
|
||||
Height:150
|
||||
Visible:true
|
||||
Children:
|
||||
Label@CONNECTING_TITLE:
|
||||
Id:CONNECTING_TITLE
|
||||
@@ -369,4 +365,4 @@ Background@CONNECTING_BG:
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Abort
|
||||
Bold:True
|
||||
Bold:True
|
||||
Reference in New Issue
Block a user