void OnWindow(int windowID)
        {
            GUILayout.BeginVertical( GUILayout.Width(225));

            if (Settings.cfgLoaded) //If the cfg file exists
            {
                if (checklistSelected) //If the checklist is selected
                {
                    if (!selectionInProgress) //If the mode, where the checked parts are set, is active
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Current checklist:");
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(checklistSystem.ActiveChecklist.name, labelStyle);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginVertical(boxStyle);
                        for (int i = 0; i < checklistSystem.ActiveChecklist.items.Count; i++)
                        {
                            ChecklistItem tempItem = checklistSystem.ActiveChecklist.items[i];
                            tempItem.DrawItem();
                            checklistSystem.ActiveChecklist.items[i] = tempItem;
                        }
                        if (Settings.jebEnabled == true)
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("MOAR BOOSTERS!!!", labelStyle); //small joke :P
                            GUILayout.FlexibleSpace();
                            GUILayout.Toggle(false, "", ChecklistItem.checkboxStyle);
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.EndVertical();

                        if (GUILayout.Button("Change checklist", buttonStyle, GUILayout.Height(24f)))
                        {
                            mainWindow.height = 0f;
                            checklistSelected = false;
                        }

                        //-------------------------------------------------------------------------------------------
                        //⇓︾▼↓︽
                        if (showAdvanced) //Advanced options showed
                        {
                            if (!showSettings)
                            {
                                if (GUILayout.Button("Show settings", buttonStyle, GUILayout.Height(24f)))
                                {
                                    mainWindow.height = 0f;
                                    showSettings = true;
                                    if (activeToolbar == toolbarType.BLIZZY)
                                        settings_BlizzyToolbar = true;
                                    else
                                        settings_BlizzyToolbar = false;
                                    settings_CheckCrew = Settings.checkCrewAssignment;
                                    settings_LockWindow = Settings.lockOnHover;
                                }
                            }

                            if (GUILayout.Button(new GUIContent("Recheck vessel", "Use this if the automatic checking doesn't work for some reason"), buttonStyle,GUILayout.Height(24f)))
                                checklistSystem.CheckVessel();

                            GUILayout.Label("Checked area:", labelStyle);
                            if (GUILayout.Toggle(!checkSelected, new GUIContent("Entire ship", "Check the entire ship"), toggleStyle) != !checkSelected)
                            {
                                checkSelected = false;
                                checklistSystem.CheckVessel();
                                mainWindow.height = 0f;
                            }
                            if (GUILayout.Toggle(checkSelected, new GUIContent(partSelection == null || EditorLogic.RootPart == null ? "Selected parts (0)" : "Selected parts (" + partSelection.selectedParts.Intersect(EditorLogic.fetch.ship.parts).ToList().Count + ")", "Check only a selected section of the ship (e.g. lander/booster stage)"), toggleStyle) == !checkSelected)
                            {
                                checkSelected = true;
                                checklistSystem.CheckVessel();
                            }

                            if (checkSelected && EditorLogic.RootPart != null)
                            {
                                if (GUILayout.Button(new GUIContent("Select parts", "Select the checked parts"), buttonStyle, GUILayout.Height(24f)))
                                {
                                    mainWindow.height = 0f;
                                    print("[WernherChecker]: Engaging selection mode");
                                    foreach (Part part in VesselParts)
                                    {
                                        part.SetHighlightDefault();
                                    }
                                    partSelection = new PartSelection();
                                    selectionInProgress = true;
                                    selectedShowed = false;
                                    InputLockManager.SetControlLock(ControlTypes.EDITOR_PAD_PICK_PLACE | ControlTypes.EDITOR_UI, "WernherChecker_partSelection");
                                }

                                if (!selectedShowed)
                                {
                                    if (GUILayout.Button(new GUIContent("Highlight selected parts", "Highlight the parts selected for checking"), buttonStyle, GUILayout.Height(24f)))
                                    {
                                        if (partSelection != null)
                                        {
                                            foreach (Part part in partSelection.selectedParts)
                                            {
                                                if (WernherChecker.VesselParts.Contains(part))
                                                {
                                                    part.SetHighlightType(Part.HighlightType.AlwaysOn);
                                                    part.SetHighlightColor(new Color(10f, 0.9f, 0f));
                                                }
                                            }
                                        }
                                        selectedShowed = true;
                                    }
                                }
                                else
                                {
                                    if (GUILayout.Button("Hide selected parts", buttonStyle, GUILayout.Height(24f)))
                                    {
                                        /*float max, min;
                                        GUI.skin.label.CalcMinMaxWidth(new GUIContent("Thisisthecontentasdsdfsdfsd"), out min, out max);
                                        Debug.Log("Min: " + min + ", Max: " + max);*/
                                        foreach (Part part in WernherChecker.VesselParts)
                                        {
                                            part.SetHighlightDefault();
                                        }
                                        selectedShowed = false;
                                    }
                                }
                            }

                        }

                        if (GUILayout.Button(new GUIContent(showAdvanced ? "︽ Fewer Options ︽" : "︾ More Options ︾", "Show/Hide advanced options"), buttonStyle, GUILayout.Height(24f)))
                        {
                            mainWindow.height = 0f;
                            showAdvanced = !showAdvanced;
                        }
                    }
                    else
                    {
                        GUILayout.Label("Select parts to check by holding LMB and moving mouse", labelStyle);
                        GUILayout.Label("Current selection: " + partSelection.selectedParts.Count + " part(s)");
                        if (GUILayout.Button(new GUIContent("Done", "Finish part selection"), buttonStyle))
                        {
                            mainWindow.height = 0f;
                            print("[WernherChecker]: " + partSelection.selectedParts.Count + " parts selected");
                            foreach (Part part in WernherChecker.VesselParts)
                            {
                                part.SetHighlightDefault();
                            }
                            selectionInProgress = false;
                            InputLockManager.RemoveControlLock("WernherChecker_partSelection");
                            checklistSystem.CheckVessel();
                        }
                    }
                }
                else
                {
                    GUILayout.Label("Please select checklist", labelStyle);
                    SelectChecklist();
                }
            }

            else
            {
                GUILayout.Label("Cannot find config file!", labelStyle);
            }

            GUILayout.EndVertical();
            GUI.DragWindow(); //making it dragable
            SetTooltipText();
        }
