fix needless use of reflection

This commit is contained in:
Bob
2010-04-14 10:03:54 +12:00
committed by Chris Forbes
parent e791a44290
commit 0b2da36aea
2 changed files with 19 additions and 16 deletions

View File

@@ -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 => {
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);

View File

@@ -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<Widget> Children = new List<Widget>();