예제 #1
0
        public static void UnitsSettingsWindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            GUIUtil.UnitSelectionGrid <GUIUnits.Temperature>(ref TemperatureUnits);
            GUIUtil.UnitSelectionGrid <GUIUnits.Pressure>(ref PressureUnits);
            GUIUtil.UnitSelectionGrid <GUIUnits.Force>(ref ForceUnits);
            GUIUtil.UnitSelectionGrid <GUIUnits.Isp>(ref IspUnits);
            GUIUtil.UnitSelectionGrid <GUIUnits.TSFC>(ref TSFCUnits);

            GUILayout.EndVertical();

            GUI.DragWindow();

            UnitsSettingsWindowPos = GUIUtil.ClampToScreen(UnitsSettingsWindowPos);
        }
예제 #2
0
        public static void SettingsWindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            GUIUtil.SettingsWindowToggle("Show Ambient Temperature", ref ShowAmbientTemp);
            GUIUtil.SettingsWindowToggle("Show Ambient Pressure", ref ShowAmbientPressure);
            GUIUtil.SettingsWindowToggle("Show Recovery Temperature", ref ShowRecoveryTemp);
            GUIUtil.SettingsWindowToggle("Show Recovery Pressure", ref ShowRecoveryPressure);
            GUIUtil.SettingsWindowToggle("Show Inlet Percentage", ref ShowInletPercent);
            GUIUtil.SettingsWindowToggle("Show Total Pressure Recovery", ref ShowTPR);
            GUIUtil.SettingsWindowToggle("Show Thrust", ref ShowThrust);
            GUIUtil.SettingsWindowToggle("Show Thrust to Weight Ratio", ref ShowTWR);
            GUIUtil.SettingsWindowToggle("Show Thrust / Drag", ref ShowTDR);
            GUIUtil.SettingsWindowToggle("Show Isp", ref ShowIsp);
            GUIUtil.SettingsWindowToggle("Show TSFC", ref ShowTSFC);

            GUILayout.EndVertical();

            GUI.DragWindow();

            SettingsWindowPos = GUIUtil.ClampToScreen(SettingsWindowPos);
        }
