less fail, still broken

This commit is contained in:
alzeih
2010-04-24 00:05:16 +12:00
parent 480d898efe
commit 9c916be94d
3 changed files with 40 additions and 39 deletions

View File

@@ -36,6 +36,15 @@ namespace OpenRA.Widgets
GetText = () => { return Text; };
}
public ButtonWidget(ButtonWidget widget)
:base(widget)
{
Text = widget.Text;
Depressed = widget.Depressed;
VisualHeight = widget.VisualHeight;
GetText = widget.GetText;
}
public override bool HandleInput(MouseInput mi)
{
if (Chrome.selectedWidget == this)
@@ -80,27 +89,18 @@ namespace OpenRA.Widgets
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
WidgetUtils.DrawPanel(Depressed ? "dialog3" : "dialog2", Bounds);
Game.chrome.renderer.BoldFont.DrawText(Text,
var text = GetText();
Game.chrome.renderer.BoldFont.DrawText(text,
new int2(Bounds.X + Bounds.Width / 2, Bounds.Y + Bounds.Height / 2)
- new int2(Game.chrome.renderer.BoldFont.Measure(Text).X / 2,
Game.chrome.renderer.BoldFont.Measure(Text).Y / 2) + stateOffset, Color.White);
- new int2(Game.chrome.renderer.BoldFont.Measure(text).X / 2,
Game.chrome.renderer.BoldFont.Measure(text).Y / 2) + stateOffset, Color.White);
base.Draw(world);
}
public override Widget Clone()
{
Log.Write("Foo");
var widget = (base.Clone() as ButtonWidget);
Log.Write(widget.Id);
widget.Text = Text;
widget.Depressed = Depressed;
widget.VisualHeight = VisualHeight;
widget.GetText = GetText;
return widget;
return new ButtonWidget(this);
}
}

View File

@@ -40,10 +40,10 @@ namespace OpenRA.Widgets.Delegates
{
Log.Write("Client {0}",client.Name);
var template = PlayerTemplate.Clone();
template.Id = "PLAYER_{0}".F(client.Name);
template.GetWidget<ButtonWidget>("NAME").GetText = () => client.Name;
template.Id = "PLAYER_{0}".F(client.Index);
template.GetWidget<ButtonWidget>("NAME").GetText = () => {return client.Name; };
template.Bounds = new Rectangle(template.Bounds.X, template.Bounds.Y + i, template.Bounds.Width, template.Bounds.Height);
template.Visible = true;
template.IsVisible = () => {return true;};
Players.AddChild(template);
i += 30;
}

View File

@@ -55,33 +55,34 @@ namespace OpenRA.Widgets
public Widget() { IsVisible = () => Visible; }
public virtual Widget Clone()
public Widget(Widget widget)
{
Widget widget = new Widget();
Id = widget.Id;
X = widget.X;
Y = widget.Y;
Width = widget.Width;
Height = widget.Height;
Delegate = widget.Delegate;
ClickThrough = widget.ClickThrough;
Visible = widget.Visible;
widget.Id = Id;
widget.X = X;
widget.Y = Y;
widget.Width = Width;
widget.Height = Height;
widget.Delegate = Delegate;
widget.ClickThrough = ClickThrough;
widget.Visible = Visible;
Bounds = widget.Bounds;
Parent = widget.Parent;
widget.Bounds = Bounds;
widget.Parent = Parent;
OnMouseDown = widget.OnMouseDown;
OnMouseUp = widget.OnMouseUp;
OnMouseMove = widget.OnMouseMove;
IsVisible = widget.IsVisible;
widget.OnMouseDown = OnMouseDown;
widget.OnMouseUp = OnMouseUp;
widget.OnMouseMove = OnMouseMove;
widget.IsVisible = IsVisible;
foreach(var child in Children)
widget.AddChild(child.Clone());
return widget;
foreach(var child in widget.Children)
AddChild(child.Clone());
}
public virtual Widget Clone()
{
return new Widget(this);
}
public virtual void Initialize()
{
// Parse the YAML equations to find the widget bounds