diff --git a/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs b/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs index 9efd8f8530..a678e4043c 100644 --- a/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/ServerBrowserDelegate.cs @@ -46,16 +46,19 @@ namespace OpenRA.Widgets.Delegates foreach (var game in GameList) { - ButtonWidget b = new ButtonWidget(); - b.Bounds = new Rectangle(bg.Bounds.X + 20, bg.Bounds.Y + height, width, 25); - b.GetType().GetField("Id").SetValue(b, "JOIN_GAME_{0}".F(i)); - b.GetType().GetField("Text").SetValue(b, "{0} ({1})".F(game.Name, game.Address)); - b.GetType().GetField("Delegate").SetValue(b, "ServerBrowserDelegate"); + var b = new ButtonWidget + { + Bounds = new Rectangle(bg.Bounds.X + 20, bg.Bounds.Y + height, width, 25), + Id = "JOIN_GAME_{0}".F( i ), + Text = "{0} ({1})".F( game.Name, game.Address ), + Delegate = "ServerBrowserDelegate", - b.OnMouseUp = nmi => { - r.GetWidget("JOINSERVER_BG").Visible = false; - Game.JoinServer(GameList[i].Address.Split(':')[0], int.Parse(GameList[i].Address.Split(':')[1])); - return true; + OnMouseUp = nmi => + { + r.GetWidget("JOINSERVER_BG").Visible = false; + Game.JoinServer(GameList[i].Address.Split(':')[0], int.Parse(GameList[i].Address.Split(':')[1])); + return true; + }, }; bg.AddChild(b); diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 630e4cc769..fd04c4908b 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -30,13 +30,13 @@ namespace OpenRA.Widgets public class Widget { // Info defined in YAML - public readonly string Id = null; - public readonly string X = "0"; - public readonly string Y = "0"; - public readonly string Width = "0"; - public readonly string Height = "0"; - public readonly string Delegate = null; - public readonly bool ClickThrough = false; + public string Id = null; + public string X = "0"; + public string Y = "0"; + public string Width = "0"; + public string Height = "0"; + public string Delegate = null; + public bool ClickThrough = false; public bool Visible = true; public readonly List Children = new List();