예제 #3
0
        public void FlightWindowGUI(int windowID)
        {
            inAtmosphere = vessel.altitude < vessel.mainBody.atmosphereDepth;
            int tmpDisplayField = windowDisplayField;

            windowDisplayField = 0;
            int counter = 1;

            GUILayout.BeginVertical();

            if (FlightGUISettings.ShowAmbientTemp)
            {
                GUIUtil.FlightWindowField("Ambient Temperature", GUIUnitsSettings.TemperatureUnits.Format(vessel.atmosphericTemperature, GUIUnits.Temperature.kelvin));
                windowDisplayField += counter;
            }
            counter *= 2;
            if (FlightGUISettings.ShowAmbientPressure)
            {
                GUIUtil.FlightWindowField("Ambient Pressure", GUIUnitsSettings.PressureUnits.Format(vessel.staticPressurekPa, GUIUnits.Pressure.kPa));
                windowDisplayField += counter;
            }
            counter *= 2;
            if (FlightGUISettings.ShowRecoveryTemp && inAtmosphere && flightSys.InletArea > 0f && flightSys.EngineArea > 0f)
            {
                GUIUtil.FlightWindowField("Recovery Temperature", GUIUnitsSettings.TemperatureUnits.Format(flightSys.InletTherm.T, GUIUnits.Temperature.kelvin));
                windowDisplayField += counter;
            }
            counter *= 2;
            if (FlightGUISettings.ShowRecoveryPressure && inAtmosphere && flightSys.InletArea > 0f && flightSys.EngineArea > 0f)
            {
                GUIUtil.FlightWindowField("Recovery Pressure", GUIUnitsSettings.PressureUnits.Format(flightSys.InletTherm.P, GUIUnits.Pressure.Pa));
                windowDisplayField += counter;
            }
            counter *= 2;
            if (FlightGUISettings.ShowInletPercent && inAtmosphere && flightSys.EngineArea > 0f)
            {
                GUIStyle inletPercentStyle = new GUIStyle(GUIUtil.LeftLabel);
                double.IsInfinity(flightSys.AreaRatio);

                string areaPercentString = "";
                if (double.IsInfinity(flightSys.AreaRatio) || double.IsNaN(flightSys.AreaRatio))
                {
                    areaPercentString = "n/a";
                }
                else
                {
                    areaPercentString = flightSys.AreaRatio.ToString("P2");
                    Color inletPercentColor = Color.white;
                    if (flightSys.AreaRatio >= 1)
                    {
                        inletPercentColor = Color.green;
                    }
                    else if (flightSys.AreaRatio < 1)
                    {
                        inletPercentColor = Color.red;
                    }
                    inletPercentStyle.normal.textColor = inletPercentStyle.focused.textColor = inletPercentStyle.hover.textColor = inletPercentStyle.onNormal.textColor = inletPercentStyle.onFocused.textColor = inletPercentStyle.onHover.textColor = inletPercentStyle.onActive.textColor = inletPercentColor;
                }

                GUIUtil.FlightWindowField("Inlet", areaPercentString);
                windowDisplayField += counter;
            }
            counter *= 2;

            if (FlightGUISettings.ShowTPR && inAtmosphere && flightSys.InletArea > 0f && flightSys.EngineArea > 0f)
            {
                GUIUtil.FlightWindowField("TPR", flightSys.OverallTPR.ToString("P2"));
                windowDisplayField += counter;
            }
            counter *= 2;

            if (FlightGUISettings.ShowInletPressureRatio && inAtmosphere && flightSys.InletArea > 0f && flightSys.EngineArea > 0f)
            {
                GUIUtil.FlightWindowField("Inlet Pressure Ratio", (flightSys.InletTherm.P / flightSys.AmbientTherm.P).ToString("F2"));
                windowDisplayField += counter;
            }
            counter *= 2;

            double totalThrust = 0;
            double totalMDot   = 0;

            if (FlightGUISettings.ShowThrust || FlightGUISettings.ShowTWR || FlightGUISettings.ShowTDR || FlightGUISettings.ShowIsp || FlightGUISettings.ShowTSFC)
            {
                List <ModuleEngines> allEngines = flightSys.EngineList;
                for (int i = 0; i < allEngines.Count; i++)
                {
                    if (allEngines[i].EngineIgnited)
                    {
                        totalThrust += allEngines[i].finalThrust; // kN
                        totalMDot   += allEngines[i].finalThrust / allEngines[i].realIsp;
                    }
                }
                totalMDot /= 9.81d;
                totalMDot *= 1000d; // kg/s
            }

            if (FlightGUISettings.ShowThrust)
            {
                GUIUtil.FlightWindowField("Thrust", GUIUnitsSettings.ForceUnits.Format(totalThrust, GUIUnits.Force.kN));
                windowDisplayField += counter;
            }
            counter *= 2;
            if (FlightGUISettings.ShowTWR)
            {
                double TWR    = 0d;
                double weight = (FlightGlobals.getGeeForceAtPosition(vessel.CoM).magnitude *vessel.GetTotalMass());
                if (totalThrust > 0d && weight > 0d)
                {
                    TWR = totalThrust / (FlightGlobals.getGeeForceAtPosition(vessel.CoM).magnitude *vessel.GetTotalMass());
                }

                GUIUtil.FlightWindowField("TWR", TWR.ToString("F2"));
                windowDisplayField += counter;
            }
            counter *= 2;

            if (FlightGUISettings.ShowTDR && inAtmosphere)
            {
                double totalDrag = FlightDataWrapper.VesselTotalDragkN(vessel);
                double tdr       = 0;
                if (FlightDataWrapper.VesselDynPreskPa(vessel) > 0.01d)
                {
                    tdr = totalThrust / totalDrag;
                }

                GUIUtil.FlightWindowField("Thrust / Drag", tdr.ToString("G3"));
                windowDisplayField += counter;
            }
            counter *= 2;

            if (FlightGUISettings.ShowIsp)
            {
                double Isp = 0d;
                if (totalThrust > 0d && totalMDot > 0d)
                {
                    Isp = totalThrust / totalMDot; // kN/(kg/s) = km/s
                }
                GUIUtil.FlightWindowField("Specific Impulse", GUIUnitsSettings.IspUnits.Format(Isp, GUIUnits.Isp.km__s));
                windowDisplayField += counter;
            }
            counter *= 2;
            if (FlightGUISettings.ShowTSFC)
            {
                double SFC = 0d;
                if (totalThrust > 0d && totalMDot > 0d)
                {
                    SFC = totalMDot / totalThrust; // (kg/s)/kN
                }
                GUIUtil.FlightWindowField("TSFC", GUIUnitsSettings.TSFCUnits.Format(SFC, GUIUnits.TSFC.kg__kN_s));
                windowDisplayField += counter;
            }

            if (windowDisplayField != tmpDisplayField)
            {
                FlightWindowPos.height = 0;
            }

            GUILayout.BeginHorizontal();
            FlightGUISettings.ShowSettingsWindow     = GUILayout.Toggle(FlightGUISettings.ShowSettingsWindow, "Settings", GUIUtil.ButtonToggle, GUIUtil.normalWidth);
            GUIUnitsSettings.ShowUnitsSettingsWindow = GUILayout.Toggle(GUIUnitsSettings.ShowUnitsSettingsWindow, "Units", GUIUtil.ButtonToggle, GUIUtil.smallWidth);
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUI.DragWindow();

            FlightWindowPos = GUIUtil.ClampToScreen(FlightWindowPos);
        }