コード例 #1
0
        internal static void Display(int windowId)
        {
            try
            {
                title = Localizer.Format("#autoLOC_LTech_Settings_001");

                Rect rect = new Rect(position.width - 20, 4, 18, 18);
                _label    = "x";
                _tooltip  = Localizer.Format("#autoLOC_LTech_Settings_tt_001");
                _guiLabel = new GUIContent(_label, _tooltip);
                if (GUI.Button(rect, _guiLabel))
                {
                    if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedSceneIsFlight)
                    {
                        Addon.OnToolbarButtonToggle();
                    }
                    else
                    {
                        showWindow = false;
                    }
                }

                GUILayout.BeginVertical();

                DisplaySettings();

                DisplayActions();

                GUILayout.EndVertical();

                GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
                Addon.RepositionWindow(ref position);
            }
            catch (Exception ex)
            {
                if (!Addon.FrameErrTripped)
                {
                    Log.Error($"WindowSettings.Display. Error: {ex.Message}\r\n\r\n{ex.StackTrace}");
                    Addon.FrameErrTripped = true;
                }
            }
        }
コード例 #2
0
        private static void DisplayActions()
        {
            try
            {
                GUILayout.BeginHorizontal();

                // Save button
                _label    = Localizer.Format("#autoLOC_LTech_Settings_009");
                _tooltip  = Localizer.Format("#autoLOC_LTech_Settings_tt_009");
                _guiLabel = new GUIContent(_label, _tooltip);
                if (GUILayout.Button(_guiLabel, GUILayout.Height(height)))
                {
                    Settings.SaveSettings();

                    if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedSceneIsFlight)
                    {
                        Addon.OnToolbarButtonToggle();
                    }
                    else
                    {
                        showWindow = false;
                    }
                }

                // Cancel button
                _label    = Localizer.Format("#autoLOC_LTech_Settings_010");
                _tooltip  = Localizer.Format("#autoLOC_LTech_Settings_tt_010");
                _guiLabel = new GUIContent(_label, _tooltip);
                if (GUILayout.Button(_guiLabel, GUILayout.Height(height)))
                {
                    if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedSceneIsFlight)
                    {
                        Addon.OnToolbarButtonToggle();
                    }
                    else
                    {
                        showWindow = false;
                    }
                }

                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();

                // Reset button
                _label    = Localizer.Format("#autoLOC_LTech_Settings_011");
                _tooltip  = Localizer.Format("#autoLOC_LTech_Settings_tt_011");
                _guiLabel = new GUIContent(_label, _tooltip);
                if (GUILayout.Button(_guiLabel, GUILayout.Height(height)))
                {
                    Settings.ResetSettings();
                }

                GUILayout.EndHorizontal();
            }
            catch (Exception ex)
            {
                if (!Addon.FrameErrTripped)
                {
                    Log.Error($"WindowSettings.DisplayActions. Error: {ex.Message}\r\n\r\n{ex.StackTrace}");
                    Addon.FrameErrTripped = true;
                }
            }
        }