public static BBInputProfile FromTydTable(TydTable table) { var profile = new BBInputProfile(); profile.Axes = new List <BBInputAxis>(); profile.Name = table.Name; profile.Enabled = false; InGameDebug.Log("Loading new BBInputProfile..."); foreach (var node in table.Nodes) { if (node.Name.ToLowerInvariant() == "enabled") { profile.Enabled = bool.Parse((node as TydString).Value); } else if (node.Name.ToLowerInvariant() == "alwaysenabled") { profile.AlwaysEnabled = bool.Parse((node as TydString).Value); } else if (node.Name.ToLowerInvariant() == "name") { profile.Name = (node as TydString).Value; } else if (node.Name.ToLowerInvariant() == "axes") { foreach (var axisNodes in (node as TydCollection).Nodes) { profile.Axes.Add(BBInputAxis.FromTydTable(axisNodes as TydTable)); } } } profile.Axes.Sort((x, y) => y.Priority - x.Priority); InGameDebug.Log("Loaded BBInputProfile: " + profile.Name); return(profile); }
/// <summary> /// Loads all input profiles from the defs. /// </summary> public static void LoadProfiles() { InGameDebug.Log("-----BBInput: Loading input profiles..."); var profilesNode = StreamingAssetsDatabase.GetDef("Input.Profiles") as TydTable; foreach (var profileNode in profilesNode.Nodes) { Profiles.Add(BBInputProfile.FromTydTable(profileNode as TydTable)); } InGameDebug.Log("-----Input profiles loaded."); }
public static void ActivatePreviousProfile() { if (_previousProfile == null) { return; } _previousProfile.Enabled = true; foreach (var profile in Profiles) { if (profile.AlwaysEnabled) { continue; } if (profile.Enabled && profile != _previousProfile) { _previousProfile = profile; } } }
public static void SetActiveProfile(string profileName) { foreach (var profile in Profiles) { if (profile.AlwaysEnabled) { continue; } if (profile.Enabled && profile.Name != profileName) { _previousProfile = profile; } if (profileName == profile.Name) { profile.Enabled = true; } else { profile.Enabled = false; } } }