void FocusKeyDown(Key key) { if (focusWidget == widgets[keyI]) { curHotkey.BaseKey = key; SetButton(widgets[keyI], "Key: " + curHotkey.BaseKey); supressNextPress = true; } else if (focusWidget == widgets[modifyI]) { if (key == Key.ControlLeft || key == Key.ControlRight) { curHotkey.Flags |= 1; } else if (key == Key.ShiftLeft || key == Key.ShiftRight) { curHotkey.Flags |= 2; } else if (key == Key.AltLeft || key == Key.AltRight) { curHotkey.Flags |= 4; } else { curHotkey.Flags = 0; } string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); SetButton(widgets[modifyI], "Modifiers:" + flags); supressNextPress = true; } focusWidget = null; }
protected override void ContextRecreated() { string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); if (curHotkey.Text == null) { curHotkey.Text = ""; } string staysOpen = curHotkey.StaysOpen ? "ON" : "OFF"; bool existed = origHotkey.BaseKey != Key.Unknown; widgets = new Widget[] { Make(0, -150, "Key: " + curHotkey.BaseKey, 300, titleFont, BaseKeyClick), Make(0, -100, "Modifiers:" + flags, 300, titleFont, ModifiersClick), MenuInputWidget.Create(game, 500, 30, curHotkey.Text, regularFont, new StringValidator()) .SetLocation(Anchor.Centre, Anchor.Centre, 0, -35), Make(-100, 10, "Input stays open: " + staysOpen, 300, titleFont, LeaveOpenClick), Make(0, 80, existed ? "Save changes" : "Add hotkey", 300, titleFont, SaveChangesClick), Make(0, 130, existed ? "Remove hotkey" : "Cancel", 300, titleFont, RemoveHotkeyClick), MakeBack(false, titleFont, SwitchPause), }; ((InputWidget)widgets[actionI]).ShowCaret = true; widgets[actionI].OnClick = InputClick; }
void FocusKeyDown(Key key) { if (selectedI == keyI) { curHotkey.BaseKey = key; SetButton(keyI, "Key: " + curHotkey.BaseKey); supressNextPress = true; } else if (selectedI == modifyI) { if (key == Key.ControlLeft || key == Key.ControlRight) { curHotkey.Flags |= 1; } else if (key == Key.ShiftLeft || key == Key.ShiftRight) { curHotkey.Flags |= 2; } else if (key == Key.AltLeft || key == Key.AltRight) { curHotkey.Flags |= 4; } else { curHotkey.Flags = 0; } string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); SetButton(modifyI, "Modifiers:" + flags); supressNextPress = true; } selectedI = -1; }
static string MakeFlagsString(byte flags) { if (flags == 0) { return(" None"); } return(HotkeyListScreen.MakeFlagsString(flags)); }
void LostFocus() { if (focusWidget == null) { return; } if (focusWidget == widgets[keyI]) { SetButton(widgets[keyI], "Key: " + curHotkey.BaseKey); } else if (focusWidget == widgets[modifyI]) { string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); SetButton(widgets[modifyI], "Modifiers:" + flags); } focusWidget = null; supressNextPress = false; }
void LostFocus() { if (selectedI == -1) { return; } if (selectedI == keyI) { SetButton(keyI, "Key: " + curHotkey.BaseKey); } else if (selectedI == modifyI) { string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); SetButton(modifyI, "Modifiers:" + flags); } selectedI = -1; supressNextPress = false; }
public override void Init() { game.Keyboard.KeyRepeat = true; base.Init(); regularFont = new Font(game.FontName, 16, FontStyle.Regular); string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags); if (curHotkey.Text == null) { curHotkey.Text = ""; } string staysOpen = curHotkey.StaysOpen ? "yes" : "no"; bool existed = origHotkey.BaseKey != Key.Unknown; widgets = new Widget[] { Make(0, -150, "Key: " + curHotkey.BaseKey, 301, 40, titleFont, BaseKeyClick), Make(0, -100, "Modifiers:" + flags, 301, 40, titleFont, ModifiersClick), MenuInputWidget.Create( game, 0, -35, 500, 30, curHotkey.Text, Anchor.Centre, Anchor.Centre, regularFont, titleFont, new StringValidator(Utils.StringLength)), Make(-100, 10, "Input stays open: " + staysOpen, 301, 40, titleFont, LeaveOpenClick), Make(0, 80, existed ? "Save changes" : "Add hotkey", 301, 40, titleFont, SaveChangesClick), Make(0, 130, existed ? "Remove hotkey" : "Cancel", 301, 40, titleFont, RemoveHotkeyClick), MakeBack(false, titleFont, (g, w) => g.Gui.SetNewScreen(new PauseScreen(g))), }; }