void vessel_selected(ConfigNode node, CraftBrowserDialog.LoadType t)
        {
            vessel_selector = null;
            //load vessel config
            var construct = new ShipConstruct();

            if (!construct.LoadShip(node))
            {
                var shipName = node.GetValue("ship");
                Utils.Error($"Unable to load ShipConstruct '{shipName}'. " +
                            "This usually means that some parts are missing " +
                            "or some modules failed to initialize.");
                Utils.Message("Unable to load {0}", shipName);
                return;
            }
            //check if it's possible to launch such vessel
            bool cant_launch    = false;
            var  preFlightCheck = new PreFlightCheck(new Callback(() => cant_launch = false), new Callback(() => cant_launch = true));

            preFlightCheck.AddTest(new PreFlightTests.ExperimentalPartsAvailable(construct));
            preFlightCheck.RunTests();
            //cleanup loaded parts and try to store construct
            if (cant_launch)
            {
                construct.Unload();
            }
            else
            {
                StartCoroutine(delayed_process_construct(construct));
            }
        }
 public void ShowShipSelector()
 {
     CraftBrowserDialog.Spawn(
         facility: EditorFacility.VAB,
         profile: HighLogic.SaveFolder,
         onFileSelected: VesselSelected,
         onCancel: () => { },
         showMergeOption: false);
 }
Example #3
0
 private void OnSelected(string fullPath, CraftBrowserDialog.LoadType loadType)
 {
     craftBrowser        = null;
     openingCraftBrowser = false;
     if (VesselMoverToolbar.addCrewMembers && VesselMoverToolbar.selectCrewMembers)
     {
         FullPath        = fullPath;
         IsSelectingCrew = true;
         return;
     }
     StartCoroutine(SpawnCraftRoutine(fullPath));
     choosingPosition = true;
 }
Example #4
0
        private IEnumerator StartVesselSpawnRoutine()
        {
            openingCraftBrowser = true;

            //float width = 450;
            //float height = Screen.height * 0.7f;
            yield return(null);

            Debug.Log("[Vessel Mover] - profile:" + HighLogic.SaveFolder);
            Debug.Log("[Vessel Mover] - profile:" + HighLogic.CurrentGame.Title.Split(new string[] { " (" }, StringSplitOptions.None)[0]);
            //craftBrowser = new CraftBrowserDialog(new Rect((Screen.width - width) / 2, (Screen.height - height) / 2, width, height), EditorFacility.SPH, HighLogic.CurrentGame.Title.Split(new string[] { " (" }, StringSplitOptions.None)[0], "Spawn Vessel", OnSelected, OnCancelled, HighLogic.Skin, Texture2D.whiteTexture, false, false);
            craftBrowser = CraftBrowserDialog.Spawn(EditorFacility.SPH, HighLogic.SaveFolder, OnSelected, OnCancelled, false);
        }
        public void loadVessel()
        {
            string strpath = HighLogic.SaveFolder;

            EditorFacility [] facility = new EditorFacility[] {
                EditorFacility.VAB,
                EditorFacility.SPH,
                EditorFacility.None,
            };

            CraftBrowserDialog.Spawn(facility[1],
                                     strpath,
                                     craftSelectOkay,
                                     craftSelectCancel,
                                     false);
        }
Example #6
0
        public void SelectVessel()
        {
            if (vessel_selector != null)
            {
                return;
            }
            var facility = EditorLogic.fetch != null ?
                           EditorLogic.fetch.ship.shipFacility :
                           EditorFacility.VAB;

            vessel_selector =
                CraftBrowserDialog.Spawn(
                    facility,
                    HighLogic.SaveFolder,
                    vessel_selected,
                    selection_canceled, false);
        }
Example #7
0
 void selection_canceled()
 {
     vessel_selector = null;
 }
Example #8
0
 private void OnCancelled()
 {
     craftBrowser        = null;
     openingCraftBrowser = false;
 }
Example #9
0
 private void craftSelectCancel()
 {
     craftlist = null;
 }
Example #10
0
 private void craftSelectComplete(string filename,
                                  CraftBrowserDialog.LoadType lt)
 {
     craftlist = null;
     control.LoadCraft(filename, control.builder.part.flagURL);
 }
Example #11
0
        void SelectCraft()
        {
            GUILayout.BeginHorizontal("box");
            GUILayout.FlexibleSpace();
            // VAB / SPH / Subassembly selection
            ExBuildControl.CraftType maxType = ExBuildControl.CraftType.SubAss;
            if (buildCraftList == null || true)
            {
                maxType = ExBuildControl.CraftType.SPH;
                if (control.craftType == ExBuildControl.CraftType.SubAss)
                {
                    control.craftType = ExBuildControl.CraftType.VAB;
                }
            }
            for (var t = ExBuildControl.CraftType.VAB; t <= maxType; t++)
            {
                if (GUILayout.Toggle(control.craftType == t, t.ToString(),
                                     GUILayout.Width(80)))
                {
                    control.craftType = t;
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            string strpath = HighLogic.SaveFolder;

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Select Craft", Styles.normal,
                                 GUILayout.ExpandWidth(true)))
            {
                EditorFacility [] facility = new EditorFacility[] {
                    EditorFacility.VAB,
                    EditorFacility.SPH,
                    EditorFacility.None,
                };
                var  diff  = HighLogic.CurrentGame.Parameters.Difficulty;
                bool stock = diff.AllowStockVessels;
                if (control.craftType == ExBuildControl.CraftType.SubAss)
                {
                    diff.AllowStockVessels = false;
                }
                //GUILayout.Button is "true" when clicked
                craftlist = CraftBrowserDialog.Spawn(facility[(int)control.craftType],
                                                     strpath,
                                                     craftSelectComplete,
                                                     craftSelectCancel,
                                                     false);
                if (buildCraftList != null &&
                    control.craftType == ExBuildControl.CraftType.SubAss)
                {
                    craftSubfolder.SetValue(craftlist, "../Subassemblies");
                    buildCraftList.Invoke(craftlist, null);
                }
                diff.AllowStockVessels = stock;
            }
            GUI.enabled = control.craftConfig != null;
            if (GUILayout.Button("Reload", Styles.normal,
                                 GUILayout.ExpandWidth(false)))
            {
                control.LoadCraft(control.filename, control.flagname);
            }
            if (GUILayout.Button("Clear", Styles.normal,
                                 GUILayout.ExpandWidth(false)))
            {
                control.UnloadCraft();
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
        }