Migrate ButtonWidget to NamedHotkey.

This commit is contained in:
Paul Chote
2017-07-23 14:25:27 +00:00
committed by reaperrr
parent 42bf232b37
commit 1e0148e092
20 changed files with 120 additions and 100 deletions

View File

@@ -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;