// IEnumerator loadScene(GameScenes scenes, EditorFacility facility = EditorFacility.None) void loadScene(GameScenes scenes, EditorFacility facility = EditorFacility.None) { //yield return new WaitForEndOfFrame (); if (scenes != GameScenes.EDITOR) { HighLogic.LoadScene(scenes); } else if (facility != EditorFacility.None) { EditorFacility editorFacility = EditorFacility.None; if (ShipConstruction.ShipConfig != null) { editorFacility = ShipConstruction.ShipType; } if (HighLogic.LoadedSceneIsFlight && FlightGlobals.fetch) { FlightGlobals.PersistentVesselIds.Clear(); FlightGlobals.PersistentLoadedPartIds.Clear(); FlightGlobals.PersistentUnloadedPartIds.Clear(); } EditorDriver.StartupBehaviour = (editorFacility == facility ? EditorDriver.StartupBehaviours.LOAD_FROM_CACHE : EditorDriver.StartupBehaviours.START_CLEAN); EditorDriver.StartEditor(facility); } InputLockManager.ClearControlLocks(); }
void menuWindow(int windowID) { GUILayout.BeginVertical(); if (GUILayout.Button("buy a new ship", HighLogic.Skin.button)) { craftBrowser = LoadCraftDialog.Create(EditorFacility.VAB, HighLogic.CurrentGame.Title.Split(new string[] { " (" }, StringSplitOptions.None)[0], OnSelected, OnCancelled, false); MenuWindow = false; } if (GUILayout.Button("Sell a ship", HighLogic.Skin.button)) { MenuWindow = false; sellWindow = true; } if (GUILayout.Button("Design a new ship", HighLogic.Skin.button)) { MenuWindow = false; sellWindow = false; aboutWindow = false; GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.BACKUP); EditorDriver.StartEditor(EditorFacility.VAB); } if (GUILayout.Button("close", HighLogic.Skin.button)) { MenuWindow = false; MainMenu.menuWindow = true; } GUILayout.EndVertical(); }
public void Start() { if (autostart) { HighLogic.SaveFolder = save_name; DebugToolbar.toolbarShown = true; if (mode == "editor") { var editor = EditorFacility.VAB; GamePersistence.LoadGame("persistent", HighLogic.SaveFolder, true, false); if (craft_name != null || craft_name != "") { string path = Paths.joined(KSPUtil.ApplicationRootPath, "saves", save_name, "Ships", "VAB", craft_name + ".craft"); EditorDriver.StartAndLoadVessel(path, editor); } else { EditorDriver.StartEditor(editor); } } else if (mode == "spacecenter") { HighLogic.LoadScene(GameScenes.SPACECENTER); } else if (mode == "flight") { FlightDriver.StartAndFocusVessel("quicksave", 1); } } }
protected void transfer_craft_dialog() { if (CraftData.active_craft.Count > 0) { string resp = ""; bool switch_editor = false; Dictionary <string, EditorFacility> lookup = new Dictionary <string, EditorFacility> { { "SPH", EditorFacility.SPH }, { "VAB", EditorFacility.VAB }, { "Subassembly", EditorFacility.None } }; int selected_transfer_option = -1; if (CraftData.active_craft.Count == 1) { lookup.Remove(CraftData.active_craft[0].construction_type); } string[] transfer_options = new List <string>(lookup.Keys).ToArray(); string opt = null; show_dialog("Transfer Craft", "Select where to Transfer " + (CraftData.active_craft.Count > 1 ? "these" : "this") + " craft to:", d => { section(() => { switch_editor = GUILayout.Toggle(switch_editor, ""); button("Switch editor after transfer", "bold", () => { switch_editor = !switch_editor; }); }); section(() => { selected_transfer_option = GUILayout.SelectionGrid(selected_transfer_option, transfer_options, transfer_options.Length, "button.large"); }); if (selected_transfer_option != -1) { opt = transfer_options[selected_transfer_option]; selected_transfer_option = -1; resp = CraftData.transfer_active_craft_to(lookup[opt]); if (switch_editor) { if (CraftManager.version.Split('.')[1] == "0") { EditorDriver.StartAndLoadVessel(CraftData.active_craft[0].path, lookup[opt]); } else { EditorLogic.fetch.SwitchEditor(); CraftData.select_craft(CraftData.active_craft[0]); load_craft("load"); } } } section(() => { fspace(); button("Cancel", close_dialog); }); return(resp); }); } }
public void OnCraftEdit() { if (FlightGlobals.ActiveVessel == null) { return; } GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); EdditingVessel = true; Vesselid = FlightGlobals.ActiveVessel.protoVessel.vesselID; EditorDriver.StartAndLoadVessel(InflightSave.TemporarySaveVessel(FlightGlobals.ActiveVessel), EditorFacility.VAB); }
public void loadEditor() { //Save the game. GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); // Setup facility EditorDriver.StartupBehaviour = EditorDriver.StartupBehaviours.START_CLEAN; if (loadVAB) { EditorDriver.StartEditor(EditorFacility.VAB); } else { EditorDriver.StartEditor(EditorFacility.SPH); } }
IEnumerator loadScene(GameScenes scenes, EditorFacility facility = EditorFacility.None) { yield return(new WaitForEndOfFrame()); if (scenes != GameScenes.EDITOR) { HighLogic.LoadScene(scenes); } else if (facility != EditorFacility.None) { EditorFacility editorFacility = EditorFacility.None; if (ShipConstruction.ShipConfig != null) { editorFacility = ShipConstruction.ShipType; } EditorDriver.StartupBehaviour = (editorFacility == facility ? EditorDriver.StartupBehaviours.LOAD_FROM_CACHE : EditorDriver.StartupBehaviours.START_CLEAN); EditorDriver.StartEditor(facility); } InputLockManager.ClearControlLocks(); }
void OnMouseDown() { if (HighLogic.LoadedScene == GameScenes.SPACECENTER && !InputLockManager.IsLocked(ControlTypes.KSC_FACILITIES)) { EditorFacility facility; staticInstance.HighlightObject(Color.clear); if (staticInstance.launchSite.LaunchSiteType == SiteType.VAB) { facility = EditorFacility.VAB; } else { facility = EditorFacility.SPH; } EditorDriver.StartupBehaviour = EditorDriver.StartupBehaviours.START_CLEAN; EditorDriver.StartEditor(facility); } }
private static void DrawBLPlusWindow(int windowID) { //bLPlusPosition.xMax = buildListWindowPosition.xMin; //bLPlusPosition.width = 100; bLPlusPosition.yMin = buildListWindowPosition.yMin; bLPlusPosition.height = 225; //bLPlusPosition.height = bLPlusPosition.yMax - bLPlusPosition.yMin; KCT_BuildListVessel b = KCT_Utilities.FindBLVesselByID(IDSelected); GUILayout.BeginVertical(); if (GUILayout.Button("Scrap")) { InputLockManager.SetControlLock(ControlTypes.KSC_ALL, "KCTPopupLock"); DialogOption[] options = new DialogOption[2]; options[0] = new DialogOption("Yes", ScrapVessel); options[1] = new DialogOption("No", DummyVoid); MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", windowTitle: "Scrap Vessel", options: options); PopupDialog.SpawnPopupDialog(diag, false, windowSkin); showBLPlus = false; ResetBLWindow(); } if (GUILayout.Button("Edit")) { showBLPlus = false; editorWindowPosition.height = 1; string tempFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/Ships/temp.craft"; b.shipNode.Save(tempFile); GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); KCT_GameStates.editedVessel = b; KCT_GameStates.EditorShipEditingMode = true; KCT_GameStates.delayStart = true; InputLockManager.SetControlLock(ControlTypes.EDITOR_EXIT, "KCTEditExit"); InputLockManager.SetControlLock(ControlTypes.EDITOR_LOAD, "KCTEditLoad"); InputLockManager.SetControlLock(ControlTypes.EDITOR_NEW, "KCTEditNew"); InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, "KCTEditLaunch"); KCT_GameStates.EditedVesselParts.Clear(); foreach (ConfigNode node in b.ExtractedPartNodes) { string name = KCT_Utilities.PartNameFromNode(node) + KCT_Utilities.GetTweakScaleSize(node); if (!KCT_GameStates.EditedVesselParts.ContainsKey(name)) { KCT_GameStates.EditedVesselParts.Add(name, 1); } else { ++KCT_GameStates.EditedVesselParts[name]; } } //EditorDriver.StartAndLoadVessel(tempFile); EditorDriver.StartAndLoadVessel(tempFile, b.type == KCT_BuildListVessel.ListType.VAB ? EditorFacility.VAB : EditorFacility.SPH); } if (GUILayout.Button("Rename")) { centralWindowPosition.width = 360; centralWindowPosition.x = (Screen.width - 360) / 2; centralWindowPosition.height = 1; showBuildList = false; showBLPlus = false; showRename = true; newName = b.shipName; //newDesc = b.getShip().shipDescription; } if (GUILayout.Button("Duplicate")) { KCT_Utilities.AddVesselToBuildList(b.NewCopy(true), b.InventoryParts.Count > 0); } if (KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()) != null && GUILayout.Button("Rollback")) { KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()).SwapRolloutType(); } if (!b.isFinished && GUILayout.Button("Warp To")) { KCT_GameStates.targetedItem = b; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(b); KCT_GameStates.warpInitiated = true; showBLPlus = false; } if (!b.isFinished && GUILayout.Button("Move to Top")) { if (b.type == KCT_BuildListVessel.ListType.VAB) { b.RemoveFromBuildList(); KCT_GameStates.ActiveKSC.VABList.Insert(0, b); } else if (b.type == KCT_BuildListVessel.ListType.SPH) { b.RemoveFromBuildList(); KCT_GameStates.ActiveKSC.SPHList.Insert(0, b); } } if (!b.isFinished && GUILayout.Button("Rush Build 10%\n√" + Math.Round(0.2 * b.GetTotalCost()))) { double cost = b.GetTotalCost(); cost *= 0.2; double remainingBP = b.buildPoints - b.progress; if (Funding.Instance.Funds >= cost) { b.AddProgress(remainingBP * 0.1); KCT_Utilities.SpendFunds(cost, TransactionReasons.None); } } if (GUILayout.Button("Close")) { showBLPlus = false; } GUILayout.EndVertical(); float width = bLPlusPosition.width; bLPlusPosition.x = buildListWindowPosition.x - width; bLPlusPosition.width = width; }
IEnumerator QStart() { while (!Ready || !QuickStart_Persistent.Ready) { yield return(0); } yield return(new WaitForSecondsRealtime(QSettings.Instance.WaitLoading)); yield return(new WaitForEndOfFrame()); QDebug.Log("SpaceCenter Loaded", "QSpaceCenter"); if (QSettings.Instance.gameScene == (int)GameScenes.FLIGHT) { string _saveGame = GamePersistence.SaveGame(QSaveGame.FILE, HighLogic.SaveFolder, SaveMode.OVERWRITE); if (!string.IsNullOrEmpty(QuickStart_Persistent.vesselID)) { int _idx = HighLogic.CurrentGame.flightState.protoVessels.FindLastIndex(pv => pv.vesselID == QuickStart_Persistent.VesselID); if (_idx != -1) { QDebug.Log(string.Format("StartAndFocusVessel: {0}({1})[{2}] idx: {3}", QSaveGame.vesselName, QSaveGame.vesselType, QuickStart_Persistent.vesselID, _idx), "QSpaceCenter"); FlightDriver.StartAndFocusVessel(_saveGame, _idx); } else { QDebug.Warning("QStart: invalid idx", "QSpaceCenter"); DestroyThis(); } } else { QDebug.Warning("QStart: No vessel found", "QSpaceCenter"); DestroyThis(); } } if (QSettings.Instance.gameScene == (int)GameScenes.TRACKSTATION) { HighLogic.LoadScene(GameScenes.LOADINGBUFFER); HighLogic.LoadScene(GameScenes.TRACKSTATION); InputLockManager.ClearControlLocks(); QDebug.Log("Goto Tracking Station", "QSpaceCenter"); DestroyThis(); } if (QSettings.Instance.gameScene == (int)GameScenes.EDITOR) { if (QSettings.Instance.enableEditorLoadAutoSave && File.Exists(QuickStart_Persistent.shipPath)) { EditorDriver.StartAndLoadVessel(QuickStart_Persistent.shipPath, (EditorFacility)QSettings.Instance.editorFacility); QDebug.Log("StartAndLoadVessel: " + QuickStart_Persistent.shipPath, "QSpaceCenter"); } else { EditorDriver.StartupBehaviour = EditorDriver.StartupBehaviours.START_CLEAN; EditorDriver.StartEditor((EditorFacility)QSettings.Instance.editorFacility); QDebug.Log("StartEditor", "QSpaceCenter"); } InputLockManager.ClearControlLocks(); QDebug.Log("Goto " + (QSettings.Instance.editorFacility == (int)EditorFacility.VAB ? "Vehicle Assembly Building" : "Space Plane Hangar"), "QSpaceCenter"); DestroyThis(); } Destroy(this); yield break; }