make ResourceBarWidget generic

This commit is contained in:
Chris Forbes
2012-09-25 19:43:57 +12:00
parent c42f270ce0
commit 84f7aa56e1
4 changed files with 6 additions and 5 deletions

View File

@@ -110,12 +110,12 @@
<Compile Include="Widgets\PowerBarWidget.cs" />
<Compile Include="Widgets\ProductionPaletteWidget.cs" />
<Compile Include="Widgets\ProductionTabsWidget.cs" />
<Compile Include="Widgets\SiloBarWidget.cs" />
<Compile Include="Widgets\SupportPowersWidget.cs" />
<Compile Include="Widgets\ToggleButtonWidget.cs" />
<Compile Include="Widgets\TooltipContainerWidget.cs" />
<Compile Include="WithFire.cs" />
<Compile Include="WithRoof.cs" />
<Compile Include="Widgets\ResourceBarWidget.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -153,10 +153,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
});
};
var siloBar = playerWidgets.Get<SiloBarWidget>("SILOBAR");
var siloBar = playerWidgets.Get<ResourceBarWidget>("SILOBAR");
siloBar.GetProvided = () => playerResources.OreCapacity;
siloBar.GetUsed = () => playerResources.Ore;
siloBar.TooltipFormat = "Silo Usage: {0}/{1}";
siloBar.RightIndicator = true;
siloBar.GetBarColor = () =>
{
if (playerResources.Ore == playerResources.OreCapacity) return Color.Red;

View File

@@ -17,7 +17,7 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Cnc.Widgets
{
public class SiloBarWidget : Widget
public class ResourceBarWidget : Widget
{
public readonly string TooltipTemplate = "SIMPLE_TOOLTIP";
public readonly string TooltipContainer;
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.Widgets
public Func<Color> GetBarColor = () => Color.White;
[ObjectCreator.UseCtor]
public SiloBarWidget(World world)
public ResourceBarWidget(World world)
{
tooltipContainer = Lazy.New(() =>
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

View File

@@ -170,7 +170,7 @@ Container@PLAYER_WIDGETS:
Height:168
Background:panel-black
Children:
SiloBar@SILOBAR:
ResourceBar@SILOBAR:
X:1
Y:1
Width:PARENT_RIGHT-2