Ejemplo n.º 1
0
        private void OnMainWindow(int windowID)
        {
            GUIStyle style = new GUIStyle(GUI.skin.toggle);

            GUILayout.BeginVertical();
            GUILayout.TextArea("Hello World!", GUILayout.ExpandHeight(true), GUILayout.MaxHeight(100));
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Ejemplo n.º 2
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()
Ejemplo n.º 3
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();
        }