Beispiel #1
0
 internal void SaveAxis()
 {
     if (Axis.Name == SaveName || !AxisManager.LocalAxes.ContainsKey(Axis.Name))
     {
         Axis.Dispose();
     }
     Axis = Axis.Clone();
     Axis.editor.Open();
     Axis.Name = SaveName;
     AxisManager.AddLocalAxis(Axis);
     Callback?.Invoke(Axis);
     Destroy(this);
 }
Beispiel #2
0
        internal static void Load()
        {
            try
            {
                // load mod configuration
                ACM.Instance.ModEnabled        = spaar.ModLoader.Configuration.GetBool("acm-enabled", true);
                ACM.Instance.ModUpdaterEnabled = spaar.ModLoader.Configuration.GetBool("mod-updater-enabled", true);
                ACM.Instance.DBUpdaterEnabled  = spaar.ModLoader.Configuration.GetBool("db-updater-enabled", true);

                // read input axes
                int count = spaar.ModLoader.Configuration.GetInt("number-of-axes", 0);
                for (int i = 0; i < count; i++)
                {
                    string    name = spaar.ModLoader.Configuration.GetString("axis-" + i + "-name", null);
                    InputAxis axis = null;
                    if (name != null)
                    {
                        var type = spaar.ModLoader.Configuration.GetString("axis-" + name + "-type", null);
                        if (type == AxisType.Chain.ToString())
                        {
                            axis = new ChainAxis(name);
                        }
                        if (type == AxisType.Controller.ToString())
                        {
                            axis = new ControllerAxis(name);
                        }
                        if (type == AxisType.Custom.ToString())
                        {
                            axis = new CustomAxis(name);
                        }
                        if (type == AxisType.Standard.ToString() || // backwards compatibility
                            type == AxisType.Inertial.ToString() || // backwards compatibility
                            type == AxisType.Key.ToString())
                        {
                            axis = new KeyAxis(name);
                        }
                        if (type == AxisType.Mouse.ToString())
                        {
                            axis = new MouseAxis(name);
                        }
                    }
                    if (axis != null)
                    {
                        axis?.Load();
                        AxisManager.AddLocalAxis(axis);
                    }
                }

                // refresh chain axis links
                foreach (var entry in AxisManager.LocalAxes)
                {
                    if (entry.Value.Type == AxisType.Chain)
                    {
                        (entry.Value as ChainAxis).RefreshLinks();
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log("[ACM]: Error loading saved axes:");
                Debug.LogException(e);
            }
        }