Fix production tooltip padding.
This commit is contained in:
@@ -50,6 +50,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ActorInfo lastActor = null;
|
ActorInfo lastActor = null;
|
||||||
Hotkey lastHotkey = Hotkey.Invalid;
|
Hotkey lastHotkey = Hotkey.Invalid;
|
||||||
var lastPowerState = pm == null ? PowerState.Normal : pm.PowerState;
|
var lastPowerState = pm == null ? PowerState.Normal : pm.PowerState;
|
||||||
|
var descLabelY = descLabel.Bounds.Y;
|
||||||
|
var descLabelPadding = descLabel.Bounds.Height;
|
||||||
|
|
||||||
tooltipContainer.BeforeRender = () =>
|
tooltipContainer.BeforeRender = () =>
|
||||||
{
|
{
|
||||||
@@ -88,8 +90,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
var prereqs = buildable.Prerequisites.Select(a => ActorName(mapRules, a))
|
var prereqs = buildable.Prerequisites.Select(a => ActorName(mapRules, a))
|
||||||
.Where(s => !s.StartsWith("~", StringComparison.Ordinal) && !s.StartsWith("!", StringComparison.Ordinal));
|
.Where(s => !s.StartsWith("~", StringComparison.Ordinal) && !s.StartsWith("!", StringComparison.Ordinal));
|
||||||
requiresLabel.Text = prereqs.Any() ? requiresFormat.F(prereqs.JoinWith(", ")) : "";
|
|
||||||
var requiresSize = requiresFont.Measure(requiresLabel.Text);
|
var requiresSize = int2.Zero;
|
||||||
|
if (prereqs.Any())
|
||||||
|
{
|
||||||
|
requiresLabel.Text = requiresFormat.F(prereqs.JoinWith(", "));
|
||||||
|
requiresSize = requiresFont.Measure(requiresLabel.Text);
|
||||||
|
requiresLabel.Visible = true;
|
||||||
|
descLabel.Bounds.Y = descLabelY + requiresLabel.Bounds.Height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
requiresLabel.Visible = false;
|
||||||
|
descLabel.Bounds.Y = descLabelY;
|
||||||
|
}
|
||||||
|
|
||||||
var powerSize = new int2(0, 0);
|
var powerSize = new int2(0, 0);
|
||||||
if (pm != null)
|
if (pm != null)
|
||||||
@@ -116,6 +130,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
descLabel.Text = buildable.Description.Replace("\\n", "\n");
|
descLabel.Text = buildable.Description.Replace("\\n", "\n");
|
||||||
var descSize = descFont.Measure(descLabel.Text);
|
var descSize = descFont.Measure(descLabel.Text);
|
||||||
|
descLabel.Bounds.Width = descSize.X;
|
||||||
|
descLabel.Bounds.Height = descSize.Y + descLabelPadding;
|
||||||
|
|
||||||
var leftWidth = new[] { nameSize.X + hotkeyWidth, requiresSize.X, descSize.X }.Aggregate(Math.Max);
|
var leftWidth = new[] { nameSize.X + hotkeyWidth, requiresSize.X, descSize.X }.Aggregate(Math.Max);
|
||||||
var rightWidth = new[] { powerSize.X, timeSize.X, costSize.X }.Aggregate(Math.Max);
|
var rightWidth = new[] { powerSize.X, timeSize.X, costSize.X }.Aggregate(Math.Max);
|
||||||
@@ -124,9 +140,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
timeLabel.Bounds.X = powerLabel.Bounds.X = costLabel.Bounds.X = timeIcon.Bounds.Right + iconMargin;
|
timeLabel.Bounds.X = powerLabel.Bounds.X = costLabel.Bounds.X = timeIcon.Bounds.Right + iconMargin;
|
||||||
widget.Bounds.Width = leftWidth + rightWidth + 3 * nameLabel.Bounds.X + timeIcon.Bounds.Width + iconMargin;
|
widget.Bounds.Width = leftWidth + rightWidth + 3 * nameLabel.Bounds.X + timeIcon.Bounds.Width + iconMargin;
|
||||||
|
|
||||||
var leftHeight = nameSize.Y + requiresSize.Y + descSize.Y;
|
// Set the bottom margin to match the left margin
|
||||||
var rightHeight = powerSize.Y + timeSize.Y + costSize.Y;
|
var leftHeight = descLabel.Bounds.Bottom + descLabel.Bounds.X;
|
||||||
widget.Bounds.Height = Math.Max(leftHeight, rightHeight) * 3 / 2 + 3 * nameLabel.Bounds.Y;
|
|
||||||
|
// Set the bottom margin to match the top margin
|
||||||
|
var rightHeight = (powerLabel.Visible ? powerIcon.Bounds.Bottom : timeIcon.Bounds.Bottom) + costIcon.Bounds.Top;
|
||||||
|
|
||||||
|
widget.Bounds.Height = Math.Max(leftHeight, rightHeight);
|
||||||
|
|
||||||
lastActor = actor;
|
lastActor = actor;
|
||||||
lastHotkey = hotkey;
|
lastHotkey = hotkey;
|
||||||
|
|||||||
@@ -102,18 +102,19 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
Label@REQUIRES:
|
Label@REQUIRES:
|
||||||
X: 5
|
X: 5
|
||||||
Y: 19
|
Y: 19
|
||||||
Height: 23
|
Height: 15
|
||||||
Font: TinyBold
|
Font: TinyBold
|
||||||
Text: Requires {0}
|
Text: Requires {0}
|
||||||
Label@DESC:
|
Label@DESC:
|
||||||
X: 5
|
X: 5
|
||||||
Y: 39
|
Y: 19
|
||||||
Height: 23
|
Height: 5
|
||||||
Font: TinyBold
|
Font: TinyBold
|
||||||
VAlign: Top
|
VAlign: Top
|
||||||
Image@COST_ICON:
|
Image@COST_ICON:
|
||||||
Y: 5
|
Y: 5
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-cost
|
ImageName: production-tooltip-cost
|
||||||
Label@COST:
|
Label@COST:
|
||||||
@@ -123,6 +124,7 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
X: 3
|
X: 3
|
||||||
Y: 24
|
Y: 24
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-time
|
ImageName: production-tooltip-time
|
||||||
Label@TIME:
|
Label@TIME:
|
||||||
@@ -132,6 +134,7 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
Image@POWER_ICON:
|
Image@POWER_ICON:
|
||||||
Y: 44
|
Y: 44
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-power
|
ImageName: production-tooltip-power
|
||||||
Label@POWER:
|
Label@POWER:
|
||||||
|
|||||||
@@ -246,19 +246,20 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
Font: Bold
|
Font: Bold
|
||||||
Label@REQUIRES:
|
Label@REQUIRES:
|
||||||
X: 7
|
X: 7
|
||||||
Y: 21
|
Y: 25
|
||||||
Height: 23
|
Height: 15
|
||||||
Font: TinyBold
|
Font: TinyBold
|
||||||
Text: Requires {0}
|
Text: Requires {0}
|
||||||
Label@DESC:
|
Label@DESC:
|
||||||
X: 7
|
X: 7
|
||||||
Y: 41
|
Y: 25
|
||||||
Height: 23
|
Height: 2
|
||||||
Font: TinyBold
|
Font: TinyBold
|
||||||
VAlign: Top
|
VAlign: Top
|
||||||
Image@COST_ICON:
|
Image@COST_ICON:
|
||||||
Y: 5
|
Y: 5
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-cost
|
ImageName: production-tooltip-cost
|
||||||
Label@COST:
|
Label@COST:
|
||||||
@@ -268,6 +269,7 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
X: 3
|
X: 3
|
||||||
Y: 26
|
Y: 26
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-time
|
ImageName: production-tooltip-time
|
||||||
Label@TIME:
|
Label@TIME:
|
||||||
@@ -277,6 +279,7 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
Image@POWER_ICON:
|
Image@POWER_ICON:
|
||||||
Y: 46
|
Y: 46
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-power
|
ImageName: production-tooltip-power
|
||||||
Label@POWER:
|
Label@POWER:
|
||||||
|
|||||||
@@ -250,18 +250,19 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
Label@REQUIRES:
|
Label@REQUIRES:
|
||||||
X: 7
|
X: 7
|
||||||
Y: 21
|
Y: 21
|
||||||
Height: 23
|
Height: 15
|
||||||
Font: TinyBold
|
Font: TinyBold
|
||||||
Text: Requires {0}
|
Text: Requires {0}
|
||||||
Label@DESC:
|
Label@DESC:
|
||||||
X: 7
|
X: 7
|
||||||
Y: 41
|
Y: 21
|
||||||
Height: 23
|
Height: 5
|
||||||
Font: TinyBold
|
Font: TinyBold
|
||||||
VAlign: Top
|
VAlign: Top
|
||||||
Image@COST_ICON:
|
Image@COST_ICON:
|
||||||
Y: 5
|
Y: 5
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-cost
|
ImageName: production-tooltip-cost
|
||||||
Label@COST:
|
Label@COST:
|
||||||
@@ -271,6 +272,7 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
X: 3
|
X: 3
|
||||||
Y: 26
|
Y: 26
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-time
|
ImageName: production-tooltip-time
|
||||||
Label@TIME:
|
Label@TIME:
|
||||||
@@ -280,6 +282,7 @@ Background@PRODUCTION_TOOLTIP:
|
|||||||
Image@POWER_ICON:
|
Image@POWER_ICON:
|
||||||
Y: 46
|
Y: 46
|
||||||
Width: 16
|
Width: 16
|
||||||
|
Height: 16
|
||||||
ImageCollection: sidebar-bits
|
ImageCollection: sidebar-bits
|
||||||
ImageName: production-tooltip-power
|
ImageName: production-tooltip-power
|
||||||
Label@POWER:
|
Label@POWER:
|
||||||
|
|||||||
Reference in New Issue
Block a user