Esempio n. 1
0
        /// <summary>
        /// Add Buttons/Dropdowns to ToolBar
        /// </summary>
        /// <param name="name"></param>
        /// <param name="buttons"></param>
        /// <param name="subButtons"></param>
        public void Add(string name, GUIDropDownButtonConfig[] buttons, params SubDropdownConfig[] subButtons)
        {
            GUIDropDown toAdd = new GUIDropDown(                                                          //DONT EVER TOUCH THE MATHS HERE, I DONT WANT MORE GREY HAIR pls
                (this.countDiv == 0 ? UDim2.Zero : new UDim2(this.buttonWidth * this.countDiv, 0, 0, 0)), //if this is our first button then pin it to the far left
                new UDim2(this.buttonWidth, 0, 1, 0),
                this.theme,
                false)
            {
                Parent = this.bar, Text = name
            };

            foreach (GUIDropDownButtonConfig btnConfig in buttons) //foreach button wanted
            {
                toAdd.AddItem(btnConfig);                          //add to bar
            }

            if (subButtons != null)                         //if there is a sub menu
            {
                for (int i = 0; i < subButtons.Length; i++) //then for how many
                {
                    GUIDropDown subToAdd = new GUIDropDown(UDim2.Zero, new UDim2(.5f, 0, 1, 0), this.theme, false)
                    {
                        HideMainButton = true
                    };                                                                                                 //create a dropdown menu
                    toAdd.AddItemSub((subButtons[i].Title != null ? subButtons[i].Title : "Sub Drop Menu"), subToAdd); //add it to the current button with title
                    foreach (GUIDropDownButtonConfig btnConfig in subButtons[i].subButtons)                            //then foreach button within the sub menu
                    {
                        subToAdd.AddItem(btnConfig);                                                                   //add to new dropdown menu entry
                    }
                }
            }

            this.countDiv++; //increment up so all buttons fit; somewhat
        }
        public StaticAnalysisGraphGUI(EditorSimManager simManager, GUIDropDown <int> flapSettingDropDown, GUIDropDown <CelestialBody> bodySettingDropdown)
        {
            this.simManager          = simManager;
            this.flapSettingDropdown = flapSettingDropDown;
            this.bodySettingDropdown = bodySettingDropdown;

            //Set up defaults for AoA Sweep
            aoASweepInputs              = new GraphInputs();
            aoASweepInputs.lowerBound   = "0";
            aoASweepInputs.upperBound   = "25";
            aoASweepInputs.numPts       = "100";
            aoASweepInputs.flapSetting  = 0;
            aoASweepInputs.pitchSetting = "0";
            aoASweepInputs.otherInput   = "0.2";

            //Set up defaults for Mach Sweep
            machSweepInputs              = new GraphInputs();
            machSweepInputs.lowerBound   = "0";
            machSweepInputs.upperBound   = "3";
            machSweepInputs.numPts       = "100";
            machSweepInputs.flapSetting  = 0;
            machSweepInputs.pitchSetting = "0";
            machSweepInputs.otherInput   = "2";

            _graph.SetBoundaries(0, 25, 0, 2);
            _graph.SetGridScaleUsingValues(5, 0.5);
            _graph.horizontalLabel = Localizer.Format("FAREditorStaticGraphAoA");
            _graph.verticalLabel   = Localizer.Format("FAREditorStaticGraphCoeff");
            _graph.Update();
        }
Esempio n. 3
0
        void OnEditModeSelected(GUIDropDown dropDown, GUIDropDownButton btn)
        {
            EditorToolType mode = (EditorToolType)btn.Index;

            SetToolType(mode);
            screen.WorldEditor.SetToolType(mode);
        }
Esempio n. 4
0
        void OnFogSelected(GUIDropDown dropDown, GUIDropDownButton btn)
        {
            for (int i = 0; i < fogButtons.Length; i++)
            {
                fogButtons[i].Toggled = false;
            }

            fogButtons[btn.Index].Toggled = true;

            if (btn.Index == 0)
            {
                renderer.FogEnabled = false;
            }
            else
            {
                renderer.FogEnabled = true;

                if (btn.Index == 1)
                {
                    renderer.GFXSettings.FogQuality = FogQuality.Low;
                }
                else if (btn.Index == 2)
                {
                    renderer.GFXSettings.FogQuality = FogQuality.Medium;
                }
                else if (btn.Index == 3)
                {
                    renderer.GFXSettings.FogQuality = FogQuality.High;
                }
            }
        }
Esempio n. 5
0
        void OnPCFSelected(GUIDropDown dropDown, GUIDropDownButton btn)
        {
            for (int i = 0; i < pcfButtons.Length; i++)
            {
                pcfButtons[i].Toggled = false;
            }

            int v = (int)btn.Value;

            renderer.GFXSettings.ShadowPCFSamples = v;

            switch (v)
            {
            case 1:
                dropDown.Items[0].Toggled = true; break;

            case 2:
                dropDown.Items[1].Toggled = true; break;

            case 4:
                dropDown.Items[2].Toggled = true; break;

            case 6:
                dropDown.Items[3].Toggled = true; break;

            case 12:
                dropDown.Items[4].Toggled = true; break;
            }
        }
        public StaticAnalysisGraphGUI(EditorSimManager simManager, GUIDropDown<int> flapSettingDropDown, GUIDropDown<CelestialBody> bodySettingDropdown)
        {
            this.simManager = simManager;
            this.flapSettingDropdown = flapSettingDropDown;
            this.bodySettingDropdown = bodySettingDropdown;

            //Set up defaults for AoA Sweep
            aoASweepInputs = new GraphInputs();
            aoASweepInputs.lowerBound = "0";
            aoASweepInputs.upperBound = "25";
            aoASweepInputs.numPts = "100";
            aoASweepInputs.flapSetting = 0;
            aoASweepInputs.pitchSetting = "0";
            aoASweepInputs.otherInput = "0.2";

            //Set up defaults for Mach Sweep
            machSweepInputs = new GraphInputs();
            machSweepInputs.lowerBound = "0";
            machSweepInputs.upperBound = "3";
            machSweepInputs.numPts = "100";
            machSweepInputs.flapSetting = 0;
            machSweepInputs.pitchSetting = "0";
            machSweepInputs.otherInput = "2";

            _graph.SetBoundaries(0, 25, 0, 2);
            _graph.SetGridScaleUsingValues(5, 0.5);
            _graph.horizontalLabel = "Angle of Attack, degrees";
            _graph.verticalLabel = "Cl\nCd\nCm\nL/D / 10";
            _graph.Update();
        }
 public TurbopumpCalculator(BiPropellantConfig config, EngineCalculatorBase engineCalc)
 {
     this.engineCalc   = engineCalc;
     this.biPropConfig = config;
     fuelAux           = PropellantMixtureLibrary.AuxPropellantProperties[config.Fuel];
     oxAux             = PropellantMixtureLibrary.AuxPropellantProperties[config.Oxidizer];
     if ((object)pumpEffFromSpecificSpeed == null)
     {
         LoadEfficiencyCurves();
     }
     if (turbopumpArrangementSelector == null)
     {
         string[] turbopumpString = new string[] {
             "Direct Drive",
             "Gear Reduction",
             "Two Turbine"
         };
         TurbopumpArrangementEnum[] turbopumpEnums = new TurbopumpArrangementEnum[] {
             TurbopumpArrangementEnum.DIRECT_DRIVE,
             TurbopumpArrangementEnum.GEAR_REDUCTION,
             TurbopumpArrangementEnum.TWO_TURBINE
         };
         turbopumpArrangementSelector = new GUIDropDown <TurbopumpArrangementEnum>(turbopumpString, turbopumpEnums);
     }
 }
Esempio n. 8
0
        void Start()
        {
            if (CompatibilityChecker.IsAllCompatible() && instance == null)
            {
                instance = this;
            }
            else
            {
                GameObject.Destroy(this);
                return;
            }

            showGUI = false;
            if (FARDebugAndSettings.FARDebugButtonStock)
            {
                FARDebugAndSettings.FARDebugButtonStock.SetFalse(false);
            }

            _vehicleAero = new VehicleAerodynamics();

            guiRect = new Rect(Screen.width / 4, Screen.height / 6, 10, 10);

            _instantSim = new InstantConditionSim();
            GUIDropDown <int>           flapSettingDropDown   = new GUIDropDown <int>(new string[] { Localizer.Format("FARFlapSetting0"), Localizer.Format("FARFlapSetting1"), Localizer.Format("FARFlapSetting2"), Localizer.Format("FARFlapSetting3") }, new int[] { 0, 1, 2, 3 }, 0);
            GUIDropDown <CelestialBody> celestialBodyDropdown = CreateBodyDropdown();

            modeDropdown = new GUIDropDown <FAREditorMode>(FAReditorMode_str, new FAREditorMode[] { FAREditorMode.STATIC, FAREditorMode.STABILITY, FAREditorMode.SIMULATION, FAREditorMode.AREA_RULING });

            _simManager = new EditorSimManager(_instantSim);

            _editorGraph     = new StaticAnalysisGraphGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDeriv       = new StabilityDerivGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDerivLinSim = new StabilityDerivSimulationGUI(_simManager);

            Color crossSection = GUIColors.GetColor(3);

            crossSection.a = 0.8f;

            Color crossSectionDeriv = GUIColors.GetColor(2);

            crossSectionDeriv.a = 0.8f;

            _areaRulingOverlay = EditorAreaRulingOverlay.CreateNewAreaRulingOverlay(new Color(0.05f, 0.05f, 0.05f, 0.7f), crossSection, crossSectionDeriv, 10, 5);
            guiRect.height     = 500;
            guiRect.width      = 650;


            //GameEvents.onEditorVariantApplied.Add(UpdateGeometryEvent); // Rodhern: Downgrade to KSP 1.3.1
            GameEvents.onEditorPartEvent.Add(UpdateGeometryEvent);
            GameEvents.onEditorUndo.Add(ResetEditorEvent);
            GameEvents.onEditorRedo.Add(ResetEditorEvent);
            GameEvents.onEditorShipModified.Add(ResetEditorEvent);
            GameEvents.onEditorLoad.Add(ResetEditorEvent);

            GameEvents.onGUIEngineersReportReady.Add(AddDesignConcerns);
            GameEvents.onGUIEngineersReportDestroy.Add(RemoveDesignConcerns);

            RequestUpdateVoxel();
        }
 public void Dispose()
 {
     aoASweepInputs      = machSweepInputs = null;
     flapSettingDropdown = null;
     bodySettingDropdown = null;
     simManager          = null;
     _graph = null;
 }
        public StabilityDerivGUI(EditorSimManager simManager, GUIDropDown <int> flapSettingDropDown, GUIDropDown <CelestialBody> bodySettingDropdown)
        {
            this.simManager      = simManager;
            _flapSettingDropdown = flapSettingDropDown;
            _bodySettingDropdown = bodySettingDropdown;

            stabDerivOutput = new StabilityDerivOutput();
        }
        public StabilityDerivGUI(EditorSimManager simManager, GUIDropDown<int> flapSettingDropDown, GUIDropDown<CelestialBody> bodySettingDropdown)
        {
            this.simManager = simManager;
            _flapSettingDropdown = flapSettingDropDown;
            _bodySettingDropdown = bodySettingDropdown;

            stabDerivOutput = new StabilityDerivOutput();
        }
        public static void LoadConfiguration()
        {
            string[] namesTmp = Enum.GetNames(typeof(KSPActionGroup));
            var      names    = new string[namesTmp.Length - 1];

            for (int i = 0; i < namesTmp.Length - 1; ++i)
            {
                names[i] = namesTmp[i];
            }
            var agTypes = new KSPActionGroup[names.Length];

            actionGroupDropDown = new GUIDropDown <KSPActionGroup> [3];

            for (int i = 0; i < agTypes.Length; i++)
            {
                agTypes[i] = (KSPActionGroup)Enum.Parse(typeof(KSPActionGroup), names[i]);
            }
            // straight forward, reading the (action name, action group) tuples
            PluginConfiguration config = FARDebugAndSettings.config;

            for (int i = 0; i < ACTION_COUNT; ++i)
            {
                try
                {
                    // don't forget to initialize the gui
                    string currentGuiString = currentGuiStrings[i] = id2actionGroup[i].ToString();
                    id2actionGroup[i] =
                        (KSPActionGroup)Enum.Parse(typeof(KSPActionGroup),
                                                   config.GetValue(configKeys[i], currentGuiString));
                    FARLogger.Info($"Loaded AG {configKeys[i]} as {currentGuiString}");
                }
                catch (Exception e)
                {
                    FARLogger.Warning("Error reading config key '" +
                                      configKeys[i] +
                                      "' with value '" +
                                      config.GetValue(configKeys[i], "n/a") +
                                      "' gave " +
                                      e);
                }

                int initIndex = 0;
                for (int j = 0; j < agTypes.Length; j++)
                {
                    if (id2actionGroup[i] != agTypes[j])
                    {
                        continue;
                    }
                    initIndex = j;
                    break;
                }

                var dropDown = new GUIDropDown <KSPActionGroup>(names, agTypes, initIndex);
                actionGroupDropDown[i] = dropDown;
            }
        }
        void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

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

            settingsWindow = new GUIDropDown <int>(new string[4] {
                "Flt Data", "Stab Aug", "Air Spd", "Aero Viz"
            }, new int[4] {
                0, 1, 2, 3
            }, 0);
            //boxStyle.padding = new RectOffset(4, 4, 4, 4);

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

            this.enabled = true;

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

            activeFlightGUICount++;

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

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
Esempio n. 14
0
        void Start()
        {
            if (CompatibilityChecker.IsAllCompatible() && instance == null)
            {
                instance = this;
            }
            else
            {
                GameObject.Destroy(this);
                return;
            }

            _vehicleAero = new VehicleAerodynamics();

            guiRect = new Rect(Screen.width / 4, Screen.height / 6, 10, 10);

            _instantSim = new InstantConditionSim();
            GUIDropDown <int>           flapSettingDropDown   = new GUIDropDown <int>(new string[] { "0 (up)", "1 (init climb)", "2 (takeoff)", "3 (landing)" }, new int[] { 0, 1, 2, 3 }, 0);
            GUIDropDown <CelestialBody> celestialBodyDropdown = CreateBodyDropdown();

            modeDropdown = new GUIDropDown <FAREditorMode>(FAReditorMode_str, new FAREditorMode[] { FAREditorMode.STATIC, FAREditorMode.STABILITY, FAREditorMode.SIMULATION, FAREditorMode.AREA_RULING });

            _simManager = new EditorSimManager(_instantSim);

            _editorGraph     = new StaticAnalysisGraphGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDeriv       = new StabilityDerivGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDerivLinSim = new StabilityDerivSimulationGUI(_simManager);

            Color crossSection = GUIColors.GetColor(3);

            crossSection.a = 0.8f;

            Color crossSectionDeriv = GUIColors.GetColor(2);

            crossSectionDeriv.a = 0.8f;

            _areaRulingOverlay = EditorAreaRulingOverlay.CreateNewAreaRulingOverlay(new Color(0.05f, 0.05f, 0.05f, 0.7f), crossSection, crossSectionDeriv, 10, 5);
            guiRect.height     = 500;
            guiRect.width      = 650;


            GameEvents.onEditorPartEvent.Add(UpdateGeometryEvent);
            GameEvents.onEditorUndo.Add(ResetEditorEvent);
            GameEvents.onEditorRedo.Add(ResetEditorEvent);
            GameEvents.onEditorShipModified.Add(ResetEditorEvent);
            GameEvents.onEditorLoad.Add(ResetEditorEvent);

            GameEvents.onGUIEngineersReportReady.Add(AddDesignConcerns);
            GameEvents.onGUIEngineersReportDestroy.Add(RemoveDesignConcerns);

            RequestUpdateVoxel();
        }
