Exemplo n.º 1
0
        internal static void Display(int windowId)
        {
            // Reset Tooltip active flag...
            ToolTipActive = false;

            var rect = new Rect(496, 4, 16, 16);

            if (GUI.Button(rect, new GUIContent("", "Close Window")))
            {
                ShowWindow = false;
                ToolTip    = "";
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips)
            {
                ToolTip = RMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
            }

            GUILayout.BeginVertical();
            Utilities.DebugScrollPosition = GUILayout.BeginScrollView(Utilities.DebugScrollPosition, GUILayout.Height(300), GUILayout.Width(500));
            GUILayout.BeginVertical();

            foreach (var error in Utilities.ErrorList)
            {
                GUILayout.TextArea(error, GUILayout.Width(460));
            }

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

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Clear log", GUILayout.Height(20)))
            {
                Utilities.ErrorList.Clear();
                Utilities.ErrorList.Add("Info:  Log Cleared at " + DateTime.UtcNow + " UTC.");
            }
            if (GUILayout.Button("Save Log", GUILayout.Height(20)))
            {
                // Create log file and save.
                Savelog();
            }
            if (GUILayout.Button("Close", GUILayout.Height(20)))
            {
                // Create log file and save.
                ShowWindow = false;
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
            RMSettings.RepositionWindows("WindowDebugger");
        }
Exemplo n.º 2
0
        internal static void Display(int windowId)
        {
            // Reset Tooltip active flag...
            ToolTipActive = false;

            var rect = new Rect(371, 4, 16, 16);

            if (GUI.Button(rect, new GUIContent("", "Close Window")))
            {
                ToolTip = "";
                RMSettings.RestoreTempSettings();
                ShowWindow = false;
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips)
            {
                ToolTip = RMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
            }

            // 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"))
            {
                //If EnableAging has been turned ON when it was previously OFF, we reset age processing, otherwise they could all die instantly.
                if (RMLifeSpan.Instance.RMGameSettings.EnableAging && RMSettings.PrevEnableAging == false)
                {
                    Utilities.LogMessage("RosterManagerWindowSettings.Display Save settings, aging has been enabled. Reset all birthdays.", "info", RMSettings.VerboseLogging);
                    var currentTime = Planetarium.GetUniversalTime();
                    foreach (var rmkerbal in RMLifeSpan.Instance.RMKerbals.AllrmKerbals)
                    {
                        rmkerbal.Value.TimelastBirthday = currentTime;
                        rmkerbal.Value.TimeNextBirthday = RMKerbal.BirthdayNextDue(currentTime);
                    }
                }
                //If EnableSalaries has been turned OFF when it was previously ON, reset any kerbals from tourist back to active.
                if (!RMLifeSpan.Instance.RMGameSettings.EnableSalaries && RMSettings.PrevEnableSalaries)
                {
                    Utilities.LogMessage("RosterManagerWindowSettings.Display Save settings, salaries have been turned off. Reset all salary related fields for all kerbals.", "info", RMSettings.VerboseLogging);
                    foreach (var rmkerbal in RMLifeSpan.Instance.RMKerbals.AllrmKerbals)
                    {
                        if (rmkerbal.Value.Type == ProtoCrewMember.KerbalType.Tourist && rmkerbal.Value.Kerbal.rosterStatus != ProtoCrewMember.RosterStatus.Dead)
                        {
                            rmkerbal.Value.Type         = ProtoCrewMember.KerbalType.Crew;
                            rmkerbal.Value.Kerbal.type  = ProtoCrewMember.KerbalType.Crew;
                            rmkerbal.Value.Trait        = rmkerbal.Value.RealTrait;
                            rmkerbal.Value.Kerbal.trait = rmkerbal.Value.RealTrait;
                            KerbalRoster.SetExperienceTrait(rmkerbal.Value.Kerbal, rmkerbal.Value.Trait);
                            RMKerbal.RegisterExperienceTrait(rmkerbal.Value);
                        }
                        rmkerbal.Value.SalaryContractDispute          = false;
                        rmkerbal.Value.SalaryContractDisputePeriods   = 0;
                        rmkerbal.Value.SalaryContractDisputeProcessed = true;
                    }
                }
                //If EnableSalaries has been turned ON when it was previously OFF, reset all kerbals salary time to now.
                if (RMLifeSpan.Instance.RMGameSettings.EnableSalaries && RMSettings.PrevEnableSalaries == false)
                {
                    Utilities.LogMessage("RosterManagerWindowSettings.Display Save settings, salaries have been turned on. Reset all salary related fields for all kerbals.", "info", RMSettings.VerboseLogging);
                    var currentTime = Planetarium.GetUniversalTime();
                    foreach (var rmkerbal in RMLifeSpan.Instance.RMKerbals.AllrmKerbals)
                    {
                        rmkerbal.Value.Timelastsalary = currentTime;
                        rmkerbal.Value.TimeSalaryDue  = RMKerbal.SalaryNextDue(currentTime);
                    }
                }
                RMSettings.SaveSettings();
                ShowWindow = false;
            }
            if (GUILayout.Button("Cancel"))
            {
                // We've canclled, so restore original settings.
                RMSettings.RestoreTempSettings();
                ShowWindow = false;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
            RMSettings.RepositionWindows("WindowSettings");
        }
Exemplo n.º 3
0
        internal static void Display(int windowId)
        {
            // Reset Tooltip active flag...
            ToolTipActive = false;

            // Close window button
            var rect = new Rect(Position.width - 20, 4, 16, 16);

            if (GUI.Button(rect, new GUIContent("", "Close Window")))
            {
                SelectedKerbal = null;
                DisplayMode    = DisplayModes.Index;
                ToolTip        = "";
                if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.EDITOR || HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.FLIGHT)
                {
                    RMAddon.OnRMRosterToggle();
                }
                else
                {
                    ShowWindow = false;
                }
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips)
            {
                ToolTip = RMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
            }

            // Ok, now lets render the window...
            try
            {
                GUILayout.BeginVertical();
                DisplayRosterFilter();
                DisplayRosterViewer();

                switch (DisplayMode)
                {
                case DisplayModes.Index:
                    DisplayActionButtonsIndex();
                    break;

                case DisplayModes.Edit:
                    GUILayout.Label("Kerbal Manager", RMStyle.LabelStyleBoldCenter, GUILayout.Width(680));
                    DisplayTabButtons();
                    DisplaySelectedTab();
                    break;

                case DisplayModes.Create:
                    GUILayout.Label("Create a Kerbal", RMStyle.LabelStyleBoldCenter, GUILayout.Width(680));
                    DisplaySelectProfession();
                    DisplaySelectGender();
                    DisplayActionButtonsCreate();
                    break;

                default:
                    DisplayActionButtonsIndex();
                    break;
                }
                GUILayout.EndVertical();
                GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
                RMSettings.RepositionWindows("WindowRoster");
            }
            catch (Exception ex)
            {
                Utilities.LogMessage(string.Format(" in Roster Window.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
            }
        }
Exemplo n.º 4
0
        internal static void Display(int windowId)
        {
            // Reset Tooltip active flag...
            ToolTipActive = false;

            var rect = new Rect(680, 4, 16, 16);

            if (GUI.Button(rect, new GUIContent("", "Close Window")))
            {
                ToolTip    = "";
                ShowWindow = false;
            }
            if (Event.current.type == EventType.Repaint && ShowToolTips)
            {
                ToolTip = RMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
            }

            GUILayout.BeginVertical();
            DisplayRosterFilter();

            DisplayHeadings();

            _scrollViewerPosition = GUILayout.BeginScrollView(_scrollViewerPosition, RMStyle.ScrollStyle, GUILayout.Height(280), GUILayout.Width(680));
            GUILayout.BeginVertical();
            if (IsAll || IsDispute || IsStrike)
            {
                DisplayDisputes();
            }
            if (IsAll || IsContracted)
            {
                DisplayContracted();
            }

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

            GUILayout.BeginHorizontal();
            var    disputekerbals = new List <RMKerbal>(RMLifeSpan.Instance.RMKerbals.AllrmKerbals.Values.Where(a => a.SalaryContractDispute).ToList());
            string buttonToolTip;

            if (disputekerbals.Any())
            {
                buttonToolTip = "Accept All Payrises. Kerbals will continue working.";
                if (GUILayout.Button(new GUIContent("Accept All", buttonToolTip), RMStyle.ButtonStyle))
                {
                    // Accept all disputes.
                    foreach (var disputekerbal in disputekerbals.Where(disputekerbal => !disputekerbal.SalaryContractDisputeProcessed))
                    {
                        AcceptDispute(disputekerbal);
                    }
                    ToolTip    = "";
                    ShowWindow = false;
                }
                rect = GUILayoutUtility.GetLastRect();
                if (Event.current.type == EventType.Repaint && ShowToolTips)
                {
                    ToolTip = RMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
                }

                buttonToolTip = "Decline All Payrises, All listed kerbals will become tourists until you can pay them.";
                if (GUILayout.Button(new GUIContent("Decline All", buttonToolTip), RMStyle.ButtonStyle))
                {
                    // Decline all disputes.
                    foreach (var disputekerbal in disputekerbals.Where(disputekerbal => !disputekerbal.SalaryContractDisputeProcessed))
                    {
                        DeclineDispute(disputekerbal);
                    }
                    ToolTip    = "";
                    ShowWindow = false;
                }
                rect = GUILayoutUtility.GetLastRect();
                if (Event.current.type == EventType.Repaint && ShowToolTips)
                {
                    ToolTip = RMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
                }
            }
            if (_recontractFlag)
            {
                buttonToolTip = "ReContract All Disputed Kerbals.";
                if (GUILayout.Button(new GUIContent("Recontract All", buttonToolTip), RMStyle.ButtonStyle))
                {
                    // ReContract all disputes.
                    foreach (var disputekerbal in disputekerbals.Where(disputekerbal => disputekerbal.SalaryContractDisputeProcessed))
                    {
                        ReContract(disputekerbal);
                    }
                    ToolTip    = "";
                    ShowWindow = false;
                }
                rect = GUILayoutUtility.GetLastRect();
                if (Event.current.type == EventType.Repaint && ShowToolTips)
                {
                    ToolTip = RMToolTips.SetActiveToolTip(rect, GUI.tooltip, ref ToolTipActive, 10);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUI.DragWindow(new Rect(0, 0, Screen.width, 30));
            RMSettings.RepositionWindows("WindowContracts");
        }