Example #1
0
        /// <summary>
        /// For an inputkey, try find where possibly it is already used.
        /// This covers game Settings class, and self (OptionsKeymapping class).
        /// </summary>
        /// <param name="k">Key to search for the conflicts</param>
        /// <param name="sampleCategory">Check the same category keys if possible</param>
        /// <returns>Empty string for no conflict, or the conflicting key name</returns>
        private string FindConflict(KeybindSetting.Editable editedKeybind,
                                    InputKey sample,
                                    string sampleCategory)
        {
            if (Keybind.IsEmpty(sample))
            {
                // empty key never conflicts
                return(string.Empty);
            }

            var inGameSettings = FindConflictInGameSettings(sample);

            if (!string.IsNullOrEmpty(inGameSettings))
            {
                return(inGameSettings);
            }

            // Saves and null 'self.editingBinding_' to allow rebinding the key to itself.
            var saveEditingBinding = editedKeybind.TargetKey.value;

            editedKeybind.TargetKey.value = SavedInputKey.Empty;

            // Check in TMPE settings
            var tmpeSettingsType = typeof(KeybindSettingsBase);
            var tmpeFields       = tmpeSettingsType.GetFields(BindingFlags.Static | BindingFlags.Public);

            var inTmpe = FindConflictInTmpe(sample, sampleCategory, tmpeFields);

            editedKeybind.TargetKey.value = saveEditingBinding;
            return(inTmpe);
        }
Example #2
0
        /// <summary>
        /// Set the button text to welcoming message. Push the button as modal blocking
        /// everything else on screen and capturing the input.
        /// </summary>
        /// <param name="editable">The keysetting and inputkey inside it, to edit</param>
        /// <param name="keybindButton">The button to become modal</param>
        private void StartKeybindEditMode(KeybindSetting.Editable editable, UIButton keybindButton)
        {
            currentlyEditedBinding_ = editable;

            keybindButton.buttonsMask =
                UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle |
                UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 |
                UIMouseButton.Special3;
            keybindButton.text = "Press key (or Esc)";
            keybindButton.Focus();
            UIView.PushModal(keybindButton, OnKeybindModalPopped);
        }