Пример #1
0
        private void DrawBlacklistGUI(int windowID)
        {
            GUILayout.BeginVertical();
            scrollPos = GUILayout.BeginScrollView(scrollPos, HighLogic.Skin.textArea, GUILayout.Height(Screen.height / 4));
            foreach (string s in Settings.Instance.BlackList.ignore)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(s);
                if (GUILayout.Button("Remove", GUILayout.ExpandWidth(false)))
                {
                    Settings.Instance.BlackList.Remove(s);
                    break;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUILayout.BeginHorizontal();
            tempListItem = GUILayout.TextField(tempListItem);
            if (GUILayout.Button("Add", GUILayout.ExpandWidth(false)))
            {
                Settings.Instance.BlackList.Add(tempListItem);
                tempListItem = "";
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Save"))
            {
                Settings.Instance.BlackList.Save();
                showBlacklist = false;
            }
            if (GUILayout.Button("Cancel"))
            {
                Settings.Instance.BlackList.Load();
                showBlacklist = false;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
            {
                GUI.DragWindow();
            }
        }
Пример #2
0
        private void CrewSelectionWindow(int windowID)
        {
            KerbalRoster kerbalRoster = HighLogic.CurrentGame.CrewRoster;

            GUILayout.BeginVertical();
            _displayViewerPosition = GUILayout.BeginScrollView(_displayViewerPosition, GUI.skin.box, GUILayout.Height(250), GUILayout.Width(280));
            IEnumerator <ProtoCrewMember> kerbals = kerbalRoster.Kerbals(ProtoCrewMember.RosterStatus.Available).GetEnumerator();

            while (kerbals.MoveNext())
            {
                ProtoCrewMember crewMember = kerbals.Current;
                if (crewMember == null)
                {
                    continue;
                }
                bool     selected    = SelectedCrewMembers.Contains(crewMember);
                GUIStyle buttonStyle = selected ? ButtonToggledStyle : HighLogic.Skin.button;
                selected = GUILayout.Toggle(selected, $"{crewMember.name}, {crewMember.gender}, {crewMember.trait}", buttonStyle);
                if (selected && !SelectedCrewMembers.Contains(crewMember))
                {
                    SelectedCrewMembers.Clear();
                    SelectedCrewMembers.Add(crewMember);
                }
                else if (!selected && SelectedCrewMembers.Contains(crewMember))
                {
                    SelectedCrewMembers.Clear();
                }
            }
            kerbals.Dispose();
            GUILayout.EndScrollView();
            GUILayout.Space(20);
            if (GUILayout.Button("Select", HighLogic.Skin.button))
            {
                VesselSpawn.SelectedCrewData = SelectedCrewMembers;
                VesselSpawn.IsSelectingCrew  = false;
                VesselSpawn.IsCrewSelected   = true;
            }
            GUILayout.EndVertical();
        }
Пример #3
0
        public override void OnRender()
        {
            try
            {
                List <Part> parts = EditorLogic.fetch.ship != null ? EditorLogic.fetch.ship.Parts : new List <Part>();

                this.highlight.BeginTracking();

                GUILayout.BeginVertical();

#if false
                // If Blizzy's toolbar is available, give the user the option to pick the stock toolbar.
                if (ToolbarManager.ToolbarAvailable)
#endif
                {
                    //bool stockToolbar = PartWizardPlugin.ToolbarIsStock;
                    bool stockToolbar = GUILayout.Toggle(PartWizardPlugin.ToolbarIsStock, Localized.UseStockToolbar, GUILayout.Width(200));
                    if (stockToolbar != PartWizardPlugin.ToolbarIsStock)
                    {
#if false
                        PartWizardPlugin.ToolbarTypeToggleActive = true;
#endif
                        PartWizardPlugin.ToolbarIsStock = stockToolbar;
                        PartWizardPlugin.Instance.SaveToolbarConfiguration();
                    }
                }

                #region Display Mode Control

                GUILayout.BeginHorizontal();
                this.viewType = (ViewType)GUIControls.HorizontalToggleSet((int)this.viewType, this.viewTypeContents, this.selectedViewTypeStyle, this.unselectedViewTypeStyle);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Sort by:");
                this.sortBy = (SortBy)GUIControls.HorizontalToggleSet((int)this.sortBy, this.sortTypeContents, this.selectedViewTypeStyle, this.unselectedViewTypeStyle);
                GUILayout.EndHorizontal();

                List <Part> buyableParts = null;

                if (this.viewType == ViewType.Hidden)
                {
                    parts = parts.FindAll((p) => { return(p.partInfo.category == PartCategories.none); });
                }
                else if (this.viewType == ViewType.Unavailable)
                {
                    parts = parts.FindAll((p) => {
                        bool result = false;

                        // Get the R&D technology state for the current part.
                        ProtoTechNode techState = ResearchAndDevelopment.Instance.GetTechState(p.partInfo.TechRequired);

                        // If there is a state or the technology is locked or the part hasn't been purchased...
                        if (techState == null || techState.state != RDTech.State.Available || !techState.partsPurchased.Contains(p.partInfo))
                        {
                            // ...add it to the list.
                            result = true;
                        }

                        return(result);
                    });
                    Debug.Log("total # buyable part: " + parts.Count.ToString());
                    // Stash the filtered list in to the buyable list.
                    buyableParts = parts;
                    // Create a new collection with a copy of all the buyable parts.
                    parts = new List <Part>(buyableParts);
                    // Create a hash set to act as a filter for duplicate parts.
                    HashSet <string> duplicatePartFilter = new HashSet <string>();
                    // Remove each part that has already been added to the hash filter.
                    parts.RemoveAll((p) => !duplicatePartFilter.Add(p.name));

                    // Here parts is a list of unique buyable parts and buyableParts is all of the buyable parts, including duplicates.
                    Debug.Log("total # buyable part after dup filter: " + parts.Count.ToString());
                }

                #endregion
                if (parts != null && parts.Count > 0)
                {
                    switch (sortBy)
                    {
                    case SortBy.Name:
                        parts.Sort((p, q) => p.partInfo.title.CompareTo(q.partInfo.title));
                        break;

                    case SortBy.StageAsc:
                        if (this.viewType != ViewType.Unavailable)
                        {
                            parts.Sort((p, q) => p.inverseStage.CompareTo(q.inverseStage));
                        }
                        else
                        {
                            parts.Sort((p, q) => p.partInfo.title.CompareTo(q.partInfo.title));
                        }
                        break;

                    case SortBy.StageDesc:
                        if (this.viewType != ViewType.Unavailable)
                        {
                            parts.Sort((q, p) => p.inverseStage.CompareTo(q.inverseStage));
                        }
                        else
                        {
                            parts.Sort((p, q) => p.partInfo.title.CompareTo(q.partInfo.title));
                        }
                        break;
                    }
                }
                #region Part List

                GUILayout.BeginVertical(GUIControls.PanelStyle);

                this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, false, false);

                int totalEntryCost   = 0;
                int visiblePartCount = 0;
                int lastStage        = 0;
                if (parts != null && parts.Count > 0)
                {
                    lastStage = parts[0].inverseStage;
                }

                if (this.viewType == ViewType.Category)
                {
                    if (GUILayout.Button(Localized.ViewAll))
                    {
                        for (int i = 0; i < visibleCategories.Length; i++)
                        {
                            visibleCategories[i] = true;
                        }
                    }
                    if (GUILayout.Button(Localized.Clear))
                    {
                        for (int i = 0; i < visibleCategories.Length; i++)
                        {
                            visibleCategories[i] = false;
                        }
                    }

                    for (PartCategories partCategories = PartCategories.Propulsion; partCategories < PartCategories.Coupling; partCategories++)
                    {
                        // Need to add one to the PartCategories because "none" is a -1, and some parts have a category = none
                        visibleCategories[(int)partCategories + 1] = GUILayout.Toggle(visibleCategories[(int)partCategories + 1], partCategories.ToString(), toggleStyle);
                    }
                }
                else if (this.viewType == ViewType.Resources)
                {
                    if (GUILayout.Button(Localized.ViewAll))
                    {
                        foreach (ResourceInfo resourceInfo in this.availableResources.Values)
                        {
                            resourceInfo.Visible = true;
                        }
                    }

                    if (GUILayout.Button(Localized.Clear))
                    {
                        foreach (ResourceInfo resourceInfo in this.availableResources.Values)
                        {
                            resourceInfo.Visible = false;
                        }
                    }

                    foreach (string availableResource in this.availableResources.Keys)
                    {
                        bool resourceVisible = GUILayout.Toggle(this.availableResources[availableResource].Visible, availableResource, toggleStyle);

                        this.availableResources[availableResource].Visible = resourceVisible;
                    }
                }
                else
                {
                    foreach (Part part in parts)
                    {
                        // Reset part name label color to default; some conditions may change the color to indicate various things.
                        labelStyle.normal.textColor = PartWizardWindow.DefaultPartNameColor;
                        // Check if this part's category is currently visible.
                        // Need to add one to the PartCategories because "none" is a -1, and some parts have a category = none
                        if (visibleCategories[(int)part.partInfo.category + 1])
                        {
                            // The part's category is visible, now check resource conditions to determine final visibility.
                            bool partVisible = false;

                            if (this.availableResources[Localized.ShowPartsWithoutResources].Visible && part.Resources.Count == 0)
                            {
                                partVisible = true;
                            }
                            else
                            {
                                foreach (PartResource partResource in part.Resources)
                                {
                                    if (this.availableResources[partResource.resourceName].Visible)
                                    {
                                        partVisible = true;
                                        break;
                                    }
                                }
                            }
                            if (partVisible)
                            {
                                totalEntryCost += part.partInfo.entryCost;
                                visiblePartCount++;

                                GUIControls.BeginMouseOverHorizontal();

                                bool actionEditorPartButtonMouseOver = false;

                                #region Part Label

                                if (sortBy == SortBy.StageAsc || sortBy == SortBy.StageDesc)
                                {
                                    if (lastStage != part.inverseStage)
                                    {
                                        lastStage = part.inverseStage;
                                    }
                                    GUILayout.Label(lastStage.ToString() + ": ");
                                }
                                if (EditorLogic.fetch.editorScreen != EditorScreen.Actions)
                                {
                                    // Check compound parts for integrity.
                                    if (part is CompoundPart)
                                    {
                                        CompoundPart compoundPart = (CompoundPart)part;
                                        if (compoundPart.attachState == CompoundPart.AttachState.Detached || compoundPart.attachState == CompoundPart.AttachState.Attaching || compoundPart.target == compoundPart.parent)
                                        {
                                            labelStyle.normal.textColor = Color.red;
                                        }
                                    }
                                    labelStyle.fixedWidth = 250;
                                    GUILayout.Label(new GUIContent(part.partInfo.title, part.partInfo.name), labelStyle);
                                }
                                else
                                {
                                    Log.Write("EditorScreen.Actions, part: " + part.partInfo.title);
                                    if (GUIControls.MouseOverButton(new GUIContent(part.partInfo.title, part.partInfo.name), out actionEditorPartButtonMouseOver, this.actionEditorModePartButtonStyle))
                                    {
                                        // Each part gets the EditorActionPartSelector added to it when the editor switches to the Actions screen. (And it
                                        // gets taken away when leaving that screen.)
                                        EditorActionPartSelector selector = part.GetComponent <EditorActionPartSelector>();

                                        // Make sure we have it...
                                        if (selector != null)
                                        {
                                            // ...and select it.
                                            selector.Select();

                                            Log.Write("Action editor selecting part {0}.", part.name);
                                        }
                                    }
                                }

                                #endregion

                                // Adds space between the part name and the buttons (if any) associated with the part.
                                GUILayout.FlexibleSpace();

                                // Only enable the following buttons if there is no actively selected part, but we want to have them drawn.
                                GUI.enabled = EditorLogic.SelectedPart == null;

                                bool deleted = false;                   // Will be set to true if the delete button was pressed.
                                bool bought  = false;                   // Will be set to true if the buy button was pressed.

                                bool breakSymmetryMouseOver = false;    // Will be set to true if the mouse is over the part's break symmetry button.
                                bool deleteButtonMouseOver  = false;    // Will be set to true if the mouse is over the part's delete button.
                                bool buyButtonMouseOver     = false;    // Will be set to true if the mouse is over the part's buy button.

                                string deleteTooltip = default(string);
                                string buyTooltip    = default(string);

                                if (this.viewType == ViewType.All || this.viewType == ViewType.Hidden)
                                {
                                    #region Break Symmetry Button

                                    string breakabilityReport = default(string);
                                    GUI.enabled = EditorLogic.SelectedPart == null && EditorLogic.fetch.editorScreen == EditorScreen.Parts && PartWizard.HasBreakableSymmetry(part, out breakabilityReport);

                                    string breakSymmetryTooltip = GUI.enabled ? Localized.BreakSymmetryDescription : default(string);

                                    breakSymmetryMouseOver = false;
                                    if (GUIControls.MouseOverButton(new GUIContent(Localized.BreakSymmetryButtonText, breakSymmetryTooltip), out breakSymmetryMouseOver, Configuration.PartActionButtonWidth))
                                    {
                                        this.symmetryEditorWindow.Part = part;

                                        if (!this.symmetryEditorWindow.Visible)
                                        {
                                            this.symmetryEditorWindow.Show(this);

                                            // Short circuit the mouse over for breaking symmetry when showing the Symmetry Editor in case it appears over top of this
                                            // button and immediately begins highlighting parts. This would cause *this* window's highlighting to be stuck on the part.
                                            breakSymmetryMouseOver = false;
                                        }
                                    }

                                    breakSymmetryMouseOver &= GUI.enabled;  // Clear mouse over flag if the symmetry button was disabled.

                                    #endregion

                                    #region Delete Button

                                    GUI.enabled = EditorLogic.SelectedPart == null && EditorLogic.fetch.editorScreen == EditorScreen.Parts && PartWizard.IsDeleteable(part);

                                    deleteTooltip = GUI.enabled
                                        ? ((part.symmetryCounterparts.Count == 0) ? Localized.DeletePartSingularDescription : Localized.DeletePartPluralDescription)
                                        : default(string);

                                    if (GUIControls.MouseOverButton(new GUIContent(Localized.DeletePartButtonText, deleteTooltip), out deleteButtonMouseOver, Configuration.PartActionButtonWidth))
                                    {
                                        PartWizard.Delete(part);

                                        // Set a flag so additional GUI logic can decide what to do in the case where a part is deleted.
                                        deleted = true;
                                    }

                                    deleteButtonMouseOver &= GUI.enabled;   // Clear mouse over flag if the delete button was disabled.

                                    #endregion
                                }
                                else // this.viewType == ViewType.Unavailable
                                {
                                    #region Buy Button

                                    GUI.enabled = EditorLogic.SelectedPart == null && (double)part.partInfo.entryCost <= Funding.Instance.Funds && PartWizard.IsBuyable(part);

                                    buyTooltip = GUI.enabled ? string.Format(Localized.BuyPartDescriptionTextFormat, part.partInfo.entryCost) : default(string);

                                    if (GUIControls.MouseOverButton(new GUIContent(Localized.BuyPartButtonText, buyTooltip), out buyButtonMouseOver, Configuration.PartActionButtonWidth))
                                    {
                                        Log.Write("Buying part {0}.", part.name);

                                        PartWizard.Buy(part, true);

                                        // Set a flag so additional GUI logic can decide what to do in the case where a part is bought.
                                        bought = true;
                                    }

                                    buyButtonMouseOver &= GUI.enabled;  // Clear mouse over flag if the buy button was disabled.

                                    #endregion
                                }

                                GUI.enabled = true;

                                bool groupMouseOver = false;
                                GUIControls.EndMouseOverHorizontal(out groupMouseOver);     // End of row for this part.

                                // If we deleted a part, then just jump out of the loop since the parts list has been modified.
                                if (deleted || bought)
                                {
                                    break;
                                }

                                #region Part Highlighting Control

                                if (breakSymmetryMouseOver)
                                {
                                    this.highlight.Add(part, Configuration.HighlightColorEditableSymmetryRoot, Configuration.HighlightColorEditableSymmetryCounterparts, true);
                                }
                                else if (deleteButtonMouseOver)
                                {
                                    this.highlight.Add(part, Configuration.HighlightColorDeletablePart, Configuration.HighlightColorDeletableCounterparts, true);
                                }
                                else if (buyButtonMouseOver)
                                {
                                    // TODO: Duplicate code!
                                    buyableParts.ForEach((p) => {
                                        if (part.name == p.name)
                                        {
                                            this.highlight.Add(p, Configuration.HighlightColorBuyablePart);
                                        }
                                    });
                                }
                                else if (groupMouseOver)
                                {
                                    if (viewType != ViewType.Unavailable)
                                    {
                                        Color highlightColor            = (part == EditorLogic.RootPart) ? Configuration.HighlightColorRootPart : Configuration.HighlightColorSinglePart;
                                        Color counterpartHighlightColor = Configuration.HighlightColorCounterparts;

                                        if (EditorLogic.fetch.editorScreen == EditorScreen.Actions)
                                        {
                                            highlightColor            = Configuration.HighlightColorActionEditorTarget;
                                            counterpartHighlightColor = Configuration.HighlightColorActionEditorTarget;
                                        }

                                        this.highlight.Add(part, highlightColor, counterpartHighlightColor, false);
                                    }
                                    else
                                    {
                                        // TODO: Duplicate code!
                                        buyableParts.ForEach((p) => {
                                            if (part.name == p.name)
                                            {
                                                Log.Write("Highlighting 2 part: " + part.partInfo.title);
                                                this.highlight.Add(p, Configuration.HighlightColorBuyablePart, false);
                                            }
                                        });
                                    }
                                }
                                else if (actionEditorPartButtonMouseOver)
                                {
                                    Log.Write("Highlighting part: " + part.partInfo.title);
                                    this.highlight.Add(part, Configuration.HighlightColorActionEditorTarget, Configuration.HighlightColorActionEditorTarget);
                                }

                                #endregion
                            }
                        }
                    }
                }

                GUILayout.EndScrollView();

                GUILayout.EndVertical();

                if (viewType == ViewType.Unavailable)
                {
                    int  buyableEntryCost = 0;
                    bool enableBulkBuy    = false;

                    foreach (Part p in parts)
                    {
                        buyableEntryCost += p.partInfo.entryCost;

                        enableBulkBuy |= PartWizard.IsBuyable(p);
                    }

                    GUI.enabled = parts.Count > 0 && (double)buyableEntryCost <= Funding.Instance.Funds && enableBulkBuy;

                    bool buyAllMouseOver = false;
                    if (GUIControls.MouseOverButton(new GUIContent(string.Format(Localized.BuyAllButtonTextFormat, buyableEntryCost)), out buyAllMouseOver))
                    {
                        foreach (Part part in parts)
                        {
                            if (PartWizard.IsBuyable(part))
                            {
                                Log.Write("Buying part {0}.", part.name);

                                PartWizard.Buy(part, false);
                            }
                        }

                        PartWizard.SaveGame();
                    }

                    // TODO: Highlight all parts that will be bought by clicking Buy All.
                    if (buyAllMouseOver)
                    {
                        buyableParts.ForEach((p) => {
                            this.highlight.Add(p, Configuration.HighlightColorBuyablePart);
                        });
                    }

                    GUI.enabled = true;
                }

                #endregion

                #region Status Area

                // Push everything above this up, otherwise it will be centered vertically.
                GUILayout.FlexibleSpace();

                if (viewType == ViewType.All || viewType == ViewType.Hidden || viewType == ViewType.Unavailable)
                {
                    string status = default(string);

                    if (!string.IsNullOrEmpty(GUI.tooltip))
                    {
                        if (parts.Count != 1)
                        {
                            status = string.Format(CultureInfo.CurrentCulture, Localized.StatusLabelPluralTooltipTextFormat, visiblePartCount, GUI.tooltip, parts.Count - visiblePartCount);
                        }
                        else
                        {
                            status = string.Format(CultureInfo.CurrentCulture, Localized.StatusLabelSingularTooltipTextFormat, visiblePartCount, GUI.tooltip, parts.Count - visiblePartCount);
                        }
                    }
                    else
                    {
                        if (parts.Count != 1)
                        {
                            status = string.Format(CultureInfo.CurrentCulture, Localized.StatusLabelPluralTextFormat, visiblePartCount, parts.Count - visiblePartCount);
                        }
                        else
                        {
                            status = string.Format(CultureInfo.CurrentCulture, Localized.StatusLabelSingularTextFormat, visiblePartCount, parts.Count - visiblePartCount);
                        }
                    }

                    GUILayout.Label(status, this.tooltipLabelStyle);
                }

                #endregion

                GUILayout.EndVertical();

                if (this.Visible && this.mouseOver)
                {
                    this.highlight.EndTracking();
                }
                else
                {
                    this.highlight.CancelTracking();
                }
            }
            catch (Exception e)
            {
                Log.Write("PartWizardWindow.OnRender() unexpected exception caught.");

                Log.Write(e.Message);
                Log.Write(e.StackTrace);

                this.highlight.CancelTracking();

                throw;
            }
            finally
            {
                GUI.DragWindow();
            }
        }
Пример #4
0
        /*************************************************************************************************************************/
        public void MainGUI(int windowID)
        {
            List <string> save_files = new List <string>();
            Vessel        temp_vessel;
            string        temp_string;
            Guid          guid_delete_vessel = FlightGlobals.ActiveVessel.id;
            bool          delete_vessel      = false;
            float         scrollbar_size;
            bool          scrollbar_enable = false;
            float         window_height, window_width, scrollbar_width_offset;

            window_height = 60;
            window_width  = 280;

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();

            if (!_SETTING_Minimize)
            {
                if (_SAVE_Has_Launched)
                {
                    GUILayout.Box("Mission Time: " + get_time_string(Planetarium.GetUniversalTime() - _SAVE_Launched_At), text_main, GUILayout.Width(188));
                }
                else
                {
                    GUILayout.Box("Mission Time: " + "00:00", text_main, GUILayout.Width(137));
                }
            }
            else
            {
                GUILayout.Space(5);
            }

            if (_SETTING_Armed)
            {
                temp_string = "Armed";
            }
            else
            {
                temp_string = "Arm";
            }

            if (!_SAVE_Has_Launched)
            {
                _SETTING_Armed = GUILayout.Toggle(_SETTING_Armed, temp_string, button_small, GUILayout.Width(50));
            }
            else
            if (_SETTING_Minimize)
            {
                GUILayout.Box("Flight", text_main, GUILayout.Width(50));
            }

            if (!_SETTING_Minimize)
            {
                show_setting = GUILayout.Toggle(show_setting, buttonContent, button_small, GUILayout.Width(25));
                if (show_setting)
                {
                    buttonContent = upContent;
                }
                else
                {
                    buttonContent = downContent;
                }
            }

            _SETTING_Minimize = GUILayout.Toggle(_SETTING_Minimize, "_", button_small, GUILayout.Width(25));
            if (really_close && _SETTING_Minimize)
            {
                _SETTING_Minimize = false;
            }

            if (!_SETTING_Minimize)
            {
                really_close = GUILayout.Toggle(really_close, "x", button_small, GUILayout.Width(25));
            }
            else
            {
                window_width = 105;
            }

            GUILayout.EndHorizontal();

            if (really_close)
            {
                if (_SAVE_Has_Launched)
                {
                    GUILayout.Space(5);
                    window_height += 5;

                    GUILayout.Box("Plugin will be reset!", text_heading, GUILayout.Width(266));
                    window_height += 29;
                    GUILayout.Box("Close?", text_heading, GUILayout.Width(266));
                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button("YES", button_big, GUILayout.Width(132)))
                    {
                        close_FMRS();
                    }

                    if (GUILayout.Button("NO", button_big, GUILayout.Width(133)))
                    {
                        really_close = false;
                    }

                    GUILayout.EndHorizontal();
                    window_height += 58;
                }
                else
                {
                    close_FMRS();
                }
            }

            if (really_close == false && _SETTING_Minimize == false && show_setting == true)
            {
                GUILayout.Space(5);
                window_height += 5;
                GUILayout.BeginVertical(/* area_style ,*/ GUILayout.Width(266));
                GUILayout.Space((5 * 30) + 5);
                _SETTING_Messages     = GUI.Toggle(new Rect(5, 35 + (30 * 1), 25, 25), _SETTING_Messages, "Messaging System");
                window_height        += 30;
                _SETTING_Auto_Cut_Off = GUI.Toggle(new Rect(5, 35 + (30 * 2), 25, 25), _SETTING_Auto_Cut_Off, "Auto Cut Off Engines");
                window_height        += 30;
                _SETTING_Auto_Recover = GUI.Toggle(new Rect(5, 35 + (30 * 3), 25, 25), _SETTING_Auto_Recover, "Auto Recover Landed Crafts");
                window_height        += 30;
                _SETTING_Throttle_Log = GUI.Toggle(new Rect(5, 35 + (30 * 4), 25, 25), _SETTING_Throttle_Log, "Throttle Logger WIP");
                window_height        += 30;
                Timer_Stage_Delay     = GUI.HorizontalSlider(new Rect(45, 35 + (30 * 6) + 15, 205, 25), Timer_Stage_Delay, 0.2f, 5.0f);
                window_height        += 45;
                GUI.Label(new Rect(20, 35 + (30 * 7), 225, 25), "Stage Save Delay: " + Timer_Stage_Delay.ToString("F1"));
                GUILayout.EndVertical();
                window_height += 42;
            }

            if (really_close == false && _SETTING_Minimize == false && show_setting == false)
            {
                if (Vessels_dropped.Count > 0)
                {
                    GUILayout.Space(5);
                    window_height += 5;

                    GUILayout.Box("Separated Stages:", text_heading, GUILayout.Width(266));
                    window_height += 33;

                    foreach (KeyValuePair <Guid, string> temp_keyvalue in Vessels_dropped)
                    {
                        if (!save_files.Contains(temp_keyvalue.Value))
                        {
                            save_files.Add(temp_keyvalue.Value);
                        }
                    }

                    save_files.Sort(delegate(string x, string y)
                    {
                        return(get_save_value(save_cat.SAVEFILE, y).CompareTo(get_save_value(save_cat.SAVEFILE, x)));
                    });

                    nr_save_files = save_files.Count;

                    scrollbar_size  = nr_save_files * 61;
                    scrollbar_size += (Vessels_dropped.Count - nr_save_files) * 25;
                    if (_SAVE_Switched_To_Dropped && can_q_save_load)
                    {
                        scrollbar_size += 43;
                    }

                    if (scrollbar_size > 225)
                    {
                        scrollbar_enable = true;
                        scroll_Vector    = GUILayout.BeginScrollView(scroll_Vector, scrollbar_stlye, GUILayout.Width(266), GUILayout.Height(225));
                        GUILayout.BeginVertical();
                        window_height         += 220;
                        scrollbar_width_offset = 0;
                    }
                    else
                    {
                        GUILayout.BeginVertical(/* area_style, */ GUILayout.Width(266));
                        window_height         += scrollbar_size;
                        scrollbar_width_offset = 20;
                    }

                    while (save_files.Count != 0)
                    {
                        GUILayout.Space(5);
                        GUILayout.BeginVertical(); //  area_style);
                        if (save_files.Last().Contains("separated_"))
                        {
                            GUILayout.Box("Separated at " + get_time_string(Convert.ToDouble(get_save_value(save_cat.SAVEFILE, save_files.Last())) - _SAVE_Launched_At), text_main, GUILayout.Width(230 + scrollbar_width_offset));
                        }
                        else
                        {
                            GUILayout.Box("Stage " + save_files.Last().Substring(10) + " separated at " + get_time_string(Convert.ToDouble(get_save_value(save_cat.SAVEFILE, save_files.Last())) - _SAVE_Launched_At), text_main, GUILayout.Width(230 + scrollbar_width_offset));
                        }

                        foreach (KeyValuePair <Guid, string> vessel_in_savefile in Vessels_dropped)
                        {
                            if (FMRS_SAVE_Util.Instance.jumpInProgress)
                            {
                                GUI.enabled = false;
                            }
                            if (vessel_in_savefile.Value == save_files.Last())
                            {
                                GUILayout.BeginHorizontal();
                                if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.RECOVERED)
                                {
                                    GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " recovered", text_cyan, GUILayout.Width(205 + scrollbar_width_offset));
                                }
                                else if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.LANDED)
                                {
                                    GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", text_green, GUILayout.Width(205 + scrollbar_width_offset));
                                }
                                else if (vessel_in_savefile.Key == FlightGlobals.ActiveVessel.id || vessel_in_savefile.Key == anz_id)
                                {
                                    float temp_float = 230 + scrollbar_width_offset;
                                    if (can_q_save_load)
                                    {
                                        GUILayout.EndHorizontal();
                                        GUILayout.Space(5);
                                        GUILayout.BeginVertical(/* area_style, */ GUILayout.Width(230));
                                        temp_float = 222 + scrollbar_width_offset;
                                    }
                                    if (FlightGlobals.ActiveVessel.LandedOrSplashed)
                                    {
                                        GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", text_green, GUILayout.Width(temp_float));
                                    }
                                    else
                                    {
                                        GUILayout.Box("contr.: " + Vessels_dropped_names[vessel_in_savefile.Key], text_yellow, GUILayout.Width(temp_float));
                                    }
                                    if (can_q_save_load)
                                    {
                                        if (GUILayout.Button("Jump back to Separation", button_main, GUILayout.Width(222 + scrollbar_width_offset)))
                                        {
                                            jump_to_vessel(vessel_in_savefile.Key, false);
                                        }

                                        GUILayout.EndVertical();
                                        GUILayout.Space(5);
                                        GUILayout.BeginHorizontal();
                                    }
                                }
                                else if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.DESTROYED)
                                {
                                    GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " destroyed", text_red, GUILayout.Width(205 + scrollbar_width_offset));
                                }
                                else
                                {
                                    temp_vessel = FlightGlobals.Vessels.Find(p => p.id == vessel_in_savefile.Key);

                                    if (temp_vessel == null)
                                    {
                                        if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key], button_main, GUILayout.Width(205 + scrollbar_width_offset)))
                                        {
                                            jump_to_vessel(vessel_in_savefile.Key, true);
                                        }
                                    }
                                    else
                                    {
                                        if (loaded_vessels.Contains(temp_vessel.id) && _SAVE_Switched_To_Dropped)
                                        {
                                            if (temp_vessel.LandedOrSplashed)
                                            {
                                                if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", button_green, GUILayout.Width(205 + scrollbar_width_offset)))
                                                {
                                                    FlightGlobals.ForceSetActiveVessel(temp_vessel);
                                                }
                                            }
                                            else
                                            {
                                                if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key] + " is near", button_yellow, GUILayout.Width(205 + scrollbar_width_offset)))
                                                {
                                                    FlightGlobals.ForceSetActiveVessel(temp_vessel);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key], button_main, GUILayout.Width(205 + scrollbar_width_offset)))
                                            {
                                                jump_to_vessel(vessel_in_savefile.Key, true);
                                            }
                                        }
                                    }
                                }

                                if (vessel_in_savefile.Key != FlightGlobals.ActiveVessel.id && vessel_in_savefile.Key != anz_id)
                                {
                                    if (GUILayout.Button("X", button_small_red, GUILayout.Width(25)))
                                    {
                                        guid_delete_vessel = vessel_in_savefile.Key;
                                        delete_vessel      = true;
                                    }
                                }
                                GUILayout.EndHorizontal();
                                button_main.normal.textColor = button_main.focused.textColor = Color.white;
                            }
                            GUI.enabled = true;
                        }
                        GUILayout.EndVertical();
                        temp_string = save_files.Last();
                        save_files.Remove(temp_string);
                    }

                    if (scrollbar_enable)
                    {
                        GUILayout.EndVertical();
                        GUILayout.EndScrollView();
                    }
                    else
                    {
                        GUILayout.EndVertical();
                    }
                }

                if (_SAVE_Switched_To_Dropped)
                {
                    GUILayout.Space(5);
                    window_height += 5;
                    if (FMRS_SAVE_Util.Instance.jumpInProgress)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Jump back to Main Mission", button_big, GUILayout.Width(266)))
                    {
                        jump_to_vessel("Main");
                    }
                    GUI.enabled    = true;
                    window_height += 31;
                }

                if (_SAVE_Has_Launched && can_restart)
                {
                    GUILayout.Space(5);
                    window_height += 5;
                    if (FMRS_SAVE_Util.Instance.jumpInProgress)
                    {
                        GUI.enabled = false;
                    }
                    if (revert_to_launch)
                    {
                        GUILayout.Box("Revert Flight?", text_heading, GUILayout.Width(266));

                        GUILayout.BeginHorizontal();

                        if (GUILayout.Button("YES", button_big, GUILayout.Width(132)))
                        {
                            // _SETTING_Enabled = false;
                            jump_to_vessel(_SAVE_Main_Vessel, "before_launch");
                        }
                        if (GUILayout.Button("NO", button_big, GUILayout.Width(133)))
                        {
                            revert_to_launch = false;
                        }

                        GUILayout.EndHorizontal();
                        window_height += 58;
                    }
                    else
                    {
                        if (_SAVE_Flight_Reset)
                        {
                            revert_to_launch = GUILayout.Toggle(revert_to_launch, "Revert To Plugin Start", button_big, GUILayout.Width(266));
                        }
                        else
                        {
                            revert_to_launch = GUILayout.Toggle(revert_to_launch, "Revert To Launch", button_big, GUILayout.Width(266));
                        }
                        window_height += 31;
                    }
                    GUI.enabled = true;
                }
            }
            GUILayout.EndVertical();

            if (delete_vessel && guid_delete_vessel != FlightGlobals.ActiveVessel.id)
            {
                delete_dropped_vessel(guid_delete_vessel);
            }

            windowPos.height = window_height;
            //   windowPos.width = window_width;

            GUI.DragWindow();
        }
