コード例 #1
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();
        }
コード例 #2
0
        private void ToolbarWindow(int windowID)
        {
            float line = 0;

            line += 1.25f;

            if (FlightGlobals.ActiveVessel && (FlightGlobals.ActiveVessel.LandedOrSplashed || VesselMove.Instance.IsMovingVessel))
            {
                if (!VesselMove.Instance.IsMovingVessel)
                {
                    if (GUI.Button(LineRect(ref line, 1.5f), "Move Vessel", HighLogic.Skin.button))
                    {
                        VesselMove.Instance.StartMove(FlightGlobals.ActiveVessel, true);
                    }
                    line += 0.2f;

                    Rect spawnVesselRect = LineRect(ref line);
                    svRectScreenSpace    = new Rect(spawnVesselRect);
                    svRectScreenSpace.x += toolbarRect.x;
                    svRectScreenSpace.y += toolbarRect.y;

                    if (GUI.Button(spawnVesselRect, "Spawn Vessel", HighLogic.Skin.button))
                    {
                        VesselSpawn.instance.StartVesselSpawn();
                    }

                    line += .75f;
                    Rect crewRect1 = LineRect(ref line);
                    Rect crewRect2 = new Rect(crewRect1.x + crewRect1.width / 2 + 5f, crewRect1.y, crewRect1.width / 2, crewRect1.height);
                    crewRect1.width      = crewRect1.width / 2;
                    svCrewScreenSpace    = new Rect(crewRect1);
                    svCrewScreenSpace.x += toolbarRect.x;
                    svCrewScreenSpace.y += toolbarRect.y;
                    addCrewMembers       = GUI.Toggle(crewRect1, addCrewMembers, "Spawn Crew");
                    if (!addCrewMembers)
                    {
                        GUI.enabled = false;
                    }
                    selectCrewMembers = GUI.Toggle(crewRect2, selectCrewMembers, "Choose Crew");
                    GUI.enabled       = true;
                    showMoveHelp      = false;
                }
                else
                {
                    if (GUI.Button(LineRect(ref line, 2), "Place Vessel", HighLogic.Skin.button))
                    {
                        VesselMove.Instance.EndMove();
                    }

                    line += 0.3f;

                    if (GUI.Button(LineRect(ref line, 2), "Drop Vessel", HighLogic.Skin.button))
                    {
                        VesselMove.Instance.DropMove();
                    }

                    line += 0.3f;

                    if (GUI.Button(LineRect(ref line), "Help", HighLogic.Skin.button))
                    {
                        showMoveHelp = !showMoveHelp;
                    }
                }
            }
            else
            {
                GUIStyle centerLabelStyle = new GUIStyle(HighLogic.Skin.label);
                centerLabelStyle.alignment = TextAnchor.UpperCenter;
                GUI.Label(LineRect(ref line), "You need to be landed to use this!", centerLabelStyle);
            }

            toolbarRect.height = (line * toolbarLineHeight) + (toolbarMargin * 2);
            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
            VMUtils.RepositionWindow(ref toolbarRect);
        }
