Hide invalid hotkey from button tooltips.
This commit is contained in:
@@ -18,19 +18,24 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
public ButtonTooltipLogic(Widget widget, ButtonWidget button)
|
||||
{
|
||||
var label = widget.Get<LabelWidget>("LABEL");
|
||||
var hotkey = widget.Get<LabelWidget>("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;
|
||||
|
||||
if (button.Key.IsValid())
|
||||
{
|
||||
var hotkey = widget.Get<LabelWidget>("HOTKEY");
|
||||
hotkey.Visible = true;
|
||||
|
||||
var hotkeyLabel = "({0})".F(button.Key.DisplayString());
|
||||
hotkey.GetText = () => hotkeyLabel;
|
||||
hotkey.Bounds.X = labelWidth + 2 * label.Bounds.X;
|
||||
|
||||
var panelWidth = hotkey.Bounds.X + label.Bounds.X
|
||||
+ Game.Renderer.Fonts[label.Font].Measure(hotkeyLabel).X;
|
||||
widget.Bounds.Width = panelWidth;
|
||||
widget.Bounds.Width = hotkey.Bounds.X + label.Bounds.X + font.Measure(hotkeyLabel).X;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ Background@BUTTON_TOOLTIP:
|
||||
Height: 23
|
||||
Font: Bold
|
||||
Label@HOTKEY:
|
||||
Visible: false
|
||||
TextColor: 255,255,0
|
||||
Height: 23
|
||||
Font: Bold
|
||||
|
||||
@@ -20,6 +20,7 @@ Background@BUTTON_TOOLTIP:
|
||||
Height: 23
|
||||
Font: Bold
|
||||
Label@HOTKEY:
|
||||
Visible: false
|
||||
Y: 3
|
||||
Height: 23
|
||||
TextColor: 255,255,0
|
||||
|
||||
@@ -20,6 +20,7 @@ Background@BUTTON_TOOLTIP:
|
||||
Height: 23
|
||||
Font: Bold
|
||||
Label@HOTKEY:
|
||||
Visible: false
|
||||
Y: 2
|
||||
Height: 23
|
||||
TextColor: 255,255,0
|
||||
|
||||
Reference in New Issue
Block a user