public ConfigNode AsConfigNode()
        {
            //save the source node, the variables, the teacher name, the student names, Started/Completed and the elapsed time
            ConfigNode node = new ConfigNode("ACTIVE_COURSE");
            node.AddValue("id", id);
            node.AddValue("name", name);
            node.AddValue("elapsedTime", elapsedTime);
            node.AddValue("Started", Started);
            node.AddValue("Completed", Completed);
            node.AddValue("teacher", Teacher != null ? Teacher.name : "NA");
            ConfigNode studentNode = new ConfigNode("STUDENTS");
            foreach (ProtoCrewMember student in Students)
                studentNode.AddValue("student", student.name);
            node.AddNode("STUDENTS", studentNode);

            ConfigNode variableNode = new ConfigNode("VARIABLES");
            foreach (KeyValuePair<string, string> kvp in Variables)
            {
                variableNode.AddValue(kvp.Key, kvp.Value);
            }
            node.AddNode("VARIABLES", variableNode);
            node.AddNode("SOURCE_NODE", sourceNode);

            return node;
        }
        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);
            }
        }
 public override void OnSave(ConfigNode node)
 {
     try
     {
         if (!vessel.isEVA)
         {
             foreach (ProtoCrewMember crewmember in part.protoModuleCrew)
             {
                 if (VanAllen.crew_rad_exposure.ContainsKey(crewmember.name))
                 {
                     double current_rad = VanAllen.crew_rad_exposure[crewmember.name];
                     ConfigNode rad_node = new ConfigNode("KERBAL_RADIATION_" + crewmember.name);
                     rad_node.AddValue("lifetimeDose", current_rad);
                     node.AddNode(rad_node);
                 }
             }
         }
         else
         {
             if (VanAllen.crew_rad_exposure.ContainsKey(vessel.vesselName))
             {
                 double current_rad = VanAllen.crew_rad_exposure[vessel.vesselName];
                 ConfigNode rad_node = new ConfigNode("KERBAL_RADIATION_" + vessel.vesselName);
                 rad_node.AddValue("lifetimeDose", current_rad);
                 node.AddNode(rad_node);
             }
         }
     }
     catch (Exception ex) { }
 }
Example #4
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 #5
0
        public void Save(ConfigNode resourceNode)
        {
            resourceNode.AddNode(generatorNode);

            foreach (var body in bodies)
            {
                var bodyNode = new ConfigNode("Body");
                bodyNode.AddValue("Name", body.Key.name);
                body.Value.Save(bodyNode);
                resourceNode.AddNode(bodyNode);
            }
        }