Esempio n. 15
0
        /// <summary>
        /// Show/Hide a window element
        /// </summary>
        /// <param name="dropDown"></param>
        /// <param name="button"></param>
        void showWindowElement(GUIDropDown dropDown, GUIDropDownButton button)
        {
            Type lookingFor = button.Value as Type;

            for (int i = 0; i < windowElements.Count; i++)
            {
                var item = windowElements[i];
                if (item != null && item.GetType() == lookingFor)
                {
                    item.Visible = !item.Visible;
                }
            }
        }
        public StabilityAugmentation(Vessel vessel)
        {
            _vessel        = vessel;
            systemDropdown = new GUIDropDown <int>(systemLabel, new int[] { 0, 1, 2, 3, 4, 5 }, 0);
            LoadSettings();
            systemInstances = new ControlSystem[systemTemplates.Length];

            for (int i = 0; i < systemInstances.Length; i++)
            {
                systemInstances[i] = new ControlSystem(systemTemplates[i]);
            }
            _vessel.OnAutopilotUpdate += OnAutoPilotUpdate;
        }
        public StabilityAugmentation(Vessel vessel)
        {
            _vessel = vessel;
            systemDropdown = new GUIDropDown<int>(systemLabel, new int[] { 0, 1, 2, 3, 4, 5 }, 0);
            LoadSettings();
            systemInstances = new ControlSystem[systemTemplates.Length];

            for (int i = 0; i < systemInstances.Length; i++)
            {
                systemInstances[i] = new ControlSystem(systemTemplates[i]);
            }
            _vessel.OnAutopilotUpdate += OnAutoPilotUpdate;
        }
Esempio n. 18
0
        void OnDestroy()
        {
            FlightGUIDrawer.SetGUIActive(this, false);
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            SaveConfigs();
            if (_vessel)
            {
                vesselFlightGUI.Remove(_vessel);
            }
            _physicsCalcs = null;

            if (_flightDataGUI != null)
            {
                _flightDataGUI.SaveSettings();
            }
            _flightDataGUI = null;

            if (_stabilityAugmentation != null)
            {
                _stabilityAugmentation.SaveAndDestroy();
            }
            _stabilityAugmentation = null;

            if (_airSpeedGUI != null)
            {
                _airSpeedGUI.SaveSettings();
            }
            _airSpeedGUI = null;

            if (_aeroVizGUI != null)
            {
                _aeroVizGUI.SaveSettings();
            }

            _flightStatusGUI = null;
            settingsWindow   = null;

            activeFlightGUICount--;

            if (activeFlightGUICount <= 0)
            {
                activeFlightGUICount = 0;
                if (blizzyFlightGUIButton != null)
                {
                    ClearBlizzyToolbarButton();
                }
            }

            savedShowGUI = showGUI;
        }
Esempio n. 19
0
        GUIDropDown <CelestialBody> CreateBodyDropdown()
        {
            CelestialBody[] bodies    = FlightGlobals.Bodies.ToArray();
            string[]        bodyNames = new string[bodies.Length];
            for (int i = 0; i < bodyNames.Length; i++)
            {
                bodyNames[i] = bodies[i].bodyName;
            }

            int kerbinIndex = 1;
            GUIDropDown <CelestialBody> celestialBodyDropdown = new GUIDropDown <CelestialBody>(bodyNames, bodies, kerbinIndex);

            return(celestialBodyDropdown);
        }
Esempio n. 20
0
        void SetupDefaultGraphicsSettings(GUIDropDown menu)
        {
            menu.Items[0].Toggled = renderer.GFXSettings.ApplyFXAA;
            menu.Items[1].Toggled = renderer.GFXSettings.RenderShadows;

            if (renderer.FogEnabled)
            {
                menu.Items[2].Sub.Items[0].Toggled = true;
            }
            else
            {
                if (!renderer.FogEnabled)
                {
                    menu.Items[2].Sub.Items[0].Toggled = true;
                }
                else if (renderer.GFXSettings.FogQuality == FogQuality.Low)
                {
                    menu.Items[2].Sub.Items[1].Toggled = true;
                }
                else if (renderer.GFXSettings.FogQuality == FogQuality.Medium)
                {
                    menu.Items[2].Sub.Items[2].Toggled = true;
                }
                else if (renderer.GFXSettings.FogQuality == FogQuality.High)
                {
                    menu.Items[2].Sub.Items[3].Toggled = true;
                }
            }

            switch (renderer.GFXSettings.ShadowPCFSamples)
            {
            case 1:
                menu.Items[3].Sub.Items[0].Toggled = true; break;

            case 2:
                menu.Items[3].Sub.Items[1].Toggled = true; break;

            case 4:
                menu.Items[3].Sub.Items[2].Toggled = true; break;

            case 6:
                menu.Items[3].Sub.Items[3].Toggled = true; break;

            case 12:
                menu.Items[3].Sub.Items[4].Toggled = true; break;
            }
        }
Esempio n. 21
0
        public static void LoadConfiguration()
        {
            string[] namesTmp = Enum.GetNames(typeof(KSPActionGroup));
            string[] names    = new string[namesTmp.Length - 1];

            for (int i = 0; i < namesTmp.Length - 1; ++i)
            {
                names[i] = namesTmp[i];
            }
            KSPActionGroup[] agTypes = new KSPActionGroup[names.Length];
            actionGroupDropDown = new GUIDropDown <KSPActionGroup> [3];

            for (int i = 0; i < agTypes.Length; i++)
            {
                agTypes[i] = (KSPActionGroup)Enum.Parse(typeof(KSPActionGroup), names[i]);
            }
            // straight forward, reading the (action name, action group) tuples
            KSP.IO.PluginConfiguration config = FARDebugAndSettings.config;
            for (int i = 0; i < ACTION_COUNT; ++i)
            {
                try
                {
                    id2actionGroup[i]    = (KSPActionGroup)Enum.Parse(typeof(KSPActionGroup), config.GetValue(configKeys[i], id2actionGroup[i].ToString()));;
                    currentGuiStrings[i] = id2actionGroup[i].ToString(); // don't forget to initialize the gui
                    Debug.Log(String.Format("FAR: loaded AG {0} as {1}", configKeys[i], id2actionGroup[i]));
                }
                catch (Exception e)
                {
                    Debug.LogWarning("FAR: error reading config key '" + configKeys[i] + "' with value '" + config.GetValue(configKeys[i], "n/a") + "' gave " + e.ToString());
                }
                int initIndex = 0;
                for (int j = 0; j < agTypes.Length; j++)
                {
                    if (id2actionGroup[i] == agTypes[j])
                    {
                        initIndex = j;
                        break;
                    }
                }
                GUIDropDown <KSPActionGroup> dropDown = new GUIDropDown <KSPActionGroup>(names, agTypes, initIndex);
                actionGroupDropDown[i] = dropDown;
            }
        }
        void OnDestroy()
        {
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            SaveConfigs();
            if (_vessel)
            {
                vesselFlightGUI.Remove(_vessel);
            }
            _physicsCalcs = null;

            if (_flightDataGUI != null)
            {
                _flightDataGUI.SaveSettings();
            }
            _flightDataGUI = null;

            if (_stabilityAugmentation != null)
            {
                _stabilityAugmentation.SaveAndDestroy();
            }
            _stabilityAugmentation = null;

            if (_airSpeedGUI != null)
            {
                _airSpeedGUI.SaveSettings();
            }
            _airSpeedGUI = null;

            _flightStatusGUI = null;
            settingsWindow   = null;

            if (blizzyFlightGUIButton != null)
            {
                blizzyFlightGUIButton.Destroy();
            }
        }
        public override void CalculateEngineProperties()
        {
            if (turbopump == null)
            {
                turbopump = new TurbopumpCalculator(biPropConfig, this);

                string[] turbineExhaustString = new string[] {
                    "Direct",
                    "Into Nozzle"
                };
                TurbineExhaustEnum[] turbExhaustEnums = new TurbineExhaustEnum[] {
                    TurbineExhaustEnum.DIRECT,
                    TurbineExhaustEnum.INTO_NOZZLE
                };

                turbineExhaustSelector = new GUIDropDown <TurbineExhaustEnum>(turbineExhaustString, turbExhaustEnums);
            }


            CalculateMainCombustionChamberParameters();
            AssumePumpPressureRise();
            SolveGasGenTurbine(oxRich);
            CalculateEngineAndNozzlePerformanceProperties();
        }
        GUIDropDown<CelestialBody> CreateBodyDropdown()
        {
            CelestialBody[] bodies = FlightGlobals.Bodies.ToArray();
            string[] bodyNames = new string[bodies.Length];
            for (int i = 0; i < bodyNames.Length; i++)
                bodyNames[i] = bodies[i].bodyName;

            int kerbinIndex = 1;
            GUIDropDown<CelestialBody> celestialBodyDropdown = new GUIDropDown<CelestialBody>(bodyNames, bodies, kerbinIndex);
            return celestialBodyDropdown;
        }
        void OnDestroy()
        {
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            SaveConfigs();
            if (_vessel)
            {
                vesselFlightGUI.Remove(_vessel);
            }
            _physicsCalcs = null;

            if(_flightDataGUI != null)
                _flightDataGUI.SaveSettings();
            _flightDataGUI = null;

            if(_stabilityAugmentation != null)
                _stabilityAugmentation.SaveAndDestroy();
            _stabilityAugmentation = null;

            if(_airSpeedGUI != null)
                _airSpeedGUI.SaveSettings();
            _airSpeedGUI = null;

            _flightStatusGUI = null;
            settingsWindow = null;

            if (blizzyFlightGUIButton != null)
                blizzyFlightGUIButton.Destroy();
        }