Пример #5
0
        /*
         * Main window
         */
        private void HandleMainWindow(int windowID)
        {
            GUIStyle _settingsToggleGroupStyle = new GUIStyle(GUI.skin.toggle);

            _settingsToggleGroupStyle.margin.left += 40;

            //save Window Position
            _config.MainWindowXPosition = (int)_editorMainWindow.xMin;
            _config.MainWindowYPosition = (int)_editorMainWindow.yMin;

            GUILayout.BeginVertical();
            GUILayout.EndVertical();
            GUILayout.BeginVertical();

            if (GUILayout.Button(Constants.guiSettingsGUIContent, GUILayout.MaxWidth(160)))
            {
                _mainWindowsSettingsMode = !_mainWindowsSettingsMode;
            }
            //Settings
            if (_mainWindowsSettingsMode)
            {
                _editorMainWindow.height         = Constants.guiMainWindowHSettingsExpanded;
                _settingsScrollPosition          = GUILayout.BeginScrollView(_settingsScrollPosition);
                _config.includeAllNodes          = GUILayout.Toggle(_config.includeAllNodes, Constants.guiAllNodesGUIContent);
                Welder.includeAllNodes           = _config.includeAllNodes;
                _config.dontProcessMasslessParts = GUILayout.Toggle(_config.dontProcessMasslessParts, Constants.guiDontProcessMasslessPartsGUIContent);
                Welder.dontProcessMasslessParts  = _config.dontProcessMasslessParts;
                _config.dataBaseAutoReload       = GUILayout.Toggle(_config.dataBaseAutoReload, Constants.guiDbAutoReloadGUIContent);
                _config.useNamedCfgFile          = GUILayout.Toggle(_config.useNamedCfgFile, Constants.guiUseNamedCfgFileGUIContent);
                _config.advancedDebug            = GUILayout.Toggle(_config.advancedDebug, Constants.guiAdvancedDebugGUIContent);
                _config.clearEditor        = GUILayout.Toggle(_config.clearEditor, Constants.guiClearEditorGUIContent);
                _config.fileSimplification = GUILayout.Toggle(_config.fileSimplification, Constants.guiFileSimplificationGUIContent);
                Welder.fileSimplification  = _config.fileSimplification;
                GUILayout.Space(10.0f);
                GUILayout.Label(" Vector Precision: " + _config.precisionDigits);
                _config.precisionDigits = (int)GUILayout.HorizontalSlider(_config.precisionDigits, 1, 6);
                Welder.precisionDigits  = _config.precisionDigits;
                GUILayout.Space(10.0f);
                GUILayout.Label("Strength params calculation method");
//				_config.StrengthCalcMethod = (StrengthParamsCalcMethod)GUILayout.SelectionGrid((int)_config.StrengthCalcMethod, Constants.StrengthParamsCalcMethodsGUIContent, 1, GUILayout.MaxWidth(140));
                foreach (StrengthParamsCalcMethod method in Enum.GetValues(typeof(StrengthParamsCalcMethod)))
                {
                    if (GUILayout.Toggle((_config.StrengthCalcMethod == method), Constants.StrengthParamsCalcMethodsGUIContent[(int)method], _settingsToggleGroupStyle))
                    {
                        _config.StrengthCalcMethod = method;
                        Welder.StrengthCalcMethod  = method;
                    }
                }
                GUILayout.Space(10.0f);
                GUILayout.Label("MaxTemp calculation method");
//				_config.MaxTempCalcMethod = (MaxTempCalcMethod)GUILayout.SelectionGrid((int)_config.MaxTempCalcMethod, Constants.MaxTempCalcMethodsGUIContent, 1, GUILayout.MaxWidth(140));
                foreach (MaxTempCalcMethod method in Enum.GetValues(typeof(MaxTempCalcMethod)))
                {
                    if (GUILayout.Toggle((_config.MaxTempCalcMethod == method), Constants.MaxTempCalcMethodsGUIContent[(int)method], _settingsToggleGroupStyle))
                    {
                        _config.MaxTempCalcMethod = method;
                        Welder.MaxTempCalcMethod  = method;
                    }
                }
                GUILayout.EndScrollView();

//				GUILayout.Space(10.0f);
                if (GUILayout.Button(Constants.guiSaveSettingsButtonGUIContent, GUILayout.MaxWidth(160)))
                {
                    FileManager.saveConfig(_config);
                    _config = FileManager.loadConfig();
                }
            }
            else
            {
                _editorMainWindow.height = Constants.guiMainWindowH;
                GUILayout.Space(20.0f);
            }

            //SelectPArtbranch button
            if (GUILayout.RepeatButton(Constants.guiSelectPartGUIContent, GUILayout.MaxWidth(160)))
            {
                this.state = DisplayState.partSelection;
            }

            //Weld button
            if (GUILayout.Button(Constants.guiWeldItButtonGUIContent, GUILayout.MaxWidth(160)))
            {
                FileManager.saveConfig(_config);

                if (EditorLockManager.isEditorLocked())
                {
                    if (_selectedPartbranch == null)
                    {
                        _selectedPartbranch = EditorLogic.RootPart;
                    }
                    repositionPreWeldment(_selectedPartbranch);
                    weldPart(_selectedPartbranch);
                }
            }
            if (GUILayout.Button(Constants.guiCloseGUIContent, GUILayout.MaxWidth(160)))
            {
                closeMainwindow();
            }
            //Hints area
            GUILayout.TextArea(GUI.tooltip, GUILayout.ExpandHeight(true), GUILayout.MaxHeight(100));
            GUIStyle VersionLabelGUIStyle = new GUIStyle(GUI.skin.label);

            VersionLabelGUIStyle.fontSize = 12;
            GUILayout.Label(Constants.logVersion, VersionLabelGUIStyle);
            GUILayout.EndVertical();

            GUI.DragWindow();
        }         //private void OnMainWindow()
