move all databinding for the silobar into ui logic

This commit is contained in:
Chris Forbes
2012-09-25 19:39:33 +12:00
parent af31ae4931
commit c42f270ce0
3 changed files with 17 additions and 17 deletions

View File

@@ -27,21 +27,17 @@ namespace OpenRA.Mods.Cnc.Widgets
EWMA providedLerp = new EWMA(0.3f);
EWMA usedLerp = new EWMA(0.3f);
public Func<float> GetProvided, GetUsed;
public string TooltipFormat = "Silo Usage: {0}/{1}";
public Func<float> GetProvided = () => 0;
public Func<float> GetUsed = () => 0;
public string TooltipFormat = "";
public bool RightIndicator = false;
readonly PlayerResources pr;
public Func<Color> GetBarColor = () => Color.White;
[ObjectCreator.UseCtor]
public SiloBarWidget(World world)
{
pr = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
tooltipContainer = Lazy.New(() =>
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
GetProvided = () => pr.OreCapacity;
GetUsed = () => pr.Ore;
}
public override void MouseEntered()
@@ -84,12 +80,5 @@ namespace OpenRA.Mods.Cnc.Widgets
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos);
}
Color GetBarColor()
{
if (pr.Ore == pr.OreCapacity) return Color.Red;
if (pr.Ore >= LowStorageThreshold * pr.OreCapacity) return Color.Orange;
return Color.LimeGreen;
}
}
}