diff --git a/OpenRA.Mods.Common/Widgets/Logic/SimpleTooltipLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SimpleTooltipLogic.cs index de350cb159..1054cf6c3d 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SimpleTooltipLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SimpleTooltipLogic.cs @@ -22,17 +22,26 @@ namespace OpenRA.Mods.Common.Widgets.Logic var font = Game.Renderer.Fonts[label.Font]; var cachedWidth = 0; + var cachedHeight = 0; + var horizontalPadding = label.Bounds.Width - widget.Bounds.Width; + if (horizontalPadding <= 0) + horizontalPadding = 2 * label.Bounds.X; + var vertcalPadding = widget.Bounds.Height - label.Bounds.Height; + if (vertcalPadding <= 0) + vertcalPadding = 2 * label.Bounds.Y; var labelText = ""; tooltipContainer.BeforeRender = () => { labelText = getText(); var textDim = font.Measure(labelText); - if (textDim.X != cachedWidth) + if (textDim.X != cachedWidth || textDim.Y != cachedHeight) { label.Bounds.Width = textDim.X; - widget.Bounds.Width = 2 * label.Bounds.X + textDim.X; + widget.Bounds.Width = horizontalPadding + textDim.X; label.Bounds.Height = textDim.Y; - widget.Bounds.Height = 4 * label.Bounds.Y + textDim.Y; + widget.Bounds.Height = vertcalPadding + textDim.Y; + cachedWidth = textDim.X; + cachedHeight = textDim.Y; } }; diff --git a/mods/cnc/chrome/tooltips.yaml b/mods/cnc/chrome/tooltips.yaml index 97a440feb5..4edecb9033 100644 --- a/mods/cnc/chrome/tooltips.yaml +++ b/mods/cnc/chrome/tooltips.yaml @@ -1,7 +1,7 @@ Background@SIMPLE_TOOLTIP: Logic: SimpleTooltipLogic Background: panel-black - Height: 25 + Height: 27 Children: Label@LABEL: X: 5 diff --git a/mods/d2k/chrome/tooltips.yaml b/mods/d2k/chrome/tooltips.yaml index 7a664d7289..5d3843c90a 100644 --- a/mods/d2k/chrome/tooltips.yaml +++ b/mods/d2k/chrome/tooltips.yaml @@ -1,7 +1,7 @@ Background@SIMPLE_TOOLTIP: Logic: SimpleTooltipLogic Background: dialog3 - Height: 31 + Height: 34 Children: Label@LABEL: X: 5 diff --git a/mods/ra/chrome/tooltips.yaml b/mods/ra/chrome/tooltips.yaml index d7b2f375e1..455a225bbe 100644 --- a/mods/ra/chrome/tooltips.yaml +++ b/mods/ra/chrome/tooltips.yaml @@ -1,7 +1,7 @@ Background@SIMPLE_TOOLTIP: Logic: SimpleTooltipLogic Background: dialog4 - Height: 29 + Height: 32 Children: Label@LABEL: X: 7