From 5e974b495931401a2d13ee0de116de7e70896b74 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 21 Sep 2016 07:05:23 +0100 Subject: [PATCH] Fix control group decoration position. --- .../WithSpriteControlGroupDecoration.cs | 33 ++++++------------- mods/cnc/rules/defaults.yaml | 1 - mods/cnc/sequences/misc.yaml | 1 + mods/d2k/sequences/misc.yaml | 1 + mods/ra/rules/defaults.yaml | 1 - mods/ra/sequences/misc.yaml | 1 + 6 files changed, 13 insertions(+), 25 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteControlGroupDecoration.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteControlGroupDecoration.cs index 2f875771a0..b238f8a330 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteControlGroupDecoration.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteControlGroupDecoration.cs @@ -69,33 +69,20 @@ namespace OpenRA.Mods.Common.Traits.Render pipImages.PlayFetchIndex(Info.GroupSequence, () => (int)group); var bounds = self.VisualBounds; - var halfSize = (0.5f * pipImages.Image.Size.XY).ToInt2(); - - var boundsOffset = new int2(bounds.Left + bounds.Right, bounds.Top + bounds.Bottom) / 2; - var sizeOffset = -halfSize; + var boundsOffset = 0.5f * new float2(bounds.Left + bounds.Right, bounds.Top + bounds.Bottom); if (Info.ReferencePoint.HasFlag(ReferencePoints.Top)) - { - boundsOffset -= new int2(0, bounds.Height / 2); - sizeOffset += new int2(0, halfSize.Y); - } - else if (Info.ReferencePoint.HasFlag(ReferencePoints.Bottom)) - { - boundsOffset += new int2(0, bounds.Height / 2); - sizeOffset -= new int2(0, halfSize.Y); - } + boundsOffset -= new float2(0, 0.5f * bounds.Height); + + if (Info.ReferencePoint.HasFlag(ReferencePoints.Bottom)) + boundsOffset += new float2(0, 0.5f * bounds.Height); if (Info.ReferencePoint.HasFlag(ReferencePoints.Left)) - { - boundsOffset -= new int2(bounds.Width / 2, 0); - sizeOffset += new int2(halfSize.X, 0); - } - else if (Info.ReferencePoint.HasFlag(ReferencePoints.Right)) - { - boundsOffset += new int2(bounds.Width / 2, 0); - sizeOffset -= new int2(halfSize.X, 0); - } + boundsOffset -= new float2(0.5f * bounds.Width, 0); - var pxPos = wr.Viewport.WorldToViewPx(wr.ScreenPxPosition(self.CenterPosition) + boundsOffset) + sizeOffset; + if (Info.ReferencePoint.HasFlag(ReferencePoints.Right)) + boundsOffset += new float2(0.5f * bounds.Width, 0); + + var pxPos = wr.Viewport.WorldToViewPx(wr.ScreenPxPosition(self.CenterPosition) + boundsOffset.ToInt2()) - (0.5f * pipImages.Image.Size.XY).ToInt2(); yield return new UISpriteRenderable(pipImages.Image, self.CenterPosition, pxPos, 0, palette, 1f); } } diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index aafad4d330..5b5c607b4a 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -194,7 +194,6 @@ Beach: 80 SelectionDecorations: WithSpriteControlGroupDecoration: - ReferencePoint: Top Selectable: Bounds: 12,17,0,-6 Targetable: diff --git a/mods/cnc/sequences/misc.yaml b/mods/cnc/sequences/misc.yaml index 2bcf3281a0..c63506abfe 100644 --- a/mods/cnc/sequences/misc.yaml +++ b/mods/cnc/sequences/misc.yaml @@ -255,6 +255,7 @@ pips: Length: * groups: pdigits Length: * + Offset: 9, 5 pip-hazmat: pip-hazmat Length: * diff --git a/mods/d2k/sequences/misc.yaml b/mods/d2k/sequences/misc.yaml index 5836af2bae..8da79d2fd6 100644 --- a/mods/d2k/sequences/misc.yaml +++ b/mods/d2k/sequences/misc.yaml @@ -124,6 +124,7 @@ pips: groups: DATA.R8 Start: 17 Length: 10 + Offset: 3, 3 pickup-indicator: DATA.R8 Start: 112 pip-empty: DATA.R8 diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 105f5cf9fb..7884101e2b 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -191,7 +191,6 @@ Beach: 80 SelectionDecorations: WithSpriteControlGroupDecoration: - ReferencePoint: Top Selectable: Bounds: 12,18,0,-8 Targetable: diff --git a/mods/ra/sequences/misc.yaml b/mods/ra/sequences/misc.yaml index c23f6ca5f5..ed9365c5b1 100644 --- a/mods/ra/sequences/misc.yaml +++ b/mods/ra/sequences/misc.yaml @@ -93,6 +93,7 @@ pips: groups: Start: 8 Length: 10 + Offset: 9, 5 medic: Start: 20 # ready: