move all databinding for the silobar into ui logic
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user