From b31daf23caba7bc959482bd46896cbba803ef2fb Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 22 Oct 2013 19:45:00 +1300 Subject: [PATCH] Blink the KeyboardEntryWidget on focus. --- OpenRA.Game/Widgets/HotkeyEntryWidget.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/OpenRA.Game/Widgets/HotkeyEntryWidget.cs b/OpenRA.Game/Widgets/HotkeyEntryWidget.cs index 714b3b1da1..daa83ff1d8 100644 --- a/OpenRA.Game/Widgets/HotkeyEntryWidget.cs +++ b/OpenRA.Game/Widgets/HotkeyEntryWidget.cs @@ -59,6 +59,8 @@ namespace OpenRA.Widgets if (!RenderBounds.Contains(mi.Location) || !TakeKeyboardFocus()) return false; + blinkCycle = 15; + return true; } @@ -83,6 +85,18 @@ namespace OpenRA.Widgets return true; } + protected int blinkCycle = 15; + protected bool showEntry = true; + + public override void Tick() + { + if (HasKeyboardFocus && --blinkCycle <= 0) + { + blinkCycle = 15; + showEntry ^= true; + } + } + public override void Draw() { var apparentText = Key.DisplayString(); @@ -100,6 +114,10 @@ namespace OpenRA.Widgets WidgetUtils.DrawPanel(state, RenderBounds); + // Blink the current entry to indicate focus + if (HasKeyboardFocus && !showEntry) + return; + // Inset text by the margin and center vertically var textPos = pos + new int2(LeftMargin, (Bounds.Height - textSize.Y) / 2 - VisualHeight);