ColorBlockWidget tweaks + Widget Refactoring

This commit is contained in:
Paul Chote
2010-04-25 13:46:21 +12:00
committed by Chris Forbes
parent ca0a9b4930
commit 89b36764c6
3 changed files with 8 additions and 6 deletions

View File

@@ -25,19 +25,17 @@ namespace OpenRA.Widgets
{
class ColorBlockWidget : Widget
{
public int PaletteIndex = 0;
public Func<int> GetPaletteIndex;
public ColorBlockWidget()
: base()
{
GetPaletteIndex = () => { return PaletteIndex; };
GetPaletteIndex = () => 0;
}
public ColorBlockWidget(Widget widget)
:base(widget)
{
PaletteIndex = (widget as ColorBlockWidget).PaletteIndex;
GetPaletteIndex = (widget as ColorBlockWidget).GetPaletteIndex;
}

View File

@@ -82,9 +82,15 @@ namespace OpenRA.Widgets
public int2 DrawPosition()
{
return new int2(Bounds.X, Bounds.Y) + ((Parent == null) ? int2.Zero : Parent.DrawPosition());
return new int2(Bounds.X, Bounds.Y) + ParentPosition();
}
public int2 ParentPosition()
{
return (Parent == null) ? int2.Zero : Parent.DrawPosition();
}
public virtual void Initialize()
{
// Parse the YAML equations to find the widget bounds