/***************************************************************************************************************
          * new persistence model
          ***************************************************************************************************************/

         public static void SaveHallOfFame(List<LogbookEntry> logbook, ConfigNode node)
         {
            Log.Info("saving hall of fame (" + logbook.Count + " logbook entries)");

            List<LogbookEntry> logbookCopy = new List<LogbookEntry>(logbook);

            Stopwatch sw = new Stopwatch();
            sw.Start();

            try
            {
               foreach (LogbookEntry entry in logbookCopy)
               {
                  ConfigNode entryNode = new ConfigNode(PERSISTENCE_NODE_ENTRY_NAME);
                  if (Log.IsLogable(Log.LEVEL.DETAIL)) Log.Detail("saving logbook entry " + entry);
                  entryNode.AddValue(Constants.CONFIGNODE_KEY_TIME, entry.UniversalTime.ToString());
                  entryNode.AddValue(Constants.CONFIGNODE_KEY_NAME, entry.Name);
                  entryNode.AddValue(Constants.CONFIGNODE_KEY_CODE, entry.Code);
                  entryNode.AddValue(Constants.CONFIGNODE_KEY_DATA, entry.Data);
                  node.AddNode(entryNode);
               }
            }
            catch
            {
               Log.Error("exception while saving hall of fame detected; hall of fame may be corrupt");
            }
            finally
            {
               sw.Stop();
               Log.Info("hall of fame saved in " + sw.ElapsedMilliseconds + "ms");
            }
         }
        protected override void OnParameterSave(ConfigNode node)
        {
            base.OnParameterSave(node);

            node.AddValue("minSignalDelay", minSignalDelay);
            node.AddValue("maxSignalDelay", maxSignalDelay);
        }
        protected override void OnParameterSave(ConfigNode node)
        {
            base.OnParameterSave(node);

            node.AddValue("hasConnectivity", hasConnectivity);
            node.AddValue("vesselKey", vesselKey);
        }
        static private void AddPlanetScienceValuesToTreeNode( ConfigNode treeConfigNode )
        {
            foreach ( CelestialBody tempBody in FlightGlobals.Bodies )
			{
                ConfigNode bodyConfigNode = new ConfigNode( "BODY_SCIENCE_PARAMS" );

                bodyConfigNode.AddValue( "name", tempBody.name );

	            bodyConfigNode.AddValue( "LandedDataValue", tempBody.scienceValues.LandedDataValue );
                bodyConfigNode.AddValue( "SplashedDataValue", tempBody.scienceValues.SplashedDataValue );

                bodyConfigNode.AddValue( "FlyingLowDataValue", tempBody.scienceValues.FlyingLowDataValue );
                bodyConfigNode.AddValue( "FlyingHighDataValue", tempBody.scienceValues.FlyingHighDataValue );

                bodyConfigNode.AddValue( "InSpaceLowDataValue", tempBody.scienceValues.InSpaceLowDataValue );
                bodyConfigNode.AddValue( "InSpaceHighDataValue", tempBody.scienceValues.InSpaceHighDataValue );

                bodyConfigNode.AddValue( "flyingAltitudeThreshold", tempBody.scienceValues.flyingAltitudeThreshold );
                bodyConfigNode.AddValue( "spaceAltitudeThreshold" , tempBody.scienceValues.spaceAltitudeThreshold );

                bodyConfigNode.AddValue( "RecoveryValue", tempBody.scienceValues.RecoveryValue );

                treeConfigNode.AddNode( bodyConfigNode );
            }
        }
 public override void OnSave(ConfigNode configNode)
 {
     base.OnSave(configNode);
     configNode.AddValue("latitude", latitude);
     configNode.AddValue("longitude", longitude);
     configNode.AddValue("altitude", altitude);
 }
        protected override void OnSave(ConfigNode node)
        {
            int bodyID = targetBody.flightGlobalsIndex;
            node.AddValue(KEESExperimentContract.TARGET_BODY, bodyID);

            node.AddValue(KEESExperimentContract.EXPERIMENT_STRING, experiment.name);
        }
        public void OnSave(ConfigNode configNode)
        {
            configNode.AddValue("name", name);
            configNode.AddValue("aspectRatio", aspectRatio);

            foreach (CutSceneCamera cameraDefinition in cameras)
            {
                ConfigNode child = new ConfigNode(cameraDefinition.GetType().Name);
                configNode.AddNode(child);

                cameraDefinition.OnSave(child);
            }

            foreach (Actor actor in actors)
            {
                ConfigNode child = new ConfigNode(actor.GetType().Name);
                configNode.AddNode(child);

                actor.OnSave(child);
            }

            foreach (CutSceneAction action in actions)
            {
                ConfigNode child = new ConfigNode(action.GetType().Name);
                configNode.AddNode(child);

                action.OnSave(child);
            }
        }
