protected void drawLoadAndCancelButtons(EditorBayItem editorBayItem) { Color oldColor = GUI.backgroundColor; ShipConstruct ship = EditorLogic.fetch.ship; //Load button GUILayout.BeginHorizontal(); GUI.backgroundColor = XKCDColors.LemonYellow; if (GUILayout.Button(launchIcon, buttonOptions)) { loadVessel(editorBayItem); /* * //Launch the vessel. This will fill the ship with a default crew, which isn't what we want. * if (isVAB) * HighLogic.CurrentGame.editorFacility = EditorFacility.VAB; * else * HighLogic.CurrentGame.editorFacility = EditorFacility.SPH; * * VesselCrewManifest manifest = KSP.UI.CrewAssignmentDialog.Instance.GetManifest(); * if (manifest == null) * manifest = HighLogic.CurrentGame.CrewRoster.DefaultCrewForVessel(EditorLogic.fetch.ship.SaveShip(), null, true); * * FlightDriver.StartWithNewLaunch(editorBayItem.vesselFilePath, EditorLogic.FlagURL, EditorLogic.fetch.launchSiteName, manifest); */ } launchIcon = selectLoadIcon(); GUI.backgroundColor = oldColor; //Cancel Integration button GUI.backgroundColor = XKCDColors.ColorTranslator.FromHtml("#fe7e56"); if (GUILayout.Button(exitIcon, buttonOptions)) { //Return workers BARISScenario.Instance.ReturnWorkers(editorBayItem); //Clear the bay editorBayItem.Clear(); BARISLaunchButtonManager.editorBayItem = null; //Delete the vessel file editorBayItem.DeleteSnapshot(); BARISScenario.Instance.SetEditorBay(editorBayItem); //Save the game GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); } exitIcon = selectExitIcon(); GUI.backgroundColor = oldColor; GUILayout.EndHorizontal(); }
protected void drawLoadAndCancelButtons(EditorBayItem editorBayItem) { Color oldColor = GUI.backgroundColor; ShipConstruct ship = EditorLogic.fetch.ship; //Load button GUILayout.BeginHorizontal(); GUI.backgroundColor = XKCDColors.LemonYellow; if (KACWrapper.InstanceExists && KACWrapper.APIReady && editorBayItem.isCompleted) { if (GUILayout.Button(launchIcon, buttonOptions)) { loadVessel(editorBayItem); } launchIcon = selectLoadIcon(); } else if (!KACWrapper.AssemblyExists || !KACWrapper.APIReady) { if (GUILayout.Button(launchIcon, buttonOptions)) { loadVessel(editorBayItem); } launchIcon = selectLoadIcon(); } GUI.backgroundColor = oldColor; //Cancel Integration button GUI.backgroundColor = XKCDColors.ColorTranslator.FromHtml("#fe7e56"); if (GUILayout.Button(exitIcon, buttonOptions)) { //Return workers BARISScenario.Instance.ReturnWorkers(editorBayItem); //Clear the bay editorBayItem.Clear(); BARISLaunchButtonManager.editorBayItem = null; //Delete the vessel file editorBayItem.DeleteSnapshot(); BARISScenario.Instance.SetEditorBay(editorBayItem); //Save the game GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); } exitIcon = selectExitIcon(); GUI.backgroundColor = oldColor; GUILayout.EndHorizontal(); }
/* * protected void destroyFacility() * { * List<EditorBayItem> bayItems = null; * * //Set the facility as destroyed. * * //If the facility is the VAB or SPH, then clear the bays as well. * bayItems = BARISScenario.Instance.GetBuildsInProgress(isVAB); * foreach (EditorBayItem doomed in bayItems) * doomed.Clear(); * * //Inform player * string message = Localizer.Format(BARISScenario.BuildingDestroyedMsg); * BARISScenario.Instance.LogPlayerMessage(message); * } */ protected void applyIntegrationLost() { List <EditorBayItem> bayItems = null; EditorBayItem bayItem = null; string message = string.Empty; bayItems = BARISScenario.Instance.GetBuildsInProgress(isVAB); if (bayItems.Count > 0) { int index = UnityEngine.Random.Range(0, bayItems.Count - 1); bayItem = bayItems[index]; message = bayItem.vesselName + Localizer.Format(BARISScenario.VesselBuildFailedMsg); bayItem.Clear(); //Inform player BARISScenario.Instance.LogPlayerMessage(message); } }
protected void drawEmptyBay() { ShipConstruct ship = EditorLogic.fetch.ship; Color oldColor = GUI.backgroundColor; if (ship.parts.Count > 0) { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); //If the new integration button is pressed then record the info we need //to add editor bay data to the database. GUI.backgroundColor = XKCDColors.ColorTranslator.FromHtml("#97f5ff"); if (GUILayout.Button(newIcon, buttonOptions)) { //Set up a new vehicle integration editorBayItem.Clear(); editorBayItem.vesselName = ship.shipName; //Generate snapshot of the vessel ConfigNode shipNode = ship.SaveShip(); editorBayItem.vesselFilePath = savesFolder + ship.shipName + isVAB + editorBayItem.editorBayID + ".cfg"; debugLog("Vessel file: " + editorBayItem.vesselFilePath); if (File.Exists(editorBayItem.vesselFilePath)) { File.Delete(editorBayItem.vesselFilePath); } shipNode.Save(editorBayItem.vesselFilePath); editorBayItem.vesselThumbnail = null; float dryCost, fuelCost; ship.GetShipCosts(out dryCost, out fuelCost); editorBayItem.rushJobCost = dryCost; calculateReliability(editorBayItem, ship); editorBayItem.totalVesselParts = ship.parts.Count; //Generate thumbnail ShipConstruction.CaptureThumbnail(ship, "thumbs", thumbnailBaseFileName + ship.shipName); //Generate the full path to the thumbnail and add it to the editorBayItem editorBayItem.thumbnailPath = thumbnailFullPath + ship.shipName + ".png"; //Add workers int availableWorkers = BARISScenario.Instance.GetAvailableWorkers(isVAB); if (availableWorkers >= BARISScenario.MaxWorkersPerBay) { editorBayItem.workerCount = BARISScenario.MaxWorkersPerBay; availableWorkers -= editorBayItem.workerCount; BARISScenario.Instance.SetAvailableWorkers(availableWorkers, isVAB); } else { editorBayItem.workerCount = availableWorkers; BARISScenario.Instance.SetAvailableWorkers(0, isVAB); } //Generate a KAC alarm (if KAC is installed) setKACAlarm(editorBayItem); //Save the new item BARISScenario.Instance.SetEditorBay(editorBayItem); GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.BACKUP); //Cleanup debugLog(editorBayItem.ToString()); } newIcon = selectNewIcon(); GUI.backgroundColor = oldColor; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); //Tooltip if (string.IsNullOrEmpty(newToolTip) == false) { GUILayout.Label(newToolTip); } else { GUILayout.Label(" "); } } }