public void LoadConfig(ConfigNode node) { this.clearAll(); //Load custom info scripts, which are stored in our ConfigNode: ConfigNode[] scriptNodes = node.GetNodes(); foreach (ConfigNode scriptNode in scriptNodes) { MechJebModuleScriptAction obj = null; if (scriptNode.name.CompareTo(MechJebModuleScriptActionSmartASS.NAME) == 0) { obj = new MechJebModuleScriptActionSmartASS(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionAscent.NAME) == 0) { obj = new MechJebModuleScriptActionAscent(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionTimer.NAME) == 0) { obj = new MechJebModuleScriptActionTimer(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionCrewTransfer.NAME) == 0) { obj = new MechJebModuleScriptActionCrewTransfer(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionDockingAutopilot.NAME) == 0) { obj = new MechJebModuleScriptActionDockingAutopilot(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionPause.NAME) == 0) { obj = new MechJebModuleScriptActionPause(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionStaging.NAME) == 0) { obj = new MechJebModuleScriptActionStaging(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionTargetDock.NAME) == 0) { obj = new MechJebModuleScriptActionTargetDock(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionTarget.NAME) == 0) { obj = new MechJebModuleScriptActionTarget(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionControlFrom.NAME) == 0) { obj = new MechJebModuleScriptActionControlFrom(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionUndock.NAME) == 0) { obj = new MechJebModuleScriptActionUndock(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionDockingShield.NAME) == 0) { obj = new MechJebModuleScriptActionDockingShield(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionQuicksave.NAME) == 0) { obj = new MechJebModuleScriptActionQuicksave(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionRCS.NAME) == 0) { obj = new MechJebModuleScriptActionRCS(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionActiveVessel.NAME) == 0) { obj = new MechJebModuleScriptActionActiveVessel(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionActivateEngine.NAME) == 0) { obj = new MechJebModuleScriptActionActivateEngine(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionSAS.NAME) == 0) { obj = new MechJebModuleScriptActionSAS(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionThrottle.NAME) == 0) { obj = new MechJebModuleScriptActionThrottle(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionExecuteNode.NAME) == 0) { obj = new MechJebModuleScriptActionExecuteNode(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionManoeuver.NAME) == 0) { obj = new MechJebModuleScriptActionManoeuver(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionLanding.NAME) == 0) { obj = new MechJebModuleScriptActionLanding(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionWarp.NAME) == 0) { obj = new MechJebModuleScriptActionWarp(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionTolerance.NAME) == 0) { obj = new MechJebModuleScriptActionTolerance(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionWaitFor.NAME) == 0) { obj = new MechJebModuleScriptActionWaitFor(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionFor.NAME) == 0) { obj = new MechJebModuleScriptActionFor(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionIf.NAME) == 0) { obj = new MechJebModuleScriptActionIf(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionWhile.NAME) == 0) { obj = new MechJebModuleScriptActionWhile(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionParallel.NAME) == 0) { obj = new MechJebModuleScriptActionParallel(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionActionGroup.NAME) == 0) { obj = new MechJebModuleScriptActionActionGroup(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionLoadScript.NAME) == 0) { obj = new MechJebModuleScriptActionLoadScript(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionRendezvous.NAME) == 0) { obj = new MechJebModuleScriptActionRendezvous(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionRendezvousAP.NAME) == 0) { obj = new MechJebModuleScriptActionRendezvousAP(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionIRSequencer.NAME) == 0) { obj = new MechJebModuleScriptActionIRSequencer(scriptModule, core, this); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionKos.NAME) == 0) { obj = new MechJebModuleScriptActionKos(scriptModule, core, this); } else { Log.err("MechJebModuleScript.LoadConfig : Unknown node {0}", scriptNode.name); } if (obj != null) { ConfigNode.LoadObjectFromConfig(obj, scriptNode); obj.postLoad(scriptNode); this.addAction(obj); } } }
public void LoadConfig(int slot, bool notify) { if (vessel == null) { return; } if (slot != 9) { this.selectedSlot = slot; //Select the slot for the UI. Except slot 9 (temp) } ConfigNode node = new ConfigNode("MechJebScriptSettings"); if (File.Exists <MechJebCore>("mechjeb_settings_script_" + vesselSaveName + "_" + slot + ".cfg")) { try { node = ConfigNode.Load(IOUtils.GetFilePathFor(this.GetType(), "mechjeb_settings_script_" + vesselSaveName + "_" + slot + ".cfg")); } catch (Exception e) { Debug.LogError("MechJebModuleScript.LoadConfig caught an exception trying to load mechjeb_settings_script_" + vesselSaveName + "_" + slot + ".cfg: " + e); } } else if (notify) { this.setFlashMessage("ERROR: File not found: mechjeb_settings_script_" + vesselSaveName + "_" + slot + ".cfg", 1); } if (node == null) { return; } this.clearAll(); //Load custom info scripts, which are stored in our ConfigNode: ConfigNode[] scriptNodes = node.GetNodes(); foreach (ConfigNode scriptNode in scriptNodes) { MechJebModuleScriptAction obj = null; if (scriptNode.name.CompareTo(MechJebModuleScriptActionAscent.NAME) == 0) { obj = new MechJebModuleScriptActionAscent(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionTimer.NAME) == 0) { obj = new MechJebModuleScriptActionTimer(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionCrewTransfer.NAME) == 0) { obj = new MechJebModuleScriptActionCrewTransfer(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionDockingAutopilot.NAME) == 0) { obj = new MechJebModuleScriptActionDockingAutopilot(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionPause.NAME) == 0) { obj = new MechJebModuleScriptActionPause(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionStaging.NAME) == 0) { obj = new MechJebModuleScriptActionStaging(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionTargetDock.NAME) == 0) { obj = new MechJebModuleScriptActionTargetDock(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionTarget.NAME) == 0) { obj = new MechJebModuleScriptActionTarget(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionControlFrom.NAME) == 0) { obj = new MechJebModuleScriptActionControlFrom(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionUndock.NAME) == 0) { obj = new MechJebModuleScriptActionUndock(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionDockingShield.NAME) == 0) { obj = new MechJebModuleScriptActionDockingShield(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionQuicksave.NAME) == 0) { obj = new MechJebModuleScriptActionQuicksave(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionRCS.NAME) == 0) { obj = new MechJebModuleScriptActionRCS(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionActiveVessel.NAME) == 0) { obj = new MechJebModuleScriptActionActiveVessel(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionActivateEngine.NAME) == 0) { obj = new MechJebModuleScriptActionActivateEngine(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionSAS.NAME) == 0) { obj = new MechJebModuleScriptActionSAS(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionThrottle.NAME) == 0) { obj = new MechJebModuleScriptActionThrottle(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionExecuteNode.NAME) == 0) { obj = new MechJebModuleScriptActionExecuteNode(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionManoeuver.NAME) == 0) { obj = new MechJebModuleScriptActionManoeuver(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionLanding.NAME) == 0) { obj = new MechJebModuleScriptActionLanding(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionWarp.NAME) == 0) { obj = new MechJebModuleScriptActionWarp(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionTolerance.NAME) == 0) { obj = new MechJebModuleScriptActionTolerance(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionWaitFor.NAME) == 0) { obj = new MechJebModuleScriptActionWaitFor(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionActionGroup.NAME) == 0) { obj = new MechJebModuleScriptActionActionGroup(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionLoadScript.NAME) == 0) { obj = new MechJebModuleScriptActionLoadScript(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionRendezvous.NAME) == 0) { obj = new MechJebModuleScriptActionRendezvous(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionRendezvousAP.NAME) == 0) { obj = new MechJebModuleScriptActionRendezvousAP(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionIRSequencer.NAME) == 0) { obj = new MechJebModuleScriptActionIRSequencer(this, core); } else if (scriptNode.name.CompareTo(MechJebModuleScriptActionKos.NAME) == 0) { obj = new MechJebModuleScriptActionKos(this, core); } else { Debug.LogError("MechJebModuleScript.LoadConfig : Unknown node " + scriptNode.name); } if (obj != null) { ConfigNode.LoadObjectFromConfig(obj, scriptNode); obj.postLoad(scriptNode); this.addAction(obj); } } }