Пример #6
0
        void GUIActive(int windowID)
        {
#if false
            if (HighLogic.LoadedScene == GameScenes.SETTINGS)
            {
                GUI.BringWindowToFront(09271);
            }
#endif
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name: ");
            nameString = GUILayout.TextField(nameString);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Width: ");
            xString = GUILayout.TextField(xString);
            xString = Regex.Replace(xString, @"[^0-9]", "");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Height: ");
            yString = GUILayout.TextField(yString);
            yString = Regex.Replace(yString, @"[^0-9]", "");
            GUILayout.EndHorizontal();
            fullScreen  = GUILayout.Toggle(fullScreen, "Fullscreen");
            reloadScene = GUILayout.Toggle(reloadScene, "Reload scene");
            if (GUILayout.Button("Set Screen Resolution"))
            {
                if (xString != null && yString != null)
                {
                    x = Convert.ToInt32(xString);
                    y = Convert.ToInt32(yString);

                    if (x > 0 && y > 0)
                    {
                        GameSettings.SCREEN_RESOLUTION_HEIGHT = y;
                        GameSettings.SCREEN_RESOLUTION_WIDTH  = x;
                        GameSettings.FULLSCREEN = fullScreen;
                        GameSettings.SaveSettings();
                        Screen.SetResolution(x, y, fullScreen);
                        Log.detail("Set screen resolution");

                        if (reloadScene)
                        {
                            if (HighLogic.LoadedScene != GameScenes.LOADING)
                            {
                                HighLogic.LoadScene(HighLogic.LoadedScene);
                            }
                            else
                            {
                                ScreenMessages.PostScreenMessage("You cannot reload the scene while loading the game!", 1);
                            }
                        }
                    }
                    else
                    {
                        ScreenMessages.PostScreenMessage("One or both of your values is too small.  Please enter a valid value.", 1, ScreenMessageStyle.UPPER_CENTER);
                    }
                }
                else
                {
                    ScreenMessages.PostScreenMessage("The values you have set are invalid.  Please set a valid value.", 1, ScreenMessageStyle.UPPER_CENTER);
                }
            }

            if (nameString == "")
            {
                GUI.enabled = false;
            }

            if (GUILayout.Button("Save"))
            {
                string newName       = nameString;
                string newX          = xString;
                string newY          = yString;
                bool   newFullscreen = fullScreen;

                ConfigNode config = new ConfigNode(newName);
                config.AddValue("name", newName);
                config.AddValue("x", newX);
                config.AddValue("y", newY);
                config.AddValue("fullscreen", newFullscreen.ToString());
                this.presets.Create(config);

                ScreenMessages.PostScreenMessage("Preset saved.  You can change the preset later by using the same name in this editor.", 5, ScreenMessageStyle.UPPER_CENTER);
                this.presets.ReloadFiles();
            }


            GUI.enabled = 0 != this.presets.files.Count;

            if (deleteEnabled)
            {
                if (GUILayout.Button("Disable Delete"))
                {
                    deleteEnabled = false;
                }
            }
            else
            {
                if (GUILayout.Button("Enable Delete"))
                {
                    deleteEnabled = true;
                }
            }
            if (GUILayout.Button("Close"))
            {
                toolbarButton.Active = false;
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical();

            scrollViewPos = GUILayout.BeginScrollView(scrollViewPos);

            foreach (Data.ConfigNode configNode in this.presets.files)
            {
                ConfigNode config = configNode.Node;
                if (deleteEnabled)
                {
                    if (GUILayout.Button("Delete " + config.GetValue("name")))
                    {
                        confirmDeleteEnabled = true;
                        this.presets.MarkForDeletion(configNode);
                    }
                }
                else
                {
                    if (GUILayout.Button(config.GetValue("name")))
                    {
                        int xVal;
                        int.TryParse(config.GetValue("x"), out xVal);
                        int yVal;
                        int.TryParse(config.GetValue("y"), out yVal);
                        bool fullscreen;
                        bool.TryParse(config.GetValue("fullscreen"), out fullscreen);
                        GameSettings.SCREEN_RESOLUTION_HEIGHT = yVal;
                        GameSettings.SCREEN_RESOLUTION_WIDTH  = xVal;
                        GameSettings.FULLSCREEN = fullscreen;
                        GameSettings.SaveSettings();
                        Screen.SetResolution(xVal, yVal, fullscreen);
                        Log.detail("Set screen resolution from preset");
                    }
                }
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (GUI.Button(new Rect(anyresWinRect.width - 18, 3f, 15f, 15f), new GUIContent("X")))
            {
                toolbarButton.Active = false;
            }

            GUI.DragWindow();
        }
Пример #7
0
        private void DoWindow(int id)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("For each mod, select which toolbar to put it's button on.");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("If the Blizzy toobar is not installed, all buttons will be put on the stock toolbar, regardless of the setting");
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Stock", GUILayout.Width(50));
            GUILayout.Label("Blizzy", GUILayout.Width(50));
            GUILayout.Label("Both", GUILayout.Width(50));
            GUILayout.Label("None", GUILayout.Width(50));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            //ToolbarControl.sortedModList = ToolbarControl.sortedModList.OrderBy(x => x.displayName).ToList();


            scrollVector = GUILayout.BeginScrollView(scrollVector, scrollbar_style, GUILayout.Height(scrollBarHeight));

            foreach (ToolbarControl.Mod mod in ToolbarControl.sortedModList)
            {
                bool doUseButtons = false;
                GUILayout.BeginHorizontal();
                bool stock = GUILayout.Toggle(mod.useStock, "", GUILayout.Width(60));
                if (stock != mod.useStock)
                {
                    if (ToolbarControl.registeredMods[mod.modId].useStock == ToolbarControl.registeredMods[mod.modId].useBlizzy &&
                        ToolbarControl.registeredMods[mod.modId].useStock)
                    {
                        ToolbarControl.registeredMods[mod.modId].useBlizzy = false;
                    }
                    else
                    {
                        ToolbarControl.registeredMods[mod.modId].useStock  = stock;
                        ToolbarControl.registeredMods[mod.modId].useBlizzy = !stock;
                    }

                    doUseButtons = true;
                }

                bool blizzy = GUILayout.Toggle(mod.useBlizzy, "", GUILayout.Width(50));

                if (blizzy != ToolbarControl.registeredMods[mod.modId].useBlizzy)
                {
                    if (ToolbarControl.registeredMods[mod.modId].useStock == ToolbarControl.registeredMods[mod.modId].useBlizzy &&
                        ToolbarControl.registeredMods[mod.modId].useBlizzy)
                    {
                        ToolbarControl.registeredMods[mod.modId].useStock = false;
                    }
                    else
                    {
                        ToolbarControl.registeredMods[mod.modId].useBlizzy = blizzy;
                        ToolbarControl.registeredMods[mod.modId].useStock  = !blizzy;
                    }

                    doUseButtons = true;
                }

                bool both    = (stock & blizzy);
                bool newboth = GUILayout.Toggle(both, "", GUILayout.Width(50));
                if (newboth != both)
                {
                    ToolbarControl.registeredMods[mod.modId].useBlizzy = true;
                    ToolbarControl.registeredMods[mod.modId].useStock  = true;

                    doUseButtons = true;
                }
                if (!ToolbarControl.registeredMods[mod.modId].noneAllowed)
                {
                    GUI.enabled = false;
                }
                bool none    = (!stock & !blizzy);
                bool newnone = GUILayout.Toggle(none, "", GUILayout.Width(25));
                if (newnone != none)
                {
                    ToolbarControl.registeredMods[mod.modId].useBlizzy = false;
                    ToolbarControl.registeredMods[mod.modId].useStock  = false;

                    doUseButtons = true;
                }

                if (doUseButtons)
                {
                    ToolbarControl.SaveData();
                    if (ToolbarControl.registeredMods[mod.modId].modToolbarControl != null)
                    {
                        ToolbarControl.registeredMods[mod.modId].modToolbarControl.UseButtons(mod.modId);
                    }
                    else
                    {
                        Log.Debug("mod.Key: " + mod.modId + " modToolbarControl is null");
                    }
                }
                GUI.enabled = true;
                GUILayout.Label(" " + mod.displayName);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Close"))
            {
                GUIEnabled = false;
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("?"))
            {
                IntroWindowClass.showHelp  = true;
                IntroWindowClass.automoved = 0;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }
Пример #8
0
        internal void drawWindow(int id)
        {
            if (PartCommander.Instance.settings.altSkin)
            {
                GUI.skin = PartCommander.Instance.modStyleUnity.skin;
            }
            else
            {
                GUI.skin = PartCommander.Instance.modStyle.skin;
            }
            GUILayout.BeginVertical();
            GUILayout.Label("Settings", modStyle.guiStyles["titleLabel"]);
            GUILayout.EndVertical();
            if (Event.current.type == EventType.Repaint)
            {
                dragRect = GUILayoutUtility.GetLastRect();
            }
            GUILayout.BeginVertical();
            scrollPos = GUILayout.BeginScrollView(scrollPos);

            GUILayout.BeginHorizontal();
            bool newHideUnAct = GUILayout.Toggle(settings.hideUnAct, "Hide unactionable parts", modStyle.guiStyles["toggleText"]);

            if (newHideUnAct != settings.hideUnAct)
            {
                PartCommander.Instance.updateParts = true;
                settings.hideUnAct = newHideUnAct;
                settings.Save();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();

            GUILayout.Label("Font Size:", modStyle.guiStyles["settingsLabel"]);
            bool fontChanged = false;

            GUILayout.FlexibleSpace();
            if (settings.fontSize <= 12)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("<", modStyle.guiStyles["settingsButton"]))
            {
                settings.fontSize--;
                fontChanged = true;
            }
            GUI.enabled = true;
            string s = GUILayout.TextField(settings.fontSize.ToString(), modStyle.guiStyles["settingsLabel"]);

            if (settings.fontSize >= 20)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button(">", modStyle.guiStyles["settingsButton"]))
            {
                settings.fontSize++;
                fontChanged = true;
            }
            GUI.enabled = true;
            if (fontChanged)
            {
                settings.Save();
                PartCommander.Instance.modStyle.UpdateFontSize(settings.fontSize);
                PartCommander.Instance.modStyleUnity.UpdateFontSize(settings.fontSize);
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();

            bool newAltSkin = GUILayout.Toggle(settings.altSkin, "Use alternate skin", modStyle.guiStyles["toggleText"]);

            if (newAltSkin != settings.altSkin)
            {
                settings.altSkin = newAltSkin;
                settings.Save();
                if (PartCommander.Instance.settings.altSkin)
                {
                    modStyle = PartCommander.Instance.modStyleUnity;
                    PartCommander.Instance.modStyle = PartCommander.Instance.modStyleUnity;
                }
                else
                {
                    modStyle = PartCommander.Instance.modStyleKSP;
                    PartCommander.Instance.modStyle = PartCommander.Instance.modStyle;
                }
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();

            bool newEnableHotKey = GUILayout.Toggle(settings.enableHotKey, "Enable hot key", modStyle.guiStyles["toggleText"]);

            if (newEnableHotKey != settings.enableHotKey)
            {
                settings.enableHotKey = newEnableHotKey;
                settings.Save();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();

            if (settingHotKey)
            {
                GUILayout.Label("Type a new hot key...", modStyle.guiStyles["settingsLabel"]);
                if (Event.current.isKey)
                {
                    settings.hotKey = Event.current.keyCode;
                    settings.Save();
                    settingHotKey = false;
                }
            }
            else
            {
                if (settings.enableHotKey)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Mod + ");
                    if (GUILayout.Button(new GUIContent(settings.hotKey.ToString(), "Click to set new hot key"), modStyle.guiStyles["settingsButton"]))
                    {
                        settingHotKey = true;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
            GUILayout.Space(25f);
            GUILayout.EndVertical();

            if (GUI.Button(new Rect(windowRect.width - 18, 3f, 15f, 15f), new GUIContent("", "Close"), modStyle.guiStyles["closeButton"]))
            {
                showWindow = false;
            }
            // Create resize button in bottom right corner
            if (GUI.RepeatButton(new Rect(windowRect.width - 23, windowRect.height - 23, 20, 20), "", modStyle.guiStyles["resizeButton"]))
            {
                resizingWindow = true;
            }
            GUI.DragWindow();
        }
        private void DisplayCLSWindow()
        {
            // set scrollviewer sizes...
            if (Event.current.type == EventType.Repaint)
            {
                _scrollY      = _scrollCrew.height > _scrollParts.height ? _scrollCrew.height : _scrollParts.height;
                _scrollXCrew  = _scrollCrew.width > 140 ? _scrollCrew.width : 140;
                _scrollXParts = _scrollParts.width > 240 ? _scrollParts.width : 240;

                // reset counters.
                _scrollCrew.height = _scrollParts.height = _scrollCrew.width = _scrollParts.width = 0;
            }
            try
            {
                Rect rect = new Rect(_windowPosition.width - 20, 4, 16, 16);
                if (GUI.Button(rect, ""))
                {
                    OnCLSButtonToggle();
                }
                rect = new Rect(_windowPosition.width - 90, 4, 65, 16);
                if (GUI.Button(rect, new GUIContent(_clsLocOptions, _clsLocOptionTt))) // "Options","Click to view/edit options"
                {
                    _optionsVisible = !_optionsVisible;
                }
                GUILayout.BeginVertical();
                GUI.enabled = true;

                // Build strings describing the contents of each of the spaces.
                if (null != _vessel)
                {
                    string[] spaceNames       = new string[_vessel.Spaces.Count];
                    int      counter          = 0;
                    int      newSelectedSpace = -1;

                    string partsList = "";
                    List <ICLSSpace> .Enumerator spaces = _vessel.Spaces.GetEnumerator();
                    while (spaces.MoveNext())
                    {
                        if (spaces.Current == null)
                        {
                            continue;
                        }
                        if (spaces.Current.Name == "")
                        {
                            spaceNames[counter] = $"{_clsLocSpace} {counter + 1}";
                        }
                        else
                        {
                            spaceNames[counter] = spaces.Current.Name;
                        }
                        counter++;
                    }
                    spaces.Dispose();

                    if (_vessel.Spaces.Count > 0)
                    {
                        newSelectedSpace = DisplaySpaceButtons(WindowSelectedSpace, spaceNames);
                    }


                    // Only fiddle with the highlighting if the selected space has actually changed
                    UpdateDisplayHighlghting(newSelectedSpace);

                    // Update the space that has been selected.
                    WindowSelectedSpace = newSelectedSpace;

                    // If one of the spaces has been selected then display lists of the crew and parts that make it up
                    if (WindowSelectedSpace != -1)
                    {
                        Rect _rect;
                        // Loop through all the parts in the newly selected space and create a list of all the spaces in it.
                        partsList = $"{_clsLocParts}:";
                        List <ICLSPart> .Enumerator parts = _vessel.Spaces[WindowSelectedSpace].Parts.GetEnumerator();
                        while (parts.MoveNext())
                        {
                            if (parts.Current == null)
                            {
                                continue;
                            }
                            partsList += $"\n- {(parts.Current.Part).partInfo.title}";
                        }
                        parts.Dispose();

                        string crewList = $"{_clsLocInfo}:";
                        if (_vessel.Spaces[WindowSelectedSpace].Crew.Count == 0)
                        {
                            crewList += $"\n- {_clsLocNone}";
                        }
                        else
                        {
                            List <ICLSKerbal> .Enumerator crewmembers = _vessel.Spaces[WindowSelectedSpace].Crew.GetEnumerator();
                            while (crewmembers.MoveNext())
                            {
                                if (crewmembers.Current == null)
                                {
                                    continue;
                                }
                                crewList += $"\n- {(crewmembers.Current.Kerbal).name}";
                            }
                            crewmembers.Dispose();
                        }

                        // Display the text box that allows the space name to be changed
                        GUILayout.BeginHorizontal();
                        GUILayout.Label($"{_clsLocName}:");  // "Name:"
                        _spaceNameEditField = GUILayout.TextField(_spaceNameEditField, GUILayout.Width(200));
                        if (GUILayout.Button(_clsLocUpdate)) // "Update"
                        {
                            _vessel.Spaces[WindowSelectedSpace].Name = _spaceNameEditField;
                        }
                        GUILayout.EndHorizontal();

                        // Lets use 2 scrollers for Crew and parts to save space...
                        GUILayout.BeginHorizontal();

                        // Crew Scroller
                        _scrollViewerCrew = GUILayout.BeginScrollView(_scrollViewerCrew, GUILayout.Width(_scrollXCrew), GUILayout.Height(20 > _scrollY ? 20 : _scrollY + 20));
                        GUILayout.BeginVertical();

                        // Display the crew capacity of the space.
                        GUILayout.Label($"{_clsLocCapacity}:  {_vessel.Spaces[WindowSelectedSpace].MaxCrew}");
                        _rect = GUILayoutUtility.GetLastRect();
                        if (Event.current.type == EventType.Repaint)
                        {
                            _scrollCrew.height = _rect.height;
                            _scrollCrew.width  = _rect.width;
                        }

                        // Crew Capacity
                        GUILayout.Label(crewList);
                        _rect = GUILayoutUtility.GetLastRect();
                        if (Event.current.type == EventType.Repaint)
                        {
                            _scrollCrew.height += _rect.height;
                            _scrollCrew.width   = _scrollCrew.width > _rect.width ? _scrollCrew.width : _rect.width;
                        }

                        GUILayout.EndVertical();
                        GUILayout.EndScrollView();

                        // Part Scroller
                        _scrollViewerParts = GUILayout.BeginScrollView(_scrollViewerParts, GUILayout.Width(_scrollXParts), GUILayout.Height(20 > _scrollY ? 20 : _scrollY + 20));
                        GUILayout.BeginVertical();

                        // Display the Part count of the space.
                        GUILayout.Label($"{_clsLocPartCount}:  {_vessel.Spaces[WindowSelectedSpace].Parts.Count}"); // Selected Space Parts Count
                        _rect = GUILayoutUtility.GetLastRect();
                        if (Event.current.type == EventType.Repaint)
                        {
                            _scrollParts.height = _rect.height;
                            _scrollParts.width  = _rect.width;
                        }

                        // Display the list of component parts.
                        GUILayout.Label(partsList);
                        _rect = GUILayoutUtility.GetLastRect();
                        if (Event.current.type == EventType.Repaint)
                        {
                            _scrollParts.height += _rect.height;
                            _scrollParts.width   = _scrollParts.width > _rect.width ? _scrollParts.width : _rect.width;
                        }

                        GUILayout.EndVertical();
                        GUILayout.EndScrollView();
                        GUILayout.EndHorizontal();
                    }
                }
                else
                {
                    GUILayout.Label("", GUILayout.Height(20));                                        // Add some vertical space.
                    GUILayout.Label(_clsLocNoVessel, CLSStyles.LabelStyleBold, GUILayout.Width(380)); // "No current vessel"
                }
                GUILayout.EndVertical();
                GUI.DragWindow();
                RepositionWindow(ref _windowPosition);
            }
            catch (Exception ex)
            {
                Log.error(ex, this);
            }
        }
        public override void OnRender()
        {
            try
            {
                GUILayout.BeginVertical();

                this.scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);

                this.highlight.BeginTracking();

                if (this.mouseOver)
                {
                    this.highlight.Add(this.part, Configuration.HighlightColorSymmetryEditor, Configuration.HighlightColorSymmetryEditor);
                }

                for (int index = 0; index < this.symmetryGroups.Count; index++)
                {
                    PartGroup group = this.symmetryGroups[index];

                    GUIControls.BeginMouseOverVertical(GUIControls.PanelStyle);

                    GUILayout.BeginHorizontal();

                    GUILayout.Label(new GUIContent(string.Format(CultureInfo.CurrentCulture, Localized.GroupLabelText, index + 1)));

                    // Don't allow group removal if there is only one group.
                    GUI.enabled = (this.symmetryGroups.Count > 1);

                    if (GUILayout.Button(SymmetryEditorWindow.RemoveGroupButtonText))
                    {
                        // If there's a group above, use it. If not, then use the one below.
                        PartGroup destinationGroup = (index > 0) ? this.symmetryGroups[index - 1] : this.symmetryGroups[index + 1];

                        destinationGroup.MergeFrom(group);

                        this.symmetryGroups.Remove(group);

                        break;
                    }

                    GUILayout.EndHorizontal();

                    GUI.enabled = true;

                    bool mouseOverPart = false;

                    foreach (Part groupPart in group.Parts)
                    {
                        GUIControls.BeginMouseOverHorizontal();

                        GUILayout.Label(new GUIContent(groupPart.partInfo.title));

                        GUI.enabled = index < this.symmetryGroups.Count - 1;

                        if (GUILayout.Button(SymmetryEditorWindow.MoveDownButtonText, Configuration.PartActionButtonWidth))
                        {
                            PartGroup nextGroup = this.symmetryGroups[index + 1];

                            group.MoveTo(groupPart, nextGroup);

                            break;
                        }

                        GUI.enabled = index > 0;

                        if (GUILayout.Button(SymmetryEditorWindow.MoveUpButtonText, Configuration.PartActionButtonWidth))
                        {
                            PartGroup previousGroup = this.symmetryGroups[index - 1];

                            group.MoveTo(groupPart, previousGroup);

                            break;
                        }

                        GUI.enabled = true;

                        bool mouseOverPartArea = false;
                        GUIControls.EndMouseOverVertical(out mouseOverPartArea);

                        if (mouseOverPartArea)
                        {
                            // First add the group with the child part color, recursively.
                            this.highlight.Add(group, Configuration.HighlightColorEditableSymmetryChildParts, true);
                            // Next add the group with the counterparts highlighted, non-recursively.
                            this.highlight.Add(group, Configuration.HighlightColorCounterparts, false);
                            // Last add the specific part, non-recursively.
                            this.highlight.Add(groupPart, Configuration.HighlightColorSinglePart, false);

                            mouseOverPart = true;
                        }
                    }

                    bool groupMouseOver = false;
                    GUIControls.EndMouseOverVertical(out groupMouseOver);

                    if (!mouseOverPart && groupMouseOver)
                    {
                        this.highlight.Add(group, Configuration.HighlightColorEditableSymmetryCounterparts, true);
                    }
                }

                // Enable the Add Group button only if there is enough symmetrical parts to fill it.
                GUI.enabled = (this.symmetryGroups.Count < (this.part.symmetryCounterparts.Count + 1));

                if (GUILayout.Button(SymmetryEditorWindow.AddGroupButtonText))
                {
                    this.symmetryGroups.Add(new PartGroup());
                }

                GUI.enabled = true;

                GUILayout.EndScrollView();

                // Push everything above this up, otherwise it will be centered vertically.
                GUILayout.FlexibleSpace();

                GUILayout.BeginHorizontal();

                #region OK Button

                if (GUILayout.Button(Localized.OK))
                {
                    int symmetricGroupsCreated = 0;
                    int partsProcessed         = 0;

                    foreach (PartGroup group in this.symmetryGroups)
                    {
                        if (group.Parts.Count > 0)
                        {
                            partsProcessed += group.Count;

                            Part symmetricRoot = group.Extract(0);

                            PartWizard.CreateSymmetry(symmetricRoot, group.Parts);

                            symmetricGroupsCreated++;

#if DEBUG
                            Log.WriteSymmetryReport(symmetricRoot);
#endif
                        }
                    }

                    Log.Write("Modified symmetry for {0}, creating {1} symmetric group(s) from {2} parts.", part.name, symmetricGroupsCreated, partsProcessed);

                    this.Hide();
                }

                #endregion

                #region Cancel Button

                if (GUILayout.Button(Localized.Cancel))
                {
                    this.Hide();
                }

                #endregion

                GUILayout.EndHorizontal();

                GUILayout.EndVertical();

                if (this.Visible && this.mouseOver)
                {
                    this.highlight.EndTracking();
                }
                else
                {
                    this.highlight.CancelTracking();
                }
            }
            catch (Exception e)
            {
                Log.Write("SymmetryEditorWindow.OnRender() unexpected exception caught.");

                Log.Write(e.Message);
                Log.Write(e.StackTrace);

                this.highlight.CancelTracking();

                throw;
            }
            finally
            {
                GUI.DragWindow();
            }
        }
Пример #11
0
        public override void WindowElements()
        {
            GUILayout.BeginVertical();
            GUILayout.Label("WARNING: You can click through this window!", HighLogic.Skin.label);
            //Red
            GUILayout.BeginHorizontal();
            GUILayout.Label("Red:", HighLogic.Skin.label, GUILayout.Width(50));
            if (float.TryParse(GUILayout.TextField(color.r.ToString(), HighLogic.Skin.textField), out f))
            {
                color.r = Mathf.Clamp01(f);
            }
            GUILayout.EndHorizontal();
            color.r = GUILayout.HorizontalSlider(color.r, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb);
            //Green
            GUILayout.BeginHorizontal();
            GUILayout.Label("Green:", HighLogic.Skin.label, GUILayout.Width(50));
            if (float.TryParse(GUILayout.TextField(color.g.ToString(), HighLogic.Skin.textField), out f))
            {
                color.g = Mathf.Clamp01(f);
            }
            GUILayout.EndHorizontal();
            color.g = GUILayout.HorizontalSlider(color.g, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb);
            //Blue
            GUILayout.BeginHorizontal();
            GUILayout.Label("Blue:", HighLogic.Skin.label, GUILayout.Width(50));
            if (float.TryParse(GUILayout.TextField(color.b.ToString(), HighLogic.Skin.textField), out f))
            {
                color.b = Mathf.Clamp01(f);
            }
            GUILayout.EndHorizontal();
            color.b = GUILayout.HorizontalSlider(color.b, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb);
            //alpha
            if (showAlpha)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Alpha:", HighLogic.Skin.label, GUILayout.Width(50));
                if (float.TryParse(GUILayout.TextField(color.a.ToString(), HighLogic.Skin.textField), out f))
                {
                    color.a = Mathf.Clamp01(f);
                }
                GUILayout.EndHorizontal();
                color.a = GUILayout.HorizontalSlider(color.a, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb);
            }
            //preset list
            if (presets.Count > 0)
            {
                selectedIndex = -1;
                for (int j = 0; j < presets.Count; j++)
                {
                    if (float.Parse(presets[j].GetValue("r")) == color.r && float.Parse(presets[j].GetValue("g")) == color.g &&
                        float.Parse(presets[j].GetValue("b")) == color.b && float.Parse(presets[j].GetValue("a")) == color.a)
                    {
                        selectedIndex = j;
                        break;
                    }
                }
                GUILayout.Label("Select preset:", HighLogic.Skin.label);
                scrollPosition = GUILayout.BeginScrollView(scrollPosition, HighLogic.Skin.horizontalSlider, HighLogic.Skin.label, GUILayout.Height(48));
                i = GUILayout.Toolbar(selectedIndex, (from n in presets select n.GetValue("name")).ToArray(), HighLogic.Skin.button);
                GUILayout.EndScrollView();
                if (i >= 0)
                {
                    color = new Color(float.Parse(presets[i].GetValue("r")), float.Parse(presets[i].GetValue("g")), float.Parse(presets[i].GetValue("b")), showAlpha ? float.Parse(presets[i].GetValue("a")) : 1);
                }
            }
            else
            {
                selectedIndex = -1;
            }

            //add preset
            newPresetName = GUILayout.TextField(newPresetName, HighLogic.Skin.textField);
            GUILayout.BeginHorizontal();
            if (selectedIndex == -1 && GUILayout.Button("Add preset", HighLogic.Skin.button))
            {
                ConfigNode n = new ConfigNode("PRESET");
                n.AddValue("r", color.r);
                n.AddValue("g", color.g);
                n.AddValue("b", color.b);
                n.AddValue("a", color.a);
                n.AddValue("name", newPresetName);
                presets.Add(n);
                SavePresets();
                newPresetName = "";
            }
            //rename preset
            if (selectedIndex >= 0 && GUILayout.Button("Rename preset", HighLogic.Skin.button))
            {
                presets[selectedIndex].SetValue("name", newPresetName);
                newPresetName = "";
                SavePresets();
            }
            //delete preset
            if (selectedIndex >= 0 && GUILayout.Button("Delete preset", HighLogic.Skin.button))
            {
                presets.RemoveAt(selectedIndex);
                SavePresets();
            }
            GUILayout.EndHorizontal();
            //End
            GUILayout.EndVertical();
        }