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