diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index c1c6fd0b5f..991fd59a89 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -6,6 +6,7 @@ using OpenRa.Game.Graphics; using OpenRa.Game.Support; using System.Drawing; using IjwFramework.Types; +using IjwFramework.Collections; namespace OpenRa.Game { @@ -20,6 +21,8 @@ namespace OpenRa.Game readonly Animation cantBuild; readonly List> buildItems = new List>(); + readonly Cache clockAnimations; + readonly List digitSprites; public Chrome(Renderer r) { @@ -28,8 +31,8 @@ namespace OpenRa.Game chromeRenderer = new SpriteRenderer(renderer, true, renderer.RgbaSpriteShader); buildPaletteRenderer = new SpriteRenderer(renderer, true); - specialBinSprite = new Sprite(specialBin, new Rectangle(0, 0, 64, 256), TextureChannel.Alpha); - moneyBinSprite = new Sprite(specialBin, new Rectangle(128, 0, 384, 64), TextureChannel.Alpha); + specialBinSprite = new Sprite(specialBin, new Rectangle(0, 0, 32, 256), TextureChannel.Alpha); + moneyBinSprite = new Sprite(specialBin, new Rectangle(512-320, 0, 320, 64), TextureChannel.Alpha); sprites = groups .SelectMany(g => Rules.Categories[g]) @@ -40,6 +43,16 @@ namespace OpenRa.Game cantBuild = new Animation("clock"); cantBuild.PlayFetchIndex("idle", () => 0); + + clockAnimations = new Cache( + s => { + var anim = new Animation("clock"); + anim.PlayFetchIndex("idle", ClockAnimFrame(s)); + return anim; + }); + + digitSprites = Util.MakeArray(10, a => a) + .Select(n => new Sprite(specialBin, new Rectangle(32 + 14 * n, 0, 14, 17), TextureChannel.Alpha)).ToList(); } public void Draw() @@ -59,7 +72,15 @@ namespace OpenRa.Game PerfHistory.Render(renderer, Game.worldRenderer.lineRenderer); chromeRenderer.DrawSprite(specialBinSprite, float2.Zero, 0); - chromeRenderer.DrawSprite(moneyBinSprite, new float2( Game.viewport.Width - 384, 0 ), 0); + chromeRenderer.DrawSprite(moneyBinSprite, new float2( Game.viewport.Width - 320, 0 ), 0); + + var moneyDigits = Game.LocalPlayer.Cash.ToString(); + var x = Game.viewport.Width - 155; + foreach( var d in moneyDigits.Reverse() ) + { + chromeRenderer.DrawSprite(digitSprites[d - '0'], new float2(x,6), 0); + x -= 14; + } chromeRenderer.Flush(); DrawBuildPalette("Building"); @@ -68,6 +89,17 @@ namespace OpenRa.Game static string[] groups = new string[] { "Building", "Defense", "Vehicle", "Ship", "Infantry", "Plane" }; Dictionary sprites; + const int NumClockFrames = 54; + Func ClockAnimFrame(string group) + { + return () => + { + var producing = Game.LocalPlayer.Producing(group); + if (producing == null) return 0; + return (producing.TotalTime - producing.RemainingTime) * NumClockFrames / producing.TotalTime; + }; + } + void DrawBuildPalette(string queueName) { var buildItem = Game.LocalPlayer.Producing(queueName); @@ -76,18 +108,22 @@ namespace OpenRa.Game var buildableItems = Rules.TechTree.BuildableItems(Game.LocalPlayer, queueName).ToArray(); var allItems = Rules.TechTree.AllItems(Game.LocalPlayer, queueName) + .Where( a => Rules.UnitInfo[a].TechLevel != -1 ) .OrderBy( a => Rules.UnitInfo[a].TechLevel ); + + var currentItem = Game.LocalPlayer.Producing(queueName); + foreach (var item in allItems) { - if (Rules.UnitInfo[item].TechLevel == -1) continue; - var rect = new Rectangle(Game.viewport.Width - (3 - x) * 64 - 20, 32 + 48 * y, 64, 48); + var rect = new Rectangle(Game.viewport.Width - (3 - x) * 64 - 10, 40 + 48 * y, 64, 48); buildPaletteRenderer.DrawSprite(sprites[item], Game.viewport.Location + new float2(rect.Location), 0); - if (!buildableItems.Contains(item)) - { - /* don't have the necessary prereqs! */ + if (!buildableItems.Contains(item) || (currentItem != null && currentItem.Item != item)) buildPaletteRenderer.DrawSprite(cantBuild.Image, Game.viewport.Location + new float2(rect.Location), 0); - } + + if (currentItem != null && currentItem.Item == item) + buildPaletteRenderer.DrawSprite(clockAnimations[queueName].Image, + Game.viewport.Location + new float2(rect.Location), 0); buildItems.Add(Pair.New(rect, item)); if (++x == 3) { x = 0; y++; } diff --git a/OpenRa.Game/Sidebar.cs b/OpenRa.Game/Sidebar.cs index 1a5dc11e23..14df947dee 100644 --- a/OpenRa.Game/Sidebar.cs +++ b/OpenRa.Game/Sidebar.cs @@ -25,7 +25,7 @@ namespace OpenRa.Game Dictionary sprites = new Dictionary(); const int spriteWidth = 64, spriteHeight = 48; - static string[] groups = new string[] { "Building", "Vehicle", "Ship", "Infantry", "Plane" }; + static string[] groups = new string[] { "Building", "Defense", "Vehicle", "Ship", "Infantry", "Plane" }; Dictionary clockAnimations = new Dictionary(); //group->clockAnimation diff --git a/bits.psd b/bits.psd index 0dc50b63e4..8b2e81a287 100644 Binary files a/bits.psd and b/bits.psd differ diff --git a/specialbin.png b/specialbin.png index 673ca32853..4f00bdce1b 100644 Binary files a/specialbin.png and b/specialbin.png differ