public override void OnLoad(ConfigNode node)
 {
     try
     {
         base.OnLoad(node);
         nextCheck = ConfigNodeUtil.ParseValue <int>(node, "nextCheck", 0);
         foreach (ConfigNode child in node.GetNodes("CelestialBodyInfo"))
         {
             CelestialBodyInfo cbi = new CelestialBodyInfo();
             try
             {
                 cbi.body = ConfigNodeUtil.ParseValue <CelestialBody>(child, "body");
             }
             catch (Exception e)
             {
                 LoggingUtil.LogWarning(this, "Error loading celestial body, skipping.  Error was:");
                 LoggingUtil.LogException(e);
                 continue;
             }
             cbi.coverage              = ConfigNodeUtil.ParseValue <UInt32>(child, "coverage", 0);
             cbi.activeRange           = ConfigNodeUtil.ParseValue <double>(child, "activeRange");
             celestialBodies[cbi.body] = cbi;
         }
     }
     catch (Exception e)
     {
         LoggingUtil.LogError(this, "Error loading RemoteTechProgressTracker from persistance file!");
         LoggingUtil.LogException(e);
         ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.SCENARIO_MODULE_LOAD, e, "RemoteTechProgressTracker");
     }
 }
 protected sealed override void OnSave(ConfigNode node)
 {
     try
     {
         if (Root != null)
         {
             node.AddValue("ContractIdentifier", Root.ToString());
         }
         node.AddValue("title", title ?? "");
         node.AddValue("notes", notes ?? "");
         if (completeInSequence)
         {
             node.AddValue("completeInSequence", completeInSequence);
         }
         if (hideChildren)
         {
             node.AddValue("hideChildren", hideChildren);
         }
         OnParameterSave(node);
     }
     catch (Exception e)
     {
         LoggingUtil.LogException(e);
         ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.PARAMETER_SAVE, e, Root.ToString(), ID);
     }
 }
        protected sealed override void OnLoad(ConfigNode node)
        {
            try
            {
                title              = ConfigNodeUtil.ParseValue <string>(node, "title", "");
                notes              = ConfigNodeUtil.ParseValue <string>(node, "notes", "");
                hideChildren       = ConfigNodeUtil.ParseValue <bool?>(node, "hideChildren", (bool?)false).Value;
                completeInSequence = ConfigNodeUtil.ParseValue <bool?>(node, "completeInSequence", (bool?)false).Value;
                OnParameterLoad(node);

                if (hideChildren)
                {
                    foreach (ContractParameter p in this.GetChildren())
                    {
                        ContractConfiguratorParameter ccParam = p as ContractConfiguratorParameter;
                        if (ccParam != null)
                        {
                            ccParam.Hide();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string contractName = "unknown";
                try
                {
                    contractName = ConfigNodeUtil.ParseValue <string>(node, "ContractIdentifier");
                }
                catch { }
                LoggingUtil.LogException(e);
                ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.PARAMETER_LOAD, e, contractName, ID);
            }
        }
示例#4
0
 protected sealed override void OnLoad(ConfigNode node)
 {
     try
     {
         title              = ConfigNodeUtil.ParseValue <string>(node, "title", "");
         notes              = ConfigNodeUtil.ParseValue <string>(node, "notes", "");
         completedMessage   = ConfigNodeUtil.ParseValue <string>(node, "completedMessage", "");
         hidden             = ConfigNodeUtil.ParseValue <bool?>(node, "hidden", (bool?)false).Value;
         hideChildren       = ConfigNodeUtil.ParseValue <bool?>(node, "hideChildren", (bool?)false).Value;
         completeInSequence = ConfigNodeUtil.ParseValue <bool?>(node, "completeInSequence", (bool?)false).Value;
         fakeFailures       = ConfigNodeUtil.ParseValue <bool?>(node, "fakeFailures", (bool?)false).Value;
         OnParameterLoad(node);
     }
     catch (Exception e)
     {
         string contractName = "unknown";
         try
         {
             contractName = ConfigNodeUtil.ParseValue <string>(node, "ContractIdentifier");
         }
         catch { }
         LoggingUtil.LogException(e);
         ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.PARAMETER_LOAD, e, contractName, ID);
     }
 }
 public override void OnSave(ConfigNode node)
 {
     try
     {
         base.OnSave(node);
         node.AddValue("nextCheck", nextCheck);
         foreach (CelestialBodyInfo cbi in celestialBodies.Values)
         {
             ConfigNode child = new ConfigNode("CelestialBodyInfo");
             child.AddValue("body", cbi.body.name);
             child.AddValue("coverage", cbi.coverage);
             child.AddValue("activeRange", cbi.activeRange);
             node.AddNode(child);
         }
     }
     catch (Exception e)
     {
         LoggingUtil.LogError(this, "Error saving RemoteTechProgressTracker to persistance file!");
         LoggingUtil.LogException(e);
         ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.SCENARIO_MODULE_SAVE, e, "RemoteTechProgressTracker");
     }
 }