protected override void WindowGUI(int windowID) { GUILayout.BeginVertical(); if (this.warmingUp) { GUILayout.Label("Warming up. Please wait... " + this.spendTime + "s"); } else { GUILayout.BeginHorizontal(); GUIStyle style2 = new GUIStyle(GUI.skin.button); if (!started && this.actionsList.Count > 0) { style2.normal.textColor = Color.green; if (GUILayout.Button("START", style2)) { this.start(); } } else if (started) { style2.normal.textColor = Color.red; if (GUILayout.Button("STOP", style2)) { this.stop(); } } if (this.actionsList.Count > 0) { if (minifiedGUI) { if (GUILayout.Button("Full GUI")) { this.minifiedGUI = false; } } else { if (GUILayout.Button("Compact GUI")) { this.minifiedGUI = true; } } } GUILayout.EndHorizontal(); if (!this.minifiedGUI && !this.started) { GUILayout.BeginHorizontal(); style2.normal.textColor = Color.white; if (GUILayout.Button("Clear All", style2)) { this.clearAll(); } selectedSlot = GuiUtils.ComboBox.Box(selectedSlot, scriptsList.ToArray(), scriptsList); if (deployScriptNameField) { scriptNames[selectedSlot] = GUILayout.TextField(scriptNames[selectedSlot], GUILayout.Width(120), GUILayout.ExpandWidth(false)); if (scriptNames[selectedSlot].Length > 20) //Limit the script name to 20 chars { scriptNames[selectedSlot] = scriptNames[selectedSlot].Substring(0, 20); } if (GUILayout.Button("<<")) { this.deployScriptNameField = false; this.updateScriptsNames(); this.SaveScriptModuleConfig(); } } else { if (GUILayout.Button(">>")) { this.deployScriptNameField = true; } } if (GUILayout.Button(GameDatabase.Instance.GetTexture("MechJeb2/Icons/delete", true), new GUILayoutOption[] { GUILayout.Width(20), GUILayout.Height(20) })) { if (!this.waitingDeletionConfirmation) { this.waitingDeletionConfirmation = true; this.setFlashMessage("Warning: To confirm deletion of slot " + (selectedSlot + 1) + " - " + scriptNames[selectedSlot] + ", press again the delete button", 0); } else { this.DeleteConfig(this.selectedSlot, true); scriptNames[selectedSlot] = ""; this.updateScriptsNames(); this.SaveScriptModuleConfig(); } } if (GUILayout.Button("Save", style2)) { this.SaveConfig(this.selectedSlot, true); } if (GUILayout.Button("Load", style2)) { this.LoadConfig(this.selectedSlot, true); } GUILayout.EndHorizontal(); if (this.flashMessage.Length > 0) { GUILayout.BeginHorizontal(); GUIStyle sflash = new GUIStyle(GUI.skin.label); if (this.flashMessageType == 1) { sflash.normal.textColor = Color.red; } else { sflash.normal.textColor = Color.yellow; } GUILayout.Label(this.flashMessage, sflash); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label("Add action"); selectedActionIndex = GuiUtils.ComboBox.Box(selectedActionIndex, actionNames, this); if (actionNames[selectedActionIndex].CompareTo("MODULE Ascent Autopilot") == 0 || actionNames[selectedActionIndex].CompareTo("MODULE Landing") == 0) { if (GUILayout.Button(GameDatabase.Instance.GetTexture("MechJeb2/Icons/view", true), GUILayout.ExpandWidth(false))) { if (actionNames[selectedActionIndex].CompareTo("MODULE Ascent Autopilot") == 0) { //Open the ascent module GUI core.GetComputerModule <MechJebModuleAscentGuidance>().enabled = true; } if (actionNames[selectedActionIndex].CompareTo("MODULE Landing") == 0) { //Open the DockingGuidance module GUI core.GetComputerModule <MechJebModuleLandingGuidance>().enabled = true; } } } if (GUILayout.Button("Add")) { if (actionNames[selectedActionIndex].CompareTo("Timer") == 0) { this.addAction(new MechJebModuleScriptActionTimer(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Decouple") == 0) { this.addAction(new MechJebModuleScriptActionUndock(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Dock Shield") == 0) { this.addAction(new MechJebModuleScriptActionDockingShield(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Staging") == 0) { this.addAction(new MechJebModuleScriptActionStaging(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Target Dock") == 0) { this.addAction(new MechJebModuleScriptActionTargetDock(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Target Body") == 0) { this.addAction(new MechJebModuleScriptActionTarget(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Control From") == 0) { this.addAction(new MechJebModuleScriptActionControlFrom(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Pause") == 0) { this.addAction(new MechJebModuleScriptActionPause(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Crew Transfer") == 0) { this.addAction(new MechJebModuleScriptActionCrewTransfer(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Quicksave") == 0) { this.addAction(new MechJebModuleScriptActionQuicksave(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("RCS") == 0) { this.addAction(new MechJebModuleScriptActionRCS(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Switch Vessel") == 0) { this.addAction(new MechJebModuleScriptActionActiveVessel(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Activate Engine") == 0) { this.addAction(new MechJebModuleScriptActionActivateEngine(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("SAS") == 0) { this.addAction(new MechJebModuleScriptActionSAS(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Execute node") == 0) { this.addAction(new MechJebModuleScriptActionExecuteNode(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Maneuver") == 0) { this.addAction(new MechJebModuleScriptActionManoeuver(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Node tolerance") == 0) { this.addAction(new MechJebModuleScriptActionTolerance(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Warp") == 0) { this.addAction(new MechJebModuleScriptActionWarp(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Wait for") == 0) { this.addAction(new MechJebModuleScriptActionWaitFor(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Action Group") == 0) { this.addAction(new MechJebModuleScriptActionActionGroup(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("Load Script") == 0) { this.addAction(new MechJebModuleScriptActionLoadScript(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("MODULE Ascent Autopilot") == 0) { this.addAction(new MechJebModuleScriptActionAscent(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("MODULE Docking Autopilot") == 0) { this.addAction(new MechJebModuleScriptActionDockingAutopilot(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("MODULE Landing") == 0) { this.addAction(new MechJebModuleScriptActionLanding(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("MODULE Rendezvous") == 0) { this.addAction(new MechJebModuleScriptActionRendezvous(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("MODULE Rendezvous Autopilot") == 0) { this.addAction(new MechJebModuleScriptActionRendezvousAP(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("[IR Sequencer] Sequence") == 0) { this.addAction(new MechJebModuleScriptActionIRSequencer(this, core)); } else if (actionNames[selectedActionIndex].CompareTo("[kOS] Command") == 0) { this.addAction(new MechJebModuleScriptActionKos(this, core)); } } GUILayout.EndHorizontal(); } for (int i = 0; i < actionsList.Count; i++) //Don't use "foreach" here to avoid nullpointer exception { MechJebModuleScriptAction actionItem = actionsList[i]; if (!this.minifiedGUI || actionItem.isStarted()) { actionItem.WindowGUI(windowID); } } } GUILayout.EndVertical(); base.WindowGUI(windowID); }