Esempio n. 1
0
        internal static void LoadCurrentVesselConfig(Vessel vessel)
        {
            vessel = vessel ?? FlightGlobals.ActiveVessel;             // better safe than sorry

            Save.ConfigNode config = Save.ConfigNode.For("GPWS_SETTINGS");
            if (config.IsLoadable)
            {
                config.Load();
            }

            string     vesselSaneName = sanitize(vessel.vesselName);
            ConfigNode vesselNode     = config.Node.GetNode(vesselSaneName) ?? new ConfigNode(vesselSaneName);

            {
                currentPlaneConfigNode      = vesselNode.GetNode(planeDefaultConfigNode.name) ?? KSPe.ConfigNodeWithSteroids.from(planeDefaultConfigNode);
                currentPlaneConfigNode.name = planeDefaultConfigNode.name;
                CurrentPlaneConfig.Load(currentPlaneConfigNode);
            }

            {
                currentLanderConfigNode      = vesselNode.GetNode(landerDefaultConfigNode.name) ?? KSPe.ConfigNodeWithSteroids.from(landerDefaultConfigNode);
                currentLanderConfigNode.name = landerDefaultConfigNode.name;
                CurrentLanderConfig.Load(currentLanderConfigNode);
            }
        }
Esempio n. 2
0
        internal static void SaveCurrentVesselConfig(Vessel vessel)
        {
            if (null == vessel)
            {
                return;                             // Better safe than sorry
            }
            string vesselSaneName = sanitize(vessel.vesselName);

            Save.ConfigNode config = Save.ConfigNode.For("GPWS_SETTINGS");
            if (config.IsLoadable)
            {
                config.Load();
            }

            ConfigNode gpwsNode   = config.Node;
            ConfigNode vesselNode = gpwsNode.GetNode(vesselSaneName);

            if (null == vesselNode)
            {
                vesselNode      = new ConfigNode(vesselSaneName);
                vesselNode.name = vesselSaneName;
                gpwsNode.AddNode(vesselNode);
            }
            {
                ConfigNode planeNode = new ConfigNode(planeDefaultConfigNode.name);
                CurrentPlaneConfig.Save(planeNode);
                vesselNode.RemoveNode(planeNode.name);
                vesselNode.AddNode(planeNode);
            }
            {
                ConfigNode landerNode = new ConfigNode(landerDefaultConfigNode.name);;
                CurrentLanderConfig.Save(landerNode);
                vesselNode.RemoveNode(landerNode.name);
                vesselNode.AddNode(landerNode);
            }
            config.Save();
        }