コード例 #3
0
        private static void OnWindow(int winID)
        {
            rwyListLength = Rwy.customRunways.Count * 40;

            rwyListVector = GUI.BeginScrollView(new Rect(10, 20, 150, 270), rwyListVector, new Rect(0, 0, 135, rwyListLength + 35));

            if (GUI.Button(new Rect(2, 0, 130, 30), "Create Runway"))
            {
                tempRwy  = new NavUtilLib.Runway();
                isNewRwy = true;
            }

            for (int i = 0; i < Rwy.customRunways.Count; i++)
            {
                if (i == Rwy.cRwyIdx && !isNewRwy)
                {
                    if (GUI.Button(new Rect(2, (i * 40) + 40, 130, 30), "* " + Rwy.customRunways[i].ident))
                    {
                        Rwy.cRwyIdx = i;
                        tempRwy     = Rwy.customRunways[i];
                        isNewRwy    = false;
                    }
                }
                else
                {
                    if (GUI.Button(new Rect(2, (i * 40) + 40, 130, 30), Rwy.customRunways[i].ident))
                    {
                        Rwy.cRwyIdx = i;
                        tempRwy     = Rwy.customRunways[i];
                        isNewRwy    = false;
                    }
                }
            }
            GUI.EndScrollView();
            //begin runway info area

            GUI.Label(new Rect(170, 20, 200, 20), "Runway Ident");

            GUI.Label(new Rect(170, 70, 150, 20), "Runway Heading");

            GUI.Label(new Rect(170, 120, 150, 20), "Runway Elevation (m)");



            GUI.Label(new Rect(170, 185, 240, 20), "Marker distance from current point (m)");

            GUI.Label(new Rect(190, 200, 60, 20), " Inner");
            GUI.Label(new Rect(260, 200, 60, 20), " Middle");
            GUI.Label(new Rect(330, 200, 60, 20), " Outer");


            //isNewRwy


            //only difference is textbox vs label
            if (isNewRwy)
            {
                GUI.Label(new Rect(340, 70, 85, 20), "Auto Hdg?");
                useAutoHdg = GUI.Toggle(new Rect(350, 90, 20, 20), useAutoHdg, "");

                GUI.Label(new Rect(340, 120, 85, 20), "Auto Elevation?");
                useAutoElevation = GUI.Toggle(new Rect(350, 140, 20, 20), useAutoElevation, "");


                tempRwy.ident = GUI.TextField(new Rect(170, 40, 200, 20), tempRwy.ident);

                GUI.Label(new Rect(340, 70, 85, 20), "Auto Hdg?");
                useAutoHdg = GUI.Toggle(new Rect(350, 90, 20, 20), useAutoHdg, "");
                if (useAutoHdg)
                {
                    tempRwy.hdg = (float)Math.Round(FlightGlobals.ship_heading, 2);

                    GUI.Label(new Rect(170, 90, 150, 20), tempRwy.hdg.ToString() + "°");
                }
                else
                {
                    tempRwy.hdg = Convert.ToSingle(GUI.TextField(new Rect(170, 90, 150, 20), Convert.ToString(tempRwy.hdg)));
                }

                GUI.Label(new Rect(340, 120, 85, 20), "Auto Alt?");
                useAutoElevation = GUI.Toggle(new Rect(350, 140, 20, 20), useAutoElevation, "");
                if (useAutoElevation)
                {
                    tempRwy.altMSL = (float)Math.Round(FlightGlobals.ActiveVessel.altitude, 1);

                    GUI.Label(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL) + "m");
                }
                else
                {
                    tempRwy.altMSL = Convert.ToSingle(GUI.TextField(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL)));
                }



                GUI.Label(new Rect(170, 165, 120, 20), "Use Marker Becons?");
                makeMarkers = GUI.Toggle(new Rect(350, 168, 20, 20), makeMarkers, "");


                if (makeMarkers)
                {
                    tempRwy.innerMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(190, 220, 60, 20), Convert.ToString(tempRwy.innerMarkerDist)));

                    tempRwy.middleMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(260, 220, 60, 20), Convert.ToString(tempRwy.middleMarkerDist)));
                    tempRwy.outerMarkerDist  = Convert.ToSingle(GUI.TextField(new Rect(330, 220, 60, 20), Convert.ToString(tempRwy.outerMarkerDist)));

                    if (tempRwy.innerMarkerDist < -500)
                    {
                        tempRwy.innerMarkerDist = -500;
                    }


                    if (tempRwy.middleMarkerDist < -500)
                    {
                        tempRwy.middleMarkerDist = -500;
                    }


                    if (tempRwy.outerMarkerDist < -500)
                    {
                        tempRwy.outerMarkerDist = -500;
                    }
                }
            }
            else
            {
                GUI.Label(new Rect(170, 40, 200, 20), tempRwy.ident);

                GUI.Label(new Rect(170, 90, 150, 20), tempRwy.hdg.ToString() + "°");
                GUI.Label(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL) + "m");

                if (tempRwy.innerMarkerDist > -500)
                {
                    GUI.Label(new Rect(190, 220, 60, 20), tempRwy.innerMarkerDist.ToString() + "m");
                }
                else
                {
                    GUI.Label(new Rect(190, 220, 60, 20), "  N/A");
                }

                if (tempRwy.middleMarkerDist > -500)
                {
                    GUI.Label(new Rect(260, 220, 60, 20), tempRwy.middleMarkerDist.ToString() + "m");
                }
                else
                {
                    GUI.Label(new Rect(260, 220, 60, 20), "  N/A");
                }

                if (tempRwy.outerMarkerDist > -500)
                {
                    GUI.Label(new Rect(330, 220, 60, 20), tempRwy.outerMarkerDist.ToString() + "m");
                }
                else
                {
                    GUI.Label(new Rect(330, 220, 60, 20), "  N/A");
                }
            }

            if (isNewRwy)
            {
                if (GUI.Button(new Rect(170, 250, 200, 20), "Create Runway"))
                {
                    //create the runway and add to database
                    tempRwy.body        = FlightGlobals.currentMainBody.bodyName;
                    tempRwy.gsLatitude  = (float)FlightGlobals.ship_latitude;
                    tempRwy.gsLongitude = (float)FlightGlobals.ship_longitude;

                    Vector2d loc = NavUtilLib.Utils.CalcCoordinatesFromInitialPointBearingDistance(new Vector2d(tempRwy.gsLatitude, tempRwy.gsLongitude), tempRwy.hdg, 1000, FlightGlobals.currentMainBody.Radius);

                    tempRwy.locLatitude  = (float)loc.x;
                    tempRwy.locLongitude = (float)loc.y;

                    if (!makeMarkers)
                    {
                        tempRwy.innerMarkerDist  = -1000;
                        tempRwy.middleMarkerDist = -1000;
                        tempRwy.outerMarkerDist  = -1000;
                    }


                    Rwy.customRunways.Add(tempRwy);
                    Rwy.currentBodyRunways.Add(tempRwy);

                    Rwy.cRwyIdx = Rwy.customRunways.FindIndex(r => r.ident == tempRwy.ident);

                    WriteCustomRwys();

                    isNewRwy = false;
                }
            }
            else
            {
                //show delete button
                if (GUI.Button(new Rect(170, 250, 200, 20), "Delete This Runway"))
                {
                    Rwy.allRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]);
                    if (Rwy.currentBodyRunways.Contains(Rwy.customRunways[Rwy.cRwyIdx]))
                    {
                        Rwy.currentBodyRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]);
                    }
                    Rwy.customRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]);

                    WriteCustomRwys();

                    Rwy.cRwyIdx = 0;

                    isNewRwy = true;
                    tempRwy  = new NavUtilLib.Runway();
                }
            }
            GUI.DragWindow();
        }