Esempio n. 26
0
        public EditorUI(MasterRenderer renderer, EditorScreen screen)
        {
            this.renderer = renderer;
            this.screen   = screen;

            GUISystem = renderer.Sprites.GUISystem;

            area = new GUIArea(GUISystem);
            renderer.Sprites.Add(area);

            Theme = EditorTheme.Glass;

            TranslateTerrainWindow transTerrainWindow;

            newWindow = new NewWorldWindow(GUISystem, screen, Theme);

            transTerrainWindow          = new TranslateTerrainWindow(GUISystem, Theme);
            transTerrainWindow.OnApply += (sender, d) => { screen.World.TranslateTerrain(d); };

            GUIFrame topBar = new GUIFrame(UDim2.Zero, new UDim2(1, 0, 0, 40), Theme);

            float menuItemWidth = 220;

            GUIDropDown fileMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                Parent = topBar, Text = "File"
            };

            fileMenu.AddItem("New", null, (d, b) => { newWindow.Visible = true; });
            fileMenu.AddItem("Open", null, (d, b) => { openWorldWindow.Visible = true; });
            fileMenu.AddItem("Save", null, (d, b) => { if (screen.CurrentFile != null)
                                                       {
                                                           screen.SaveWorld();
                                                       }
                                                       else
                                                       {
                                                           saveWorldWindow.Visible = true;
                                                       } });
            fileMenu.AddItem("Save As...", null, (d, b) => { saveWorldWindow.Visible = true; });

            GUIDropDown editMenu = new GUIDropDown(new UDim2(0, menuItemWidth, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                Parent = topBar, Text = "Edit"
            };

            GUIDropDown editModeMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                HideMainButton = true
            };

            editMenu.AddItemSub("Mode", editModeMenu);
            editModeButtons = new GUIDropDownButton[] {
                editModeMenu.AddItem("Select", null, OnEditModeSelected),
                editModeMenu.AddItem("Add", null, OnEditModeSelected),
                editModeMenu.AddItem("Delete", null, OnEditModeSelected),
                editModeMenu.AddItem("Paint", null, OnEditModeSelected),
                editModeMenu.AddItem("Terrain Move", null, OnEditModeSelected),
                editModeMenu.AddItem("Terraform", null, OnEditModeSelected),
            };

            GUIDropDown insertSubMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                HideMainButton = true
            };

            editMenu.AddItemSub("Insert", insertSubMenu);
            GUIDropDownButton[] insertButtons = new GUIDropDownButton[] {
                insertSubMenu.AddItem("Command Post", null, (d, b) => { screen.World.AddNewCommandPost(); }),
                insertSubMenu.AddItem("Intel", null, (d, b) => { screen.World.AddNewIntel(); }),
            };

            editMenu.AddItem("Bake Damage Colors", null, (d, b) => { screen.WorldEditor.TerrainEditor.BakeDamageColors(); });
            editMenu.AddItem("Translate Terrain", null, (d, b) => { transTerrainWindow.Visible = true; });

            editModeButtons[0].Toggled = true;

            GUIDropDown gfxMenu = new GUIDropDown(new UDim2(0, menuItemWidth * 2, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                Parent = topBar, Text = "Graphics"
            };

            gfxMenu.AddItem("FXAA", null, (d, b) => { TogglePostProcess(b, true); });
            gfxMenu.AddItem("Shadows", null, (d, b) => { b.Toggled = renderer.GFXSettings.RenderShadows = !renderer.GFXSettings.RenderShadows; });

            GUIDropDown gfxFogMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                HideMainButton = true
            };

            gfxMenu.AddItemSub("Fog", gfxFogMenu);
            fogButtons    = new GUIDropDownButton[4];
            fogButtons[0] = gfxFogMenu.AddItem("Off", null, OnFogSelected);
            fogButtons[1] = gfxFogMenu.AddItem("Low", null, OnFogSelected);
            fogButtons[2] = gfxFogMenu.AddItem("Medium", null, OnFogSelected);
            fogButtons[3] = gfxFogMenu.AddItem("High", null, OnFogSelected);

            GUIDropDown gfxPCFMenu = new GUIDropDown(UDim2.Zero, new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                HideMainButton = true
            };

            gfxMenu.AddItemSub("PCF Samples", gfxPCFMenu);
            pcfButtons    = new GUIDropDownButton[5];
            pcfButtons[0] = gfxPCFMenu.AddItem("1", 1, OnPCFSelected);
            pcfButtons[1] = gfxPCFMenu.AddItem("2", 2, OnPCFSelected);
            pcfButtons[2] = gfxPCFMenu.AddItem("4", 4, OnPCFSelected);
            pcfButtons[3] = gfxPCFMenu.AddItem("6", 6, OnPCFSelected);
            pcfButtons[4] = gfxPCFMenu.AddItem("12", 12, OnPCFSelected);

            GUIDropDown viewMenu = new GUIDropDown(new UDim2(0, menuItemWidth * 3, 0, 0), new UDim2(0, menuItemWidth, 1, 0), Theme, false)
            {
                Parent = topBar, Text = "View"
            };

            viewMenu.AddItem("Color Picker", null, (d, b) => { ColorWindow.Visible = true; });
            viewMenu.AddItem("Chunk Borders", null, (d, b) => { b.Toggled = screen.World.ShowChunkBorders = !screen.World.ShowChunkBorders; });

            currentToolLabel = new GUILabel(new UDim2(1f, -5, 0, 5), UDim2.Zero, "Current Tool: Add", TextAlign.TopRight, Theme)
            {
                Parent = topBar
            };

            SetupDefaultGraphicsSettings(gfxMenu);
            area.AddTopLevel(topBar);

            GUIFrame bottomBar = new GUIFrame(new UDim2(0, 0, 1, -30), new UDim2(1, 0, 0, 30), Theme);

            statusLeft = new GUILabel(UDim2.Zero, new UDim2(0.5f, 0, 1, 0), "<left status>", TextAlign.Left, Theme)
            {
                Parent = bottomBar
            };
            statusRight = new GUILabel(new UDim2(0.5f, 0, 0, 0), new UDim2(0.5f, 0, 1, 0), "<right status>", TextAlign.Right, Theme)
            {
                Parent = bottomBar
            };
            statusMid = new GUILabel(new UDim2(0.25f, 0, 0, 0), new UDim2(0.5f, 0, 1f, 0), "", TextAlign.Center, Theme)
            {
                Parent = bottomBar
            };

            area.AddTopLevel(bottomBar);

            openWorldWindow = new FileBrowserWindow(GUISystem, Theme, new UDim2(0.75f, 0, 0.75f, 0), "Open World",
                                                    FileBrowserMode.OpenFile, new string[] { ".aosw" },
                                                    (window) =>
            {
                if (File.Exists(window.FileName))
                {
                    screen.LoadWorld(window.FileName);
                }
            });

            saveWorldWindow = new FileBrowserWindow(GUISystem, Theme, new UDim2(0.75f, 0, 0.75f, 0), "Save World",
                                                    FileBrowserMode.Save, new string[] { ".aosw" },
                                                    (window) =>
            {
                string fullPath = Path.Combine(window.CurrentDirectory, window.FileName);

                if (!Path.HasExtension(fullPath))
                {
                    fullPath += ".aosw";
                }

                screen.SaveWorld(fullPath);
            });

            ColorWindow          = new GUIColorPickerWindow(GUISystem, new UDim2(0.3f, 0, 0.3f, 0), Theme);
            ColorWindow.Visible  = true;
            ColorWindow.Position = new UDim2(0.7f, -10, 0.7f, -10);
            ColorWindow.MinSize  = new UDim2(0, 400, 0, 300);
            ColorWindow.MaxSize  = new UDim2(0, 550, 0, 400);
            popup         = new MessageWindow(GUISystem, Theme, new UDim2(0.6f, 0, 0.3f, 0), "Alert!");
            popup.MinSize = new UDim2(0, 215, 0, 200);
            popup.MaxSize = new UDim2(0, 600, 0, 275);

            GUISystem.Add(ColorWindow, transTerrainWindow, openWorldWindow, saveWorldWindow, newWindow, popup);
        }
Esempio n. 27
0
        /// <summary>
        /// Set a GFX option and reflect setting on button
        /// </summary>
        /// <param name="dropDown"></param>
        /// <param name="button"></param>
        void SetGfxOption(GUIDropDown dropDown, GUIDropDownButton button)
        {
            if (button.Value == null)
            {
                return; //it should never be null but just in case...
            }
            if (button.Value.GetType() == typeof(int))
            {
                var SubMenu = TopBarHelper.GetSubMenus();
                foreach (KeyValuePair <string, GUIDropDownButton> btn in SubMenu["PCF Samples"])
                {
                    if (btn.Value.Toggled)
                    {
                        btn.Value.Toggled = false; //only toggle off if on
                        break;                     //prevent more than whats needed
                    }
                }
                renderer.GFXSettings.ShadowPCFSamples = (button.Value as int? != null ? (int)button.Value : 1); //we try to safe cast as int nullable; if we fail we hard set to 1
                button.Toggled = true;
            }

            if (button.Value.GetType() == typeof(FogQuality))
            {
                FogQuality myType = (FogQuality)button.Value;


                var SubMenu = TopBarHelper.GetSubMenus();
                foreach (KeyValuePair <string, GUIDropDownButton> btn in SubMenu["Fog"])
                {
                    if (btn.Value.Toggled)
                    {
                        btn.Value.Toggled = false; //only toggle off if on
                        break;                     //prevent more than whats needed
                    }
                }

                switch (myType)
                {
                case FogQuality.Off:
                {
                    bool currentSetting = renderer.FogEnabled;
                    renderer.FogEnabled = !currentSetting;
                    button.Toggled      = currentSetting;    //dont need to invert the bool, all buttons are false by default due to the foreach loop
                    break;
                }

                case FogQuality.Low:
                {
                    renderer.FogEnabled             = true;
                    renderer.GFXSettings.FogQuality = FogQuality.Low;
                    button.Toggled = true;
                    break;
                }

                case FogQuality.Medium:
                {
                    renderer.FogEnabled             = true;
                    renderer.GFXSettings.FogQuality = FogQuality.Medium;
                    button.Toggled = true;
                    break;
                }

                case FogQuality.High:
                {
                    renderer.FogEnabled             = true;
                    renderer.GFXSettings.FogQuality = FogQuality.High;
                    button.Toggled = true;
                    break;
                }
                }
            }

            if (button.Value.GetType() == typeof(gfxType))
            {                                           //check for enum gfxType
                gfxType myType = (gfxType)button.Value; // /should/ be safe to case as gfxType
                switch (myType)
                {
                case gfxType.fxaa:
                {
                    bool currentSetting = renderer.GFXSettings.ApplyFXAA;         //easier to read
                    renderer.GFXSettings.ApplyFXAA = !currentSetting;
                    button.Toggled = !currentSetting;
                    break;
                }

                case gfxType.shadows:
                {
                    bool currentSetting = renderer.GFXSettings.RenderShadows;         //easier to read
                    renderer.GFXSettings.RenderShadows = !currentSetting;
                    button.Toggled = !currentSetting;
                    break;
                }

                case gfxType.wireframe:
                {
                    bool currentSetting = renderer.GlobalWireframe;         //easier to read
                    renderer.GlobalWireframe = !currentSetting;
                    button.Toggled           = !currentSetting;
                    break;
                }
                }
            }
        }
Esempio n. 28
0
        protected override void LoadContent()
        {
            graphicsWidth  = GraphicsDevice.Viewport.Width;
            graphicsHeight = GraphicsDevice.Viewport.Height;

            //for whatever reason, window isn't centered automatically
            //since MonoGame 3.6 (nuget package might be broken), so
            //let's do it manually
            Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - graphicsWidth) / 2,
                                        (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - graphicsHeight) / 2);

            TextureLoader.Init(GraphicsDevice);

            GUI.Init(Window, settings.SelectedContentPackages, GraphicsDevice);
            GUICanvas.Instance.NonScaledSize = new Point(graphicsWidth, graphicsHeight);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            GUI.LoadContent(false);

            backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png");
            titleTexture      = TextureLoader.FromFile("Content/UI/titleText.png");

            guiRoot = new GUIFrame(new RectTransform(new Point(graphicsWidth, graphicsHeight), null), style: null);
            GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.75f), guiRoot.RectTransform, Anchor.Center)
            {
                AbsoluteOffset = new Point(0, 25)
            },
                                                style: null);

            launchButton = new GUIButton(new RectTransform(new Point(100, 30), paddedFrame.RectTransform, Anchor.BottomRight), "START")
            {
                OnClicked = LaunchClick
            };

            int y = 0;
            var checkForUpdates = new GUITickBox(new RectTransform(new Point(20, 20), paddedFrame.RectTransform), "Automatically check for updates")
            {
                Selected = settings.AutoCheckUpdates
            };

            updateInfoText = new GUITextBlock(new RectTransform(new Point(20, 20), paddedFrame.RectTransform)
            {
                AbsoluteOffset = new Point(0, 30)
            }, "");

            updateInfoBox = new GUIListBox(new RectTransform(new Point(330, 210), paddedFrame.RectTransform)
            {
                AbsoluteOffset = new Point(0, 55)
            })
            {
                Visible = false
            };

            progressBar = new GUIProgressBar(new RectTransform(new Point(220, 20), paddedFrame.RectTransform, Anchor.BottomLeft)
            {
                AbsoluteOffset = new Point(110, 0)
            },
                                             0.0f, Color.Green)
            {
                Visible = false
            };

            downloadButton = new GUIButton(new RectTransform(new Point(100, 20), paddedFrame.RectTransform, Anchor.BottomLeft), "Download")
            {
                OnClicked = DownloadButtonClicked,
                Visible   = false
            };

            //-----------------------------------------------------------------
            //-----------------------------------------------------------------

            int x = 360;

            new GUITextBlock(new RectTransform(new Point(20, 20), paddedFrame.RectTransform)
            {
                AbsoluteOffset = new Point(x, y)
            }, "Resolution");
            resolutionDD = new GUIDropDown(new RectTransform(new Point(200, 20), paddedFrame.RectTransform)
            {
                AbsoluteOffset = new Point(x, y + 20)
            });

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if (supportedModes.FirstOrDefault(m => m.Width == mode.Width && m.Height == mode.Height) != null)
                {
                    continue;
                }

                resolutionDD.AddItem(mode.Width + "x" + mode.Height, mode);
                supportedModes.Add(mode);

                if (settings.GraphicsWidth == mode.Width && settings.GraphicsHeight == mode.Height)
                {
                    resolutionDD.SelectItem(mode);
                }
            }

            if (resolutionDD.SelectedItemData == null)
            {
                resolutionDD.SelectItem(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Last());
            }

            new GUITextBlock(new RectTransform(new Point(20, 20), paddedFrame.RectTransform)
            {
                AbsoluteOffset = new Point(x, y + 50)
            }, "Display mode");
            displayModeDD = new GUIDropDown(new RectTransform(new Point(200, 20), paddedFrame.RectTransform)
            {
                AbsoluteOffset = new Point(x, y + 70)
            });
            displayModeDD.AddItem("Fullscreen", WindowMode.Fullscreen);
            displayModeDD.AddItem("Windowed", WindowMode.Windowed);
