Migrate ButtonWidget to NamedHotkey.
This commit is contained in:
@@ -25,17 +25,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var font = Game.Renderer.Fonts[label.Font];
|
||||
var text = button.GetTooltipText();
|
||||
var labelWidth = font.Measure(text).X;
|
||||
var key = button.Key.GetValue();
|
||||
|
||||
label.GetText = () => text;
|
||||
label.Bounds.Width = labelWidth;
|
||||
widget.Bounds.Width = 2 * label.Bounds.X + labelWidth;
|
||||
|
||||
if (button.Key.IsValid())
|
||||
if (key.IsValid())
|
||||
{
|
||||
var hotkey = widget.Get<LabelWidget>("HOTKEY");
|
||||
hotkey.Visible = true;
|
||||
|
||||
var hotkeyLabel = "({0})".F(button.Key.DisplayString());
|
||||
var hotkeyLabel = "({0})".F(key.DisplayString());
|
||||
hotkey.GetText = () => hotkeyLabel;
|
||||
hotkey.Bounds.X = labelWidth + 2 * label.Bounds.X;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user