Example #8
0
        public override void OnSave(ConfigNode node)
        {
            base.OnSave(node);
            node.AddValue("selectedObject", selectedObject.ToString());

            node.AddValue("showGui", showGui.ToString());
        }
        protected override void OnSave(ConfigNode configNode)
        {
            base.OnSave(configNode);

            configNode.AddValue("url", url);
            configNode.AddValue("craftType", craftType);
        }
Example #10
0
		public void Save()
		{
			ConfigNode settings = new ConfigNode("SmartStage");
			settings.AddValue("autoUpdateStaging", autoUpdateStaging);
			settings.AddValue("showInFlight", plugin.showInFlight);
			settings.Save(KSP.IO.IOUtils.GetFilePathFor(typeof(MainWindow), "settings.cfg"));
		}
Example #11
0
        public static void test()
        {
            ConfigNode testNode = new ConfigNode("TESTNODE");
            testNode.AddValue("fooName", "fooValue");

            ConfigNode innerTestNode = new ConfigNode("INNERTESTNODE");
            ConfigNode innerInnerTestNode = new ConfigNode("SUPERINNERTESTNODE");
            innerInnerTestNode.AddValue("superFooName", "superFooValue");
            innerTestNode.AddValue("innerFooName", "innerFooValue");
            innerTestNode.AddNode(innerInnerTestNode);
            testNode.AddNode(innerTestNode);

            innerTestNode = new ConfigNode("INNERTESTNODE2");
            innerTestNode.AddValue("innerFooName2", "innerFooValue2");
            innerTestNode.AddValue("innerFooName2-2", "innerFooValue2-2");
            testNode.AddNode(innerTestNode);


            String data = testNode.ToString();
            MonoBehaviour.print("raw node string: " + data);
            ConfigNode reparsedNode = SSTUNodeUtils.parseConfigNode(data);
            MonoBehaviour.print("new node: " + reparsedNode);

            ConfigNode stockReparsedNode = ConfigNode.Parse(data);
            MonoBehaviour.print("stockNewNode: " + stockReparsedNode.nodes[0]);
        }