#if (!OSX)
            // Fullscreen option just sets itself to borderless on macOS.
            displayModeDD.AddItem(TextManager.Get("BorderlessWindowed"), WindowMode.BorderlessWindowed);
            displayModeDD.SelectItem(settings.WindowMode);
#else
            if (settings.WindowMode == WindowMode.BorderlessWindowed)
            {
                displayModeDD.SelectItem(WindowMode.Fullscreen);
            }
            else
            {
                displayModeDD.SelectItem(settings.WindowMode);
            }
#endif
            displayModeDD.OnSelected = (guiComponent, userData) => { settings.WindowMode = (WindowMode)guiComponent.UserData; return(true); };

            new GUITextBlock(new RectTransform(new Point(20, 20), paddedFrame.RectTransform)
            {
                AbsoluteOffset = new Point(x, y + 100)
            }, "Content packages");
            contentPackageList = new GUIListBox(new RectTransform(new Point(200, 120), paddedFrame.RectTransform)
            {
                AbsoluteOffset = new Point(x, y + 120)
            });

            foreach (ContentPackage contentPackage in ContentPackage.List)
            {
                new GUITickBox(new RectTransform(new Vector2(1.0f, 0.1f), contentPackageList.Content.RectTransform, minSize: new Point(0, 15)), contentPackage.Name)
                {
                    UserData   = contentPackage,
                    OnSelected = SelectContentPackage,
                    Selected   = settings.SelectedContentPackages.Contains(contentPackage)
                };
            }
        }
 public void Dispose()
 {
     aoASweepInputs = machSweepInputs = null;
     flapSettingDropdown = null;
     bodySettingDropdown = null;
     simManager = null;
     _graph = null;
 }
