Пример #1
0
        protected bool showTab(tabs tab)
        {
            switch (tab)
            {
            case tabs.Maintenance:
            case tabs.Facilities:
            case tabs.Integration:
                return(HighLogic.LoadedScene == GameScenes.SPACECENTER && HighLogic.CurrentGame.Mode == Game.Modes.CAREER);

            case tabs.Tooling:
            case tabs.ToolingType:
            case tabs.Contracts:
                return(HighLogic.CurrentGame.Mode == Game.Modes.CAREER);

            case tabs.Avionics:
                return(HighLogic.LoadedSceneIsEditor);

            case tabs.Astronauts:
                return(HighLogic.LoadedScene == GameScenes.SPACECENTER);

            case tabs.Training:
            case tabs.Courses:
            case tabs.NewCourse:
            case tabs.Naut:
            case tabs.CareerLog:
            default:
                return(true);
            }
        }
Пример #2
0
        /*Events*/

        //When tabs are changed...
        private void MainTabs_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (mainTabs.SelectedIndex)
            {
            case 0:
                currentTab = tabs.MAIN;
                break;

            case 1:
            {
                currentTab             = tabs.USERS;
                pnlRightBtns.IsEnabled = true;
                break;
            }

            case 2:
            {
                currentTab             = tabs.BRANCHES;
                pnlRightBtns.IsEnabled = true;
                break;
            }

            case 3:
            {
                currentTab             = tabs.SHIFTS;
                pnlRightBtns.IsEnabled = true;
                break;
            }
            }
        }
Пример #3
0
 private void tabSelector()
 {
     GUILayout.BeginHorizontal();
     try {
         if (showTab(tabs.Maintenance) && toggleButton("Maintenance", currentTab == tabs.Maintenance))
         {
             currentTab = tabs.Maintenance;
         }
         if (showTab(tabs.Tooling) && toggleButton("Tooling", currentTab == tabs.Tooling))
         {
             currentTab = tabs.Tooling;
         }
         if (showTab(tabs.Training) && toggleButton("Astronauts", currentTab == tabs.Training))
         {
             currentTab = tabs.Training;
         }
         if (showTab(tabs.Courses) && toggleButton("Courses", currentTab == tabs.Courses))
         {
             currentTab = tabs.Courses;
         }
         if (showTab(tabs.Avionics) && toggleButton("Avionics", currentTab == tabs.Avionics))
         {
             currentTab = tabs.Avionics;
         }
     } finally {
         GUILayout.EndHorizontal();
     }
 }
Пример #4
0
 public FlightSceneWindow(RangeSafety instance)
 {
     rangeSafetyInstance  = instance;
     windowPos            = new Rect(0, 0, 0, 0);
     pressedButton        = new GUIStyle(HighLogic.Skin.button);
     pressedButton.normal = pressedButton.active;
     currentTab           = tabs.FlightCorridor;
 }
Пример #5
0
        public void DrawWindow(int windowID)
        {
            try
            {
                GUILayout.BeginVertical();
                try {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Flight Corridor", currentTab == tabs.FlightCorridor ? pressedButton : HighLogic.Skin.button))
                    {
                        currentTab = tabs.FlightCorridor;
                    }
                    if (GUILayout.Button("ARM Actions", currentTab == tabs.ArmActions ? pressedButton : HighLogic.Skin.button))
                    {
                        currentTab = tabs.ArmActions;
                    }
                    if (GUILayout.Button("Settings", currentTab == tabs.Settings ? pressedButton : HighLogic.Skin.button))
                    {
                        currentTab = tabs.Settings;
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUIUtils.SimpleLabel("State", FlightRange.GetRangeStateText(rangeSafetyInstance.flightRange.State, rangeSafetyInstance.flightCorridor.Status));
                    GUILayout.EndHorizontal();

                    switch (currentTab)
                    {
                    case tabs.FlightCorridor:
                        FlightCorridorTab();
                        break;

                    case tabs.ArmActions:
                        ArmActionsTab();
                        break;

                    case tabs.Settings:
                        SettingsTab();
                        break;
                    }
                }
                finally
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                }
            }
            finally
            {
                GUI.DragWindow();
                rangeSafetyInstance.settings.windowX = windowPos.x;
                rangeSafetyInstance.settings.windowY = windowPos.y;
            }
        }
