Polish button tooltips. Add tooltips/hotkeys for menu/sell/repair

This commit is contained in:
Paul Chote
2011-07-05 17:43:19 +12:00
parent 460451c402
commit b4489028de
6 changed files with 42 additions and 34 deletions

View File

@@ -19,8 +19,20 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
public ButtonTooltipLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] TooltipButtonWidget button)
{
widget.GetWidget<LabelWidget>("LABEL").GetText = () => button.TooltipText;
widget.GetWidget<LabelWidget>("HOTKEY").GetText = () => button.Key;
var label = widget.GetWidget<LabelWidget>("LABEL");
var hotkey = widget.GetWidget<LabelWidget>("HOTKEY");
label.GetText = () => button.TooltipText;
var labelWidth = Game.Renderer.Fonts[label.Font].Measure(button.TooltipText).X;
label.Bounds.Width = labelWidth;
var hotkeyLabel = "({0})".F(button.Key.ToUpperInvariant());
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;
}
}
}