Example #1
0
		protected HotkeyEntryWidget(HotkeyEntryWidget widget)
			: base(widget)
		{
			Font = widget.Font;
			TextColor = widget.TextColor;
			TextColorDisabled = widget.TextColorDisabled;
			VisualHeight = widget.VisualHeight;
		}
Example #2
0
        void InitHotkeyRemapDialog(Widget panel)
        {
            var label = new CachedTransform <HotkeyDefinition, string>(hd => hd.Description + ":");

            panel.Get <LabelWidget>("HOTKEY_LABEL").GetText = () => label.Update(selectedHotkeyDefinition);

            var duplicateNotice = panel.Get <LabelWidget>("DUPLICATE_NOTICE");

            duplicateNotice.TextColor = ChromeMetrics.Get <Color>("NoticeErrorColor");
            duplicateNotice.IsVisible = () => !isHotkeyValid;
            var duplicateNoticeText = new CachedTransform <HotkeyDefinition, string>(hd => hd != null ? duplicateNotice.Text.F(hd.Description) : duplicateNotice.Text);

            duplicateNotice.GetText = () => duplicateNoticeText.Update(duplicateHotkeyDefinition);

            var defaultNotice = panel.Get <LabelWidget>("DEFAULT_NOTICE");

            defaultNotice.TextColor = ChromeMetrics.Get <Color>("NoticeInfoColor");
            defaultNotice.IsVisible = () => isHotkeyValid && isHotkeyDefault;

            var originalNotice = panel.Get <LabelWidget>("ORIGINAL_NOTICE");

            originalNotice.TextColor = ChromeMetrics.Get <Color>("NoticeInfoColor");
            originalNotice.IsVisible = () => isHotkeyValid && !isHotkeyDefault;
            var originalNoticeText = new CachedTransform <HotkeyDefinition, string>(hd => originalNotice.Text.F(hd.Default.DisplayString()));

            originalNotice.GetText = () => originalNoticeText.Update(selectedHotkeyDefinition);

            var resetButton = panel.Get <ButtonWidget>("RESET_HOTKEY_BUTTON");

            resetButton.IsDisabled = () => isHotkeyDefault;
            resetButton.OnClick    = ResetHotkey;

            var clearButton = panel.Get <ButtonWidget>("CLEAR_HOTKEY_BUTTON");

            clearButton.IsDisabled = () => !hotkeyEntryWidget.Key.IsValid();
            clearButton.OnClick    = ClearHotkey;

            var overrideButton = panel.Get <ButtonWidget>("OVERRIDE_HOTKEY_BUTTON");

            overrideButton.IsDisabled = () => isHotkeyValid;
            overrideButton.IsVisible  = () => !isHotkeyValid;
            overrideButton.OnClick    = OverrideHotkey;

            hotkeyEntryWidget             = panel.Get <HotkeyEntryWidget>("HOTKEY_ENTRY");
            hotkeyEntryWidget.IsValid     = () => isHotkeyValid;
            hotkeyEntryWidget.OnLoseFocus = ValidateHotkey;
            hotkeyEntryWidget.OnEscKey    = () =>
            {
                hotkeyEntryWidget.Key = modData.Hotkeys[selectedHotkeyDefinition.Name].GetValue();
            };

            validHotkeyEntryWidth   = hotkeyEntryWidget.Bounds.Width;
            invalidHotkeyEntryWidth = validHotkeyEntryWidth - (clearButton.Bounds.X - overrideButton.Bounds.X);
        }
        public HotkeyDialogLogic(Widget widget, Action onSave, HotkeyDefinition hotkeyDefinition, HotkeyManager hotkeyManager)
        {
            panel           = widget;
            this.onSave     = onSave;
            definition      = hotkeyDefinition;
            manager         = hotkeyManager;
            currentHotkey   = manager[definition.Name].GetValue();
            hotkeyEntry     = panel.Get <HotkeyEntryWidget>("HOTKEY_ENTRY");
            resetButton     = panel.Get <ButtonWidget>("RESET_BUTTON");
            clearButton     = panel.Get <ButtonWidget>("CLEAR_BUTTON");
            cancelButton    = panel.Get <ButtonWidget>("CANCEL_BUTTON");
            duplicateNotice = panel.Get <LabelWidget>("DUPLICATE_NOTICE");
            defaultNotice   = panel.Get <LabelWidget>("DEFAULT_NOTICE");
            originalNotice  = panel.Get <LabelWidget>("ORIGINAL_NOTICE");

            panel.Get <LabelWidget>("HOTKEY_LABEL").GetText = () => hotkeyDefinition.Description + ":";

            duplicateNotice.TextColor = ChromeMetrics.Get <Color>("NoticeErrorColor");
            duplicateNotice.GetText   = () =>
            {
                return((duplicateHotkey != null) ? duplicateNotice.Text.F(duplicateHotkey.Description) : duplicateNotice.Text);
            };
            defaultNotice.TextColor  = ChromeMetrics.Get <Color>("NoticeInfoColor");
            originalNotice.TextColor = ChromeMetrics.Get <Color>("NoticeInfoColor");
            originalNotice.Text      = originalNotice.Text.F(hotkeyDefinition.Default.DisplayString());

            resetButton.OnClick  = Reset;
            clearButton.OnClick  = Clear;
            cancelButton.OnClick = Cancel;

            hotkeyEntry.Key         = currentHotkey;
            hotkeyEntry.IsValid     = () => isValid;
            hotkeyEntry.OnTakeFocus = OnHotkeyEntryTakeFocus;
            hotkeyEntry.OnLoseFocus = OnHotkeyEntryLoseFocus;
            hotkeyEntry.OnEscape    = Cancel;
            hotkeyEntry.OnReturn    = Cancel;
            hotkeyEntry.TakeKeyboardFocus();

            Validate();
            isFirstValidation = false;
        }