Пример #1
0
        //select craft in crafts list by it's ID and adjust the scroll to focus on the selected craft
        protected void jump_to_craft(int index)
        {
            GUIUtility.keyboardControl = 0;
            if (index < 0)
            {
                index = 0;
            }
            else if (index > CraftData.filtered.Count - 1)
            {
                index = CraftData.filtered.Count - 1;
            }
            CraftData craft = CraftData.filtered[index];

            if (craft != null)
            {
                CraftData.select_craft(craft);
                if (craft.list_position < scroll_pos["main"].y)
                {
                    scroll_pos["main"] = new Vector2(scroll_pos["main"].x, craft.list_position);
                }
                else if (craft.list_position + craft.list_height > scroll_pos["main"].y + main_section_height)
                {
                    scroll_pos["main"] = new Vector2(scroll_pos["main"].x, craft.list_position - main_section_height + craft.list_height + 5);
                }
            }
        }
Пример #2
0
 public static void toggle_selected(CraftData craft)
 {
     if (craft.selected)
     {
         craft.selected = false;
     }
     else
     {
         CraftData.select_craft(craft);
     }
 }
        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);
                });
            }
        }
Пример #4
0
 internal static void restore_previously_selected()
 {
     CraftData.deselect_all();
     foreach (string path in previously_selected)
     {
         CraftData craft = CraftData.all_craft.Find(c => c.path == path);
         if (craft != null)
         {
             craft.group_selected = true;
         }
     }
     if (active_craft.Count == 1)
     {
         CraftData.select_craft(active_craft[0]);
     }
 }
Пример #5
0
 public static void toggle_group_select(CraftData craft)
 {
     if (active_craft.Count == 0 || (active_craft.Count == 1 && active_craft[0] == craft))
     {
         toggle_selected(craft);
     }
     else
     {
         if (craft.group_selected)
         {
             craft.group_selected = false;
         }
         else
         {
             CraftData.group_select(craft);
         }
     }
     if (active_craft.Count == 1)
     {
         CraftData.select_craft(active_craft[0]);
     }
 }
Пример #6
0
        private void get_current_craft(bool allow_retry = true)
        {
            CraftData craft = CraftData.all_craft.Find(c =>
                                                       c.save_dir == CraftManager.main_ui.current_save_dir && c.construction_type == EditorDriver.editorFacility.ToString() && c.name == EditorLogic.fetch.ship.shipName
                                                       );

            if (craft != null)
            {
                CraftData.select_craft(craft);
            }
            else
            {
                if (allow_retry)
                {
                    refresh();
                    get_current_craft(false);
                }
                else
                {
                    CraftData.deselect_all();
                }
            }
            last_editor_craft_name = EditorLogic.fetch.ship.shipName;
        }