// Save keybindings public void SaveKeyBinds() { string path = GetKeyBindsSavePath(); KeyBindData_v1 keyBindsData = new KeyBindData_v1(); keyBindsData.actionKeyBinds = new Dictionary <KeyCode, string>(); foreach (var item in actionKeyDict) { keyBindsData.actionKeyBinds.Add(item.Key, item.Value.ToString()); } // If unknown actions were detected in this run, make sure we append them back to the settings file, so we won't break // the newer builds potentially using them. foreach (var item in unknownActions) { keyBindsData.actionKeyBinds.Add(item.Key, item.Value); } string json = SaveLoadManager.Serialize(keyBindsData.GetType(), keyBindsData); File.WriteAllText(path, json); RaiseSavedKeyBindsEvent(); }
void LoadKeyBinds() { string path = GetKeyBindsSavePath(); string json = File.ReadAllText(path); KeyBindData_v1 keyBindsData = SaveLoadManager.Deserialize(typeof(KeyBindData_v1), json) as KeyBindData_v1; actionKeyDict = keyBindsData.actionKeyBinds; RaiseLoadedKeyBindsEvent(); }
// Save keybindings public void SaveKeyBinds() { string path = GetKeyBindsSavePath(); KeyBindData_v1 keyBindsData = new KeyBindData_v1(); keyBindsData.actionKeyBinds = actionKeyDict; string json = SaveLoadManager.Serialize(keyBindsData.GetType(), keyBindsData); File.WriteAllText(path, json); RaiseSavedKeyBindsEvent(); }
void LoadKeyBinds() { string path = GetKeyBindsSavePath(); string json = File.ReadAllText(path); KeyBindData_v1 keyBindsData = SaveLoadManager.Deserialize(typeof(KeyBindData_v1), json) as KeyBindData_v1; foreach (var item in keyBindsData.actionKeyBinds) { if (!actionKeyDict.ContainsKey(item.Key)) { actionKeyDict.Add(item.Key, item.Value); } } RaiseLoadedKeyBindsEvent(); }
void LoadKeyBinds() { string path = GetKeyBindsSavePath(); string json = File.ReadAllText(path); KeyBindData_v1 keyBindsData = SaveLoadManager.Deserialize(typeof(KeyBindData_v1), json) as KeyBindData_v1; foreach (var item in keyBindsData.actionKeyBinds) { KeyCode key = ParseKeyCodeString(item.Key); var actionVal = ActionNameToEnum(item.Value); if (!actionKeyDict.ContainsKey(key) && actionVal != Actions.Unknown) { actionKeyDict.Add(key, actionVal); } else { // This action is unknown in this game, make sure we still keep it so once we save the settings, we // won't discard them. unknownActions.Add(key, item.Value); } } if (keyBindsData.axisActionKeyBinds != null) { foreach (var item in keyBindsData.axisActionKeyBinds) { if (!axisActionKeyDict.ContainsKey((String)item.Key)) { axisActionKeyDict.Add((String)item.Key, item.Value); } } UpdateAxisBindingCache(); } else { keyBindsData.axisActionKeyBinds = new Dictionary <String, AxisActions>(); } RaiseLoadedKeyBindsEvent(); }
void LoadKeyBinds() { string path = GetKeyBindsSavePath(); string json = File.ReadAllText(path); KeyBindData_v1 keyBindsData = SaveLoadManager.Deserialize(typeof(KeyBindData_v1), json) as KeyBindData_v1; foreach (var item in keyBindsData.actionKeyBinds) { var actionVal = ActionNameToEnum(item.Value); if (!actionKeyDict.ContainsKey(item.Key) && actionVal != Actions.Unknown) { actionKeyDict.Add(item.Key, actionVal); } else { // This action is unknown in this game, make sure we still keep it so once we save the settings, we // won't discard them. unknownActions.Add(item.Key, item.Value); } } RaiseLoadedKeyBindsEvent(); }
void SaveKeyBinds() { string path = GetKeyBindsSavePath(); KeyBindData_v1 keyBindsData = new KeyBindData_v1(); keyBindsData.actionKeyBinds = actionKeyDict; string json = SaveLoadManager.Serialize(keyBindsData.GetType(), keyBindsData); File.WriteAllText(path, json); RaiseSavedKeyBindsEvent(); }