Exemplo n.º 1
0
        internal static void Display(int windowId)
        {
            Title = SmUtils.SmTags["#smloc_settings_001"];
            // set input locks when mouseover window...
            //_inputLocked = GuiUtils.PreventClickthrough(ShowWindow, Position, _inputLocked);

            // Reset Tooltip active flag...
            ToolTipActive = false;

            Rect rect = new Rect(Position.width - 20, 4, 16, 16);

            // "Close Window.\r\nSettings will not be immediately saved,\r\n but will be remembered while in game.")))
            if (GUI.Button(rect, new GUIContent("", SmUtils.SmTags["#smloc_settings_tt_001"])))
            {
                ToolTip = "";
                if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
                {
                    SMAddon.OnSmSettingsClicked();
                }
                else
                {
                    SMSettings.MemStoreTempSettings();
                    ShowWindow = false;
                }
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
            }

            GUILayout.BeginVertical();

            DisplayTabButtons();

            _displayViewerPosition = GUILayout.BeginScrollView(_displayViewerPosition, SMStyle.ScrollStyle,
                                                               GUILayout.Height(300), GUILayout.Width(380));
            GUILayout.BeginVertical();

            DisplaySelectedTab(_displayViewerPosition);

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

            DisplayActionButtons();

            GUILayout.EndVertical();

            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
            SMAddon.RepositionWindow(ref Position);
        }
Exemplo n.º 2
0
        private static void WindowToggleButtons()
        {
            GUILayout.BeginHorizontal();

            GUIStyle settingsStyle = WindowSettings.ShowWindow ? SMStyle.ButtonToggledStyle : SMStyle.ButtonStyle;

            if (GUILayout.Button(SMUtils.Localize("#smloc_manifest_012"), settingsStyle, GUILayout.Height(20))) // "Settings"
            {
                try
                {
                    WindowSettings.ShowWindow = !WindowSettings.ShowWindow;
                    if (WindowSettings.ShowWindow)
                    {
                        // Store settings in case we cancel later...
                        SMSettings.MemStoreTempSettings();
                    }
                }
                catch (Exception ex)
                {
                    SMUtils.LogMessage(
                        string.Format(" opening Settings Window.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), SMUtils.LogType.Error,
                        true);
                }
            }

            GUIStyle rosterStyle = WindowRoster.ShowWindow ? SMStyle.ButtonToggledStyle : SMStyle.ButtonStyle;

            if (GUILayout.Button(SMUtils.Localize("#smloc_manifest_013"), rosterStyle, GUILayout.Height(20))) // "Roster"
            {
                try
                {
                    WindowRoster.ShowWindow = !WindowRoster.ShowWindow;
                    if (WindowRoster.ShowWindow)
                    {
                        WindowRoster.GetRosterList();
                    }
                    else
                    {
                        WindowRoster.SelectedKerbal = null;
                        WindowRoster.ToolTip        = "";
                    }
                }
                catch (Exception ex)
                {
                    SMUtils.LogMessage(
                        string.Format(" opening Roster Window.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), SMUtils.LogType.Error,
                        true);
                }
            }

            GUIStyle controlStyle = WindowControl.ShowWindow ? SMStyle.ButtonToggledStyle : SMStyle.ButtonStyle;

            if (GUILayout.Button(SMUtils.Localize("#smloc_manifest_014"), controlStyle, GUILayout.Height(20))) // "Control"
            {
                try
                {
                    WindowControl.ShowWindow = !WindowControl.ShowWindow;
                }
                catch (Exception ex)
                {
                    SMUtils.LogMessage(
                        string.Format(" opening Control Window.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), SMUtils.LogType.Error,
                        true);
                }
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 3
0
        internal static void Display(int windowId)
        {
            Title = $"{SmUtils.SmTags["#smloc_debug_000"]}:  {SMSettings.CurVersion}";

            // set input locks when mouseover window...
            //_inputLocked = GuiUtils.PreventClickthrough(ShowWindow, Position, _inputLocked);

            // Reset Tooltip active flag...
            ToolTipActive = false;

            Rect rect = new Rect(Position.width - 20, 4, 16, 16);

            if (GUI.Button(rect, new GUIContent("", SmUtils.SmTags["#smloc_window_tt_001"]))) // "Close Window"
            {
                ShowWindow = false;
                SMSettings.MemStoreTempSettings();
                ToolTip = "";
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
            }

            GUILayout.BeginVertical();
            SmUtils.DebugScrollPosition = GUILayout.BeginScrollView(SmUtils.DebugScrollPosition, SMStyle.ScrollStyle,
                                                                    GUILayout.Height(300), GUILayout.Width(500));
            GUILayout.BeginVertical();

            List <string> .Enumerator errors = SmUtils.LogItemList.GetEnumerator();
            while (errors.MoveNext())
            {
                if (errors.Current == null)
                {
                    continue;
                }
                GUILayout.TextArea(errors.Current, GUILayout.Width(460));
            }
            errors.Dispose();

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

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(SmUtils.SmTags["#smloc_debug_001"], GUILayout.Height(20))) //"Clear log"
            {
                SmUtils.LogItemList.Clear();
                SmUtils.LogItemList.Add($"Info:  Log Cleared at {DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)} UTC.");
            }
            if (GUILayout.Button(SmUtils.SmTags["#smloc_debug_002"], GUILayout.Height(20))) // "Save Log"
            {
                // Create log file and save.
                Savelog();
            }
            if (GUILayout.Button(SmUtils.SmTags["#smloc_debug_003"], GUILayout.Height(20))) // "Close"
            {
                // Create log file and save.
                ShowWindow = false;
                SMSettings.MemStoreTempSettings();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
            SMAddon.RepositionWindow(ref Position);
        }