Пример #1
0
 void OnSelected(string fullPath, string flagUrl, CraftBrowser.LoadType loadType)
 {
     StartCoroutine(SpawnCraftRoutine(fullPath));
     craftBrowser        = null;
     openingCraftBrowser = false;
     choosingPosition    = true;
 }
 private void OnLoad(ShipConstruct data0, CraftBrowser.LoadType data1)
 {
     if(data1 == CraftBrowser.LoadType.Normal)
     {
         ShipConcerns.Clear();
         SectionConcerns.Clear();
     }
 }
 private void EditorLoad(ShipConstruct data0, CraftBrowser.LoadType data1)
 {
     switch (data1)
     {
         case CraftBrowser.LoadType.Merge:
             RenameSections(data0);
             break;
     }
 }
Пример #4
0
        IEnumerator StartVesselSpawnRoutine()
        {
            openingCraftBrowser = true;

            float width  = 450;
            float height = Screen.height * 0.7f;

            yield return(null);

            craftBrowser = new CraftBrowser(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);
        }
        void SelectCraft()
        {
            GUILayout.BeginHorizontal("box");
            GUILayout.FlexibleSpace();
            // VAB / SPH selection
            for (var t = ExLaunchPad.CraftType.VAB;
                 t <= ExLaunchPad.CraftType.SubAss;
                 t++)
            {
                if (GUILayout.Toggle(pad.craftType == t, t.ToString(),
                                     GUILayout.Width(80)))
                {
                    pad.craftType = t;
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            string strpath = HighLogic.SaveFolder;

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Select Craft", Styles.normal,
                                 GUILayout.ExpandWidth(true)))
            {
                string [] dir   = new string[] { "VAB", "SPH", "../Subassemblies" };
                var       diff  = HighLogic.CurrentGame.Parameters.Difficulty;
                bool      stock = diff.AllowStockVessels;
                if (pad.craftType == ExLaunchPad.CraftType.SubAss)
                {
                    diff.AllowStockVessels = false;
                }
                //GUILayout.Button is "true" when clicked
                var clrect = new Rect(Screen.width / 2, 100, 350, 500);
                craftlist = new CraftBrowser(clrect, dir[(int)pad.craftType],
                                             strpath, "Select a ship to load",
                                             craftSelectComplete,
                                             craftSelectCancel,
                                             HighLogic.Skin,
                                             EditorLogic.ShipFileImage, true);
                diff.AllowStockVessels = stock;
            }
            GUI.enabled = pad.craftConfig != null;
            if (GUILayout.Button("Clear", Styles.normal,
                                 GUILayout.ExpandWidth(false)))
            {
                pad.UnloadCraft();
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
        }
Пример #6
0
        void vessel_selected(string filename, string flagname)
        {
            EditorLogic EL = EditorLogic.fetch;

            if (EL == null)
            {
                return;
            }
            //load vessel config
            vessel_selector = null;
            PackedConstruct pc = new PackedConstruct(filename, flagname);

            if (pc.construct == null)
            {
                Utils.Log("PackedConstruct: unable to load ShipConstruct from {0}. " +
                          "This usually means that some parts are missing " +
                          "or some modules failed to initialize.", filename);
                ScreenMessager.showMessage(string.Format("Unable to load {0}", filename), 3);
                return;
            }
            //check if the construct contains launch clamps
            if (Utils.HasLaunchClamp(pc.construct))
            {
                ScreenMessager.showMessage(string.Format("{0} has launch clamps. Remove them before storing.", pc.name), 3);
                pc.UnloadConstruct();
                return;
            }
            //check if it's possible to launch such vessel
            bool           cant_launch    = false;
            PreFlightCheck preFlightCheck = new PreFlightCheck(new Callback(() => cant_launch = false), new Callback(() => cant_launch = true));

            preFlightCheck.AddTest(new PreFlightTests.ExperimentalPartsAvailable(pc.construct));
            preFlightCheck.RunTests();
            pc.UnloadConstruct();
            //cleanup loaded parts and try to store construct
            if (cant_launch)
            {
                return;
            }
            if (try_store_construct(pc))
            {
                change_part_params(pc.metric);
            }
        }
Пример #7
0
 private void OnEditorLoad(ShipConstruct sp, CraftBrowser.LoadType lt)
 {
 }
Пример #8
0
 void hangar_content_editor(int windowID)
 {
     GUILayout.BeginVertical();
     GUILayout.BeginHorizontal();
     //Vessel selector
     if(GUILayout.Button("Select Vessel", Styles.normal_button, GUILayout.ExpandWidth(true)))
         vessel_selector =
             new CraftBrowser(new Rect(eWindowPos) { height = 500 },
                 facility,
                 HighLogic.SaveFolder, "Select a ship to store",
                 vessel_selected,
                 selection_canceled,
                 HighLogic.Skin,
                 EditorLogic.ShipFileImage, true);
     GUILayout.EndHorizontal();
     //hangar info
     if(ConnectedStorage.Count > 1)
         HangarGUI.UsedVolumeLabel(TotalUsedVolume, TotalUsedVolumeFrac, "Total Used Volume");
     HangarGUI.UsedVolumeLabel(UsedVolume, UsedVolumeFrac);
     //hangar contents
     var constructs = Storage.GetConstructs();
     constructs.Sort((a, b) => a.name.CompareTo(b.name));
     constructs_scroll = GUILayout.BeginScrollView(constructs_scroll, GUILayout.Height(200), GUILayout.Width(windows_width));
     GUILayout.BeginVertical();
     foreach(PackedConstruct pc in constructs)
     {
         GUILayout.BeginHorizontal();
         HangarGUI.PackedVesselLabel(pc);
         if(GUILayout.Button("+1", Styles.green_button, GUILayout.Width(25)))
             try_store_vessel(pc.Clone());
         if(GUILayout.Button("X", Styles.red_button, GUILayout.Width(25)))
             Storage.RemoveVessel(pc);
         GUILayout.EndHorizontal();
     }
     GUILayout.EndVertical();
     GUILayout.EndScrollView();
     //unfit constructs
     constructs = Storage.UnfitConstucts;
     if(constructs.Count > 0)
     {
         GUILayout.Label("Unfit vessels:", Styles.yellow, GUILayout.ExpandWidth(true));
         unfit_scroll = GUILayout.BeginScrollView(unfit_scroll, GUILayout.Height(100), GUILayout.Width(windows_width));
         GUILayout.BeginVertical();
         foreach(PackedConstruct pc in Storage.UnfitConstucts)
         {
             GUILayout.BeginHorizontal();
             HangarGUI.PackedVesselLabel(pc);
             if(GUILayout.Button("^", Styles.green_button, GUILayout.Width(25)))
             { if(try_store_vessel(pc.Clone())) Storage.RemoveUnfit(pc); }
             if(GUILayout.Button("X", Styles.red_button, GUILayout.Width(25)))
                 Storage.RemoveUnfit(pc);
             GUILayout.EndHorizontal();
         }
         GUILayout.EndVertical();
         GUILayout.EndScrollView();
     }
     //common buttons
     if(GUILayout.Button("Clear", Styles.red_button, GUILayout.ExpandWidth(true)))
         Storage.ClearConstructs();
     if(GUILayout.Button("Close", Styles.normal_button, GUILayout.ExpandWidth(true)))
     {
         Utils.LockEditor(eLock, false);
         selected_window[EditorWindows.EditContent] = false;
     }
     GUILayout.EndVertical();
     GUI.DragWindow(new Rect(0, 0, Screen.width, 20));
 }
        void SelectCraft()
        {
            GUILayout.BeginHorizontal ("box");
            GUILayout.FlexibleSpace ();
            // VAB / SPH selection
            for (var t = ExLaunchPad.CraftType.VAB;
                 t <= ExLaunchPad.CraftType.SubAss;
                 t++) {
                if (GUILayout.Toggle (pad.craftType == t, t.ToString (),
                                      GUILayout.Width (80))) {
                    pad.craftType = t;
                }
            }
            GUILayout.FlexibleSpace ();
            GUILayout.EndHorizontal ();

            string strpath = HighLogic.SaveFolder;

            GUILayout.BeginHorizontal ();
            if (GUILayout.Button ("Select Craft", Styles.normal,
                                  GUILayout.ExpandWidth (true))) {
                string []dir = new string[] {"VAB", "SPH", "../Subassemblies"};
                var diff = HighLogic.CurrentGame.Parameters.Difficulty;
                bool stock = diff.AllowStockVessels;
                if (pad.craftType == ExLaunchPad.CraftType.SubAss) {
                    diff.AllowStockVessels = false;
                }
                //GUILayout.Button is "true" when clicked
                var clrect = new Rect (Screen.width / 2, 100, 350, 500);
                craftlist = new CraftBrowser (clrect, dir[(int)pad.craftType],
                                              strpath, "Select a ship to load",
                                              craftSelectComplete,
                                              craftSelectCancel,
                                              HighLogic.Skin,
                                              EditorLogic.ShipFileImage, true);
                diff.AllowStockVessels = stock;
            }
            GUI.enabled = pad.craftConfig != null;
            if (GUILayout.Button ("Clear", Styles.normal,
                                  GUILayout.ExpandWidth (false))) {
                pad.UnloadCraft ();
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal ();
        }
 private void craftSelectCancel()
 {
     craftlist = null;
 }
        private void craftSelectComplete(string filename, string flagname,
										  CraftBrowser.LoadType lt)
        {
            craftlist = null;
            control.LoadCraft (filename, flagname);
        }
        // GUI FUNCTIONS
        void CraftSelectionArea()
        {
            GUILayout.BeginVertical();

            if (GUILayout.Button("Select Blueprint", HighLogic.Skin.button, GUILayout.ExpandWidth(true)))
            {
                Rect craftPos = new Rect(m_WindowPosition.xMin + m_WindowPosition.width, m_WindowPosition.yMin, 350, 500);
                m_CraftList = new CraftBrowser(craftPos, EditorFacility.VAB, HighLogic.SaveFolder, "Select Blueprint", SelectedCraft, CancelledCraftSelection, HighLogic.Skin, null, false, false);

                if(m_BuildCraftList != null)
                {
                    m_BuildCraftList.Invoke(m_CraftList, null);
                }
            }

            if(m_Vessel.HasVessel())
            {
                GUILayout.Label("Selected Vehicle: " + m_Vessel.GetName(), HighLogic.Skin.label);
            }

            GUILayout.EndVertical();
        }
 private void craftSelectCancel()
 {
     craftlist = null;
 }
 private void craftSelectComplete(string filename, string flagname)
 {
     craftlist = null;
     pad.LoadCraft(filename, flagname);
 }
Пример #15
0
 private void craftSelectComplete(string filename, string flagname,
                                  CraftBrowser.LoadType lt)
 {
     craftlist = null;
     control.LoadCraft(filename, flagname);
 }
Пример #16
0
        void SelectCraft()
        {
            GUILayout.BeginHorizontal("box");
            GUILayout.FlexibleSpace();
            // VAB / SPH / Subassembly selection
            ExBuildControl.CraftType maxType = ExBuildControl.CraftType.SubAss;
            if (buildCraftList == null)
            {
                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
                var       clrect   = new Rect(Screen.width / 2, 100, 350, 500);
                Texture2D fileicon = Instantiate(AssetBase.GetTexture("craftThumbGeneric")) as Texture2D;
                craftlist = new CraftBrowser(clrect, facility[(int)control.craftType],
                                             strpath,
                                             "Select a ship to load",
                                             craftSelectComplete,
                                             craftSelectCancel,
                                             HighLogic.Skin,
                                             fileicon, true,
                                             false);
                if (buildCraftList != null &&
                    control.craftType == ExBuildControl.CraftType.SubAss)
                {
                    craftlist.craftSubfolder = "../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();
        }
Пример #17
0
 public void OnShipLoad(ShipConstruct ship ,CraftBrowser.LoadType loadType)
 {
     DetachedPartReset.Start(); //start timer so it fires even if no parts load
     if (loadType == CraftBrowser.LoadType.Normal)
     {
         //Debug.Log("OnShipLoadFire!");
         disablePartAttaching = true; //disable symmetric action loading
         DetachedPartActions.Clear(); //onPartAttach fires before this point, need to get rid of the actions that adds to this list.
         StaticData.CurrentVesselActions.Clear();
         //EditorLoadFromFile();
         EditorLoadFromNode();
         //Debug.Log("AGX Ship Load of type NORMAL detected");
     }
     else
     {
         //Debug.Log("AGX Ship Load of type MERGE detected");
         //foreach (Part p in ship.parts)
         //{
         //    ModuleAGX agxPM = p.Modules.OfType<ModuleAGX>().First();
         //    foreach (AGXAction agAct in agxPM.agxActionsThisPart)
         //    {
         //        if (!CurrentVesselActions.Contains(agAct))
         //        {
         //            CurrentVesselActions.Add(agAct);
         //            if (AGXguiNames[agAct.group].Length == 0)
         //            {
         //                AGXguiNames[agAct.group] = agAct.grpName;
         //            }
         //        }
         //    }
         //}
     }
 }
 public void CancelledCraftSelection()
 {
     m_CraftList = null;
 }
Пример #19
0
 void OnCancelled()
 {
     craftBrowser = null;
     openingCraftBrowser = false;
 }
 // GUI CALLBACKS
 public void SelectedCraft(string fullPath, string flagURL, CraftBrowser.LoadType t)
 {
     m_CraftList = null;
     m_Vessel.Load(fullPath, flagURL);
 }
Пример #21
0
 void OnSelected(string fullPath, string flagUrl, CraftBrowser.LoadType loadType)
 {
     StartCoroutine(SpawnCraftRoutine(fullPath));
     craftBrowser = null;
     openingCraftBrowser = false;
     choosingPosition = true;
 }
 public void HookLoad(ShipConstruct SC, CraftBrowser.LoadType LT)
 {
     if (null != EditorLogic.RootPart)
     {
         DeactivateHighlight(EditorLogic.RootPart);
         HighlighterHook(EditorLogic.RootPart);
     }
 }
Пример #23
0
        IEnumerator StartVesselSpawnRoutine()
        {
            openingCraftBrowser = true;

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

            craftBrowser = new CraftBrowser(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);
        }
        void SelectCraft()
        {
            GUILayout.BeginHorizontal ("box");
            GUILayout.FlexibleSpace ();
            // VAB / SPH / Subassembly selection
            ExBuildControl.CraftType maxType = ExBuildControl.CraftType.SubAss;
            if (buildCraftList == null) {
                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
                var clrect = new Rect (Screen.width / 2, 100, 350, 500);
                Texture2D fileicon = Instantiate(AssetBase.GetTexture("craftThumbGeneric")) as Texture2D;
                craftlist = new CraftBrowser (clrect, facility[(int)control.craftType],
                                              strpath,
                                              "Select a ship to load",
                                              craftSelectComplete,
                                              craftSelectCancel,
                                              HighLogic.Skin,
                                              fileicon, true,
                                              false);
                if (buildCraftList != null
                    && control.craftType == ExBuildControl.CraftType.SubAss) {
                    craftlist.craftSubfolder = "../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 ();
        }
Пример #25
0
 private void OnEditorLoad(ShipConstruct s, CraftBrowser.LoadType t)
 {
     OnEditorShipModified (s);
     Logger.Log ("OnEditorLoad called", Logger.Level.Debug);
 }
 private void craftSelectComplete(string filename, string flagname)
 {
     craftlist = null;
     pad.LoadCraft (filename, flagname);
 }
Пример #27
0
 void vessel_selected(string filename, string flagname)
 {
     EditorLogic EL = EditorLogic.fetch;
     if(EL == null) return;
     //load vessel config
     vessel_selector = null;
     var pc = new PackedConstruct(filename, flagname);
     if(pc.construct == null)
     {
         Utils.Log("PackedConstruct: unable to load ShipConstruct from {0}. " +
             "This usually means that some parts are missing " +
             "or some modules failed to initialize.", filename);
         ScreenMessager.showMessage("Unable to load {0}", filename);
         return;
     }
     //check if the construct contains launch clamps
     if(Utils.HasLaunchClamp(pc.construct))
     {
         ScreenMessager.showMessage("\"{0}\" has launch clamps. Remove them before storing.", pc.name);
         pc.UnloadConstruct();
         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(pc.construct));
     preFlightCheck.RunTests();
     //cleanup loaded parts and try to store construct
     if(cant_launch) pc.UnloadConstruct();
     else StartCoroutine(delayed_try_store_construct(pc));
 }
Пример #28
0
        void hangar_content_editor(int windowID)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            //VAB / SPH / SubAss selection
            GUILayout.FlexibleSpace();
            for (var T = VesselType.VAB; T <= VesselType.SubAssembly; T++)
            {
                if (GUILayout.Toggle(vessel_type == T, T.ToString(), GUILayout.Width(100)))
                {
                    vessel_type = T;
                }
            }
            GUILayout.FlexibleSpace();
            //Vessel selector
            if (GUILayout.Button("Select Vessel", Styles.normal_button, GUILayout.ExpandWidth(true)))
            {
                Rect sWindowPos = new Rect(eWindowPos)
                {
                    height = 500
                };
                var  diff  = HighLogic.CurrentGame.Parameters.Difficulty;
                bool stock = diff.AllowStockVessels;
                if (vessel_type == VesselType.SubAssembly)
                {
                    diff.AllowStockVessels = false;
                }
                vessel_selector =
                    new CraftBrowser(sWindowPos,
                                     vessel_dirs[(int)vessel_type],
                                     HighLogic.SaveFolder, "Select a ship to store",
                                     vessel_selected,
                                     selection_canceled,
                                     HighLogic.Skin,
                                     EditorLogic.ShipFileImage, true);
                diff.AllowStockVessels = stock;
            }
            GUILayout.EndHorizontal();
            //hangar info
            float used_frac = used_volume / hangar_metric.volume;

            GUILayout.Label(string.Format("Used Volume: {0}   {1:F1}%",
                                          Utils.formatVolume(used_volume), used_frac * 100f),
                            Styles.fracStyle(1 - used_frac), GUILayout.ExpandWidth(true));
            //hangar contents
            List <PackedConstruct> constructs = packed_constructs.Values;

            constructs.Sort((a, b) => a.name.CompareTo(b.name));
            scroll_view = GUILayout.BeginScrollView(scroll_view, GUILayout.Height(200), GUILayout.Width(400));
            GUILayout.BeginVertical();
            foreach (PackedConstruct pc in constructs)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Format("{0}: {1}   Cost: {2:F1}",
                                              pc.name, Utils.formatMass(pc.metric.mass), pc.metric.cost),
                                Styles.label, GUILayout.ExpandWidth(true));
                if (GUILayout.Button("X", Styles.red_button, GUILayout.Width(25)))
                {
                    remove_construct(pc);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
            if (GUILayout.Button("Clear", Styles.red_button, GUILayout.ExpandWidth(true)))
            {
                clear_constructs();
            }
            if (GUILayout.Button("Close", Styles.normal_button, GUILayout.ExpandWidth(true)))
            {
                Utils.LockIfMouseOver(eLock, eWindowPos, false);
                editing_hangar = false;
            }
            GUILayout.EndVertical();
            GUI.DragWindow(new Rect(0, 0, 500, 20));
        }
Пример #29
0
 void OnCancelled()
 {
     craftBrowser        = null;
     openingCraftBrowser = false;
 }
Пример #30
0
 void selection_canceled()
 {
     vessel_selector = null;
 }
Пример #31
0
 void hangar_content_editor(int windowID)
 {
     GUILayout.BeginVertical();
     GUILayout.BeginHorizontal();
     //VAB / SPH / SubAss selection
     GUILayout.FlexibleSpace();
     for(var T = VesselType.VAB; T <= VesselType.SubAssembly; T++)
     { if(GUILayout.Toggle(vessel_type == T, T.ToString(), GUILayout.Width(100))) vessel_type = T; }
     GUILayout.FlexibleSpace();
     //Vessel selector
     if(GUILayout.Button("Select Vessel", Styles.normal_button, GUILayout.ExpandWidth(true)))
     {
         Rect sWindowPos  = new Rect(eWindowPos) { height = 500 };
         var  diff  = HighLogic.CurrentGame.Parameters.Difficulty;
         bool stock = diff.AllowStockVessels;
         if(vessel_type == VesselType.SubAssembly) diff.AllowStockVessels = false;
         vessel_selector =
             new CraftBrowser(sWindowPos,
                              vessel_dirs[(int)vessel_type],
                              HighLogic.SaveFolder, "Select a ship to store",
                              vessel_selected,
                              selection_canceled,
                              HighLogic.Skin,
                              EditorLogic.ShipFileImage, true);
         diff.AllowStockVessels = stock;
     }
     GUILayout.EndHorizontal();
     //hangar info
     float used_frac = used_volume/hangar_metric.volume;
     GUILayout.Label(string.Format("Used Volume: {0}   {1:F1}%",
                                   Utils.formatVolume(used_volume), used_frac*100f),
                     Styles.fracStyle(1-used_frac), GUILayout.ExpandWidth(true));
     //hangar contents
     List<PackedConstruct> constructs = packed_constructs.Values;
     constructs.Sort((a, b) => a.name.CompareTo(b.name));
     scroll_view = GUILayout.BeginScrollView(scroll_view, GUILayout.Height(200), GUILayout.Width(400));
     GUILayout.BeginVertical();
     foreach(PackedConstruct pc in constructs)
     {
         GUILayout.BeginHorizontal();
         GUILayout.Label(string.Format("{0}: {1}   Cost: {2:F1}",
                                       pc.name, Utils.formatMass(pc.metric.mass), pc.metric.cost),
                         Styles.label, GUILayout.ExpandWidth(true));
         if(GUILayout.Button("X", Styles.red_button, GUILayout.Width(25))) remove_construct(pc);
         GUILayout.EndHorizontal();
     }
     GUILayout.EndVertical();
     GUILayout.EndScrollView();
     if(GUILayout.Button("Clear", Styles.red_button, GUILayout.ExpandWidth(true))) clear_constructs();
     if(GUILayout.Button("Close", Styles.normal_button, GUILayout.ExpandWidth(true)))
     {
         Utils.LockIfMouseOver(eLock, eWindowPos, false);
         editing_hangar = false;
     }
     GUILayout.EndVertical();
     GUI.DragWindow(new Rect(0, 0, 500, 20));
 }
Пример #32
0
 void selection_canceled()
 {
     vessel_selector = null;
 }
Пример #33
0
 /// <summary>
 /// Set up to fix default crew assignment when user loads ship. (Callback)
 /// </summary>
 /// <param name="ship">The ship just loaded</param>
 /// <param name="type">How the ship was inserted</param>
 protected void OnEditorLoad(ShipConstruct ship, CraftBrowser.LoadType type)
 {
     try {
         if( type == CraftBrowser.LoadType.Normal && loadBtnPressed ) {
             // Unfortunately, the crew roster isn't set up yet here, so we
             // have to delay fixing the default assignment until either the
             // user opens the crew assignment tab, or they launch the craft.
             fixDefaultAssignment = true;
             loadBtnPressed = false;
         }
     }
     catch( Exception e ) {
         Debug.LogError("KerbalSorter: Unexpected error in EditorHook: " + e);
     }
 }
 private void ResetEditorEvent(ShipConstruct construct, CraftBrowser.LoadType type)
 {
     ResetEditor();
 }
Пример #35
0
 public void onEditorLoad(ShipConstruct ship, CraftBrowser.LoadType type)
 {
     KerbalGUIManager.print("[rusty] onEditorLoad");
 }