Example #1
0
            public LaunchConfig(string craftDirectory, string name, string launchSite, bool recover)
            {
                LaunchSite = launchSite;
                Recover    = recover;
                // Load the vessel and its default crew
                if (craftDirectory == "VAB")
                {
                    EditorDriver.editorFacility = EditorFacility.VAB;
                }
                else if (craftDirectory == "SPH")
                {
                    EditorDriver.editorFacility = EditorFacility.SPH;
                }
                else
                {
                    throw new ArgumentException("Invalid craftDirectory, should be VAB or SPH");
                }
                Path     = ShipConstruction.GetSavePath(name);
                template = ShipConstruction.LoadTemplate(Path);
                if (template == null)
                {
                    throw new InvalidOperationException("Failed to load template for vessel");
                }
                manifest = HighLogic.CurrentGame.CrewRoster.DefaultCrewForVessel(
                    template.config, VesselCrewManifest.FromConfigNode(template.config));

                facility      = (craftDirectory == "SPH") ? SpaceCenterFacility.SpaceplaneHangar : SpaceCenterFacility.VehicleAssemblyBuilding;
                facilityLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(facility);
                site          = (launchSite == "Runway") ? SpaceCenterFacility.Runway : SpaceCenterFacility.LaunchPad;
                siteLevel     = ScenarioUpgradeableFacilities.GetFacilityLevel(site);
                isPad         = (site == SpaceCenterFacility.LaunchPad);
            }
Example #2
0
        public static CraftTemplate GetTemplateByName(string name, string facility)
        {
            if (string.IsNullOrEmpty(facility))
            {
                facility = "<empty>";
            }
            if (!string.IsNullOrEmpty(name))
            {
                switch (facility.ToLower())
                {
                case ("vab"):
                    EditorDriver.editorFacility = EditorFacility.VAB;
                    break;

                case ("sph"):
                    EditorDriver.editorFacility = EditorFacility.SPH;
                    break;

                default:
                    throw new KOSException("Failed to load craft.  Facility " + facility + " not recognized, expected \"VAB\" or \"SPH\"");
                }
                var path     = ShipConstruction.GetSavePath(name);
                var template = ShipConstruction.LoadTemplate(path);
                if (template == null)
                {
                    throw new KOSException("Failed to load craft named \"" + name + "\" from given path:\n  " + path);
                }
                return(new CraftTemplate(path, template));
            }
            throw new KOSException("Failed to load craft named " + name + " from facility " + facility);
        }
        //Show user option to save current craft or carry on loading
        internal void load_craft_confirm_dialog(DialogAction action)
        {
            string resp = "";

            show_dialog("Confirm Load", "The Current Craft has unsaved changes", d => {
                section((w) => {
                    button("Save Current Craft first", "button.continue_with_save", () => {
                        string path = ShipConstruction.GetSavePath(EditorLogic.fetch.ship.shipName);
                        EditorLogic.fetch.ship.SaveShip().Save(path);
                        action(); resp = "200";
                    });
                    button("Continue Without Saving", "button.continue_no_save", () => {
                        action(); resp = "200";
                    });
                });
                GUILayout.Space(10);
                button("Cancel", "button.cancel_load", close_dialog);
                return(resp);
            });
        }
Example #4
0
        public override void OnSave(ConfigNode node)
        {
            base.OnSave(node);
            Debug.Log("OnSave called");
            ConfigNode partNode = PartLoader.getPartInfoByName("testHub").partConfig;

            Debug.Log("Adding values to partNode");
            string setValue_0 = KSPUtil.WriteVector(part.FindAttachNode(node_0).position) + ", " + KSPUtil.WriteVector(part.FindAttachNode(node_0).orientation) + ", 1";
            string setValue_1 = KSPUtil.WriteVector(part.FindAttachNode(node_1).position) + ", " + KSPUtil.WriteVector(part.FindAttachNode(node_1).orientation) + ", 1";

            if (partNode.HasValue("node_stack_" + node_0))
            {
                partNode.SetValue("node_stack_" + node_0, setValue_0);
            }
            if (partNode.HasValue("node_stack_" + node_1))
            {
                partNode.SetValue("node_stack_" + node_1, setValue_1);
            }
            ShipConstruction.GetSavePath(vessel.name);
            Debug.Log("OnSave end");
        }
 //returns the full path of the craft file
 private string craft_path()
 {
     return(ShipConstruction.GetSavePath(editor_craft_name));
 }