Пример #6
0
 private void summaryBody(tabs currentTab)
 {
     updateActiveMap();
     nautListScroll = GUILayout.BeginScrollView(nautListScroll, GUILayout.Width(480), GUILayout.Height(144));
     try {
         nautListHeading();
         for (int i = 0; i < HighLogic.CurrentGame.CrewRoster.Count; i++)
         {
             ProtoCrewMember student = HighLogic.CurrentGame.CrewRoster[i];
             if (student.type == ProtoCrewMember.KerbalType.Crew)
             {
                 nautListRow(currentTab, student);
             }
         }
     } finally {
         GUILayout.EndScrollView();
     }
 }
Пример #7
0
        private void summaryBody(tabs currentTab)
        {
            updateActiveMap();
            float scrollHeight = currentTab == tabs.Training ? 420 : 305;

            nautListScroll = GUILayout.BeginScrollView(nautListScroll, GUILayout.Width(505), GUILayout.Height(scrollHeight));
            try {
                nautListHeading();
                for (int i = 0; i < HighLogic.CurrentGame.CrewRoster.Count; i++)
                {
                    ProtoCrewMember student = HighLogic.CurrentGame.CrewRoster[i];
                    if (student.type == ProtoCrewMember.KerbalType.Crew && student.rosterStatus == ProtoCrewMember.RosterStatus.Available)
                    {
                        nautListRow(currentTab, student);
                    }
                }
            } finally {
                GUILayout.EndScrollView();
            }
        }
        public void SetActiveTab(tabs activeTab)
        {
            switch (activeTab)
            {
            case tabs.general:
                this.tabParGeneral.Select();
                break;

            case tabs.deco:
                this.tabParDeco.Select();
                break;

            case tabs.dive:
                this.tabParDive.Select();
                break;

            case tabs.parameters:
                this.tabParameters.Select();
                break;
            }
        }
Пример #9
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();
            }
        }
Пример #10
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();
            }
        }
Пример #11
0
        public void DrawWindow(int windowID)
        {
            try {
                GUILayout.BeginVertical();
                try {
                    /* If totalUpkeep is zero, we probably haven't calculated the upkeeps yet, so recalculate now */
                    if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && MaintenanceHandler.Instance.totalUpkeep == 0d)
                    {
                        MaintenanceHandler.Instance.UpdateUpkeep();
                    }

                    tabSelector();
                    if (showTab(currentTab))
                    {
                        switch (currentTab)
                        {
                        case tabs.Maintenance:
                            maintUI.summaryTab();
                            break;

                        case tabs.Facilities:
                            maintUI.facilitiesTab();
                            break;

                        case tabs.Integration:
                            maintUI.integrationTab();
                            break;

                        case tabs.Astronauts:
                            maintUI.astronautsTab();
                            break;

                        case tabs.Tooling:
                            currentTab = toolUI.toolingTab();
                            break;

                        case tabs.ToolingType:
                            toolUI.toolingTypeTab();
                            break;

                        case tabs.Training:
                            currentTab = fsUI.summaryTab();
                            break;

                        case tabs.Courses:
                            currentTab = fsUI.coursesTab();
                            break;

                        case tabs.NewCourse:
                            currentTab = fsUI.newCourseTab();
                            break;

                        case tabs.Naut:
                            fsUI.nautTab();
                            break;

                        case tabs.Avionics:
                            avUI.avionicsTab();
                            break;

                        default: // can't happen
                            break;
                        }
                    }
                } finally {
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                }
            } finally {
                GUI.DragWindow();
            }
        }
Пример #12
0
 Hierarchy(status, builder, tabs: Tabs);
Пример #13
0
 public static void SwitchTabTo(tabs newTab)
 {
     currentTab = newTab;
 }
Пример #14
0
 public TopWindow()
 {
     // Reset the tab on scene changes
     currentTab = default(tabs);
 }