Ejemplo n.º 1
0
 internal static void SetupGui()
 {
     GUI.skin = null;
     //GUI.skin = HighLogic.Skin;
     if (WindowStyle == null)
     {
         RMSettings.LoadColors();
         SetStyles();
     }
 }
Ejemplo n.º 2
0
        // Addon state event handlers
        internal void Awake()
        {
            try
            {
                if (HighLogic.LoadedScene != GameScenes.FLIGHT && HighLogic.LoadedScene != GameScenes.SPACECENTER &&
                    HighLogic.LoadedScene != GameScenes.EDITOR && HighLogic.LoadedScene != GameScenes.TRACKSTATION)
                {
                    return;
                }
                //DontDestroyOnLoad(this);
                RMSettings.ApplySettings();
                //WindowRoster.ResetKerbalProfessions();
                RmUtils.LogMessage("RosterManagerAddon.Awake Active...", "info", RMSettings.VerboseLogging);

                if (RMSettings.EnableBlizzyToolbar)
                {
                    // Let't try to use Blizzy's toolbar
                    RmUtils.LogMessage("RosterManagerAddon.Awake - Blizzy Toolbar Selected.", "Info", RMSettings.VerboseLogging);
                    if (!ActivateBlizzyToolBar())
                    {
                        // We failed to activate the toolbar, so revert to stock
                        if (ApplicationLauncher.Ready)
                        {
                            OnGuiAppLauncherReady();
                        }
                        else
                        {
                            GameEvents.onGUIApplicationLauncherReady.Add(OnGuiAppLauncherReady);
                        }
                        RmUtils.LogMessage("RosterManagerAddon.Awake - Stock Toolbar Selected.", "Info", RMSettings.VerboseLogging);
                    }
                }
                else
                {
                    // Use stock Toolbar
                    RmUtils.LogMessage("RosterManagerAddon.Awake - Stock Toolbar Selected.", "Info", RMSettings.VerboseLogging);
                    if (ApplicationLauncher.Ready)
                    {
                        OnGuiAppLauncherReady();
                    }
                    else
                    {
                        GameEvents.onGUIApplicationLauncherReady.Add(OnGuiAppLauncherReady);
                    }
                }
                // lets add our event handlers for kerbal actions
                //GameEvents.onKerbalAdded.Add(OnKerbalAdded);
            }
            catch (Exception ex)
            {
                RmUtils.LogMessage("Error in:  RosterManagerAddon.Awake.  Error:  " + ex, "Error", true);
            }
        }
Ejemplo n.º 3
0
        internal static void Display(int windowId)
        {
            // Reset Tooltip active flag...
            Rect rect = new Rect();

            ToolTipActive = false;

            rect = new Rect(371, 4, 16, 16);
            if (GUI.Button(rect, new GUIContent("", "Close Window")))
            {
                ToolTip = "";
                WindowSettings.ShowWindow = false;
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips == true)
            {
                ToolTip = Utilities.SetActiveTooltip(rect, Position, GUI.tooltip, ref ToolTipActive, 0, 0);
            }

            // Store settings in case we cancel later...
            RMSettings.StoreTempSettings();

            GUILayout.BeginVertical();
            ScrollViewerPosition = GUILayout.BeginScrollView(ScrollViewerPosition, GUILayout.Height(280), GUILayout.Width(375));
            GUILayout.BeginVertical();

            DisplayOptions();

            DisplayHighlighting();

            DisplayToolTips();

            DisplayConfiguration();

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

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Save"))
            {
                RMSettings.SaveSettings();
                WindowSettings.ShowWindow = false;
            }
            if (GUILayout.Button("Cancel"))
            {
                // We've canclled, so restore original settings.
                RMSettings.RestoreTempSettings();
                WindowSettings.ShowWindow = false;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
        }
Ejemplo n.º 4
0
        //Vessel state handlers
        internal void OnDestroy()
        {
            //Debug.Log("[RosterManager]:  RosterManagerAddon.OnDestroy");
            try
            {
                if (RMSettings.Loaded)
                {
                    try
                    {
                        RMSettings.SaveSettings();
                    }
                    catch
                    {
                        // Do nothing.
                    }
                }

                // Handle Toolbars
                if (_rmRosterBlizzy == null)
                {
                    if (_rmRosterStock != null)
                    {
                        ApplicationLauncher.Instance.RemoveModApplication(_rmRosterStock);
                        _rmRosterStock = null;
                    }
                    if (_rmRosterStock == null)
                    {
                        // Remove the stock toolbar button launcher handler
                        GameEvents.onGUIApplicationLauncherReady.Remove(OnGuiAppLauncherReady);
                    }
                }
                else
                {
                    _rmRosterBlizzy?.Destroy();
                }
                //Reset Roster Window data
                WindowRoster.DisplayMode    = WindowRoster.DisplayModes.None;
                WindowRoster.SelectedKerbal = null;
                WindowRoster.ToolTip        = "";
                //Settings.ShowRoster = false;
            }
            catch (Exception ex)
            {
                RmUtils.LogMessage("Error in:  RosterManagerAddon.OnDestroy.  " + ex, "Error", true);
            }
        }
Ejemplo n.º 5
0
        //Vessel state handlers
        internal void OnDestroy()
        {
            //Debug.Log("[RosterManager]:  RosterManagerAddon.OnDestroy");
            try
            {
                if (RMSettings.Loaded)
                {
                    RMSettings.SaveSettings();
                }

                // Handle Toolbars
                if (RMRoster_Blizzy == null)
                {
                    if (RMRoster_Stock != null)
                    {
                        ApplicationLauncher.Instance.RemoveModApplication(RMRoster_Stock);
                        RMRoster_Stock = null;
                    }
                    if (RMRoster_Stock == null)
                    {
                        // Remove the stock toolbar button launcher handler
                        GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady);
                    }
                }
                else
                {
                    if (RMRoster_Blizzy != null)
                    {
                        RMRoster_Blizzy.Destroy();
                    }
                }
                //Reset Roster Window data
                WindowRoster.OnCreate       = false;
                WindowRoster.SelectedKerbal = null;
                WindowRoster.ToolTip        = "";
                //Settings.ShowRoster = false;
            }
            catch (Exception ex)
            {
                Utilities.LogMessage("Error in:  RosterManagerAddon.OnDestroy.  " + ex.ToString(), "Error", true);
            }
        }
