void OverrideHotkey() { var duplicateHotkeyButton = hotkeyList.Get <ContainerWidget>(duplicateHotkeyDefinition.Name).Get <ButtonWidget>("HOTKEY"); WidgetUtils.TruncateButtonToTooltip(duplicateHotkeyButton, Hotkey.Invalid.DisplayString()); modData.Hotkeys.Set(duplicateHotkeyDefinition.Name, Hotkey.Invalid); Game.Settings.Save(); hotkeyEntryWidget.YieldKeyboardFocus(); }
Action ResetHotkeysPanel(Widget panel) { return(() => { foreach (var hd in modData.Hotkeys.Definitions) { modData.Hotkeys.Set(hd.Name, hd.Default); WidgetUtils.TruncateButtonToTooltip(panel.Get(hd.Name).Get <ButtonWidget>("HOTKEY"), hd.Default.DisplayString()); } }); }
void BindHotkeyPref(HotkeyDefinition hd, Widget template, Widget parent) { var key = template.Clone() as Widget; key.Id = hd.Name; key.IsVisible = () => true; key.Get <LabelWidget>("FUNCTION").GetText = () => hd.Description + ":"; var remapButton = key.Get <ButtonWidget>("HOTKEY"); WidgetUtils.TruncateButtonToTooltip(remapButton, modData.Hotkeys[hd.Name].GetValue().DisplayString()); remapButton.IsHighlighted = () => selectedHotkeyDefinition == hd; var hotkeyValidColor = ChromeMetrics.Get <Color>("HotkeyColor"); var hotkeyInvalidColor = ChromeMetrics.Get <Color>("HotkeyColorInvalid"); remapButton.GetColor = () => { return(modData.Hotkeys.GetFirstDuplicate(hd.Name, modData.Hotkeys[hd.Name].GetValue(), hd) != null ? hotkeyInvalidColor : hotkeyValidColor); }; if (selectedHotkeyDefinition == hd) { selectedHotkeyButton = remapButton; hotkeyEntryWidget.Key = modData.Hotkeys[hd.Name].GetValue(); ValidateHotkey(); } remapButton.OnClick = () => { selectedHotkeyDefinition = hd; selectedHotkeyButton = remapButton; hotkeyEntryWidget.Key = modData.Hotkeys[hd.Name].GetValue(); ValidateHotkey(); hotkeyEntryWidget.TakeKeyboardFocus(); }; parent.AddChild(key); }
void SaveHotkey() { WidgetUtils.TruncateButtonToTooltip(selectedHotkeyButton, hotkeyEntryWidget.Key.DisplayString()); modData.Hotkeys.Set(selectedHotkeyDefinition.Name, hotkeyEntryWidget.Key); Game.Settings.Save(); }