public void UpdateKeyBinding(int _index, string _actionMethodName, KeyCode _newKey, bool _mod1, bool _mod2, bool _mod3) { keyBindings[_actionMethodName].UpdateKeyBinding(_index, _newKey, _mod1, _mod2, _mod3); string _playerPrefsSetting; if (_index == 0) { _playerPrefsSetting = (_actionMethodName + "PrimaryKey"); } else { _playerPrefsSetting = (_actionMethodName + "SecondaryKey"); } PlayerPrefs.SetString(_playerPrefsSetting, _newKey.ToString()); if (_index == 0) { _playerPrefsSetting = (_actionMethodName + "ModifierListCodePrimary"); } else { _playerPrefsSetting = (_actionMethodName + "ModifierListCodeSecondary"); } PlayerPrefs.SetString(_playerPrefsSetting, KeyBinding.ParseModiferListAsInt(_mod1, _mod2, _mod3).ToString()); }
private void CreateKeyBinding(string _actionMethodName, string _description, string _defaultPrimary, bool _defaultMod1Primary, bool _defaultMod2Primary, bool _defaultMod3Primary, string _defaultSecondary, bool _defaultMod1Secondary, bool _defaultMod2Secondary, bool _defaultMod3Secondary, bool _defaultIncludeInCheatsheet = false) { KeyCode[] keyCodes = new KeyCode[2]; keyCodes[0] = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString(_actionMethodName + "PrimaryKey", _defaultPrimary)); keyCodes[1] = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString(_actionMethodName + "SecondaryKey", _defaultSecondary)); bool[] modifierListPrimary = new bool[3]; bool[] modifierListSecondary = new bool[3]; int parsedModInt = 0; if (int.TryParse(PlayerPrefs.GetString(_actionMethodName + "ModifierListCodePrimary", KeyBinding.ParseModiferListAsInt(_defaultMod1Primary, _defaultMod2Primary, _defaultMod3Primary).ToString()), out parsedModInt)) { ; } else { Debug.Log("Error parsing primary modifier list code! - _actionMethodName: " + _actionMethodName); } modifierListPrimary = KeyBinding.ParseIntAsModiferList(parsedModInt); if (int.TryParse(PlayerPrefs.GetString(_actionMethodName + "ModifierListCodeSecondary", KeyBinding.ParseModiferListAsInt(_defaultMod1Secondary, _defaultMod2Secondary, _defaultMod3Secondary).ToString()), out parsedModInt)) { ; } else { Debug.Log("Error parsing secondary modifier list code! - _actionMethodName: " + _actionMethodName); } modifierListSecondary = KeyBinding.ParseIntAsModiferList(parsedModInt); bool _includeInCheatsheet = false; Boolean.TryParse(PlayerPrefs.GetString(_actionMethodName + "IncludeInCheatsheet", _defaultIncludeInCheatsheet.ToString()), out _includeInCheatsheet); KeyBinding workingKeyBinding = new KeyBinding(_actionMethodName, _description, keyCodes[0], modifierListPrimary[0], modifierListPrimary[1], modifierListPrimary[2], keyCodes[1], modifierListSecondary[0], modifierListSecondary[1], modifierListSecondary[2], _includeInCheatsheet); keyBindings.Add(_actionMethodName, workingKeyBinding); defaultKeyBindings.Add(_actionMethodName, new KeyBinding(_actionMethodName, _description, (KeyCode)System.Enum.Parse(typeof(KeyCode), _defaultPrimary), _defaultMod1Primary, _defaultMod2Primary, _defaultMod3Primary, (KeyCode)System.Enum.Parse(typeof(KeyCode), _defaultSecondary), _defaultMod1Secondary, _defaultMod2Secondary, _defaultMod3Secondary, _defaultIncludeInCheatsheet)); workingKeyBinding.AssignKeybindComposite(KeyBinder.keyBinder.CreateKeyBindingComposite(_actionMethodName, _description, keyCodes[0].ToString(), modifierListPrimary[0], modifierListPrimary[1], modifierListPrimary[2], keyCodes[1].ToString(), modifierListSecondary[0], modifierListSecondary[1], modifierListSecondary[2], _includeInCheatsheet)); }