Fix control group decoration position.

This commit is contained in:
Paul Chote
2016-09-21 07:05:23 +01:00
parent c1e1ee0938
commit 5e974b4959
6 changed files with 13 additions and 25 deletions

View File

@@ -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);
}
}

View File

@@ -194,7 +194,6 @@
Beach: 80
SelectionDecorations:
WithSpriteControlGroupDecoration:
ReferencePoint: Top
Selectable:
Bounds: 12,17,0,-6
Targetable:

View File

@@ -255,6 +255,7 @@ pips:
Length: *
groups: pdigits
Length: *
Offset: 9, 5
pip-hazmat: pip-hazmat
Length: *

View File

@@ -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

View File

@@ -191,7 +191,6 @@
Beach: 80
SelectionDecorations:
WithSpriteControlGroupDecoration:
ReferencePoint: Top
Selectable:
Bounds: 12,18,0,-8
Targetable:

View File

@@ -93,6 +93,7 @@ pips:
groups:
Start: 8
Length: 10
Offset: 9, 5
medic:
Start: 20
# ready: