Exemple #1
0
        public UITab RenderNewCourseTab()
        {
            if (_tempCourseLblStyle == null)
            {
                _tempCourseLblStyle = new GUIStyle(GUI.skin.label);
                _tempCourseLblStyle.normal.textColor = Color.yellow;
            }

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(_selectedCourse.name);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (!string.IsNullOrEmpty(_selectedCourse.description))
            {
                GUILayout.Label(_selectedCourse.description);
            }
            if (_selectedCourse.isTemporary)
            {
                GUILayout.Label("Tech for this part is still being researched", _tempCourseLblStyle);
            }

            RenderSummaryBody(UITab.NewCourse);
            if (_selectedCourse.seatMax > 0)
            {
                GUILayout.Label($"{_selectedCourse.seatMax - _selectedCourse.Students.Count} remaining seat(s).");
            }
            if (_selectedCourse.seatMin > _selectedCourse.Students.Count)
            {
                GUILayout.Label($"{_selectedCourse.seatMin - _selectedCourse.Students.Count} more student(s) required.");
            }
            GUILayout.Label($"Will take {KSPUtil.PrintDateDeltaCompact(_selectedCourse.GetTime(), true, false)}");
            GUILayout.Label($"and finish on {KSPUtil.PrintDate(_selectedCourse.CompletionTime(), false)}");
            if (GUILayout.Button("Start Course", HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
            {
                if (_selectedCourse.StartCourse())
                {
                    CrewHandler.Instance.ActiveCourses.Add(_selectedCourse);
                    _selectedCourse = null;
                    MaintenanceHandler.Instance?.UpdateUpkeep();
                }
            }
            return(_selectedCourse == null ? UITab.Training : UITab.NewCourse);
        }
Exemple #2
0
        public tabs newCourseTab()
        {
            if (tempCourseLblStyle == null)
            {
                tempCourseLblStyle = new GUIStyle(GUI.skin.label);
                tempCourseLblStyle.normal.textColor = Color.yellow;
            }

            GUILayout.BeginHorizontal();
            try {
                GUILayout.FlexibleSpace();
                GUILayout.Label(selectedCourse.name);
                GUILayout.FlexibleSpace();
            } finally {
                GUILayout.EndHorizontal();
            }
            if (!string.IsNullOrEmpty(selectedCourse.description))
            {
                GUILayout.Label(selectedCourse.description);
            }
            if (selectedCourse.isTemporary)
            {
                GUILayout.Label("Tech for this part is still being researched", tempCourseLblStyle);
            }
            summaryBody(tabs.NewCourse);
            if (selectedCourse.seatMax > 0)
            {
                GUILayout.Label(selectedCourse.seatMax - selectedCourse.Students.Count + " remaining seat(s).");
            }
            if (selectedCourse.seatMin > selectedCourse.Students.Count)
            {
                GUILayout.Label(selectedCourse.seatMin - selectedCourse.Students.Count + " more student(s) required.");
            }
            GUILayout.Label("Will take " + KSPUtil.PrintDateDeltaCompact(selectedCourse.GetTime(), false, false));
            GUILayout.Label("and finish on " + KSPUtil.PrintDate(selectedCourse.CompletionTime(), false));
            if (GUILayout.Button("Start Course", GUILayout.ExpandWidth(false)))
            {
                if (selectedCourse.StartCourse())
                {
                    CrewHandler.Instance.ActiveCourses.Add(selectedCourse);
                    selectedCourse = null;
                }
            }
            return(selectedCourse == null ? tabs.Training : tabs.NewCourse);
        }
Exemple #3
0
        protected void nautListRow(tabs currentTab, ProtoCrewMember student)
        {
            GUIStyle     style         = HighLogic.Skin.label;
            ActiveCourse currentCourse = null;

            if (activeMap.ContainsKey(student))
            {
                currentCourse = activeMap[student];
            }
            bool onSelectedCourse = selectedCourse != null && currentCourse != null && currentCourse.id == selectedCourse.id;

            if (onSelectedCourse)
            {
                style = boldLabel;
            }
            bool selectedForCourse = selectedCourse != null && selectedCourse.Students.Contains(student);

            GUILayout.BeginHorizontal();
            try {
                GUILayout.Label(String.Format("{0} {1}", student.trait.Substring(0, 1), student.experienceLevel), GUILayout.Width(24));
                if (currentCourse == null && selectedCourse != null && (selectedForCourse || selectedCourse.MeetsStudentReqs(student)))
                {
                    if (toggleButton(student.name, selectedForCourse, GUILayout.Width(144)))
                    {
                        if (selectedForCourse)
                        {
                            selectedCourse.RemoveStudent(student);
                        }
                        else
                        {
                            selectedCourse.AddStudent(student);
                        }
                    }
                }
                else if (currentTab == tabs.Training)
                {
                    if (GUILayout.Button(student.name, GUILayout.Width(144)))
                    {
                        selectedNaut = student;
                    }
                }
                else
                {
                    GUILayout.Label(student.name, GUILayout.Width(144));
                }
                string course, complete, retires;
                if (currentCourse == null)
                {
                    if (student.inactive)
                    {
                        course   = "(inactive)";
                        complete = KSPUtil.PrintDate(student.inactiveTimeEnd, false);
                    }
                    else
                    {
                        course   = "(free)";
                        complete = "(n/a)";
                    }
                }
                else
                {
                    course   = currentCourse.name;
                    complete = KSPUtil.PrintDate(currentCourse.CompletionTime(), false);
                }
                GUILayout.Label(course, GUILayout.Width(96));
                GUILayout.Label(complete, GUILayout.Width(80));
                if (CrewHandler.Instance.kerbalRetireTimes.ContainsKey(student.name))
                {
                    retires = CrewHandler.Instance.retirementEnabled ? KSPUtil.PrintDate(CrewHandler.Instance.kerbalRetireTimes[student.name], false) : "(n/a)";
                }
                else
                {
                    retires = "(unknown)";
                }
                GUILayout.Label(retires, GUILayout.Width(80));
                if (currentCourse != null)
                {
                    if (currentCourse.seatMin > 1)
                    {
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                        {
                            cancelCourse(currentCourse);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                        {
                            leaveCourse(currentCourse, student);
                        }
                    }
                }
            } finally {
                GUILayout.EndHorizontal();
            }
        }
Exemple #4
0
 public void nautTab()
 {
     updateActiveMap();
     GUILayout.BeginHorizontal();
     try {
         GUILayout.FlexibleSpace();
         GUILayout.Label(selectedNaut.name);
         GUILayout.FlexibleSpace();
     } finally {
         GUILayout.EndHorizontal();
     }
     GUILayout.BeginHorizontal();
     try {
         GUILayout.Label(String.Format("{0} {1:D}", selectedNaut.trait, selectedNaut.experienceLevel.ToString()));
         if (CrewHandler.Instance.retirementEnabled && CrewHandler.Instance.kerbalRetireTimes.ContainsKey(selectedNaut.name))
         {
             GUILayout.Space(8);
             GUILayout.Label(String.Format("Retires NET {0}", KSPUtil.PrintDate(CrewHandler.Instance.kerbalRetireTimes[selectedNaut.name], false)),
                             rightLabel);
         }
     } finally {
         GUILayout.EndHorizontal();
     }
     if (activeMap.ContainsKey(selectedNaut))
     {
         ActiveCourse currentCourse = activeMap[selectedNaut];
         GUILayout.BeginHorizontal();
         try {
             GUILayout.Label("Studying " + currentCourse.name + " until " + KSPUtil.PrintDate(currentCourse.CompletionTime(), false));
             if (currentCourse.seatMin > 1)
             {
                 if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false)))
                 {
                     cancelCourse(currentCourse);
                 }
             }
             else
             {
                 if (GUILayout.Button("Remove", GUILayout.ExpandWidth(false)))
                 {
                     leaveCourse(currentCourse, selectedNaut);
                 }
             }
         } finally {
             GUILayout.EndHorizontal();
         }
     }
     GUILayout.Label(CrewHandler.Instance.GetTrainingString(selectedNaut));
 }
Exemple #5
0
        protected void nautListRow(tabs currentTab, ProtoCrewMember student)
        {
            GUIStyle     style         = HighLogic.Skin.label;
            ActiveCourse currentCourse = null;

            if (activeMap.ContainsKey(student))
            {
                currentCourse = activeMap[student];
            }
            bool onSelectedCourse = selectedCourse != null && currentCourse != null && currentCourse.id == selectedCourse.id;

            if (onSelectedCourse)
            {
                style = boldLabel;
            }
            bool selectedForCourse = selectedCourse != null && selectedCourse.Students.Contains(student);

            GUILayout.BeginHorizontal();
            try {
                GUILayout.Label(String.Format("{0} {1}", student.trait.Substring(0, 1), student.experienceLevel), GUILayout.Width(24));
                if (currentCourse == null && selectedCourse != null && (selectedForCourse || selectedCourse.MeetsStudentReqs(student)))
                {
                    if (toggleButton(student.name, selectedForCourse, GUILayout.Width(144)))
                    {
                        if (selectedForCourse)
                        {
                            selectedCourse.RemoveStudent(student);
                        }
                        else
                        {
                            selectedCourse.AddStudent(student);
                        }
                    }
                }
                else if (currentTab == tabs.Training)
                {
                    if (GUILayout.Button(student.name, GUILayout.Width(144)))
                    {
                        selectedNaut = student;
                    }
                }
                else
                {
                    GUILayout.Label(student.name, GUILayout.Width(144));
                }
                string course, complete, retires;
                if (currentCourse == null)
                {
                    if (student.inactive)
                    {
                        course   = "(inactive)";
                        complete = KSPUtil.PrintDate(student.inactiveTimeEnd, false);
                    }
                    else
                    {
                        course   = "(free)";
                        complete = "(n/a)";
                    }
                }
                else
                {
                    course   = currentCourse.name;
                    complete = KSPUtil.PrintDate(currentCourse.CompletionTime(), false);
                }
                GUILayout.Label(course, GUILayout.Width(96));
                GUILayout.Label(complete, GUILayout.Width(80));
                if (CrewHandler.Instance.kerbalRetireTimes.ContainsKey(student.name))
                {
                    retires = CrewHandler.Instance.retirementEnabled ? KSPUtil.PrintDate(CrewHandler.Instance.kerbalRetireTimes[student.name], false) : "(n/a)";
                }
                else
                {
                    retires = "(unknown)";
                }
                GUILayout.Label(retires, GUILayout.Width(80));
                if (currentCourse != null)
                {
                    if (currentCourse.seatMin > 1)
                    {
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                        {
                            cancelCourse(currentCourse);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                        {
                            leaveCourse(currentCourse, student);
                        }
                    }

                    if (KACWrapper.APIReady && GUILayout.Button(nautRowAlarmBtnContent, GUILayout.ExpandWidth(false)))
                    {
                        // CrewHandler processes trainings every 3600 seconds. Need to account for that to set up accurate KAC alarms.
                        double completeUT = currentCourse.CompletionTime();
                        double timeDiff   = completeUT - CrewHandler.Instance.nextUpdate;
                        double timesChRun = Math.Ceiling(timeDiff / CrewHandler.Instance.updateInterval);
                        double alarmUT    = CrewHandler.Instance.nextUpdate + timesChRun * CrewHandler.Instance.updateInterval;
                        string alarmTxt   = $"{currentCourse.name} - {student.name}";
                        KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Crew, alarmTxt, alarmUT);
                    }
                }
            } finally {
                GUILayout.EndHorizontal();
            }
        }
Exemple #6
0
        protected void RenderNautListRow(UITab currentTab, ProtoCrewMember student)
        {
            ActiveCourse currentCourse = null;

            if (_activeMap.ContainsKey(student))
            {
                currentCourse = _activeMap[student];
            }
            bool selectedForCourse = _selectedCourse != null && _selectedCourse.Students.Contains(student);

            GUILayout.BeginHorizontal();
            try
            {
                GUILayout.Label($"{student.trait.Substring(0, 1)} {student.experienceLevel}", GUILayout.Width(24));
                if (currentCourse == null && _selectedCourse != null && (selectedForCourse || _selectedCourse.MeetsStudentReqs(student)))
                {
                    var c = new GUIContent(student.name, "Select for course");
                    if (RenderToggleButton(c, selectedForCourse, GUILayout.Width(144)))
                    {
                        if (selectedForCourse)
                        {
                            _selectedCourse.RemoveStudent(student);
                        }
                        else
                        {
                            _selectedCourse.AddStudent(student);
                        }
                    }
                }
                else if (currentTab == UITab.Training)
                {
                    if (GUILayout.Button(student.name, HighLogic.Skin.button, GUILayout.Width(144)))
                    {
                        _selectedNaut = student;
                    }
                }
                else
                {
                    GUILayout.Label(student.name, GUILayout.Width(144));
                }

                string course, complete, retires;
                bool   isInactive = false;
                if (currentCourse == null)
                {
                    if (student.rosterStatus == ProtoCrewMember.RosterStatus.Assigned)
                    {
                        course   = "(in-flight)";
                        complete = "(n/a)";
                    }
                    else if (student.inactive)
                    {
                        course     = "(inactive)";
                        complete   = KSPUtil.PrintDate(student.inactiveTimeEnd, false);
                        isInactive = true;
                    }
                    else
                    {
                        course   = "(free)";
                        complete = "(n/a)";
                    }
                }
                else
                {
                    course   = currentCourse.name;
                    complete = KSPUtil.PrintDate(currentCourse.CompletionTime(), false);
                }
                GUILayout.Label(course, GUILayout.Width(96));
                GUILayout.Label(complete, GUILayout.Width(80));

                if (CrewHandler.Instance.KerbalRetireTimes.ContainsKey(student.name))
                {
                    retires = CrewHandler.Instance.RetirementEnabled ? KSPUtil.PrintDate(CrewHandler.Instance.KerbalRetireTimes[student.name], false) : "(n/a)";
                }
                else
                {
                    retires = "(unknown)";
                }
                GUILayout.Label(retires, GUILayout.Width(80));

                if (currentCourse != null)
                {
                    if (currentCourse.seatMin > 1)
                    {
                        if (GUILayout.Button(new GUIContent("X", "Cancel course"), HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                        {
                            CancelCourse(currentCourse);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button(new GUIContent("X", "Remove from course"), HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                        {
                            LeaveCourse(currentCourse, student);
                        }
                    }

                    if (KACWrapper.APIReady && GUILayout.Button(_nautRowAlarmBtnContent, HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                    {
                        CreateCourseFinishAlarm(student, currentCourse);
                    }
                }
                else if (KACWrapper.APIReady && isInactive && GUILayout.Button(_nautRowAlarmBtnContent, HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                {
                    CreateReturnToDutyAlarm(student);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
            GUILayout.EndHorizontal();
        }
Exemple #7
0
        public void RenderNautTab()
        {
            UpdateActiveCourseMap();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(_selectedNaut.name);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            try
            {
                GUILayout.Label($"{_selectedNaut.trait} {_selectedNaut.experienceLevel.ToString():D}");
                if (CrewHandler.Instance.RetirementEnabled && CrewHandler.Instance.KerbalRetireTimes.ContainsKey(_selectedNaut.name))
                {
                    GUILayout.Space(8);
                    GUILayout.Label($"Retires NET {KSPUtil.PrintDate(CrewHandler.Instance.KerbalRetireTimes[_selectedNaut.name], false)}", RightLabel);
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
            GUILayout.EndHorizontal();

            double nlt = CrewHandler.Instance.GetLatestRetireTime(_selectedNaut);

            if (nlt > 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Empty, GUILayout.ExpandWidth(true));
                GUILayout.Label($"Retires NLT {KSPUtil.PrintDate(nlt, false)}", RightLabel);
                GUILayout.EndHorizontal();
            }

            if (_activeMap.ContainsKey(_selectedNaut))
            {
                ActiveCourse currentCourse = _activeMap[_selectedNaut];
                GUILayout.BeginHorizontal();
                try
                {
                    GUILayout.Label($"Studying {currentCourse.name} until {KSPUtil.PrintDate(currentCourse.CompletionTime(), false)}");
                    if (currentCourse.seatMin > 1)
                    {
                        if (GUILayout.Button("Cancel", HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                        {
                            CancelCourse(currentCourse);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Remove", HighLogic.Skin.button, GUILayout.ExpandWidth(false)))
                        {
                            LeaveCourse(currentCourse, _selectedNaut);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.Label(CrewHandler.Instance.GetTrainingString(_selectedNaut));
        }
Exemple #8
0
        public void nautTab()
        {
            updateActiveMap();
            GUILayout.BeginHorizontal();
            try {
                GUILayout.FlexibleSpace();
                GUILayout.Label(selectedNaut.name);
                GUILayout.FlexibleSpace();
            } finally {
                GUILayout.EndHorizontal();
            }
            GUILayout.BeginHorizontal();
            try {
                GUILayout.Label($"{selectedNaut.trait} {selectedNaut.experienceLevel.ToString():D}");
                if (CrewHandler.Instance.RetirementEnabled && CrewHandler.Instance.KerbalRetireTimes.ContainsKey(selectedNaut.name))
                {
                    GUILayout.Space(8);
                    GUILayout.Label($"Retires NET {KSPUtil.PrintDate(CrewHandler.Instance.KerbalRetireTimes[selectedNaut.name], false)}", rightLabel);
                }
            } finally {
                GUILayout.EndHorizontal();
            }

            double nlt = CrewHandler.Instance.GetLatestRetireTime(selectedNaut);

            if (nlt > 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Empty, GUILayout.ExpandWidth(true));
                GUILayout.Label($"Retires NLT {KSPUtil.PrintDate(nlt, false)}", rightLabel);
                GUILayout.EndHorizontal();
            }

            if (activeMap.ContainsKey(selectedNaut))
            {
                ActiveCourse currentCourse = activeMap[selectedNaut];
                GUILayout.BeginHorizontal();
                try {
                    GUILayout.Label($"Studying {currentCourse.name} until {KSPUtil.PrintDate(currentCourse.CompletionTime(), false)}");
                    if (currentCourse.seatMin > 1)
                    {
                        if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false)))
                        {
                            cancelCourse(currentCourse);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Remove", GUILayout.ExpandWidth(false)))
                        {
                            leaveCourse(currentCourse, selectedNaut);
                        }
                    }
                } finally {
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.Label(CrewHandler.Instance.GetTrainingString(selectedNaut));
        }