コード例 #4
0
        void OnWindowGUI(int id)
        {
            GUI.skin = HighLogic.Skin;
            Historian historian = Historian.Instance;

            // column one
            using (GUILayout.AreaScope columnOne = new GUILayout.AreaScope(new Rect(15, 20, 380, 550)))
            {
                using (GUILayout.VerticalScope col = new GUILayout.VerticalScope())
                {
                    GUILayout.Space(20);
                    historian.Suppressed              = GUILayout.Toggle(historian.Suppressed, Localizer.GetStringByTag("#Historian_Suppressed"));
                    historian.AlwaysActive            = GUILayout.Toggle(historian.AlwaysActive, Localizer.GetStringByTag("#Historian_AlwaysActive"));
                    historian.AutoHideUI              = GUILayout.Toggle(historian.AutoHideUI, Localizer.GetStringByTag("#Historian_AutoHideUI"));
                    Configuration.Instance.AutoHideUI = historian.AutoHideUI;

                    Configuration.Instance.PersistentConfigurationWindow = GUILayout.Toggle(Configuration.Instance.PersistentConfigurationWindow, Localizer.GetStringByTag("#Historian_AlwaysShowConfigWindow"));
                    Configuration.Instance.EnableLauncherButton          = GUILayout.Toggle(Configuration.Instance.EnableLauncherButton, Localizer.GetStringByTag("#Historian_UseAppLauncher"));
                    Configuration.Instance.EnableToolbarButton           = GUILayout.Toggle(Configuration.Instance.EnableToolbarButton, Localizer.GetStringByTag("#Historian_UseToolbar"));
                    GUILayout.Space(10);

                    using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope())
                    {
                        int rightClickOptionsCount = 4;
                        //GUILayout.Space(40);
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_RightClickAction"));
                        GUILayout.Space(10);
                        if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight)))
                        {
                            Configuration.Instance.RightClickAction = (RightClickAction)Mathf.Clamp((int)Configuration.Instance.RightClickAction - 1, 0, rightClickOptionsCount - 1);
                        }
                        else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight)))
                        {
                            Configuration.Instance.RightClickAction = (RightClickAction)Mathf.Clamp((int)Configuration.Instance.RightClickAction + 1, 0, rightClickOptionsCount - 1);
                        }
                        GUILayout.Space(5);
                        GUILayout.Label(Configuration.Instance.RightClickAction.ToString(), GUI.skin.textArea, GUILayout.ExpandWidth(true));
                    }

                    ManageButtons();

                    GUILayout.Space(10);
                    using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_Layout"));
                        GUILayout.Space(10);
                        string[] layouts = historian.GetLayoutNames();
                        if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight)))
                        {
                            historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex - 1, 0, layouts.Length - 1);
                        }
                        else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight)))
                        {
                            historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex + 1, 0, layouts.Length - 1);
                        }
                        GUILayout.Space(5);
                        GUILayout.Label(historian.GetCurrentLayoutName(), GUI.skin.textArea, GUILayout.ExpandWidth(true));
                    }

                    GUILayout.Space(10);
                    using (GUILayout.HorizontalScope customHead = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_CustomText"));
                        GUILayout.FlexibleSpace();
                        Configuration.Instance.PersistentCustomText = GUILayout.Toggle(Configuration.Instance.PersistentCustomText, Localizer.GetStringByTag("#Historian_Persistent"), GUILayout.Width(120));
                    }
                    Configuration.Instance.CustomText = GUILayout.TextArea(Configuration.Instance.CustomText, GUI.skin.textArea, GUILayout.Height(60));

                    GUILayout.Space(10);
                    using (GUILayout.HorizontalScope spaceCentre = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_DefaultSpaceCenterLabel"));
                        GUILayout.FlexibleSpace();
                        Configuration.Instance.DefaultSpaceCenterName = GUILayout.TextField(Configuration.Instance.DefaultSpaceCenterName, GUI.skin.textArea, GUILayout.Width(150));
                    }


                    GUILayout.Space(10);
                    GUILayout.Label($"{Localizer.GetStringByTag("#Historian_LastActionTime")}: {Configuration.Instance.TimeToRememberLastAction} ms");
                    Configuration.Instance.TimeToRememberLastAction = (int)GUILayout.HorizontalSlider(Configuration.Instance.TimeToRememberLastAction, 250, 10000, GUILayout.ExpandWidth(true));
                }
            }

            // column two
            using (GUILayout.AreaScope columnTwo = new GUILayout.AreaScope(new Rect(410, 20, 220, 500)))
            {
                using (GUILayout.VerticalScope col = new GUILayout.VerticalScope())
                {
                    GUILayout.Space(20);
                    GUILayout.Label(Localizer.GetStringByTag("#Historian_DayNames"));
                    for (int i = 0; i < Configuration.Instance.KerbinDayNames.Length; i++)
                    {
                        using (GUILayout.HorizontalScope item = new GUILayout.HorizontalScope())
                        {
                            GUILayout.Label($"{i + 1}:");
                            GUILayout.FlexibleSpace();
                            Configuration.Instance.KerbinDayNames[i] = GUILayout.TextField(Configuration.Instance.KerbinDayNames[i], GUI.skin.textArea, GUILayout.Width(190f));
                        }
                    }

                    GUILayout.Space(50);
                    GUILayout.Label(Localizer.GetStringByTag("#Historian_DefaultEmptyCrewSlot"));
                    GUILayout.Space(10);
                    using (GUILayout.HorizontalScope noCrewLabel = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_CrewedLabel"));
                        GUILayout.FlexibleSpace();
                        Configuration.Instance.DefaultNoCrewLabel = GUILayout.TextField(Configuration.Instance.DefaultNoCrewLabel, GUI.skin.textArea, GUILayout.Width(120));
                    }
                    using (GUILayout.HorizontalScope noCrewLabel = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_UncrewedLabel"));
                        GUILayout.FlexibleSpace();
                        Configuration.Instance.DefaultUnmannedLabel = GUILayout.TextField(Configuration.Instance.DefaultUnmannedLabel, GUI.skin.textArea, GUILayout.Width(120));
                    }
                }
            }

            // column three
            using (GUILayout.AreaScope columnThree = new GUILayout.AreaScope(new Rect(660, 20, 220, 480)))
            {
                using (GUILayout.VerticalScope col = new GUILayout.VerticalScope())
                {
                    GUILayout.Space(20);
                    GUILayout.Label(Localizer.GetStringByTag("#Historian_MonthNames"));
                    for (int i = 0; i < Configuration.Instance.KerbinMonthNames.Length; i++)
                    {
                        using (GUILayout.HorizontalScope item = new GUILayout.HorizontalScope())
                        {
                            GUILayout.Label($"{i + 1}:");
                            GUILayout.FlexibleSpace();
                            Configuration.Instance.KerbinMonthNames[i] = GUILayout.TextField(Configuration.Instance.KerbinMonthNames[i], GUI.skin.textArea, GUILayout.Width(190f));
                        }
                    }
                }
            }

            // bottom bar
            using (GUILayout.AreaScope buttonBar = new GUILayout.AreaScope(new Rect(5, 525, 890, 30)))
            {
                using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope())
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(Localizer.GetStringByTag("#autoLOC_900539"), GUILayout.Width(100.0f))) // #autoLOC_900539 = Load
                    {
                        historian.Reload();
                    }
                    if (GUILayout.Button(Localizer.GetStringByTag("#autoLOC_174778"), GUILayout.Width(100.0f))) // #autoLOC_174778 = Save
                    {
                        Configuration.Instance.Layout = historian.GetCurrentLayoutName();

                        historian.SetConfiguration(Configuration.Instance);
                        if (!Configuration.Instance.PersistentConfigurationWindow)
                        {
                            Toggle();
                        }

                        if (!String.IsNullOrEmpty(Configuration.Instance.CustomText))
                        {
                            Configuration.Instance.TokenizedCustomText = Parser.GetTokens(Configuration.Instance.CustomText);
                        }
                    }
                    GUILayout.Space(20);
                    // GUILayout.FlexibleSpace();
                }
            }

            GUI.DragWindow();
        }
コード例 #5
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();
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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();
            }
        }