less fail, still broken
This commit is contained in:
@@ -36,6 +36,15 @@ namespace OpenRA.Widgets
|
|||||||
GetText = () => { return Text; };
|
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)
|
public override bool HandleInput(MouseInput mi)
|
||||||
{
|
{
|
||||||
if (Chrome.selectedWidget == this)
|
if (Chrome.selectedWidget == this)
|
||||||
@@ -80,27 +89,18 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0);
|
||||||
WidgetUtils.DrawPanel(Depressed ? "dialog3" : "dialog2", Bounds);
|
WidgetUtils.DrawPanel(Depressed ? "dialog3" : "dialog2", Bounds);
|
||||||
|
var text = GetText();
|
||||||
Game.chrome.renderer.BoldFont.DrawText(Text,
|
Game.chrome.renderer.BoldFont.DrawText(text,
|
||||||
new int2(Bounds.X + Bounds.Width / 2, Bounds.Y + Bounds.Height / 2)
|
new int2(Bounds.X + Bounds.Width / 2, Bounds.Y + Bounds.Height / 2)
|
||||||
- new int2(Game.chrome.renderer.BoldFont.Measure(Text).X / 2,
|
- new int2(Game.chrome.renderer.BoldFont.Measure(text).X / 2,
|
||||||
Game.chrome.renderer.BoldFont.Measure(Text).Y / 2) + stateOffset, Color.White);
|
Game.chrome.renderer.BoldFont.Measure(text).Y / 2) + stateOffset, Color.White);
|
||||||
|
|
||||||
base.Draw(world);
|
base.Draw(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone()
|
public override Widget Clone()
|
||||||
{
|
{
|
||||||
Log.Write("Foo");
|
return new ButtonWidget(this);
|
||||||
var widget = (base.Clone() as ButtonWidget);
|
|
||||||
Log.Write(widget.Id);
|
|
||||||
|
|
||||||
widget.Text = Text;
|
|
||||||
widget.Depressed = Depressed;
|
|
||||||
widget.VisualHeight = VisualHeight;
|
|
||||||
widget.GetText = GetText;
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
{
|
{
|
||||||
Log.Write("Client {0}",client.Name);
|
Log.Write("Client {0}",client.Name);
|
||||||
var template = PlayerTemplate.Clone();
|
var template = PlayerTemplate.Clone();
|
||||||
template.Id = "PLAYER_{0}".F(client.Name);
|
template.Id = "PLAYER_{0}".F(client.Index);
|
||||||
template.GetWidget<ButtonWidget>("NAME").GetText = () => client.Name;
|
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.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);
|
Players.AddChild(template);
|
||||||
i += 30;
|
i += 30;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,31 +55,32 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public Widget() { IsVisible = () => Visible; }
|
public Widget() { IsVisible = () => Visible; }
|
||||||
|
|
||||||
|
public Widget(Widget 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;
|
||||||
|
|
||||||
|
Bounds = widget.Bounds;
|
||||||
|
Parent = widget.Parent;
|
||||||
|
|
||||||
|
OnMouseDown = widget.OnMouseDown;
|
||||||
|
OnMouseUp = widget.OnMouseUp;
|
||||||
|
OnMouseMove = widget.OnMouseMove;
|
||||||
|
IsVisible = widget.IsVisible;
|
||||||
|
|
||||||
|
foreach(var child in widget.Children)
|
||||||
|
AddChild(child.Clone());
|
||||||
|
}
|
||||||
|
|
||||||
public virtual Widget Clone()
|
public virtual Widget Clone()
|
||||||
{
|
{
|
||||||
Widget widget = new Widget();
|
return new Widget(this);
|
||||||
|
|
||||||
widget.Id = Id;
|
|
||||||
widget.X = X;
|
|
||||||
widget.Y = Y;
|
|
||||||
widget.Width = Width;
|
|
||||||
widget.Height = Height;
|
|
||||||
widget.Delegate = Delegate;
|
|
||||||
widget.ClickThrough = ClickThrough;
|
|
||||||
widget.Visible = Visible;
|
|
||||||
|
|
||||||
widget.Bounds = Bounds;
|
|
||||||
widget.Parent = Parent;
|
|
||||||
|
|
||||||
widget.OnMouseDown = OnMouseDown;
|
|
||||||
widget.OnMouseUp = OnMouseUp;
|
|
||||||
widget.OnMouseMove = OnMouseMove;
|
|
||||||
widget.IsVisible = IsVisible;
|
|
||||||
|
|
||||||
foreach(var child in Children)
|
|
||||||
widget.AddChild(child.Clone());
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
|
|||||||
Reference in New Issue
Block a user