Esempio n. 30
0
        private void CreateSettingsFrame()
        {
            foreach (NetPropertyData prop in netProperties.Values)
            {
                prop.TempValue = prop.Value;
            }

            //background frame
            settingsFrame = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null);
            new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, settingsFrame.RectTransform, Anchor.Center), style: "GUIBackgroundBlocker");

            new GUIButton(new RectTransform(Vector2.One, settingsFrame.RectTransform), "", style: null).OnClicked += (btn, userData) =>
            {
                if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock)
                {
                    ToggleSettingsFrame(btn, userData);
                }
                return(true);
            };

            new GUIButton(new RectTransform(Vector2.One, settingsFrame.RectTransform), "", style: null)
            {
                OnClicked = ToggleSettingsFrame
            };

            //center frames
            GUIFrame innerFrame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.8f), settingsFrame.RectTransform, Anchor.Center)
            {
                MinSize = new Point(400, 430)
            });
            GUILayoutGroup paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.95f), innerFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform), TextManager.Get("Settings"), font: GUI.LargeFont);

            var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.04f), paddedFrame.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.01f
            };

            var tabContent = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.85f), paddedFrame.RectTransform), style: "InnerFrame");

            //tabs
            var tabValues = Enum.GetValues(typeof(SettingsTab)).Cast <SettingsTab>().ToArray();

            string[] tabNames = new string[tabValues.Count()];
            for (int i = 0; i < tabNames.Length; i++)
            {
                tabNames[i] = TextManager.Get("ServerSettings" + tabValues[i] + "Tab");
            }
            settingsTabs = new GUIFrame[tabNames.Length];
            tabButtons   = new GUIButton[tabNames.Length];
            for (int i = 0; i < tabNames.Length; i++)
            {
                settingsTabs[i] = new GUIFrame(new RectTransform(Vector2.One, tabContent.RectTransform, Anchor.Center), style: null);
                tabButtons[i]   = new GUIButton(new RectTransform(new Vector2(0.2f, 1.2f), buttonArea.RectTransform), tabNames[i], style: "GUITabButton")
                {
                    UserData  = i,
                    OnClicked = SelectSettingsTab
                };
            }
            GUITextBlock.AutoScaleAndNormalize(tabButtons.Select(b => b.TextBlock));
            SelectSettingsTab(tabButtons[0], 0);

            //"Close"
            var buttonContainer = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.05f), paddedFrame.RectTransform), style: null);
            var closeButton     = new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), buttonContainer.RectTransform, Anchor.BottomRight), TextManager.Get("Close"))
            {
                OnClicked = ToggleSettingsFrame
            };


            //--------------------------------------------------------------------------------
            //                              server settings
            //--------------------------------------------------------------------------------

            var serverTab = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsTabs[(int)SettingsTab.General].RectTransform, Anchor.Center))
            {
                Stretch         = true,
                RelativeSpacing = 0.01f
            };

            //***********************************************

            // Sub Selection
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), serverTab.RectTransform), TextManager.Get("ServerSettingsSubSelection"), font: GUI.SubHeadingFont);
            var selectionFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.02f), serverTab.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            GUIRadioButtonGroup selectionMode = new GUIRadioButtonGroup();

            for (int i = 0; i < 3; i++)
            {
                var selectionTick = new GUITickBox(new RectTransform(new Vector2(0.3f, 1.0f), selectionFrame.RectTransform), TextManager.Get(((SelectionMode)i).ToString()), font: GUI.SmallFont, style: "GUIRadioButton");
                selectionMode.AddRadioButton(i, selectionTick);
            }
            selectionFrame.RectTransform.NonScaledSize = new Point(selectionFrame.Rect.Width, selectionFrame.Children.First().Rect.Height);
            selectionFrame.RectTransform.IsFixedSize   = true;

            GetPropertyData("SubSelectionMode").AssignGUIComponent(selectionMode);

            // Mode Selection
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), serverTab.RectTransform), TextManager.Get("ServerSettingsModeSelection"), font: GUI.SubHeadingFont);
            selectionFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.02f), serverTab.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            selectionMode = new GUIRadioButtonGroup();
            for (int i = 0; i < 3; i++)
            {
                var selectionTick = new GUITickBox(new RectTransform(new Vector2(0.3f, 1.0f), selectionFrame.RectTransform), TextManager.Get(((SelectionMode)i).ToString()), font: GUI.SmallFont, style: "GUIRadioButton");
                selectionMode.AddRadioButton(i, selectionTick);
            }
            selectionFrame.RectTransform.NonScaledSize = new Point(selectionFrame.Rect.Width, selectionFrame.Children.First().Rect.Height);
            selectionFrame.RectTransform.IsFixedSize   = true;
            GetPropertyData("ModeSelectionMode").AssignGUIComponent(selectionMode);

            new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), serverTab.RectTransform), style: "HorizontalLine");

            //***********************************************

            var voiceChatEnabled = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform),
                                                  TextManager.Get("ServerSettingsVoiceChatEnabled"));

            GetPropertyData("VoiceChatEnabled").AssignGUIComponent(voiceChatEnabled);

            //***********************************************

            string autoRestartDelayLabel = TextManager.Get("ServerSettingsAutoRestartDelay") + " ";
            var    startIntervalText     = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), serverTab.RectTransform), autoRestartDelayLabel);
            var    startIntervalSlider   = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), barSize: 0.1f, style: "GUISlider")
            {
                UserData = startIntervalText,
                Step     = 0.05f,
                OnMoved  = (GUIScrollBar scrollBar, float barScroll) =>
                {
                    GUITextBlock text = scrollBar.UserData as GUITextBlock;
                    text.Text = autoRestartDelayLabel + ToolBox.SecondsToReadableTime(scrollBar.BarScrollValue);
                    return(true);
                }
            };

            startIntervalSlider.Range = new Vector2(10.0f, 300.0f);
            GetPropertyData("AutoRestartInterval").AssignGUIComponent(startIntervalSlider);
            startIntervalSlider.OnMoved(startIntervalSlider, startIntervalSlider.BarScroll);

            //***********************************************

            var startWhenClientsReady = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform),
                                                       TextManager.Get("ServerSettingsStartWhenClientsReady"));

            GetPropertyData("StartWhenClientsReady").AssignGUIComponent(startWhenClientsReady);

            CreateLabeledSlider(serverTab, "ServerSettingsStartWhenClientsReadyRatio", out GUIScrollBar slider, out GUITextBlock sliderLabel);
            string clientsReadyRequiredLabel = sliderLabel.Text;

            slider.Step    = 0.2f;
            slider.Range   = new Vector2(0.5f, 1.0f);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = clientsReadyRequiredLabel.Replace("[percentage]", ((int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 10.0f)).ToString());
                return(true);
            };
            GetPropertyData("StartWhenClientsReadyRatio").AssignGUIComponent(slider);
            slider.OnMoved(slider, slider.BarScroll);

            //***********************************************

            var allowSpecBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsAllowSpectating"));

            GetPropertyData("AllowSpectating").AssignGUIComponent(allowSpecBox);

            var shareSubsBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsShareSubFiles"));

            GetPropertyData("AllowFileTransfers").AssignGUIComponent(shareSubsBox);

            var randomizeLevelBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsRandomizeSeed"));

            GetPropertyData("RandomizeSeed").AssignGUIComponent(randomizeLevelBox);

            var saveLogsBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsSaveLogs"))
            {
                OnSelected = (GUITickBox) =>
                {
                    //TODO: fix?
                    //showLogButton.Visible = SaveServerLogs;
                    return(true);
                }
            };

            GetPropertyData("SaveServerLogs").AssignGUIComponent(saveLogsBox);

            //--------------------------------------------------------------------------------
            //                              game settings
            //--------------------------------------------------------------------------------

            var roundsTab = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsTabs[(int)SettingsTab.Rounds].RectTransform, Anchor.Center))
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };

            // Play Style Selection
            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), TextManager.Get("ServerSettingsPlayStyle"), font: GUI.SubHeadingFont);
            var playstyleList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.16f), roundsTab.RectTransform))
            {
                AutoHideScrollBar = true,
                UseGridLayout     = true
            };

            playstyleList.Padding *= 2.0f;

            List <GUITickBox>   playStyleTickBoxes = new List <GUITickBox>();
            GUIRadioButtonGroup selectionPlayStyle = new GUIRadioButtonGroup();

            foreach (PlayStyle playStyle in Enum.GetValues(typeof(PlayStyle)))
            {
                var selectionTick = new GUITickBox(new RectTransform(new Vector2(0.32f, 0.49f), playstyleList.Content.RectTransform), TextManager.Get("servertag." + playStyle), font: GUI.SmallFont, style: "GUIRadioButton")
                {
                    ToolTip = TextManager.Get("servertagdescription." + playStyle)
                };
                selectionPlayStyle.AddRadioButton((int)playStyle, selectionTick);
                playStyleTickBoxes.Add(selectionTick);
            }
            GetPropertyData("PlayStyle").AssignGUIComponent(selectionPlayStyle);
            GUITextBlock.AutoScaleAndNormalize(playStyleTickBoxes.Select(t => t.TextBlock));
            playstyleList.RectTransform.MinSize = new Point(0, (int)(playstyleList.Content.Children.First().Rect.Height * 2.0f + playstyleList.Padding.Y + playstyleList.Padding.W));

            var endVoteBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform),
                                            TextManager.Get("ServerSettingsEndRoundVoting"));

            GetPropertyData("AllowEndVoting").AssignGUIComponent(endVoteBox);

            CreateLabeledSlider(roundsTab, "ServerSettingsEndRoundVotesRequired", out slider, out sliderLabel);

            string endRoundLabel = sliderLabel.Text;

            slider.Step  = 0.2f;
            slider.Range = new Vector2(0.5f, 1.0f);
            GetPropertyData("EndVoteRequiredRatio").AssignGUIComponent(slider);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = endRoundLabel + " " + (int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 10.0f) + " %";
                return(true);
            };
            slider.OnMoved(slider, slider.BarScroll);

            var respawnBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform),
                                            TextManager.Get("ServerSettingsAllowRespawning"));

            GetPropertyData("AllowRespawn").AssignGUIComponent(respawnBox);

            CreateLabeledSlider(roundsTab, "ServerSettingsRespawnInterval", out slider, out sliderLabel);
            string intervalLabel = sliderLabel.Text;

            slider.Range     = new Vector2(10.0f, 600.0f);
            slider.StepValue = 10.0f;
            GetPropertyData("RespawnInterval").AssignGUIComponent(slider);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                GUITextBlock text = scrollBar.UserData as GUITextBlock;
                text.Text = intervalLabel + " " + ToolBox.SecondsToReadableTime(scrollBar.BarScrollValue);
                return(true);
            };
            slider.OnMoved(slider, slider.BarScroll);

            var minRespawnText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), "")
            {
                ToolTip = TextManager.Get("ServerSettingsMinRespawnToolTip")
            };

            string minRespawnLabel = TextManager.Get("ServerSettingsMinRespawn") + " ";

            CreateLabeledSlider(roundsTab, "", out slider, out sliderLabel);
            slider.ToolTip  = minRespawnText.RawToolTip;
            slider.UserData = minRespawnText;
            slider.Step     = 0.1f;
            slider.Range    = new Vector2(0.0f, 1.0f);
            GetPropertyData("MinRespawnRatio").AssignGUIComponent(slider);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = minRespawnLabel + (int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 10.0f) + " %";
                return(true);
            };
            slider.OnMoved(slider, MinRespawnRatio);

            var respawnDurationText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), "")
            {
                ToolTip = TextManager.Get("ServerSettingsRespawnDurationToolTip")
            };

            string respawnDurationLabel = TextManager.Get("ServerSettingsRespawnDuration") + " ";

            CreateLabeledSlider(roundsTab, "", out slider, out sliderLabel);
            slider.ToolTip       = respawnDurationText.RawToolTip;
            slider.UserData      = respawnDurationText;
            slider.Step          = 0.1f;
            slider.Range         = new Vector2(60.0f, 660.0f);
            slider.ScrollToValue = (GUIScrollBar scrollBar, float barScroll) =>
            {
                return(barScroll >= 1.0f ? 0.0f : barScroll *(scrollBar.Range.Y - scrollBar.Range.X) + scrollBar.Range.X);
            };
            slider.ValueToScroll = (GUIScrollBar scrollBar, float value) =>
            {
                return(value <= 0.0f ? 1.0f : (value - scrollBar.Range.X) / (scrollBar.Range.Y - scrollBar.Range.X));
            };
            GetPropertyData("MaxTransportTime").AssignGUIComponent(slider);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                if (barScroll == 1.0f)
                {
                    ((GUITextBlock)scrollBar.UserData).Text = respawnDurationLabel + TextManager.Get("Unlimited");
                }
                else
                {
                    ((GUITextBlock)scrollBar.UserData).Text = respawnDurationLabel + ToolBox.SecondsToReadableTime(scrollBar.BarScrollValue);
                }

                return(true);
            };
            slider.OnMoved(slider, slider.BarScroll);

            var traitorsMinPlayerCount = CreateLabeledNumberInput(roundsTab, "ServerSettingsTraitorsMinPlayerCount", 1, 16, "ServerSettingsTraitorsMinPlayerCountToolTip");

            GetPropertyData("TraitorsMinPlayerCount").AssignGUIComponent(traitorsMinPlayerCount);

            var ragdollButtonBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), TextManager.Get("ServerSettingsAllowRagdollButton"));

            GetPropertyData("AllowRagdollButton").AssignGUIComponent(ragdollButtonBox);

            var disableBotConversationsBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), TextManager.Get("ServerSettingsDisableBotConversations"));

            GetPropertyData("DisableBotConversations").AssignGUIComponent(disableBotConversationsBox);

            var buttonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), roundsTab.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            var monsterButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), buttonHolder.RectTransform),
                                              TextManager.Get("ServerSettingsMonsterSpawns"), style: "GUIButtonSmall")
            {
                Enabled = !GameMain.NetworkMember.GameStarted
            };
            var monsterFrame = new GUIListBox(new RectTransform(new Vector2(0.6f, 0.7f), settingsTabs[(int)SettingsTab.Rounds].RectTransform, Anchor.BottomLeft, Pivot.BottomRight))
            {
                Visible = false
            };

            monsterButton.UserData  = monsterFrame;
            monsterButton.OnClicked = (button, obj) =>
            {
                if (GameMain.NetworkMember.GameStarted)
                {
                    ((GUIComponent)obj).Visible = false;
                    button.Enabled = false;
                    return(true);
                }
                ((GUIComponent)obj).Visible = !((GUIComponent)obj).Visible;
                return(true);
            };

            InitMonstersEnabled();
            List <string> monsterNames = MonsterEnabled.Keys.ToList();

            tempMonsterEnabled = new Dictionary <string, bool>(MonsterEnabled);
            foreach (string s in monsterNames)
            {
                string translatedLabel   = TextManager.Get($"Character.{s}", true);
                var    monsterEnabledBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.1f), monsterFrame.Content.RectTransform)
                {
                    MinSize = new Point(0, 25)
                },
                                                          label: translatedLabel ?? s)
                {
                    Selected   = tempMonsterEnabled[s],
                    OnSelected = (GUITickBox tb) =>
                    {
                        tempMonsterEnabled[s] = tb.Selected;
                        return(true);
                    }
                };
            }

            var cargoButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), buttonHolder.RectTransform),
                                            TextManager.Get("ServerSettingsAdditionalCargo"), style: "GUIButtonSmall")
            {
                Enabled = !GameMain.NetworkMember.GameStarted
            };
            var cargoFrame = new GUIListBox(new RectTransform(new Vector2(0.6f, 0.7f), settingsTabs[(int)SettingsTab.Rounds].RectTransform, Anchor.BottomRight, Pivot.BottomLeft))
            {
                Visible = false
            };

            cargoButton.UserData  = cargoFrame;
            cargoButton.OnClicked = (button, obj) =>
            {
                if (GameMain.NetworkMember.GameStarted)
                {
                    ((GUIComponent)obj).Visible = false;
                    button.Enabled = false;
                    return(true);
                }
                ((GUIComponent)obj).Visible = !((GUIComponent)obj).Visible;
                return(true);
            };

            GUITextBlock.AutoScaleAndNormalize(buttonHolder.Children.Select(c => ((GUIButton)c).TextBlock));

            foreach (ItemPrefab ip in ItemPrefab.Prefabs)
            {
                if (ip.AllowAsExtraCargo.HasValue)
                {
                    if (!ip.AllowAsExtraCargo.Value)
                    {
                        continue;
                    }
                }
                else
                {
                    if (!ip.CanBeBought)
                    {
                        continue;
                    }
                }

                var itemFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), cargoFrame.Content.RectTransform)
                {
                    MinSize = new Point(0, 30)
                }, isHorizontal: true)
                {
                    Stretch         = true,
                    UserData        = cargoFrame,
                    RelativeSpacing = 0.05f
                };


                if (ip.InventoryIcon != null || ip.sprite != null)
                {
                    GUIImage img = new GUIImage(new RectTransform(new Point(itemFrame.Rect.Height), itemFrame.RectTransform),
                                                ip.InventoryIcon ?? ip.sprite, scaleToFit: true)
                    {
                        CanBeFocused = false
                    };
                    img.Color = img.Sprite == ip.InventoryIcon ? ip.InventoryIconColor : ip.SpriteColor;
                }

                new GUITextBlock(new RectTransform(new Vector2(0.75f, 1.0f), itemFrame.RectTransform),
                                 ip.Name, font: GUI.SmallFont)
                {
                    Wrap         = true,
                    CanBeFocused = false
                };

                ExtraCargo.TryGetValue(ip, out int cargoVal);
                var amountInput = new GUINumberInput(new RectTransform(new Vector2(0.35f, 1.0f), itemFrame.RectTransform),
                                                     GUINumberInput.NumberType.Int, textAlignment: Alignment.CenterLeft)
                {
                    MinValueInt = 0,
                    MaxValueInt = 100,
                    IntValue    = cargoVal
                };
                amountInput.OnValueChanged += (numberInput) =>
                {
                    if (ExtraCargo.ContainsKey(ip))
                    {
                        ExtraCargo[ip] = numberInput.IntValue;
                        if (numberInput.IntValue <= 0)
                        {
                            ExtraCargo.Remove(ip);
                        }
                    }
                    else
                    {
                        ExtraCargo.Add(ip, numberInput.IntValue);
                    }
                };
            }


            //--------------------------------------------------------------------------------
            //                              antigriefing
            //--------------------------------------------------------------------------------

            var antigriefingTab = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsTabs[(int)SettingsTab.Antigriefing].RectTransform, Anchor.Center))
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };

            var tickBoxContainer = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.16f), antigriefingTab.RectTransform))
            {
                AutoHideScrollBar = true,
                UseGridLayout     = true
            };

            tickBoxContainer.Padding *= 2.0f;

            var allowFriendlyFire = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
                                                   TextManager.Get("ServerSettingsAllowFriendlyFire"));

            GetPropertyData("AllowFriendlyFire").AssignGUIComponent(allowFriendlyFire);

            var killableNPCs = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
                                              TextManager.Get("ServerSettingsKillableNPCs"));

            GetPropertyData("KillableNPCs").AssignGUIComponent(killableNPCs);

            var destructibleOutposts = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
                                                      TextManager.Get("ServerSettingsDestructibleOutposts"));

            GetPropertyData("DestructibleOutposts").AssignGUIComponent(destructibleOutposts);

            var lockAllDefaultWires = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
                                                     TextManager.Get("ServerSettingsLockAllDefaultWires"));

            GetPropertyData("LockAllDefaultWires").AssignGUIComponent(lockAllDefaultWires);

            var allowRewiring = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
                                               TextManager.Get("ServerSettingsAllowRewiring"));

            GetPropertyData("AllowRewiring").AssignGUIComponent(allowRewiring);

            var allowWifiChatter = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
                                                  TextManager.Get("ServerSettingsAllowWifiChat"));

            GetPropertyData("AllowLinkingWifiToChat").AssignGUIComponent(allowWifiChatter);

            var allowDisguises = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
                                                TextManager.Get("ServerSettingsAllowDisguises"));

            GetPropertyData("AllowDisguises").AssignGUIComponent(allowDisguises);

            var voteKickBox = new GUITickBox(new RectTransform(new Vector2(0.48f, 0.05f), tickBoxContainer.Content.RectTransform),
                                             TextManager.Get("ServerSettingsAllowVoteKick"));

            GetPropertyData("AllowVoteKick").AssignGUIComponent(voteKickBox);

            GUITextBlock.AutoScaleAndNormalize(tickBoxContainer.Content.Children.Select(c => ((GUITickBox)c).TextBlock));

            tickBoxContainer.RectTransform.MinSize = new Point(0, (int)(tickBoxContainer.Content.Children.First().Rect.Height * 2.0f + tickBoxContainer.Padding.Y + tickBoxContainer.Padding.W));

            CreateLabeledSlider(antigriefingTab, "ServerSettingsKickVotesRequired", out slider, out sliderLabel);
            string votesRequiredLabel = sliderLabel.Text + " ";

            slider.Step    = 0.2f;
            slider.Range   = new Vector2(0.5f, 1.0f);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = votesRequiredLabel + (int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 10.0f) + " %";
                return(true);
            };
            GetPropertyData("KickVoteRequiredRatio").AssignGUIComponent(slider);
            slider.OnMoved(slider, slider.BarScroll);

            CreateLabeledSlider(antigriefingTab, "ServerSettingsAutobanTime", out slider, out sliderLabel);
            string autobanLabel = sliderLabel.Text + " ";

            slider.Step    = 0.01f;
            slider.Range   = new Vector2(0.0f, MaxAutoBanTime);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = autobanLabel + ToolBox.SecondsToReadableTime(scrollBar.BarScrollValue);
                return(true);
            };
            GetPropertyData("AutoBanTime").AssignGUIComponent(slider);
            slider.OnMoved(slider, slider.BarScroll);

            var wrongPasswordBanBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), antigriefingTab.RectTransform), TextManager.Get("ServerSettingsBanAfterWrongPassword"));

            GetPropertyData("BanAfterWrongPassword").AssignGUIComponent(wrongPasswordBanBox);
            var allowedPasswordRetries = CreateLabeledNumberInput(antigriefingTab, "ServerSettingsPasswordRetriesBeforeBan", 0, 10);

            GetPropertyData("MaxPasswordRetriesBeforeBan").AssignGUIComponent(allowedPasswordRetries);
            wrongPasswordBanBox.OnSelected += (tb) =>
            {
                allowedPasswordRetries.Enabled = tb.Selected;
                return(true);
            };

            // karma --------------------------------------------------------------------------

            var karmaBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), antigriefingTab.RectTransform), TextManager.Get("ServerSettingsUseKarma"));

            GetPropertyData("KarmaEnabled").AssignGUIComponent(karmaBox);

            karmaPresetDD = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), antigriefingTab.RectTransform));
            foreach (string karmaPreset in GameMain.NetworkMember.KarmaManager.Presets.Keys)
            {
                karmaPresetDD.AddItem(TextManager.Get("KarmaPreset." + karmaPreset), karmaPreset);
            }

            var karmaSettingsContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.5f), antigriefingTab.RectTransform), style: null);
            var karmaSettingsList      = new GUIListBox(new RectTransform(Vector2.One, karmaSettingsContainer.RectTransform))
            {
                Spacing = (int)(8 * GUI.Scale)
            };

            karmaSettingsList.Padding *= 2.0f;

            karmaSettingsBlocker = new GUIFrame(new RectTransform(Vector2.One, karmaSettingsContainer.RectTransform, Anchor.CenterLeft)
            {
                MaxSize = new Point(karmaSettingsList.ContentBackground.Rect.Width, int.MaxValue)
            }, style: null)
            {
                UserData = "karmasettingsblocker",
                Color    = Color.Black * 0.95f
            };
            karmaSettingsBlocker.Color *= 0.5f;
            karmaPresetDD.SelectItem(KarmaPreset);
            karmaSettingsBlocker.Visible = !karmaBox.Selected || KarmaPreset != "custom";
            GameMain.NetworkMember.KarmaManager.CreateSettingsFrame(karmaSettingsList.Content);
            karmaPresetDD.OnSelected = (selected, obj) =>
            {
                string newKarmaPreset = obj as string;
                if (newKarmaPreset == KarmaPreset)
                {
                    return(true);
                }

                List <NetPropertyData> properties = netProperties.Values.ToList();
                List <object>          prevValues = new List <object>();
                foreach (NetPropertyData prop in netProperties.Values)
                {
                    prevValues.Add(prop.TempValue);
                    if (prop.GUIComponent != null)
                    {
                        prop.Value = prop.GUIComponentValue;
                    }
                }
                if (KarmaPreset == "custom")
                {
                    GameMain.NetworkMember?.KarmaManager?.SaveCustomPreset();
                    GameMain.NetworkMember?.KarmaManager?.Save();
                }
                KarmaPreset = newKarmaPreset;
                GameMain.NetworkMember.KarmaManager.SelectPreset(KarmaPreset);
                karmaSettingsList.Content.ClearChildren();
                karmaSettingsBlocker.Visible = !karmaBox.Selected || KarmaPreset != "custom";
                GameMain.NetworkMember.KarmaManager.CreateSettingsFrame(karmaSettingsList.Content);
                for (int i = 0; i < netProperties.Count; i++)
                {
                    properties[i].TempValue = prevValues[i];
                }
                return(true);
            };
            AssignGUIComponent("KarmaPreset", karmaPresetDD);
            karmaBox.OnSelected = (tb) =>
            {
                karmaSettingsBlocker.Visible = !tb.Selected || KarmaPreset != "custom";
                return(true);
            };

            //--------------------------------------------------------------------------------
            //                              banlist
            //--------------------------------------------------------------------------------

            BanList.CreateBanFrame(settingsTabs[(int)SettingsTab.Banlist]);

            //--------------------------------------------------------------------------------
            //                              whitelist
            //--------------------------------------------------------------------------------

            Whitelist.CreateWhiteListFrame(settingsTabs[(int)SettingsTab.Whitelist]);
        }