Ejemplo n.º 2
0
        void OnWindow(int windowID)
        {
            GUILayout.BeginVertical(GUILayout.Width(225));

            if (Settings.cfgLoaded)           //If the cfg file exists
            {
                if (checklistSelected)        //If the checklist is selected
                {
                    if (!selectionInProgress) //If the mode, where the checked parts are set, is active
                    {
                        if (checklistSystem.ActiveChecklist.items.Count > SCROLL_GREATER)
                        {
                            scrollPos = GUILayout.BeginScrollView(scrollPos, false, false, GUILayout.Height(500)); //  , GUILayout.Width((panelWidth + 3)));
                        }
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Current checklist:");
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(checklistSystem.ActiveChecklist.name, labelStyle);
                        GUILayout.EndHorizontal();

                        GUILayout.BeginVertical(boxStyle);
                        for (int i = 0; i < checklistSystem.ActiveChecklist.items.Count; i++)
                        {
                            ChecklistItem tempItem = checklistSystem.ActiveChecklist.items[i];
                            if (tempItem.editorOnly && HighLogic.LoadedScene != GameScenes.EDITOR ||
                                tempItem.flightOnly && HighLogic.LoadedScene != GameScenes.FLIGHT)
                            {
                                continue;
                            }
                            tempItem.DrawItem();
                            checklistSystem.ActiveChecklist.items[i] = tempItem;
                        }
                        if (Settings.jebEnabled == true)
                        {
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("MOAR BOOSTERS!!!", labelStyle); //small joke :P
                            GUILayout.FlexibleSpace();
                            GUILayout.Toggle(false, "", ChecklistItem.checkboxStyle);
                            GUILayout.EndHorizontal();
                        }
                        GUILayout.EndVertical();
                        if (checklistSystem.ActiveChecklist.items.Count > SCROLL_GREATER)
                        {
                            GUILayout.EndScrollView();
                        }

                        if (GUILayout.Button("Change checklist", buttonStyle, GUILayout.Height(24f)))
                        {
                            mainWindow.height = 0f;
                            checklistSelected = false;
                        }

                        //-------------------------------------------------------------------------------------------
                        //

                        if (HighLogic.LoadedScene == GameScenes.FLIGHT)
                        {
                            checkSelected = false;
                            checklistSystem.CheckVessel();
                        }

                        if (showAdvanced && HighLogic.LoadedScene == GameScenes.EDITOR) //Advanced options showed
                        {
                            if (GUILayout.Button(new GUIContent("Recheck vessel", "Use this if the automatic checking doesn't work for some reason"), buttonStyle, GUILayout.Height(24f)))
                            {
                                checklistSystem.CheckVessel();
                            }


                            {
                                GUILayout.Label("Checked area:", labelStyle);
                                if (GUILayout.Toggle(!checkSelected, new GUIContent("Entire ship", "Check the entire ship"), toggleStyle) != !checkSelected)
                                {
                                    checkSelected = false;
                                    checklistSystem.CheckVessel();
                                    mainWindow.height = 0f;
                                }
                                if (GUILayout.Toggle(checkSelected, new GUIContent(partSelection == null || EditorLogic.RootPart == null ? "Selected parts (0)" : "Selected parts (" + partSelection.selectedParts.Intersect(EditorLogic.fetch.ship.parts).ToList().Count + ")", "Check only a selected section of the ship (e.g. lander/booster stage)"), toggleStyle) == !checkSelected)
                                {
                                    checkSelected = true;
                                    checklistSystem.CheckVessel();
                                }
                            }
                            if (checkSelected && EditorLogic.RootPart != null)
                            {
                                if (GUILayout.Button(new GUIContent("Select parts", "Select the checked parts"), buttonStyle, GUILayout.Height(24f)))
                                {
                                    mainWindow.height = 0f;
                                    print("[WernherChecker]: Engaging selection mode");
                                    foreach (Part part in VesselParts)
                                    {
                                        part.SetHighlightDefault();
                                    }
                                    partSelection       = new PartSelection();
                                    selectionInProgress = true;
                                    selectedShowed      = false;
                                    if (HighLogic.LoadedScene == GameScenes.EDITOR)
                                    {
                                        InputLockManager.SetControlLock(ControlTypes.EDITOR_PAD_PICK_PLACE | ControlTypes.EDITOR_UI, "WernherChecker_partSelection");
                                    }
                                }

                                if (!selectedShowed)
                                {
                                    if (GUILayout.Button(new GUIContent("Highlight selected parts", "Highlight the parts selected for checking"), buttonStyle, GUILayout.Height(24f)))
                                    {
                                        if (partSelection != null)
                                        {
                                            foreach (Part part in partSelection.selectedParts)
                                            {
                                                if (WernherChecker.VesselParts.Contains(part))
                                                {
                                                    part.SetHighlightType(Part.HighlightType.AlwaysOn);
                                                    part.SetHighlightColor(new Color(10f, 0.9f, 0f));
                                                }
                                            }
                                        }
                                        selectedShowed = true;
                                    }
                                }
                                else
                                {
                                    if (GUILayout.Button("Hide selected parts", buttonStyle, GUILayout.Height(24f)))
                                    {
                                        /*float max, min;
                                         * GUI.skin.label.CalcMinMaxWidth(new GUIContent("Thisisthecontentasdsdfsdfsd"), out min, out max);
                                         * Log.Info("Min: " + min + ", Max: " + max);*/
                                        foreach (Part part in WernherChecker.VesselParts)
                                        {
                                            part.SetHighlightDefault();
                                        }
                                        selectedShowed = false;
                                    }
                                }
                            }
                        }
                        if (HighLogic.LoadedScene == GameScenes.EDITOR)
                        {
                            if (GUILayout.Button(new GUIContent(showAdvanced ? "︽ Fewer Options ︽" : "︾ More Options ︾", "Show/Hide advanced options"), buttonStyle, GUILayout.Height(24f)))
                            {
                                mainWindow.height = 0f;
                                showAdvanced      = !showAdvanced;
                            }
                        }
                    }
                    else
                    {
                        GUILayout.Label("Select parts to check by holding LMB and moving mouse", labelStyle);
                        GUILayout.Label("Current selection: " + partSelection.selectedParts.Count + " part(s)");
                        if (GUILayout.Button(new GUIContent("Done", "Finish part selection"), buttonStyle))
                        {
                            mainWindow.height = 0f;
                            print("[WernherChecker]: " + partSelection.selectedParts.Count + " parts selected");
                            foreach (Part part in WernherChecker.VesselParts)
                            {
                                part.SetHighlightDefault();
                            }
                            selectionInProgress = false;
                            if (HighLogic.LoadedScene == GameScenes.EDITOR)
                            {
                                InputLockManager.RemoveControlLock("WernherChecker_partSelection");
                            }
                            checklistSystem.CheckVessel();
                        }
                    }
                }
                else
                {
                    GUILayout.Label("Please select checklist", labelStyle);
                    SelectChecklist();
                }
            }

            else
            {
                GUILayout.Label("Cannot find config file!", labelStyle);
            }

            GUILayout.EndVertical();
            GUI.DragWindow(); //making it dragable
            SetTooltipText();
        }