Example #6
0
        /// <summary>
        /// Called when the game is saved, commits inventory values into save game.
        /// </summary>
        /// <param name="root">ConfigNode passed from GameEvent</param>
        public void Commit(ConfigNode root)
        {
            // Parts
            ConfigNode N = new ConfigNode(this.GetType().FullName);
            ConfigNode p = N.AddNode("PARTS");
            foreach (string P in Parts.Inventory.Keys.Where(x => Parts.Inventory[x] != 0)) p.AddValue(P, Parts.Inventory[P]);
            // Resources, load even if recover_resources = false
            ConfigNode r = N.AddNode("RESOURCES");
            foreach (string P in Resources.Inventory.Keys.Where(x => Resources.Get(x) != 0)) r.AddValue(P, Resources.Inventory[P]);

            root.AddNode(N);
        }
		public void Save (ConfigNode node)
		{
			var req = node.AddNode ("Required");
			foreach (var res in required) {
				var r = req.AddNode ("BuildResrouce");
				res.Save (r);
			}
			var opt = node.AddNode ("Optional");
			foreach (var res in optional) {
				var r = opt.AddNode ("BuildResrouce");
				res.Save (r);
			}
		}
         /***************************************************************************************************************
          * 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");
            }
         }
Example #9
0
 /// <summary>
 /// Save settings to the underlying storage
 /// </summary>
 public void Save()
 {
     ConfigNode node = AsConfigNode;
     var clsNode = new ConfigNode (GetType ().Name);
     clsNode.AddNode (node);
     clsNode.Save (filePath);
 }
        static public void DumpCurrentTreeToFile( string sFileName, string sTreeName )
        {
            // only attempt to dump if the current game mode has a tech tree, and the tech tree is present

            if ( HighLogic.CurrentGame != null && ( HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX )
                && AssetBase.RnDTechTree != null && AssetBase.RnDTechTree.GetTreeNodes() != null )
            {
			    ConfigNode fileConfigNode = new ConfigNode();

			    ConfigNode treeConfigNode = new ConfigNode( "TECH_TREE" );

                treeConfigNode.AddValue( "name", sTreeName );

                AddAllTechNodesToTreeNode( treeConfigNode );

                AddPlanetScienceValuesToTreeNode( treeConfigNode );

                fileConfigNode.AddNode( treeConfigNode );

			    fileConfigNode.Save( KSPUtil.ApplicationRootPath.Replace( "\\", "/" ) + "GameData/ATC/" + sFileName, 
                    "Config file representing the stock tech tree\r\n" +
                    "// WARNING: This file should not be edited directly, but rather should either be altered using ModuleManager commands within your own .cfg files OR\r\n" +
                    "// a new tree .cfg should be created which settings.cfg can then be set to point to." );

                m_bHasTreeAlreadyBeenDumped = true;
            }
        }
Example #11
0
        private bool CheckForDataNodes(ConfigNode node)
        {
            foreach (string type in KRESUtils.types.Values)
            {
                if (!node.HasNode(type)) { goto Incomplete; }
                ConfigNode t = node.GetNode(type);
                foreach (CelestialBody body in KRESUtils.GetRelevantBodies(type))
                {
                    if (!t.HasNode(body.bodyName)) { goto Incomplete; }
                }
            }
            return true;

            Incomplete:
            {
                print("no nodes");
                node.ClearNodes();
                foreach(string type in KRESUtils.types.Values)
                {
                    ConfigNode t = node.AddNode(type);
                    foreach(CelestialBody body in KRESUtils.GetRelevantBodies(type))
                    {
                        ConfigNode b = t.AddNode(body.bodyName);
                        b.AddValue("currentError", 1d);
                    }
                }
                return false;
            }
        }
        public static void SaveCustomStressTemplates()
        {
            ConfigNode node = new ConfigNode("@FARAeroStress[default]:FOR[FerramAerospaceResearch]");
            int i = 0;
            node.AddNode(new ConfigNode("!FARPartStressTemplate,*"));

            foreach (FARPartStressTemplate template in StressTemplates)
            {
                node.AddNode(CreateAeroStressConfigNode(template, i));
                i++;
            }

            ConfigNode saveNode = new ConfigNode();
            saveNode.AddNode(node);
            saveNode.Save(KSPUtil.ApplicationRootPath.Replace("\\", "/") + "GameData/FerramAerospaceResearch/CustomFARAeroStress.cfg");
        }
Example #13
0
 /// <summary>
 /// Save settings to the underlying storage
 /// </summary>
 public void Save ()
 {
     ConfigNode node = AsConfigNode;
     var clsNode = new ConfigNode (nodeName);
     clsNode.AddNode (node);
     clsNode.Save (path);
 }
Example #14
0
		public override void OnSave(ConfigNode config)
		{
			var settings = new ConfigNode ("Settings");
			config.AddNode (settings);

			//XXX fill in with config node stuff to save settings to the
			// settings config node
		}
        protected override void OnSave(ConfigNode configNode)
        {
            base.OnSave(configNode);

            ConfigNode child = new ConfigNode("CUTSCENE_DEFINITION");
            cutSceneDefinition.OnSave(child);
            configNode.AddNode(child);
        }
Example #16
0
        public void Save(ConfigNode bodyNode)
        {
            bodyNode.AddValue("ScanMask", Misc.ToBase64String(scans.ToByteArray()));

            var node = Resources.Save() ?? new ConfigNode();
            node.name = "GeneratorData";
            bodyNode.AddNode(node);
        }
Example #17
0
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     if ((object)ProgressTracking.Instance != null)
     {
         ProgressTracking.Instance.achievementTree.Save(node.AddNode("Progress"));
     }
 }
        public override void OnSave(ConfigNode node)
        {
            base.OnSave(node);

            node.RemoveNodes("ScienceData");
            foreach(ScienceData data in storedData) {
                data.Save((ConfigNode)node.AddNode("ScienceData"));
            }
        }
Example #19
0
 public ConfigNode CreateConfigNode(string type)
 {
     ConfigNode configNode = new ConfigNode(this.Name);
     foreach (DefaultResource resource in this.Resources.Where(r => r.Type == type))
     {
         configNode.AddNode(resource.CreateConfigNode());
     }
     return configNode;
 }
Example #20
0
 //called on GameSave event, refresh all data from loaded vessels and save to .sfs
 private void GameSaveTrigger(ConfigNode node)
 {
     //need to call save routines here
     if (node.HasNode("VMSNode")) //note that we do not load data at this point, our data storage is static so we know what's in the save file is old, invalid data
     {
         node.RemoveNodes("VMSNode"); //should only ever be on VMSnode in a file, remove all nodes to error trap it
     }
     node.AddNode(VesselModuleStaticData.SaveRoutine());
 }
Example #21
0
 public void RefreshDestructionNode()
 {
     DestructionNode = new ConfigNode("DestructionState");
     foreach (DestructibleBuilding facility in GetDestructibleFacilityReferences())
     {
         ConfigNode aNode = new ConfigNode(facility.id);
         facility.Save(aNode);
         DestructionNode.AddNode(aNode);
     }
 }
Example #22
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);
        }
        protected override void OnParameterSave(ConfigNode node)
        {
            base.OnParameterSave(node);

            ConfigNode stagedNode = node.AddNode("STAGED_VESSELS");
            foreach (Vessel v in staged)
            {
                stagedNode.AddValue("vessel", v.id);
            }
        }
Example #24
0
        public override void OnSave(ConfigNode node)
        {
            if (hardDisk != null)
            {
                ConfigNode hdNode = hardDisk.Save("harddisk");
                node.AddNode(hdNode);
            }

            base.OnSave(node);
        }
 public override void OnSave(ConfigNode node)
 {
     base.OnSave(node);
     ConfigNode DataNode = new ConfigNode("TerminusData");
     ConfigNode TLS_Kerbals = new ConfigNode("TLS_Kerbals");
     foreach (KerbalInfo ki in Terminus_Life_Support.TrackedKerbals)
     {
         TLS_Kerbals.AddNode(ki.AsConfigNode());
     }
     DataNode.AddNode(TLS_Kerbals);
     node.AddNode(DataNode);
 }
Example #26
0
        public void Save()
        {
            ConfigNode root = new ConfigNode();
            ConfigNode rt = new ConfigNode("REMOTE_TECH");
            root.AddNode(rt);

            mCore.Network.Save(rt);
            mCore.Gui.Save(rt);
            mCore.Renderer.Save(rt);

            root.Save("RemoteTech.cfg", " RemoteTech2 configuration file.");
        }
Example #27
0
        public void SaveSettings()
        {
            ConfigNode settings = new ConfigNode("SETTINGS");
            settings.AddValue("stopTimeWarpOnFailure", stopTimeWarpOnFailure);
            settings.AddValue("alertMessageOnFailure", alertMessageOnFailure);
            settings.AddValue("highlightFailedPart", highlightFailedPart);

            ConfigNode root = new ConfigNode();
            root.AddNode(settings);

            root.Save("GameData/KerbalMechanics/Settings.cfg");
        }
        protected override void OnSave(ConfigNode node)
        {
            base.OnSave(node);

            foreach (Kerbal kerbal in kerbals)
            {
                ConfigNode kerbalNode = new ConfigNode("KERBAL");
                node.AddNode(kerbalNode);

                kerbal.Save(kerbalNode);
            }
        }
        public ConfigNode getConfigNode()
        {
            ConfigNode node = new ConfigNode(CONFIG_NODE_NAME);

            node.AddValue(TYPE_VALUE, type);
            if (equ != null)
            {
                node.AddNode(equ.getNode());
            }

            return node;
        }
Example #30
0
		public void Save(ConfigNode node)
		{
			Debug.Log("Saving path: " + pathName);
			ConfigNode pathNode = node.AddNode("CAMERAPATH");
			pathNode.AddValue("pathName", pathName);
			pathNode.AddValue("points", WriteVectorList(points));
			pathNode.AddValue("rotations", WriteQuaternionList(rotations));
			pathNode.AddValue("times", WriteFloatList(times));
			pathNode.AddValue("zooms", WriteFloatList(zooms));
			pathNode.AddValue("lerpRate", lerpRate);
			pathNode.AddValue("timeScale", timeScale);
		}