Esempio n. 31
0
        public override void OnLoad(ConfigNode node)
        {
            Instance = this;
            GeneratePresets();
            int index = 4;

            if (node.HasValue("newGame"))
            {
                newGame = bool.Parse(node.GetValue("newGame"));
            }

            if (node.HasValue("index"))
            {
                index = int.Parse(node.GetValue("index"));
            }

            dropdown = new GUIDropDown <FARDifficultyAndExactnessSettings>(presetNames.ToArray(),
                                                                           presets.ToArray(),
                                                                           index < 0 ? 2 : index);
            voxelSettings = new FARVoxelSettings();

            if (node.HasValue("numVoxelsControllableVessel"))
            {
                voxelSettings.numVoxelsControllableVessel = int.Parse(node.GetValue("numVoxelsControllableVessel"));
            }
            if (node.HasValue("numVoxelsDebrisVessel"))
            {
                voxelSettings.numVoxelsDebrisVessel = int.Parse(node.GetValue("numVoxelsDebrisVessel"));
            }
            if (node.HasValue("minPhysTicksPerUpdate"))
            {
                voxelSettings.minPhysTicksPerUpdate = int.Parse(node.GetValue("minPhysTicksPerUpdate"));
            }
            if (node.HasValue("useHigherResVoxelPoints"))
            {
                voxelSettings.useHigherResVoxelPoints = bool.Parse(node.GetValue("useHigherResVoxelPoints"));
            }
            if (node.HasValue("use32BitIndices"))
            {
                DebugVoxelMesh.Use32BitIndices = bool.Parse(node.GetValue("use32BitIndices"));
            }

            if (index == -1)
            {
                settings = new FARDifficultyAndExactnessSettings(index);

                if (node.HasValue("fractionTransonicDrag"))
                {
                    settings.fractionTransonicDrag = double.Parse(node.GetValue("fractionTransonicDrag"));
                }
                if (node.HasValue("gaussianVehicleLengthFractionForSmoothing"))
                {
                    settings.gaussianVehicleLengthFractionForSmoothing =
                        double.Parse(node.GetValue("gaussianVehicleLengthFractionForSmoothing"));
                }

                if (node.HasValue("numAreaSmoothingPasses"))
                {
                    settings.numAreaSmoothingPasses = int.Parse(node.GetValue("numAreaSmoothingPasses"));
                }
                if (node.HasValue("numDerivSmoothingPasses"))
                {
                    settings.numDerivSmoothingPasses = int.Parse(node.GetValue("numDerivSmoothingPasses"));
                }


                customSettings = settings;
            }
            else
            {
                settings       = presets[index];
                customSettings = new FARDifficultyAndExactnessSettings(-1);
            }

            currentIndex = index;


            FARLogger.Info("Loading FAR Data");
            flightGUISettings = new List <ConfigNode>();
            if (node.HasNode("FlightGUISettings"))
            {
                foreach (ConfigNode flightGUINode in node.GetNode("FlightGUISettings").nodes)
                {
                    flightGUISettings.Add(flightGUINode);
                }
            }

            FARDebugAndSettings.LoadConfigs(node);
        }
