diff --git a/OpenRA.Mods.RA/Widgets/Logic/ButtonTooltipLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ButtonTooltipLogic.cs index 88cd4d794b..6c4aadf049 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ButtonTooltipLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ButtonTooltipLogic.cs @@ -18,19 +18,24 @@ namespace OpenRA.Mods.RA.Widgets.Logic public ButtonTooltipLogic(Widget widget, ButtonWidget button) { var label = widget.Get("LABEL"); - var hotkey = widget.Get("HOTKEY"); + var font = Game.Renderer.Fonts[label.Font]; + var labelWidth = font.Measure(button.TooltipText).X; label.GetText = () => button.TooltipText; - var labelWidth = Game.Renderer.Fonts[label.Font].Measure(button.TooltipText).X; label.Bounds.Width = labelWidth; + widget.Bounds.Width = 2 * label.Bounds.X + labelWidth; - var hotkeyLabel = "({0})".F(button.Key.DisplayString()); - hotkey.GetText = () => hotkeyLabel; - hotkey.Bounds.X = labelWidth + 2 * label.Bounds.X; + if (button.Key.IsValid()) + { + var hotkey = widget.Get("HOTKEY"); + hotkey.Visible = true; - var panelWidth = hotkey.Bounds.X + label.Bounds.X - + Game.Renderer.Fonts[label.Font].Measure(hotkeyLabel).X; - widget.Bounds.Width = panelWidth; + var hotkeyLabel = "({0})".F(button.Key.DisplayString()); + hotkey.GetText = () => hotkeyLabel; + hotkey.Bounds.X = labelWidth + 2 * label.Bounds.X; + + widget.Bounds.Width = hotkey.Bounds.X + label.Bounds.X + font.Measure(hotkeyLabel).X; + } } } } \ No newline at end of file diff --git a/mods/cnc/chrome/tooltips.yaml b/mods/cnc/chrome/tooltips.yaml index effb6aec22..04405c57b5 100644 --- a/mods/cnc/chrome/tooltips.yaml +++ b/mods/cnc/chrome/tooltips.yaml @@ -18,6 +18,7 @@ Background@BUTTON_TOOLTIP: Height: 23 Font: Bold Label@HOTKEY: + Visible: false TextColor: 255,255,0 Height: 23 Font: Bold diff --git a/mods/d2k/chrome/tooltips.yaml b/mods/d2k/chrome/tooltips.yaml index 99ff0076e0..ed7ddc860a 100644 --- a/mods/d2k/chrome/tooltips.yaml +++ b/mods/d2k/chrome/tooltips.yaml @@ -20,6 +20,7 @@ Background@BUTTON_TOOLTIP: Height: 23 Font: Bold Label@HOTKEY: + Visible: false Y: 3 Height: 23 TextColor: 255,255,0 diff --git a/mods/ra/chrome/tooltips.yaml b/mods/ra/chrome/tooltips.yaml index d4ce39892b..14d4190cca 100644 --- a/mods/ra/chrome/tooltips.yaml +++ b/mods/ra/chrome/tooltips.yaml @@ -20,6 +20,7 @@ Background@BUTTON_TOOLTIP: Height: 23 Font: Bold Label@HOTKEY: + Visible: false Y: 2 Height: 23 TextColor: 255,255,0