コード例 #1
0
        private void SettingsWindow(int windowId)
        {
            GUILayout.Label(LocalizerExtensions.Get("FARFlightSettingsLabel"));
            settingsWindow.GUIDropDownDisplay();
            int selection = settingsWindow.ActiveSelection;

            switch (selection)
            {
            case 0:
                if (_flightDataGUI.SettingsDisplay())
                {
                    dataGuiRect.height = 0;
                }
                break;

            case 1:
                _stabilityAugmentation.SettingsDisplay();
                break;

            case 2:
                airSpeedGUI.AirSpeedSettings();
                break;

            case 3:
                AeroVizGUI.SettingsDisplay();
                break;
            }

            GUI.DragWindow();
        }
コード例 #2
0
        public void Display(ref Rect windowRect)
        {
            GUILayout.BeginVertical(GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
            Vessel vessel   = FlightGlobals.ActiveVessel;
            string prefix   = exposure ? "▼ " : "▶ ";
            bool   previous = exposure;

            exposure = GUILayout.Toggle(exposure,
                                        prefix + LocalizerExtensions.Get("FARDebugExposureLabel"),
                                        GUIDropDownStyles.ToggleButton);

            // changed, recompute the rect
            if (previous != exposure)
            {
                windowRect.size = Vector2.zero;
            }

            // ReSharper disable once InvertIf
            if (exposure)
            {
                if (vessel.FindVesselModuleImplementing <FARVesselAero>() is { } module)
                {
                    if (module.Exposure.Display())
                    {
                        windowRect.size = Vector2.zero;
                    }
                }
            }

            GUILayout.EndVertical();
        }
コード例 #3
0
        public string SerializedGettext(IEnumerable <CultureInfo> cultureInfos, string msgId, params object[] args)
        {
            var msgIdWithContext = LocalizerExtensions.ConvertToMsgIdWithContext(msgId);
            var result           = new StringBuilder();

            result.Append("{");
            bool addComma = false;

            foreach (var cultureInfo in cultureInfos)
            {
                if (addComma)
                {
                    result.Append(", ");
                }
                else
                {
                    addComma = true;
                }

                var    catalog = _createCatalog(cultureInfo);
                string message;

                if (string.IsNullOrEmpty(msgIdWithContext.Context))
                {
                    if (args.Any())
                    {
                        message = catalog.GetString(msgIdWithContext.MsgId, args);
                    }
                    else
                    {
                        message = catalog.GetString(msgIdWithContext.MsgId);
                    }
                }
                else
                {
                    if (args.Any())
                    {
                        message = catalog.GetParticularString(msgIdWithContext.Context, msgIdWithContext.MsgId, args);
                    }
                    else
                    {
                        message = catalog.GetParticularString(msgIdWithContext.Context, msgIdWithContext.MsgId);
                    }
                }

                result.AppendFormat("\"{0}\": \"{1}\"", cultureInfo.Name,
                                    HttpUtility.JavaScriptStringEncode(message));
            }
            result.Append("}");
            return(result.ToString());
        }
コード例 #4
0
        private void DebugVisualizationGUI()
        {
            if (!FARConfig.Voxelization.DebugInFlight)
            {
                return;
            }
            GUILayout.BeginHorizontal();
            GUI.enabled = !_vesselAero.VehicleAero.Voxelizing;
            if (GUILayout.Button(LocalizerExtensions.Get("FARDebugVoxels")))
            {
                _vesselAero.VehicleAero.DebugVisualizeVoxels(vessel.transform.localToWorldMatrix);
            }

            GUI.enabled = true;
            GUILayout.EndHorizontal();
        }
コード例 #5
0
 private void DebugWindow(int windowId)
 {
     GUILayout.Label(LocalizerExtensions.Get("FARDebugWindowLabel"));
     debugGUI.Display(ref debugGuiRect);
     GUI.DragWindow();
 }
コード例 #6
0
        private void MainFlightGUIWindow(int windowId)
        {
            GUILayout.BeginVertical(GUILayout.Height(100));
            GUILayout.BeginHorizontal();
            _strBuilder.Length = 0;
            _strBuilder.Append(LocalizerExtensions.Get("FARAbbrevMach"));
            _strBuilder.Append(": ");
            _strBuilder.Concat((float)_vesselAero.MachNumber, 3).AppendLine();
            _strBuilder.AppendFormat(LocalizerExtensions.Get("FARFlightGUIReynolds"), _vesselAero.ReynoldsNumber);
            GUILayout.Box(_strBuilder.ToString(), boxStyle, GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();

            _strBuilder.Length = 0;
            _strBuilder.Append(LocalizerExtensions.Get("FARFlightGUIAtmDens"));
            _strBuilder.Concat((float)vessel.atmDensity, 3);

            GUILayout.Box(_strBuilder.ToString(), boxStyle, GUILayout.ExpandWidth(true));

            _flightStatusGUI.Display();
            showFlightDataWindow = GUILayout.Toggle(showFlightDataWindow,
                                                    LocalizerExtensions.Get("FARFlightGUIFltDataBtn"),
                                                    buttonStyle,
                                                    GUILayout.ExpandWidth(true));
            showSettingsWindow = GUILayout.Toggle(showSettingsWindow,
                                                  LocalizerExtensions.Get("FARFlightGUIFltSettings"),
                                                  buttonStyle,
                                                  GUILayout.ExpandWidth(true));
            showDebugWindow = GUILayout.Toggle(showDebugWindow,
                                               LocalizerExtensions.Get("FARFlightGUIFltDebug"),
                                               buttonStyle,
                                               GUILayout.ExpandWidth(true));

            bool logging = GUILayout.Toggle(flightDataLogger.IsActive,
                                            LocalizerExtensions.Get("FARFlightGUIFltLogging"),
                                            buttonStyle,
                                            GUILayout.ExpandWidth(true));

            if (logging != flightDataLogger.IsActive)
            {
                if (!flightDataLogger.IsActive)
                {
                    flightDataLogger.StartLogging();
                }
                else
                {
                    flightDataLogger.StopLogging();
                }
            }

            flightDataLogger.Period =
                GUIUtils.TextEntryForInt(LocalizerExtensions.Get("FARFlightGUIFltLogPeriod"),
                                         150,
                                         flightDataLogger.Period);
            flightDataLogger.FlushPeriod =
                GUIUtils.TextEntryForInt(LocalizerExtensions.Get("FARFlightGUIFltLogFlushPeriod"),
                                         150,
                                         flightDataLogger.FlushPeriod);
            DebugVisualizationGUI();

            GUILayout.Label(LocalizerExtensions.Get("FARFlightGUIFltAssistance"));

            _stabilityAugmentation.Display();

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
コード例 #7
0
        public void DrawGUI()
        {
            GUI.skin = HighLogic.Skin;
            if (boxStyle == null)
            {
                boxStyle = new GUIStyle(GUI.skin.box);
                boxStyle.normal.textColor           = boxStyle.focused.textColor = Color.white;
                boxStyle.hover.textColor            = boxStyle.active.textColor = Color.yellow;
                boxStyle.onNormal.textColor         = boxStyle.onFocused.textColor =
                    boxStyle.onHover.textColor      =
                        boxStyle.onActive.textColor = Color.green;
                boxStyle.padding = new RectOffset(2, 2, 2, 2);
            }

            if (buttonStyle == null)
            {
                buttonStyle = new GUIStyle(GUI.skin.button);
                buttonStyle.normal.textColor        = buttonStyle.focused.textColor = Color.white;
                buttonStyle.hover.textColor         =
                    buttonStyle.active.textColor    = buttonStyle.onActive.textColor = Color.yellow;
                buttonStyle.onNormal.textColor      =
                    buttonStyle.onFocused.textColor = buttonStyle.onHover.textColor = Color.green;
                buttonStyle.padding = new RectOffset(2, 2, 2, 2);
            }

            if (_vessel != FlightGlobals.ActiveVessel || !showGUI || !showAllGUI)
            {
                return;
            }
            mainGuiRect = GUILayout.Window(GetHashCode(),
                                           mainGuiRect,
                                           MainFlightGUIWindow,
                                           "FAR, " + Version.LongString,
                                           GUILayout.MinWidth(230));
            GUIUtils.ClampToScreen(mainGuiRect);

            if (showFlightDataWindow)
            {
                dataGuiRect = GUILayout.Window(GetHashCode() + 1,
                                               dataGuiRect,
                                               FlightDataWindow,
                                               LocalizerExtensions.Get("FARFlightDataTitle"),
                                               GUILayout.MinWidth(150));
                GUIUtils.ClampToScreen(dataGuiRect);
            }

            if (showSettingsWindow)
            {
                settingsGuiRect = GUILayout.Window(GetHashCode() + 2,
                                                   settingsGuiRect,
                                                   SettingsWindow,
                                                   LocalizerExtensions.Get("FARFlightSettings"),
                                                   GUILayout.MinWidth(200));
                GUIUtils.ClampToScreen(settingsGuiRect);
            }

            // ReSharper disable once InvertIf
            if (showDebugWindow)
            {
                debugGuiRect = GUILayout.Window(GetHashCode() + 3,
                                                debugGuiRect,
                                                DebugWindow,
                                                LocalizerExtensions.Get("FARDebugWindow"),
                                                GUILayout.MinWidth(200));
                GUIUtils.ClampToScreen(debugGuiRect);
            }
        }
コード例 #8
0
        protected override void OnStart()
        {
            base.OnStart();

            showGUI = savedShowGUI;
            //since we're sharing the button, we need these shenanigans now
            if (FARDebugAndSettings.FARDebugButtonStock && HighLogic.LoadedSceneIsFlight)
            {
                if (showGUI)
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetTrue(false);
                }
                else
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetFalse(false);
                }
            }


            _vessel                = GetComponent <Vessel>();
            _vesselAero            = GetComponent <FARVesselAero>();
            _physicsCalcs          = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI       = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI         = new FlightDataGUI();
            AeroVizGUI             = new AeroVisualizationGUI();
            debugGUI               = new DebugGUI();

            settingsWindow = new GUIDropDown <int>(new[]
            {
                LocalizerExtensions.Get("FARFlightGUIWindowSelect0"),
                LocalizerExtensions.Get("FARFlightGUIWindowSelect1"),
                LocalizerExtensions.Get("FARFlightGUIWindowSelect2"),
                LocalizerExtensions.Get("FARFlightGUIWindowSelect3")
            },
                                                   new[] { 0, 1, 2, 3 });

            if (vesselFlightGUI.ContainsKey(_vessel))
            {
                vesselFlightGUI[_vessel] = this;
            }
            else
            {
                vesselFlightGUI.Add(_vessel, this);
            }
            flightDataLogger = FlightDataLogger.CreateLogger(_vessel);

            enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }

            activeFlightGUICount++;

            if (_vessel == FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel == null)
            {
                LoadConfigs();
            }

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
コード例 #9
0
        public static LocalizedHtmlString GetQuantityString(this IViewLocalizer localizer, string key, long quantity, params object[] args)
        {
            var normalizedQuantity = LocalizerExtensions.GetNormalizedQuantity(quantity);

            return(localizer[$"{key}_{normalizedQuantity}", args]);
        }