diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index 46a92c10b9..def4794ec6 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -91,6 +91,7 @@ + diff --git a/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs b/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs index ddc6e84468..96f6db7f1c 100755 --- a/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs @@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Widgets providedFrac*b.Height); Game.Renderer.LineRenderer.FillRect(rect, color); - var indicator = ChromeProvider.GetImage("powerbar-bits", "indicator"); + var indicator = ChromeProvider.GetImage("sidebar-bits", "left-indicator"); var drainedFrac = pm.PowerDrained / powerScaleBy; lastDrainedFrac = drainedFrac = float2.Lerp(lastDrainedFrac.GetValueOrDefault(drainedFrac), drainedFrac, .3f); diff --git a/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs b/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs new file mode 100755 index 0000000000..75c9ac9574 --- /dev/null +++ b/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs @@ -0,0 +1,65 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System; +using System.Drawing; +using OpenRA.Graphics; +using OpenRA.Traits; +using OpenRA.Widgets; + +namespace OpenRA.Mods.RA.Widgets +{ + public class SiloBarWidget : Widget + { + public float LowStorageThreshold = 0.8f; + float? lastCapacityFrac; + float? lastStoredFrac; + + readonly PlayerResources pr; + [ObjectCreator.UseCtor] + public SiloBarWidget( [ObjectCreator.Param] World world ) + { + pr = world.LocalPlayer.PlayerActor.Trait(); + } + + public override void DrawInner() + { + float scaleBy = 100; + var max = Math.Max(pr.OreCapacity, pr.Ore); + while (max >= scaleBy) scaleBy *= 2; + + // Current capacity + var capacityFrac = pr.OreCapacity / scaleBy; + lastCapacityFrac = capacityFrac = float2.Lerp(lastCapacityFrac.GetValueOrDefault(capacityFrac), capacityFrac, .3f); + + var color = Color.LimeGreen; + if (pr.Ore >= LowStorageThreshold*pr.OreCapacity) + color = Color.Orange; + if (pr.Ore == pr.OreCapacity) + color = Color.Red; + + var b = RenderBounds; + var rect = new RectangleF(Game.viewport.Location.X + b.X, + Game.viewport.Location.Y + b.Y + (1-capacityFrac)*b.Height, + (float)b.Width, + capacityFrac*b.Height); + Game.Renderer.LineRenderer.FillRect(rect, color); + + var indicator = ChromeProvider.GetImage("sidebar-bits", "right-indicator"); + + var storedFrac = pr.Ore / scaleBy; + lastStoredFrac = storedFrac = float2.Lerp(lastStoredFrac.GetValueOrDefault(storedFrac), storedFrac, .3f); + + float2 pos = new float2(b.X, b.Y + (1-storedFrac)*b.Height - indicator.size.Y / 2); + + Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos); + } + } +} diff --git a/artsrc/cnc/chrome.svg b/artsrc/cnc/chrome.svg index 2afc174c0a..3059c4ee32 100644 --- a/artsrc/cnc/chrome.svg +++ b/artsrc/cnc/chrome.svg @@ -55,8 +55,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="11.313708" - inkscape:cx="324.81809" - inkscape:cy="470.28486" + inkscape:cx="331.88915" + inkscape:cy="473.8204" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -105,14 +105,6 @@ inkscape:groupmode="layer" id="layer1" transform="translate(0,-540.3622)"> - + diff --git a/mods/cnc/chrome.yaml b/mods/cnc/chrome.yaml index 18da0085ee..0dfff6c556 100644 --- a/mods/cnc/chrome.yaml +++ b/mods/cnc/chrome.yaml @@ -380,5 +380,6 @@ strategic: strategic.png enemy_owned: 32,32,32,32 player_owned: 96,0,32,32 -powerbar-bits: chrome.png - indicator: 320,40,11,8 +sidebar-bits: chrome.png + left-indicator: 320,40,11,8 + right-indicator: 325,40,11,8 diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 942691735f..34cc162fd5 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -155,6 +155,12 @@ Container@INGAME_ROOT: Width:10 Height:152 Background:panel-black + Children: + SiloBar: + X:1 + Y:1 + Width:PARENT_RIGHT-2 + Height:PARENT_BOTTOM-2 Label@SILOICON: X:171 Y:170 diff --git a/mods/cnc/uibits/chrome.png b/mods/cnc/uibits/chrome.png index 252c1fd995..5ec58b3405 100644 Binary files a/mods/cnc/uibits/chrome.png and b/mods/cnc/uibits/chrome.png differ