Esempio n. 32
0
        protected override void LoadContent()
        {
            graphicsWidth  = GraphicsDevice.Viewport.Width;
            graphicsHeight = GraphicsDevice.Viewport.Height;

            //for whatever reason, window isn't centered automatically
            //since MonoGame 3.6 (nuget package might be broken), so
            //let's do it manually
            Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - graphicsWidth) / 2,
                                        (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - graphicsHeight) / 2);

            TextureLoader.Init(GraphicsDevice);

            GUI.GraphicsDevice = GraphicsDevice;
            GUI.Init(Content);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            GUI.LoadContent(false);

            backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png");
            titleTexture      = TextureLoader.FromFile("Content/UI/titleText.png");

            guiRoot         = new GUIFrame(new Rectangle(0, 0, graphicsWidth, graphicsHeight), Color.Transparent);
            guiRoot.Padding = new Vector4(40.0f, 40.0f, 40.0f, 40.0f);

            launchButton           = new GUIButton(new Rectangle(0, 0, 100, 30), "START", Alignment.BottomRight, "", guiRoot);
            launchButton.OnClicked = LaunchClick;

            int y = 50;

            var checkForUpdates = new GUITickBox(new Rectangle(0, y, 20, 20), "Automatically check for updates", Alignment.TopLeft, guiRoot);

            checkForUpdates.Selected = settings.AutoCheckUpdates;

            updateInfoText = new GUITextBlock(new Rectangle(0, y + 30, 100, 20), "", "", guiRoot);

            updateInfoBox         = new GUIListBox(new Rectangle(0, y + 55, 330, graphicsHeight - y - 55 - 30 - 80), "", guiRoot);
            updateInfoBox.Visible = false;

            progressBar         = new GUIProgressBar(new Rectangle(110, 0, 220, 20), Color.Green, 0.0f, Alignment.BottomLeft, guiRoot);
            progressBar.Visible = false;

            downloadButton           = new GUIButton(new Rectangle(0, 0, 100, 20), "Download", Alignment.BottomLeft, "", guiRoot);
            downloadButton.OnClicked = DownloadButtonClicked;
            downloadButton.Visible   = false;

            //-----------------------------------------------------------------
            //-----------------------------------------------------------------

            int x = 360;

            new GUITextBlock(new Rectangle(x, y, 20, 20), "Resolution", "", Alignment.TopLeft, Alignment.TopLeft, guiRoot);
            resolutionDD = new GUIDropDown(new Rectangle(x, y + 20, 200, 20), "", "", guiRoot);

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if (supportedModes.FirstOrDefault(m => m.Width == mode.Width && m.Height == mode.Height) != null)
                {
                    continue;
                }

                resolutionDD.AddItem(mode.Width + "x" + mode.Height, mode);
                supportedModes.Add(mode);

                if (settings.GraphicsWidth == mode.Width && settings.GraphicsHeight == mode.Height)
                {
                    resolutionDD.SelectItem(mode);
                }
            }

            if (resolutionDD.SelectedItemData == null)
            {
                resolutionDD.SelectItem(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Last());
            }

            new GUITextBlock(new Rectangle(x, y + 50, 20, 20), "Content package", "", Alignment.TopLeft, Alignment.TopLeft, guiRoot);
            contentPackageDD = new GUIDropDown(new Rectangle(x, y + 70, 200, 20), "", "", guiRoot);

            foreach (ContentPackage contentPackage in ContentPackage.list)
            {
                contentPackageDD.AddItem(contentPackage.Name, contentPackage);

                if (settings.SelectedContentPackage == contentPackage)
                {
                    contentPackageDD.SelectItem(contentPackage);
                }
            }

            //new GUIButton(new Rectangle(x,y+120,150,20), "Package Manager", GUI.Style, guiRoot);

            new GUITextBlock(new Rectangle(x, y + 130, 20, 20), "Display mode", "", Alignment.TopLeft, Alignment.TopLeft, guiRoot);
            displayModeDD = new GUIDropDown(new Rectangle(x, y + 150, 200, 20), "", "", guiRoot);
            displayModeDD.AddItem("Fullscreen", WindowMode.Fullscreen);
            displayModeDD.AddItem("Windowed", WindowMode.Windowed);
            displayModeDD.AddItem("Borderless windowed", WindowMode.BorderlessWindowed);

            displayModeDD.SelectItem(settings.WindowMode);

            displayModeDD.OnSelected = (guiComponent, userData) => { settings.WindowMode = (WindowMode)guiComponent.UserData; return(true); };

            //var fullScreenTick = new GUITickBox(new Rectangle(x,y+150,20,20), "Fullscreen", Alignment.TopLeft, guiRoot);
            //fullScreenTick.OnSelected = ToggleFullScreen;
            //fullScreenTick.Selected = settings.FullScreenEnabled;

            if (settings.AutoCheckUpdates)
            {
                CheckForUpdates();
            }
        }
        public static void LoadConfiguration()
        {
            string[] names = Enum.GetNames(typeof(KSPActionGroup));
            KSPActionGroup[] agTypes = new KSPActionGroup[names.Length];
            actionGroupDropDown = new GUIDropDown<KSPActionGroup>[3];

            for(int i = 0; i < agTypes.Length; i++)
            {
                agTypes[i] = (KSPActionGroup)Enum.Parse(typeof(KSPActionGroup), names[i]);
            }

            // straight forward, reading the (action name, action group) tuples
            KSP.IO.PluginConfiguration config = FARDebugAndSettings.config;
            for (int i = 0; i < ACTION_COUNT; ++i)
            {
                try
                {
                    id2actionGroup[i] = (KSPActionGroup)Enum.Parse(typeof(KSPActionGroup), config.GetValue(configKeys[i], id2actionGroup[i].ToString())); ;
                    currentGuiStrings[i] = id2actionGroup[i].ToString(); // don't forget to initialize the gui
                    Debug.Log(String.Format("FAR: loaded AG {0} as {1}", configKeys[i], id2actionGroup[i]));
                }
                catch (Exception e)
                {
                    Debug.LogWarning("FAR: error reading config key '" + configKeys[i] + "' with value '" + config.GetValue(configKeys[i], "n/a") + "' gave " + e.ToString());
                }
                int initIndex = 0;
                for(int j = 0; j < agTypes.Length; j++)
                {
                    if(id2actionGroup[i] == agTypes[j])
                    {
                        initIndex = j;
                        break;
                    }
                }
                GUIDropDown<KSPActionGroup> dropDown = new GUIDropDown<KSPActionGroup>(names, agTypes, initIndex);
                actionGroupDropDown[i] = dropDown;
            }
        }
        void OnDestroy()
        {
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            SaveConfigs();
            if (_vessel)
            {
                vesselFlightGUI.Remove(_vessel);
            }
            _physicsCalcs = null;

            if(_flightDataGUI != null)
                _flightDataGUI.SaveSettings();
            _flightDataGUI = null;

            if(_stabilityAugmentation != null)
                _stabilityAugmentation.SaveAndDestroy();
            _stabilityAugmentation = null;

            if(_airSpeedGUI != null)
                _airSpeedGUI.SaveSettings();
            _airSpeedGUI = null;

            if (_aeroVizGUI != null)
                _aeroVizGUI.SaveSettings();

            _flightStatusGUI = null;
            settingsWindow = null;

            activeFlightGUICount--;

            if (activeFlightGUICount <= 0)
            {
                activeFlightGUICount = 0;
                if (blizzyFlightGUIButton != null)
                    ClearBlizzyToolbarButton();
            }
            
        }
        void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

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

            settingsWindow = new GUIDropDown<int>(new string[4]{"Flt Data","Stab Aug", "Air Spd","Aero Viz"}, new int[4]{0,1,2,3}, 0);
            //boxStyle.padding = new RectOffset(4, 4, 4, 4);

            if (vesselFlightGUI.ContainsKey(_vessel))
                vesselFlightGUI[_vessel] = this;
            else
                vesselFlightGUI.Add(_vessel, this);

            this.enabled = true;

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

            activeFlightGUICount++;

            if(_vessel == FlightGlobals.ActiveVessel)
                LoadConfigs();

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
Esempio n. 36
0
        private void CreateSettingsFrame()
        {
            foreach (NetPropertyData prop in netProperties.Values)
            {
                prop.TempValue = prop.Value;
            }

            //background frame
            settingsFrame = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas), style: null, color: Color.Black * 0.5f);
            new GUIButton(new RectTransform(Vector2.One, settingsFrame.RectTransform), "", style: null).OnClicked += (btn, userData) =>
            {
                if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock)
                {
                    ToggleSettingsFrame(btn, userData);
                }
                return(true);
            };

            new GUIButton(new RectTransform(Vector2.One, settingsFrame.RectTransform), "", style: null)
            {
                OnClicked = ToggleSettingsFrame
            };

            //center frames
            GUIFrame innerFrame = new GUIFrame(new RectTransform(new Vector2(0.4f, 0.75f), settingsFrame.RectTransform, Anchor.Center)
            {
                MinSize = new Point(400, 430)
            });
            GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), innerFrame.RectTransform, Anchor.Center), style: null);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), paddedFrame.RectTransform), TextManager.Get("Settings"), font: GUI.LargeFont);

            var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), paddedFrame.RectTransform)
            {
                RelativeOffset = new Vector2(0.0f, 0.1f)
            }, isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.01f
            };

            //tabs
            var tabValues = Enum.GetValues(typeof(SettingsTab)).Cast <SettingsTab>().ToArray();

            string[] tabNames = new string[tabValues.Count()];
            for (int i = 0; i < tabNames.Length; i++)
            {
                tabNames[i] = TextManager.Get("ServerSettings" + tabValues[i] + "Tab");
            }
            settingsTabs = new GUIFrame[tabNames.Length];
            tabButtons   = new GUIButton[tabNames.Length];
            for (int i = 0; i < tabNames.Length; i++)
            {
                settingsTabs[i] = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.79f), paddedFrame.RectTransform, Anchor.Center)
                {
                    RelativeOffset = new Vector2(0.0f, 0.05f)
                },
                                               style: "InnerFrame");

                tabButtons[i] = new GUIButton(new RectTransform(new Vector2(0.2f, 1.0f), buttonArea.RectTransform), tabNames[i], style: "GUITabButton")
                {
                    UserData  = i,
                    OnClicked = SelectSettingsTab
                };
            }
            GUITextBlock.AutoScaleAndNormalize(tabButtons.Select(b => b.TextBlock));
            SelectSettingsTab(tabButtons[0], 0);

            //"Close"
            var closeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.05f), paddedFrame.RectTransform, Anchor.BottomRight), TextManager.Get("Close"))
            {
                OnClicked = ToggleSettingsFrame
            };


            //--------------------------------------------------------------------------------
            //                              server settings
            //--------------------------------------------------------------------------------

            var serverTab = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsTabs[(int)SettingsTab.General].RectTransform, Anchor.Center))
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };

            //***********************************************

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsSubSelection"));
            var selectionFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            GUIRadioButtonGroup selectionMode = new GUIRadioButtonGroup();

            for (int i = 0; i < 3; i++)
            {
                var selectionTick = new GUITickBox(new RectTransform(new Vector2(0.3f, 1.0f), selectionFrame.RectTransform), TextManager.Get(((SelectionMode)i).ToString()), font: GUI.SmallFont);
                selectionMode.AddRadioButton((SelectionMode)i, selectionTick);
            }
            DebugConsole.NewMessage(SubSelectionMode.ToString(), Color.White);
            GetPropertyData("SubSelectionMode").AssignGUIComponent(selectionMode);

            new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsModeSelection"));
            selectionFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            selectionMode = new GUIRadioButtonGroup();
            for (int i = 0; i < 3; i++)
            {
                var selectionTick = new GUITickBox(new RectTransform(new Vector2(0.3f, 1.0f), selectionFrame.RectTransform), TextManager.Get(((SelectionMode)i).ToString()), font: GUI.SmallFont);
                selectionMode.AddRadioButton((SelectionMode)i, selectionTick);
            }
            GetPropertyData("ModeSelectionMode").AssignGUIComponent(selectionMode);


            //***********************************************

            var voiceChatEnabled = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform),
                                                  TextManager.Get("ServerSettingsVoiceChatEnabled"));

            GetPropertyData("VoiceChatEnabled").AssignGUIComponent(voiceChatEnabled);

            //***********************************************

            string autoRestartDelayLabel = TextManager.Get("ServerSettingsAutoRestartDelay") + " ";
            var    startIntervalText     = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), autoRestartDelayLabel);
            var    startIntervalSlider   = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), barSize: 0.1f)
            {
                UserData = startIntervalText,
                Step     = 0.05f,
                OnMoved  = (GUIScrollBar scrollBar, float barScroll) =>
                {
                    GUITextBlock text = scrollBar.UserData as GUITextBlock;
                    text.Text = autoRestartDelayLabel + ToolBox.SecondsToReadableTime(scrollBar.BarScrollValue);
                    return(true);
                }
            };

            startIntervalSlider.Range = new Vector2(10.0f, 300.0f);
            GetPropertyData("AutoRestartInterval").AssignGUIComponent(startIntervalSlider);
            startIntervalSlider.OnMoved(startIntervalSlider, startIntervalSlider.BarScroll);

            //***********************************************

            var startWhenClientsReady = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform),
                                                       TextManager.Get("ServerSettingsStartWhenClientsReady"));

            GetPropertyData("StartWhenClientsReady").AssignGUIComponent(startWhenClientsReady);

            CreateLabeledSlider(serverTab, "ServerSettingsStartWhenClientsReadyRatio", out GUIScrollBar slider, out GUITextBlock sliderLabel);
            string clientsReadyRequiredLabel = sliderLabel.Text;

            slider.Step    = 0.2f;
            slider.Range   = new Vector2(0.5f, 1.0f);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = clientsReadyRequiredLabel.Replace("[percentage]", ((int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 10.0f)).ToString());
                return(true);
            };
            GetPropertyData("StartWhenClientsReadyRatio").AssignGUIComponent(slider);
            slider.OnMoved(slider, slider.BarScroll);

            //***********************************************

            var allowSpecBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsAllowSpectating"));

            GetPropertyData("AllowSpectating").AssignGUIComponent(allowSpecBox);


            var shareSubsBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsShareSubFiles"));

            GetPropertyData("AllowFileTransfers").AssignGUIComponent(shareSubsBox);

            var randomizeLevelBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsRandomizeSeed"));

            GetPropertyData("RandomizeSeed").AssignGUIComponent(randomizeLevelBox);

            var saveLogsBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), serverTab.RectTransform), TextManager.Get("ServerSettingsSaveLogs"))
            {
                OnSelected = (GUITickBox) =>
                {
                    //TODO: fix?
                    //showLogButton.Visible = SaveServerLogs;
                    return(true);
                }
            };

            GetPropertyData("SaveServerLogs").AssignGUIComponent(saveLogsBox);

            //--------------------------------------------------------------------------------
            //                              game settings
            //--------------------------------------------------------------------------------

            var roundsTab = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsTabs[(int)SettingsTab.Rounds].RectTransform, Anchor.Center))
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };


            var endBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform),
                                        TextManager.Get("ServerSettingsEndRoundWhenDestReached"));

            GetPropertyData("EndRoundAtLevelEnd").AssignGUIComponent(endBox);

            var endVoteBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform),
                                            TextManager.Get("ServerSettingsEndRoundVoting"));

            GetPropertyData("AllowEndVoting").AssignGUIComponent(endVoteBox);

            CreateLabeledSlider(roundsTab, "ServerSettingsEndRoundVotesRequired", out slider, out sliderLabel);

            string endRoundLabel = sliderLabel.Text;

            slider.Step  = 0.2f;
            slider.Range = new Vector2(0.5f, 1.0f);
            GetPropertyData("EndVoteRequiredRatio").AssignGUIComponent(slider);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = endRoundLabel + " " + (int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 10.0f) + " %";
                return(true);
            };
            slider.OnMoved(slider, slider.BarScroll);

            var respawnBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform),
                                            TextManager.Get("ServerSettingsAllowRespawning"));

            GetPropertyData("AllowRespawn").AssignGUIComponent(respawnBox);

            CreateLabeledSlider(roundsTab, "ServerSettingsRespawnInterval", out slider, out sliderLabel);
            string intervalLabel = sliderLabel.Text;

            slider.Step  = 0.05f;
            slider.Range = new Vector2(10.0f, 600.0f);
            GetPropertyData("RespawnInterval").AssignGUIComponent(slider);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                GUITextBlock text = scrollBar.UserData as GUITextBlock;
                text.Text = intervalLabel + " " + ToolBox.SecondsToReadableTime(scrollBar.BarScrollValue);
                return(true);
            };
            slider.OnMoved(slider, slider.BarScroll);

            var minRespawnText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), "")
            {
                ToolTip = TextManager.Get("ServerSettingsMinRespawnToolTip")
            };

            string minRespawnLabel = TextManager.Get("ServerSettingsMinRespawn") + " ";

            CreateLabeledSlider(roundsTab, "", out slider, out sliderLabel);
            slider.ToolTip  = minRespawnText.ToolTip;
            slider.UserData = minRespawnText;
            slider.Step     = 0.1f;
            slider.Range    = new Vector2(0.0f, 1.0f);
            GetPropertyData("MinRespawnRatio").AssignGUIComponent(slider);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = minRespawnLabel + (int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 10.0f) + " %";
                return(true);
            };
            slider.OnMoved(slider, MinRespawnRatio);

            var respawnDurationText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), "")
            {
                ToolTip = TextManager.Get("ServerSettingsRespawnDurationToolTip")
            };

            string respawnDurationLabel = TextManager.Get("ServerSettingsRespawnDuration") + " ";

            CreateLabeledSlider(roundsTab, "", out slider, out sliderLabel);
            slider.ToolTip       = respawnDurationText.ToolTip;
            slider.UserData      = respawnDurationText;
            slider.Step          = 0.1f;
            slider.Range         = new Vector2(60.0f, 660.0f);
            slider.ScrollToValue = (GUIScrollBar scrollBar, float barScroll) =>
            {
                return(barScroll >= 1.0f ? 0.0f : barScroll *(scrollBar.Range.Y - scrollBar.Range.X) + scrollBar.Range.X);
            };
            slider.ValueToScroll = (GUIScrollBar scrollBar, float value) =>
            {
                return(value <= 0.0f ? 1.0f : (value - scrollBar.Range.X) / (scrollBar.Range.Y - scrollBar.Range.X));
            };
            GetPropertyData("MaxTransportTime").AssignGUIComponent(slider);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                if (barScroll == 1.0f)
                {
                    ((GUITextBlock)scrollBar.UserData).Text = respawnDurationLabel + TextManager.Get("Unlimited");
                }
                else
                {
                    ((GUITextBlock)scrollBar.UserData).Text = respawnDurationLabel + ToolBox.SecondsToReadableTime(scrollBar.BarScrollValue);
                }

                return(true);
            };
            slider.OnMoved(slider, slider.BarScroll);


            var ragdollButtonBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), TextManager.Get("ServerSettingsAllowRagdollButton"));

            GetPropertyData("AllowRagdollButton").AssignGUIComponent(ragdollButtonBox);

            /*var traitorRatioBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), roundsTab.RectTransform), TextManager.Get("ServerSettingsUseTraitorRatio"));
             *
             * CreateLabeledSlider(roundsTab, "", out slider, out sliderLabel);
             * var traitorRatioSlider = slider;
             * traitorRatioBox.OnSelected = (GUITickBox) =>
             * {
             *  traitorRatioSlider.OnMoved(traitorRatioSlider, traitorRatioSlider.BarScroll);
             *  return true;
             * };
             *
             * if (TraitorUseRatio)
             * {
             *  traitorRatioSlider.Range = new Vector2(0.1f, 1.0f);
             * }
             * else
             * {
             *  traitorRatioSlider.Range = new Vector2(1.0f, maxPlayers);
             * }
             *
             * string traitorRatioLabel = TextManager.Get("ServerSettingsTraitorRatio") + " ";
             * string traitorCountLabel = TextManager.Get("ServerSettingsTraitorCount") + " ";
             *
             * traitorRatioSlider.Range = new Vector2(0.1f, 1.0f);
             * traitorRatioSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
             * {
             *  GUITextBlock traitorText = scrollBar.UserData as GUITextBlock;
             *  if (traitorRatioBox.Selected)
             *  {
             *      scrollBar.Step = 0.01f;
             *      scrollBar.Range = new Vector2(0.1f, 1.0f);
             *      traitorText.Text = traitorRatioLabel + (int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 1.0f) + " %";
             *  }
             *  else
             *  {
             *      scrollBar.Step = 1f / (maxPlayers - 1);
             *      scrollBar.Range = new Vector2(1.0f, maxPlayers);
             *      traitorText.Text = traitorCountLabel + scrollBar.BarScrollValue;
             *  }
             *  return true;
             * };
             *
             * GetPropertyData("TraitorUseRatio").AssignGUIComponent(traitorRatioBox);
             * GetPropertyData("TraitorRatio").AssignGUIComponent(traitorRatioSlider);
             *
             * traitorRatioSlider.OnMoved(traitorRatioSlider, traitorRatioSlider.BarScroll);
             * traitorRatioBox.OnSelected(traitorRatioBox);*/

            var buttonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), roundsTab.RectTransform), isHorizontal: true)
            {
                Stretch         = true,
                RelativeSpacing = 0.05f
            };

            var monsterButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), buttonHolder.RectTransform),
                                              TextManager.Get("ServerSettingsMonsterSpawns"))
            {
                Enabled = !GameMain.NetworkMember.GameStarted
            };
            var monsterFrame = new GUIListBox(new RectTransform(new Vector2(0.6f, 0.7f), settingsTabs[(int)SettingsTab.Rounds].RectTransform, Anchor.BottomLeft, Pivot.BottomRight))
            {
                Visible = false
            };

            monsterButton.UserData  = monsterFrame;
            monsterButton.OnClicked = (button, obj) =>
            {
                if (GameMain.NetworkMember.GameStarted)
                {
                    ((GUIComponent)obj).Visible = false;
                    button.Enabled = false;
                    return(true);
                }
                ((GUIComponent)obj).Visible = !((GUIComponent)obj).Visible;
                return(true);
            };

            InitMonstersEnabled();
            List <string> monsterNames = MonsterEnabled.Keys.ToList();

            tempMonsterEnabled = new Dictionary <string, bool>(MonsterEnabled);
            foreach (string s in monsterNames)
            {
                string translatedLabel   = TextManager.Get($"Character.{s}", true);
                var    monsterEnabledBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.1f), monsterFrame.Content.RectTransform)
                {
                    MinSize = new Point(0, 25)
                },
                                                          label: translatedLabel ?? s)
                {
                    Selected   = tempMonsterEnabled[s],
                    OnSelected = (GUITickBox tb) =>
                    {
                        tempMonsterEnabled[s] = tb.Selected;
                        return(true);
                    }
                };
            }

            var cargoButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), buttonHolder.RectTransform),
                                            TextManager.Get("ServerSettingsAdditionalCargo"))
            {
                Enabled = !GameMain.NetworkMember.GameStarted
            };
            var cargoFrame = new GUIListBox(new RectTransform(new Vector2(0.6f, 0.7f), settingsTabs[(int)SettingsTab.Rounds].RectTransform, Anchor.BottomRight, Pivot.BottomLeft))
            {
                Visible = false
            };

            cargoButton.UserData  = cargoFrame;
            cargoButton.OnClicked = (button, obj) =>
            {
                if (GameMain.NetworkMember.GameStarted)
                {
                    ((GUIComponent)obj).Visible = false;
                    button.Enabled = false;
                    return(true);
                }
                ((GUIComponent)obj).Visible = !((GUIComponent)obj).Visible;
                return(true);
            };

            GUITextBlock.AutoScaleAndNormalize(buttonHolder.Children.Select(c => ((GUIButton)c).TextBlock));

            foreach (ItemPrefab ip in MapEntityPrefab.List.Where(p => p is ItemPrefab).Select(p => p as ItemPrefab))
            {
                if (!ip.CanBeBought && !ip.Tags.Contains("smallitem"))
                {
                    continue;
                }

                var itemFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), cargoFrame.Content.RectTransform)
                {
                    MinSize = new Point(0, 30)
                }, isHorizontal: true)
                {
                    Stretch         = true,
                    UserData        = cargoFrame,
                    RelativeSpacing = 0.05f
                };


                if (ip.InventoryIcon != null || ip.sprite != null)
                {
                    GUIImage img = new GUIImage(new RectTransform(new Point(itemFrame.Rect.Height), itemFrame.RectTransform),
                                                ip.InventoryIcon ?? ip.sprite, scaleToFit: true)
                    {
                        CanBeFocused = false
                    };
                    img.Color = img.Sprite == ip.InventoryIcon ? ip.InventoryIconColor : ip.SpriteColor;
                }

                new GUITextBlock(new RectTransform(new Vector2(0.75f, 1.0f), itemFrame.RectTransform),
                                 ip.Name, font: GUI.SmallFont)
                {
                    Wrap         = true,
                    CanBeFocused = false
                };

                ExtraCargo.TryGetValue(ip, out int cargoVal);
                var amountInput = new GUINumberInput(new RectTransform(new Vector2(0.35f, 1.0f), itemFrame.RectTransform),
                                                     GUINumberInput.NumberType.Int, textAlignment: Alignment.CenterLeft)
                {
                    MinValueInt = 0,
                    MaxValueInt = 100,
                    IntValue    = cargoVal
                };
                amountInput.OnValueChanged += (numberInput) =>
                {
                    if (ExtraCargo.ContainsKey(ip))
                    {
                        ExtraCargo[ip] = numberInput.IntValue;
                        if (numberInput.IntValue <= 0)
                        {
                            ExtraCargo.Remove(ip);
                        }
                    }
                    else
                    {
                        ExtraCargo.Add(ip, numberInput.IntValue);
                    }
                };
            }


            //--------------------------------------------------------------------------------
            //                              antigriefing
            //--------------------------------------------------------------------------------

            var antigriefingTab = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), settingsTabs[(int)SettingsTab.Antigriefing].RectTransform, Anchor.Center))
            {
                Stretch         = true,
                RelativeSpacing = 0.02f
            };

            var voteKickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), antigriefingTab.RectTransform), TextManager.Get("ServerSettingsAllowVoteKick"));

            GetPropertyData("AllowVoteKick").AssignGUIComponent(voteKickBox);

            CreateLabeledSlider(antigriefingTab, "ServerSettingsKickVotesRequired", out slider, out sliderLabel);
            string votesRequiredLabel = sliderLabel.Text + " ";

            slider.Step    = 0.2f;
            slider.Range   = new Vector2(0.5f, 1.0f);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = votesRequiredLabel + (int)MathUtils.Round(scrollBar.BarScrollValue * 100.0f, 10.0f) + " %";
                return(true);
            };
            GetPropertyData("KickVoteRequiredRatio").AssignGUIComponent(slider);
            slider.OnMoved(slider, slider.BarScroll);

            CreateLabeledSlider(antigriefingTab, "ServerSettingsAutobanTime", out slider, out sliderLabel);
            string autobanLabel = sliderLabel.Text + " ";

            slider.Step    = 0.01f;
            slider.Range   = new Vector2(0.0f, MaxAutoBanTime);
            slider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
            {
                ((GUITextBlock)scrollBar.UserData).Text = autobanLabel + ToolBox.SecondsToReadableTime(scrollBar.BarScrollValue);
                return(true);
            };
            GetPropertyData("AutoBanTime").AssignGUIComponent(slider);
            slider.OnMoved(slider, slider.BarScroll);

            // karma --------------------------------------------------------------------------

            var karmaBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.05f), antigriefingTab.RectTransform), TextManager.Get("ServerSettingsUseKarma"));

            GetPropertyData("KarmaEnabled").AssignGUIComponent(karmaBox);

            karmaPresetDD = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), antigriefingTab.RectTransform));
            foreach (string karmaPreset in GameMain.NetworkMember.KarmaManager.Presets.Keys)
            {
                karmaPresetDD.AddItem(TextManager.Get("KarmaPreset." + karmaPreset), karmaPreset);
            }

            var karmaSettingsContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.5f), antigriefingTab.RectTransform), style: null);
            var karmaSettingsList      = new GUIListBox(new RectTransform(Vector2.One, karmaSettingsContainer.RectTransform));

            karmaSettingsBlocker = new GUIFrame(new RectTransform(Vector2.One, karmaSettingsContainer.RectTransform, Anchor.CenterLeft)
            {
                MaxSize = new Point(karmaSettingsList.Content.Rect.Width, int.MaxValue)
            },
                                                style: "InnerFrame");
            karmaPresetDD.OnSelected = (selected, obj) =>
            {
                List <NetPropertyData> properties = netProperties.Values.ToList();
                List <object>          prevValues = new List <object>();
                foreach (NetPropertyData prop in netProperties.Values)
                {
                    prevValues.Add(prop.TempValue);
                    if (prop.GUIComponent != null)
                    {
                        prop.Value = prop.GUIComponentValue;
                    }
                }
                if (KarmaPreset == "custom")
                {
                    GameMain.NetworkMember?.KarmaManager?.SaveCustomPreset();
                    GameMain.NetworkMember?.KarmaManager?.Save();
                }
                KarmaPreset = obj as string;
                GameMain.NetworkMember.KarmaManager.SelectPreset(KarmaPreset);
                karmaSettingsList.Content.ClearChildren();
                karmaSettingsBlocker.Visible = !karmaBox.Selected || KarmaPreset != "custom";
                GameMain.NetworkMember.KarmaManager.CreateSettingsFrame(karmaSettingsList.Content);
                for (int i = 0; i < netProperties.Count; i++)
                {
                    properties[i].TempValue = prevValues[i];
                }
                return(true);
            };
            karmaPresetDD.SelectItem(KarmaPreset);
            AssignGUIComponent("KarmaPreset", karmaPresetDD);
            karmaBox.OnSelected = (tb) =>
            {
                karmaSettingsBlocker.Visible = !tb.Selected || KarmaPreset != "custom";
                return(true);
            };

            //--------------------------------------------------------------------------------
            //                              banlist
            //--------------------------------------------------------------------------------

            BanList.CreateBanFrame(settingsTabs[(int)SettingsTab.Banlist]);

            //--------------------------------------------------------------------------------
            //                              whitelist
            //--------------------------------------------------------------------------------

            Whitelist.CreateWhiteListFrame(settingsTabs[(int)SettingsTab.Whitelist]);
        }
        void Start()
        {
            if (CompatibilityChecker.IsAllCompatible() && instance == null)
                instance = this;
            else
            {
                GameObject.Destroy(this);
                return;
            }

            _vehicleAero = new VehicleAerodynamics();

            guiRect = new Rect(Screen.width / 4, Screen.height / 6, 10, 10);

            _instantSim = new InstantConditionSim();
            GUIDropDown<int> flapSettingDropDown = new GUIDropDown<int>(new string[] { "0 (up)", "1 (init climb)", "2 (takeoff)", "3 (landing)" }, new int[] { 0, 1, 2, 3 }, 0);
            GUIDropDown<CelestialBody> celestialBodyDropdown = CreateBodyDropdown();

            _simManager = new EditorSimManager(_instantSim);

            _editorGraph = new StaticAnalysisGraphGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDeriv = new StabilityDerivGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDerivLinSim = new StabilityDerivSimulationGUI(_simManager);

            Color crossSection = GUIColors.GetColor(3);
            crossSection.a = 0.8f;

            Color crossSectionDeriv = GUIColors.GetColor(2);
            crossSectionDeriv.a = 0.8f;

            _areaRulingOverlay = new EditorAreaRulingOverlay(new Color(0.05f, 0.05f, 0.05f, 0.7f), crossSection, crossSectionDeriv, 10, 5);
            guiRect.height = 500;
            guiRect.width = 650;

            GameEvents.onEditorPartEvent.Add(UpdateGeometryEvent);
            GameEvents.onEditorUndo.Add(ResetEditorEvent);
            GameEvents.onEditorRedo.Add(ResetEditorEvent);
            GameEvents.onEditorShipModified.Add(ResetEditorEvent);
            GameEvents.onEditorLoad.Add(ResetEditorEvent);

            GameEvents.onGUIEngineersReportReady.Add(AddDesignConcerns);
            GameEvents.onGUIEngineersReportDestroy.Add(RemoveDesignConcerns);

            RequestUpdateVoxel();
        }