Example #12
0
        public bool Save(ConfigNode node)
        {
            node.AddValue("%enable", Enable);
            node.AddValue("%unit", Unit);

            return true;
        }
        public override bool Load(ConfigNode configNode)
        {
            // Ignore the targetBody in the base class
            configNode.AddValue("ignoreTargetBody", true);

            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "failWhenUnmet", x => failWhenUnmet = x, this, false);
            valid &= ConfigNodeUtil.ParseValue<Biome>(configNode, "biome", x => biome = x, this, (Biome)null);
            valid &= ConfigNodeUtil.ParseValue<List<Vessel.Situations>>(configNode, "situation", x => situation = x, this, new List<Vessel.Situations>());
            valid &= ConfigNodeUtil.ParseValue<float>(configNode, "minAltitude", x => minAltitude = x, this, float.MinValue);
            valid &= ConfigNodeUtil.ParseValue<float>(configNode, "maxAltitude", x => maxAltitude = x, this, float.MaxValue);
            valid &= ConfigNodeUtil.ParseValue<float>(configNode, "minTerrainAltitude", x => minTerrainAltitude = x, this, 0.0f, x => Validation.GE(x, 0.0f));
            valid &= ConfigNodeUtil.ParseValue<float>(configNode, "maxTerrainAltitude", x => maxTerrainAltitude = x, this, float.MaxValue, x => Validation.GE(x, 0.0f));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minSpeed", x => minSpeed = x, this, 0.0, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxSpeed", x => maxSpeed = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minRateOfClimb", x => minRateOfClimb = x, this, double.MinValue);
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxRateOfClimb", x => maxRateOfClimb = x, this, double.MaxValue);
            valid &= ConfigNodeUtil.ParseValue<float>(configNode, "minAcceleration", x => minAcceleration = x, this, 0.0f, x => Validation.GE(x, 0.0f));
            valid &= ConfigNodeUtil.ParseValue<float>(configNode, "maxAcceleration", x => maxAcceleration = x, this, float.MaxValue, x => Validation.GE(x, 0.0f));

            // Overload targetBody
            if (!configNode.HasValue("targetBody"))
            {
                configNode.AddValue("targetBody", "[ @/targetBody ]");
            }
            valid &= ConfigNodeUtil.ParseValue<List<CelestialBody>>(configNode, "targetBody", x => targetBodies = x, this);

            // Validation minimum set
            valid &= ConfigNodeUtil.AtLeastOne(configNode, new string[] { "targetBody", "biome", "situation", "minAltitude", "maxAltitude",
                "minTerrainAltitude", "maxTerrainAltitude", "minSpeed", "maxSpeed", "minRateOfClimb", "maxRateOfClimb", "minAcceleration", "maxAcceleration" }, this);

            return valid;
        }
 protected sealed override void OnSave(ConfigNode node)
 {
     try
     {
         if (Root != null)
         {
             node.AddValue("ContractIdentifier", Root.ToString());
         }
         node.AddValue("title", title ?? "");
         node.AddValue("notes", notes ?? "");
         node.AddValue("completedMessage", completedMessage ?? "");
         if (completeInSequence)
         {
             node.AddValue("completeInSequence", completeInSequence);
         }
         if (hidden)
         {
             node.AddValue("hidden", hidden);
         }
         if (hideChildren)
         {
             node.AddValue("hideChildren", hideChildren);
         }
         if (fakeFailures)
         {
             node.AddValue("fakeFailures", fakeFailures);
         }
         OnParameterSave(node);
     }
     catch (Exception e)
     {
         LoggingUtil.LogException(e);
         ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.PARAMETER_SAVE, e, Root.ToString(), ID);
     }
 }
 protected override void OnParameterSave(ConfigNode node)
 {
     node.AddValue("coverage", coverage);
     node.AddValue("scanName", scanName);
     node.AddValue("scanType", scanType);
     node.AddValue("targetBody", targetBody.name);
 }
