예제 #1
0
    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);
    }
예제 #2
0
    /// <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.");
    }
예제 #3
0
 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;
         }
     }
 }
예제 #4
0
 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;
         }
     }
 }