Ejemplo n.º 6
0
        // Addon state event handlers
        internal void Awake()
        {
            try
            {
                if (HighLogic.LoadedScene == GameScenes.FLIGHT || HighLogic.LoadedScene == GameScenes.SPACECENTER)
                {
                    DontDestroyOnLoad(this);
                    RMSettings.ApplySettings();
                    Utilities.LogMessage("RosterManagerAddon.Awake Active...", "info", RMSettings.VerboseLogging);

                    if (RMSettings.EnableBlizzyToolbar)
                    {
                        // Let't try to use Blizzy's toolbar
                        Utilities.LogMessage("RosterManagerAddon.Awake - Blizzy Toolbar Selected.", "Info", RMSettings.VerboseLogging);
                        if (!ActivateBlizzyToolBar())
                        {
                            // We failed to activate the toolbar, so revert to stock
                            GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
                            GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGUIAppLauncherDestroyed);
                            Utilities.LogMessage("RosterManagerAddon.Awake - Stock Toolbar Selected.", "Info", RMSettings.VerboseLogging);
                        }
                    }
                    else
                    {
                        // Use stock Toolbar
                        Utilities.LogMessage("RosterManagerAddon.Awake - Stock Toolbar Selected.", "Info", RMSettings.VerboseLogging);
                        GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
                        GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGUIAppLauncherDestroyed);
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.LogMessage("Error in:  RosterManagerAddon.Awake.  Error:  " + ex.ToString(), "Error", true);
            }
        }
Ejemplo n.º 7
0
        internal static void Display(int windowId)
        {
            // Reset Tooltip active flag...
            ToolTipActive = false;

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

            if (GUI.Button(rect, new GUIContent("", "Close Window")))
            {
                OnCreate       = false;
                SelectedKerbal = null;
                ToolTip        = "";
                if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
                {
                    RMAddon.OnRMRosterToggle();
                }
                else
                {
                    ShowWindow = false;
                }
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips == true)
            {
                ToolTip = Utilities.SetActiveTooltip(rect, Position, GUI.tooltip, ref ToolTipActive, 0, 0);
            }
            try
            {
                GUIStyle style        = GUI.skin.button;
                var      defaultColor = style.normal.textColor;
                GUILayout.BeginVertical();
                DisplayRosterFilter();

                DisplayRosterListViewer();

                if (OnCreate)
                {
                    CreateKerbalViewer();
                }
                else if (SelectedKerbal != null)
                {
                    GUILayout.Label("Kerbal Manager", RMStyle.LabelStyleBoldCenter, GUILayout.Width(680));
                    DisplayTabButtons();
                    DisplaySelectedTab();
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Create Kerbal"))
                    {
                        OnCreate = true;
                    }
                    var settingsStyle = WindowSettings.ShowWindow ? RMStyle.ButtonToggledStyle : RMStyle.ButtonStyle;
                    if (GUILayout.Button("Settings", settingsStyle))
                    {
                        try
                        {
                            WindowSettings.ShowWindow = !WindowSettings.ShowWindow;
                            if (WindowSettings.ShowWindow)
                            {
                                // Store settings in case we cancel later...
                                RMSettings.StoreTempSettings();
                            }
                        }
                        catch (Exception ex)
                        {
                            Utilities.LogMessage(string.Format(" opening Settings Window.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
                        }
                    }

                    if (RMSettings.RenameWithProfession)
                    {
                        string toolTip = "This action resets all renamed Kerbals to their KSP default professions.\r\nIt removes any non printing chars used to maintain a specific profession.\r\nUse this when you wish to revert a game save to be compatabile with KerbalStats\r\n or some other mod that creates custom professions.";
                        if (GUILayout.Button(new GUIContent("Reset Professions", toolTip)))
                        {
                            ResetKerbalProfessions();
                        }
                    }
                    rect = GUILayoutUtility.GetLastRect();
                    if (Event.current.type == EventType.Repaint && ShowToolTips == true)
                    {
                        ToolTip = Utilities.SetActiveTooltip(rect, Position, GUI.tooltip, ref ToolTipActive, 30, 30 - ScrollViewerPosition.y);
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
                GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
            }
            catch (Exception ex)
            {
                Utilities.LogMessage(string.Format(" in Roster Window.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
            }
        }