From c1e83d9415d8b82bd704294b1c14fde1d423621c Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 16 Jul 2014 18:17:57 +1200 Subject: [PATCH] Support trimmed production icon rectangles. --- OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs | 7 +++++-- mods/cnc/chrome/ingame.yaml | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs index b9c7143376..882b7620f6 100644 --- a/OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/ProductionPaletteWidget.cs @@ -38,6 +38,8 @@ namespace OpenRA.Mods.RA.Widgets public readonly Color ReadyTextAltColor = Color.Red; public readonly int Columns = 3; public readonly int2 IconSize = new int2(64, 48); + public readonly int2 IconMargin = int2.Zero; + public readonly int2 IconSpriteOffset = int2.Zero; public readonly string TabClick = null; public readonly string DisabledTabClick = null; @@ -201,7 +203,7 @@ namespace OpenRA.Mods.RA.Widgets { var x = IconCount % Columns; var y = IconCount / Columns; - var rect = new Rectangle(rb.X + x * IconSize.X + 1, rb.Y + y * IconSize.Y + 1, IconSize.X, IconSize.Y); + var rect = new Rectangle(rb.X + x * (IconSize.X + IconMargin.X), rb.Y + y * (IconSize.Y + IconMargin.Y), IconSize.X, IconSize.Y); var icon = new Animation(World, RenderSimple.GetImage(item)); icon.Play(item.Traits.Get().Icon); @@ -225,7 +227,7 @@ namespace OpenRA.Mods.RA.Widgets public override void Draw() { - var iconOffset = 0.5f * IconSize.ToFloat2(); + var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset; overlayFont = Game.Renderer.Fonts["TinyBold"]; timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; @@ -251,6 +253,7 @@ namespace OpenRA.Mods.RA.Widgets () => (first.TotalTime - first.RemainingTime) * (clock.CurrentSequence.Length - 1) / first.TotalTime); clock.Tick(); + WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, worldRenderer); } else if (!buildableItems.Any(a => a.Name == icon.Name)) diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 44f7598cd1..6af5249a42 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -397,8 +397,8 @@ Container@PLAYER_WIDGETS: Height: 50 Background: panel-black ProductionPalette@PRODUCTION_PALETTE: - X: WINDOW_RIGHT - 204 - Y: 287 + X: WINDOW_RIGHT - 203 + Y: 288 TooltipContainer: TOOLTIP_CONTAINER ReadyText: Ready HoldText: On Hold