// Resets all internally used objects and caches, can be used for example when a savegame is loaded: public static void Reset() { UpdateShipTemplateCache(); GUIStartDeployMissionTab.Reset(); GUIStartTransportMissionTab.Reset(); GUIRecordingTab.Reset(); }
// Is called by our helper-classes to draw the actual window: public static void DrawWindow() { if (!showGui) { return; } try { GUILayout.BeginVertical(); // Title: GUILayout.BeginArea(new Rect(0, 3, windowPosition.width /* windowStyle.fixedWidth */, 20)); GUILayout.Label("<size=14><b>Kerbal Space Transport System</b></size>", new GUIStyle(GUI.labelStyle) { fixedWidth = windowPosition.width /* windowStyle.fixedWidth */, alignment = TextAnchor.MiddleCenter }); GUILayout.EndArea(); // Tab-Switcher: if (MissionController.missionProfiles.Count == 0) { int x = WIDTH / 6 - 6; GUILayout.BeginHorizontal(); UnityEngine.GUI.enabled = false; for (int i = 0; i < 4; i++) { GUILayout.Button(toolbarStrings[i], GUILayout.Width(x)); } UnityEngine.GUI.enabled = true; if (GUILayout.Button(toolbarStrings[4], GUILayout.Width(x))) { selectedMainTab = 4; } if (GUILayout.Button(toolbarStrings[5], GUILayout.Width(x))) { selectedMainTab = 5; } if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { if (GUILayout.Button(toolbarStrings[6], GUILayout.Width(x))) { selectedMainTab = 6; } } GUILayout.EndHorizontal(); } else { selectedMainTab = GUILayout.Toolbar(selectedMainTab, toolbarStrings); } switch (selectedMainTab) { // Flights: case 0: GUIFlightsTab.Display(); break; // Deploy: case 1: if (HighLogic.LoadedScene == GameScenes.FLIGHT) { GUILayout.BeginScrollView(Vector2.zero, GUI.scrollStyle); GUILayout.Label("<b>Please go to the Space Center to launch a new mission.</b>"); GUILayout.EndScrollView(); } else if (GUIStartDeployMissionTab.Display()) { selectedMainTab = 0; } break; // Transport: case 2: if (HighLogic.LoadedScene == GameScenes.FLIGHT) { GUILayout.BeginScrollView(Vector2.zero, GUI.scrollStyle); GUILayout.Label("<b>Please go to the Space Center to launch a new mission.</b>"); GUILayout.EndScrollView(); } else if (GUIStartTransportMissionTab.Display()) { selectedMainTab = 0; } break; // Construct: case 3: if (HighLogic.LoadedScene == GameScenes.FLIGHT) { GUILayout.BeginScrollView(Vector2.zero, GUI.scrollStyle); GUILayout.Label("<b>Please go to the Space Center to launch a new mission.</b>"); GUILayout.EndScrollView(); } else if (GUIStartConstructMissionTab.Display()) { selectedMainTab = 0; } break; // Record: case 4: GUIRecordingTab.Display(); break; // Help: case 5: helpTabScrollPos = GUILayout.BeginScrollView(helpTabScrollPos, GUI.scrollStyle); GUILayout.Label(helpText); GUILayout.EndScrollView(); break; case 6: GUILayout.Label("<size=14><b>Alarm Clock Settings:</b></size>"); GUILayout.BeginScrollView(new Vector2(0, 0), GUI.scrollStyle); MissionController.useKACifAvailable = GUILayout.Toggle(MissionController.useKACifAvailable, "Use Kerbal Alarm Clock (if available)"); MissionController.useStockAlarmClock = GUILayout.Toggle(MissionController.useStockAlarmClock, "Use Stock Alarm Clock"); GUILayout.EndScrollView(); break; default: GUILayout.Label("<b>Not implemented yet.</b>"); break; } GUILayout.EndVertical(); UnityEngine.GUI.DragWindow(); } catch (Exception e) { Debug.LogError("DrawWindow(): " + e.ToString()); } }
// Is called by our helper-classes to draw the actual window: public static void DrawWindow() { if (!showGui) { return; } try { GUILayout.BeginVertical(); // Title: GUILayout.BeginArea(new Rect(0, 3, windowStyle.fixedWidth, 20)); GUILayout.Label("<size=14><b>Kerbal Space Transport System</b></size>", new GUIStyle(GUI.labelStyle) { fixedWidth = windowStyle.fixedWidth, alignment = TextAnchor.MiddleCenter }); GUILayout.EndArea(); // Tab-Switcher: string[] toolbarStrings = new string[] { "Flights", "Deploy", "Transport", "Construct", "Record", "Help" }; selectedMainTab = GUILayout.Toolbar(selectedMainTab, toolbarStrings); switch (selectedMainTab) { // Flights: case 0: GUIFlightsTab.Display(); break; // Deploy: case 1: if (HighLogic.LoadedScene == GameScenes.FLIGHT) { GUILayout.BeginScrollView(Vector2.zero, GUI.scrollStyle); GUILayout.Label("<b>Please go to the Space Center to launch a new mission.</b>"); GUILayout.EndScrollView(); } else if (GUIStartDeployMissionTab.Display()) { selectedMainTab = 0; } break; // Transport: case 2: if (HighLogic.LoadedScene == GameScenes.FLIGHT) { GUILayout.BeginScrollView(Vector2.zero, GUI.scrollStyle); GUILayout.Label("<b>Please go to the Space Center to launch a new mission.</b>"); GUILayout.EndScrollView(); } else if (GUIStartTransportMissionTab.Display()) { selectedMainTab = 0; } break; // Construct: case 3: if (HighLogic.LoadedScene == GameScenes.FLIGHT) { GUILayout.BeginScrollView(Vector2.zero, GUI.scrollStyle); GUILayout.Label("<b>Please go to the Space Center to launch a new mission.</b>"); GUILayout.EndScrollView(); } else if (GUIStartConstructMissionTab.Display()) { selectedMainTab = 0; } break; // Record: case 4: GUIRecordingTab.Display(); break; // Help: case 5: helpTabScrollPos = GUILayout.BeginScrollView(helpTabScrollPos, GUI.scrollStyle); GUILayout.Label(helpText); GUILayout.EndScrollView(); break; default: GUILayout.Label("<b>Not implemented yet.</b>"); break; } GUILayout.EndVertical(); UnityEngine.GUI.DragWindow(); } catch (Exception e) { Debug.LogError("[KSTS] DrawWindow(): " + e.ToString()); } }