diff --git a/OpenRa.Game/Building.cs b/OpenRa.Game/Building.cs index 3dd15bab13..c3a9f6db73 100644 --- a/OpenRa.Game/Building.cs +++ b/OpenRa.Game/Building.cs @@ -15,7 +15,7 @@ namespace OpenRa.Game this.owner = owner; animation = new Animation( name ); - animation.PlayThen( "make", delegate { animation.Play( "idle" ); } ); + animation.PlayThen( "make", delegate { animation.PlayRepeating( "idle" ); } ); owner.TechTree.Build( name, true ); } diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 22e27db09e..657430e706 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -77,6 +77,7 @@ + diff --git a/OpenRa.Game/Sidebar.cs b/OpenRa.Game/Sidebar.cs index 4e59ef09a4..a3877ed5f7 100644 --- a/OpenRa.Game/Sidebar.cs +++ b/OpenRa.Game/Sidebar.cs @@ -73,9 +73,12 @@ namespace OpenRa.Game DrawSprite(blank, ref p); } + int buildPos = 0; + int unitPos = 0; + void PopulateItemList() { - int buildPos = 0, unitPos = 0; + buildPos = 0; unitPos = 0; items.Clear(); @@ -100,7 +103,10 @@ namespace OpenRa.Game foreach (SidebarItem i in items) i.Paint(spriteRenderer, region.Location); - spriteRenderer.Flush(); //todo: fix filling + Fill(region.Size.Y, new float2(region.Location.X, buildPos + region.Location.Y)); + Fill(region.Size.Y, new float2(region.Location.X + spriteWidth, unitPos + region.Location.Y)); + + spriteRenderer.Flush(); clockRenderer.DrawSprite( clockAnimation.Images[0], region.Location, 0 ); clockAnimation.Tick(1); diff --git a/OpenRa.Game/UiOverlay.cs b/OpenRa.Game/UiOverlay.cs new file mode 100644 index 0000000000..ebb70b987c --- /dev/null +++ b/OpenRa.Game/UiOverlay.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; + +namespace OpenRa.Game +{ + class UiOverlay + { + SpriteRenderer spriteRenderer; + Sprite buildOk; + Sprite buildBlocked; + Game game; + + public UiOverlay(SpriteRenderer spriteRenderer, Game game) + { + this.spriteRenderer = spriteRenderer; + this.game = game; + + buildOk = SynthesizeTile(0x80); + buildBlocked = SynthesizeTile(0xe6); + } + + Sprite SynthesizeTile(byte paletteIndex) + { + byte[] data = new byte[24 * 24]; + + for (int i = 0; i < 24; i++) + for (int j = 0; j < 24; j++) + data[i * 24 + j] = ((i + j) % 4 < 2) ? (byte)0 : paletteIndex; + + return SheetBuilder.Add( data, new Size(24,24) ); + } + + public void Draw() + { + spriteRenderer.DrawSprite(buildOk, new float2(48, 48), 0); + spriteRenderer.DrawSprite(buildBlocked, new float2(96, 48), 0); + spriteRenderer.Flush(); + } + } +} diff --git a/OpenRa.Game/World.cs b/OpenRa.Game/World.cs index a9076ed459..a9ceb4e37a 100644 --- a/OpenRa.Game/World.cs +++ b/OpenRa.Game/World.cs @@ -16,6 +16,7 @@ namespace OpenRa.Game Game game; Region region; public IOrderGenerator orderGenerator; + UiOverlay uiOverlay; public World(Renderer renderer, Game game) { @@ -24,6 +25,8 @@ namespace OpenRa.Game game.viewport.AddRegion(region); spriteRenderer = new SpriteRenderer(renderer, true); + + uiOverlay = new UiOverlay(spriteRenderer, game); } public void Add(Actor a) { actors.Add(a); } @@ -73,6 +76,7 @@ namespace OpenRa.Game } frameEndActions.Clear(); + uiOverlay.Draw(); spriteRenderer.Flush(); } } diff --git a/sequences.xml b/sequences.xml index 570edfef2f..3856828cae 100644 --- a/sequences.xml +++ b/sequences.xml @@ -67,8 +67,8 @@ - - + +