Example #16
0
        public static ConfigNode ToConfigNode(this HarddiskFile file, string nodeName)
        {
            var node = new ConfigNode(nodeName);
            node.AddValue(FilenameValueString, file.Name);

            FileContent content = file.ReadAll();

            if (content.Category == FileCategory.KSM)
            {
                node.AddValue("binary", PersistenceUtilities.EncodeBase64(content.Bytes));
            }
            else if (content.Category == FileCategory.BINARY)
            {
                node.AddValue("binary", PersistenceUtilities.EncodeBase64(content.Bytes));
            }
            else
            {
                if (SafeHouse.Config.UseCompressedPersistence)
                {
                    node.AddValue("binary", EncodeBase64(content.String));
                }
                else
                {
                    node.AddValue("ascii", PersistenceUtilities.EncodeLine(content.String));
                }
            }
            return node;
        }
 protected override void OnParameterSave(ConfigNode node)
 {
     foreach (string param in hiddenParameters)
     {
         node.AddValue("hiddenParameter", param);
     }
     node.AddValue("failWhenCompleteOutOfOrder", failWhenCompleteOutOfOrder);
 }
 public override void OnSave(ConfigNode configNode)
 {
     configNode.AddValue("minFunds", minFunds);
     if (maxFunds != double.MaxValue)
     {
         configNode.AddValue("maxFunds", maxFunds);
     }
 }
 protected override void OnSave(ConfigNode configNode)
 {
     foreach (AvailablePart part in parts)
     {
         configNode.AddValue("part", part.name);
     }
     configNode.AddValue("unlockTech", unlockTech);
 }
 // return maxfuelmass
 public void addResource(string name, float amount)
 {
     ConfigNode newPartResource = new ConfigNode("RESOURCE");
     newPartResource.AddValue("name", name);
     newPartResource.AddValue("amount", amount / 2);
     newPartResource.AddValue("maxAmount", amount);
     PartResource res = part.AddResource(newPartResource);
 }
        public override void OnSave(ConfigNode node)
        {
            base.OnSave(node);

            node.AddValue("isDeployed", isDeployed.ToString());
            node.AddValue("isInflatable", isDeployed.ToString());
            node.AddValue("inflatedCrewCapacity", inflatedCrewCapacity.ToString());
        }
 protected override void OnParameterSave(ConfigNode node)
 {
     base.OnParameterSave(node);
     node.AddValue("minMass", minMass);
     if (maxMass != double.MaxValue)
     {
         node.AddValue("maxMass", maxMass);
     }
 }
 protected override void OnSave(ConfigNode configNode)
 {
     base.OnSave(configNode);
     configNode.AddValue("owned", owned);
     foreach (string v in vessels)
     {
         configNode.AddValue("vessel", v);
     }
 }
Example #24
0
 public static void updateEngineThrust(ModuleEngines engine, float minThrust, float maxThrust)
 {
     engine.minThrust = minThrust;
     engine.maxThrust = maxThrust;
     ConfigNode updateNode = new ConfigNode("MODULE");
     updateNode.AddValue("maxThrust", engine.maxThrust);
     updateNode.AddValue("minThrust", engine.minThrust);
     engine.Load(updateNode);
 }
Example #25
0
        public ConfigNode AsConfigNode()
        {
            ConfigNode retNode = new ConfigNode("KerbalInfo");
            retNode.AddValue("Name", Name);
            retNode.AddValue("LastUpdated", LastUpdated);
            retNode.AddValue("LastSated", LastSated);

            return retNode;
        }
Example #26
0
        public void saveConfigNode(ConfigNode config) {
            ConfigNode retval = new ConfigNode("MODULE");
            retval.AddValue("name", "DamageTestModule");
            retval.AddValue("displayDamage", displayDamage);
            retval.AddValue("lastPollTime", lastPollTime);
            retval.AddValue("vesselId", );
            retval.AddValue("partId", );

            config.AddNode(node);
        }
Example #27
0
        public ConfigNode AsNode()
        {
            ConfigNode retNode = new ConfigNode("Beacon");
            retNode.AddValue("name", name);
            retNode.AddValue("latitude", latitude);
            retNode.AddValue("longitude", longitude);
            retNode.AddValue("range", range);

            return retNode;
        }
 protected override void OnParameterSave(ConfigNode node)
 {
     base.OnParameterSave(node);
     node.AddValue("title", title);
     foreach (string vessel in vessels)
     {
         node.AddValue("vessel", vessel);
     }
     node.AddValue("defineDockedVessel", defineDockedVessel);
 }
 protected override void OnParameterSave(ConfigNode node)
 {
     node.AddValue("duration", duration);
     node.AddValue("endTime", endTime);
     node.AddValue("timerType", timerType);
     if (!string.IsNullOrEmpty(parameter))
     {
         node.AddValue("parameter", parameter);
     }
 }
 public static void SaveSettings(ConfigNode node)
 {
     Quaternion pos;
     pos.x = winpos.x;
     pos.y = winpos.y;
     pos.z = winpos.width;
     pos.w = winpos.height;
     node.AddValue ("rect", KSPUtil.WriteQuaternion (pos));
     node.AddValue ("visible", showGUI);
 }