Ejemplo n.º 1
0
        private void ErrorCheckOn(KeyBindingDef keyDef, KeyPrefs.BindingSlot slot)
        {
            KeyCode boundKeyCode = this.GetBoundKeyCode(keyDef, slot);

            if (boundKeyCode != KeyCode.None)
            {
                foreach (KeyBindingDef keyBindingDef in this.ConflictingBindings(keyDef, boundKeyCode))
                {
                    bool flag = boundKeyCode != keyDef.GetDefaultKeyCode(slot);
                    Log.Error(string.Concat(new object[]
                    {
                        "Key binding conflict: ",
                        keyBindingDef,
                        " and ",
                        keyDef,
                        " are both bound to ",
                        boundKeyCode,
                        ".",
                        (!flag) ? "" : " Fixed automatically."
                    }), false);
                    if (flag)
                    {
                        if (slot == KeyPrefs.BindingSlot.A)
                        {
                            this.keyPrefs[keyDef].keyBindingA = keyDef.defaultKeyCodeA;
                        }
                        else
                        {
                            this.keyPrefs[keyDef].keyBindingB = keyDef.defaultKeyCodeB;
                        }
                        KeyPrefs.Save();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void Init()
        {
            bool flag = !new FileInfo(GenFilePaths.KeyPrefsFilePath).Exists;
            Dictionary <string, KeyBindingData> dictionary = DirectXmlLoader.ItemFromXmlFile <Dictionary <string, KeyBindingData> >(GenFilePaths.KeyPrefsFilePath, true);

            KeyPrefs.data = new KeyPrefsData();
            KeyPrefs.unresolvedBindings = new Dictionary <string, KeyBindingData>();
            foreach (KeyValuePair <string, KeyBindingData> current in dictionary)
            {
                KeyBindingDef namedSilentFail = DefDatabase <KeyBindingDef> .GetNamedSilentFail(current.Key);

                if (namedSilentFail != null)
                {
                    KeyPrefs.data.keyPrefs[namedSilentFail] = current.Value;
                }
                else
                {
                    KeyPrefs.unresolvedBindings[current.Key] = current.Value;
                }
            }
            if (flag)
            {
                KeyPrefs.data.ResetToDefaults();
            }
            KeyPrefs.data.AddMissingDefaultBindings();
            KeyPrefs.data.ErrorCheck();
            if (flag)
            {
                KeyPrefs.Save();
            }
        }
Ejemplo n.º 3
0
        private void ErrorCheckOn(KeyBindingDef keyDef, KeyPrefs.BindingSlot slot)
        {
            KeyCode boundKeyCode = GetBoundKeyCode(keyDef, slot);

            if (boundKeyCode != 0)
            {
                foreach (KeyBindingDef item in ConflictingBindings(keyDef, boundKeyCode))
                {
                    bool flag = boundKeyCode != keyDef.GetDefaultKeyCode(slot);
                    Log.Warning("Key binding conflict: " + item + " and " + keyDef + " are both bound to " + boundKeyCode + "." + (flag ? " Fixed automatically." : ""));
                    if (flag)
                    {
                        if (slot == KeyPrefs.BindingSlot.A)
                        {
                            keyPrefs[keyDef].keyBindingA = keyDef.defaultKeyCodeA;
                        }
                        else
                        {
                            keyPrefs[keyDef].keyBindingB = keyDef.defaultKeyCodeB;
                        }
                        KeyPrefs.Save();
                    }
                }
            }
        }