public bool SetBinding(KeyBindingDef keyDef, KeyPrefs.BindingSlot slot, KeyCode keyCode)
        {
            KeyBindingData keyBindingData;

            if (this.keyPrefs.TryGetValue(keyDef, out keyBindingData))
            {
                if (slot != KeyPrefs.BindingSlot.A)
                {
                    if (slot != KeyPrefs.BindingSlot.B)
                    {
                        Log.Error("Tried to set a key binding for \"" + keyDef.LabelCap + "\" on a nonexistent slot: " + slot.ToString());
                        return(false);
                    }
                    keyBindingData.keyBindingB = keyCode;
                }
                else
                {
                    keyBindingData.keyBindingA = keyCode;
                }
                return(true);
            }
            Log.Error("Key not found in keyprefs: \"" + keyDef.LabelCap + "\"");
            return(false);
        }
Exemple #2
0
        public bool SetBinding(KeyBindingDef keyDef, KeyPrefs.BindingSlot slot, KeyCode keyCode)
        {
            if (keyPrefs.TryGetValue(keyDef, out KeyBindingData value))
            {
                switch (slot)
                {
                case KeyPrefs.BindingSlot.A:
                    value.keyBindingA = keyCode;
                    break;

                case KeyPrefs.BindingSlot.B:
                    value.keyBindingB = keyCode;
                    break;

                default:
                    Log.Error("Tried to set a key binding for \"" + keyDef.LabelCap + "\" on a nonexistent slot: " + slot.ToString());
                    return(false);
                }
                return(true);
            }
            Log.Error("Key not found in keyprefs: \"" + keyDef.LabelCap + "\"");
            return(false);
        }