Esempio n. 38
0
        protected override void OnStart()
        {
            base.OnStart();

            if (!CompatibilityChecker.IsAllCompatible())
            {
                enabled = false;
                return;
            }

            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();

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

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

            enabled = true;

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

            activeFlightGUICount++;

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

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
        public override void OnLoad(ConfigNode node)
        {
            GeneratePresets();
            int index = 4;
            if (node.HasValue("newGame"))
                newGame = bool.Parse(node.GetValue("newGame"));

            if (node.HasValue("index"))
                index = int.Parse(node.GetValue("index"));

            dropdown = new GUIDropDown<FARDifficultyAndExactnessSettings>(presetNames.ToArray(), presets.ToArray(), index < 0 ? 2 : index);
            voxelSettings = new FARVoxelSettings();

            if (node.HasValue("numVoxelsControllableVessel"))
                voxelSettings.numVoxelsControllableVessel = int.Parse(node.GetValue("numVoxelsControllableVessel"));
            if (node.HasValue("numVoxelsDebrisVessel"))
                voxelSettings.numVoxelsDebrisVessel = int.Parse(node.GetValue("numVoxelsDebrisVessel"));
            if (node.HasValue("minPhysTicksPerUpdate"))
                voxelSettings.minPhysTicksPerUpdate = int.Parse(node.GetValue("minPhysTicksPerUpdate"));

            if (index == -1)
            {
                settings = new FARDifficultyAndExactnessSettings(index);

                if (node.HasValue("fractionTransonicDrag"))
                    settings.fractionTransonicDrag = double.Parse(node.GetValue("fractionTransonicDrag"));
                if (node.HasValue("gaussianVehicleLengthFractionForSmoothing"))
                    settings.gaussianVehicleLengthFractionForSmoothing = double.Parse(node.GetValue("gaussianVehicleLengthFractionForSmoothing"));

                if (node.HasValue("numAreaSmoothingPasses"))
                    settings.numAreaSmoothingPasses = int.Parse(node.GetValue("numAreaSmoothingPasses"));
                if (node.HasValue("numDerivSmoothingPasses"))
                    settings.numDerivSmoothingPasses = int.Parse(node.GetValue("numDerivSmoothingPasses"));

                customSettings = settings;
            }
            else
            {
                settings = presets[index];
                customSettings = new FARDifficultyAndExactnessSettings(-1);
            }
            currentIndex = index;

            Debug.Log("Loading FAR Data");
            flightGUISettings = new List<ConfigNode>();
            if(node.HasNode("FlightGUISettings"))
            {
                foreach (ConfigNode flightGUINode in node.GetNode("FlightGUISettings").nodes)
                    flightGUISettings.Add(flightGUINode);
            }

            FARDebugAndSettings.LoadConfigs(node);
        }