Ejemplo n.º 1
0
 private void LogLevelButton(Log.LEVEL level, string text)
 {
     if (GUILayout.Toggle(Log.GetLevel() == level, text, FFStyles.STYLE_BUTTON) && Log.GetLevel() != level)
     {
         FinalFrontier.Config.SetLogLevel(level);
         Log.SetLevel(level);
     }
 }
Ejemplo n.º 2
0
 private void LogLevelButton(Log.LEVEL level, String text)
 {
     if (GUILayout.Toggle(Log.GetLevel() == level, text, HighLogic.Skin.button) && Log.GetLevel() != level)
     {
         NanoGauges.configuration.SetLogLevel(level);
         Log.SetLevel(level);
     }
 }
Ejemplo n.º 3
0
 private void LogLevelButton(Log.LEVEL level, String text)
 {
     if (GUILayout.Toggle(Log.GetLevel() == level, text, GUI.skin.button) && Log.GetLevel() != level)
     {
         SAVE.configuration.logLevel = level;
         Log.SetLevel(level);
     }
 }
Ejemplo n.º 4
0
        public Configuration()
        {
#if (DEBUG)
            logLevel = Log.LEVEL.INFO;
#else
            logLevel = Log.LEVEL.WARNING;
#endif
            setDefaults();
            Log.Info("Configuration - Setting default config");
        }
Ejemplo n.º 5
0
            protected override void OnWindow(int id)
            {
                Configuration config = NanoGauges.configuration;

                GUILayout.BeginVertical();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Close", HighLogic.Skin.button))
                {
                    SetVisible(false);
                }
                GUILayout.EndHorizontal();

                GUILayout.Label("Log Level:", STYLE_LABEL);
                GUILayout.BeginHorizontal();
                Log.LEVEL level = Log.GetLevel();
                LogLevelButton(Log.LEVEL.OFF, "OFF");
                LogLevelButton(Log.LEVEL.ERROR, "ERROR");
                LogLevelButton(Log.LEVEL.WARNING, "WARNING");
                LogLevelButton(Log.LEVEL.INFO, "INFO");
                LogLevelButton(Log.LEVEL.DETAIL, "DETAIL");
                LogLevelButton(Log.LEVEL.TRACE, "TRACE");
                GUILayout.EndHorizontal();

                GUILayout.Label("Hotkey:", STYLE_LABEL);
                GUILayout.BeginHorizontal();
                KeyCodeButton(KeyCode.LeftControl, "LEFT CTRL");
                KeyCodeButton(KeyCode.RightControl, "RIGHT CTRL");
                KeyCodeButton(KeyCode.LeftShift, "LEFT SHIFT");
                KeyCodeButton(KeyCode.RightShift, "RIGHT SHIFT");
                KeyCodeButton(KeyCode.LeftAlt, "LEFT ALT");
                KeyCodeButton(KeyCode.RightAlt, "RIGHT ALT");
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                // Reset Window Postions
                if (GUILayout.Button("Standard Gauge Positions", HighLogic.Skin.button))
                {
                    gauges.LayoutCurrentGaugeSet(new DefaultLayout(gauges, config));
                }
                if (GUILayout.Button("Reset Gauge Cluster", HighLogic.Skin.button))
                {
                    gauges.LayoutCurrentGaugeSet(new ClusterLayout(gauges, config));
                }
                // layout gauges
                // autolayout will only work with a 100% scale
                GUI.enabled = (NanoGauges.configuration.verticalGaugeHeight == Configuration.UNSCALED_VERTICAL_GAUGE_HEIGHT && NanoGauges.configuration.gaugeScaling == Configuration.GAUGE_SCALE_100);
                if (GUILayout.Button("Automatic Layout", HighLogic.Skin.button))
                {
                    gauges.AutoLayout();
                    config.Save();
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();
                // save gauge postions
                if (GUILayout.Button("Save Gauge Positions", HighLogic.Skin.button))
                {
                    gauges.SaveWindowPositions();
                    config.Save();
                }
                // selector gauge
                if (GUILayout.Button("Selector Gauge Location From Current Profile", HighLogic.Skin.button))
                {
                    gauges.CopySelectorPositionFrom(config.GetGaugeSetId());
                }
                // gauge sizes
                GUILayout.BeginHorizontal();
                GUILayout.Label("Size (restart required):", STYLE_LABEL);
                GaugeScaleToggle("100%", Configuration.GAUGE_SCALE_100);
                GaugeScaleToggle("110%", Configuration.GAUGE_SCALE_110);
                GaugeScaleToggle("120%", Configuration.GAUGE_SCALE_120);
                GaugeScaleToggle("150%", Configuration.GAUGE_SCALE_150);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.Label("Settings:", STYLE_LABEL);
                GUILayout.BeginVertical();
                //
                // Positions Locked & Snapin
                GUILayout.BeginHorizontal();
                config.gaugePositionsLocked = GUILayout.Toggle(config.gaugePositionsLocked, "Gauge positions locked", STYLE_TOGGLE_2_PER_ROW);
                // Snapin
                config.snapinEnabled = GUILayout.Toggle(config.snapinEnabled, "Snapin enabled", HighLogic.Skin.toggle);
                GUILayout.EndHorizontal();
                //
                GUILayout.BeginHorizontal();
                // Gauge marker
                config.gaugeMarkerEnabled = GUILayout.Toggle(config.gaugeMarkerEnabled, "Gauge marker enabled", STYLE_TOGGLE_2_PER_ROW);
                // heat indicators
                config.disableStockHeatIndicators = GUILayout.Toggle(config.disableStockHeatIndicators, "Disable heat indicators", HighLogic.Skin.toggle);
                GUILayout.EndHorizontal();
                //
                // tooltips & exact readout
                GUILayout.BeginHorizontal();
                if (config.exactReadoutEnabled)
                {
                    config.tooltipsEnabled = false;
                }
                config.tooltipsEnabled = GUILayout.Toggle(config.tooltipsEnabled, "Tooltips enabled", STYLE_TOGGLE_2_PER_ROW);
                if (config.tooltipsEnabled)
                {
                    config.exactReadoutEnabled = false;
                }
                config.exactReadoutEnabled = GUILayout.Toggle(config.exactReadoutEnabled, "Exact readout enabled", STYLE_TOGGLE_2_PER_ROW);
                GUILayout.EndHorizontal();
                //
                //
                // Stock Toolbar
                if (ToolbarManager.ToolbarAvailable)
                {
                    config.useStockToolbar = GUILayout.Toggle(config.useStockToolbar, "Use Stock Toolbar (needs a restart to take effekt)", HighLogic.Skin.toggle);
                }
                // Cam
                DrawCameraModeToggles();

                GUILayout.EndVertical();
                //
                // -------------
                // GAUGES ON/OFF
                GUILayout.BeginHorizontal();
                GUILayout.Label("Gauges:", STYLE_LABEL);
                GUILayout.FlexibleSpace();
                DrawCopyPasteButtons();
                DrawEnableDisableAllButton();
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GaugeSetButton(GaugeSet.ID.STANDARD, "STANDARD");
                GaugeSetButton(GaugeSet.ID.LAUNCH, "LAUNCH");
                GaugeSetButton(GaugeSet.ID.LAND, "LAND");
                GaugeSetButton(GaugeSet.ID.DOCK, "DOCK");
                GaugeSetButton(GaugeSet.ID.ORBIT, "ORBIT");
                GaugeSetButton(GaugeSet.ID.FLIGHT, "FLIGHT");
                GaugeSetButton(GaugeSet.ID.SET1, "SET 1");
                GaugeSetButton(GaugeSet.ID.SET2, "SET 2");
                GaugeSetButton(GaugeSet.ID.SET3, "SET 3");
                GUILayout.EndHorizontal();
                scrollPosGauges              = GUILayout.BeginScrollView(scrollPosGauges, false, true, HighLogic.Skin.horizontalScrollbar, HighLogic.Skin.verticalScrollbar, STYLE_SCROLLVIEW, GUILayout.Height(GAUGES_HEIGHT));
                this.allGaugesEnables        = true;
                config.trimIndicatorsEnabled = GUILayout.Toggle(config.trimIndicatorsEnabled, "Trim indicators enabled (restart required)", HighLogic.Skin.toggle);
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_SETS, "Gaugeset selector gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_INDICATOR, "Indicator gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_CAM, "Camera indicator gauge enabled");
                GUILayout.Label("", STYLE_LINE);
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_ALTIMETER, "Altimeter gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_SHIELD, "Ablative shielding gauge enabled (Deadly Reentry plugin required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_ABLAT, "Ablator gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_AIRIN, "Absolute air-intake gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_ACCL, "Acceleration gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_G, "Accelerometer gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_AOA, "AoA (angle of attack) gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_AMP, "Amperemeter gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_APA, "Apoapsis gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_ATM, "Atmosphere gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_ATMTEMP, "Atmosphere temperature gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_CO2, "CO2 gauge enabled (TAC life suppord required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_DTGT, "Distance to target gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_DRILLTEMP, "Drill temperature gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_Q, "Dynamic pressure (Q) gauge enabled (FAR plugin required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_CHARGE, "Electric charge gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_EVAMP, "EVA monopropellant gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_EXTTEMP, "External temperature gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_FOOD, "Food gauge enabled (TAC life suppord required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_FLOW, "Fuel flow gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_FUEL, "Fuel gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_GRAV, "Gravity gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_HEAT, "Heat shield temperatur gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_HACCL, "Horizontal acceleration gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_HSPD, "Horizontal speed gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_IMPACT, "Impact gauge");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_DISP, "ISP rate gauge (Delta Isp/s) enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_ISPE, "ISP/E gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_KARBONITE, "Karbonite gauge enabled (Real Fuels plugin required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_KAIRIN, "Kethane air intake gauge enabled (Kethane plugin required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_KETHANE, "Kethane gauge enabled (Kethane plugin required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_MACH, "Mach gauge enabled (FAR plugin required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_MAXG, "Max g gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_MONO, "Monopropellant gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_INCL, "Orbit inclination gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_ORBIT, "Orbit gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_OSPD, "Orbital speed gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_ORE, "Ore gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_OXID, "Oxidizer gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_O2, "Oxygen gauge enabled (TAC life suppord required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_PEA, "Periapsis gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_RADAR_ALTIMETER, "Radar altimeter gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_AIRPCT, "Relative air-intake gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_PROPELLANT, "Relative propellant requirement gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_SRB, "Solid fuel gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_SPD, "Speed gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_TEMP, "Temperature gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_VT, "Terminal velocity deviation gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_TIMETOAPA, "Time to apoapsis gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_TIMETOTRANS, "Time to next transition gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_TIMETOPEA, "Time to periapsis gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_THRUST, "Thrust gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_TWR, "TWR gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_VAI, "VAI (vertical attidute indicator) gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_VTGT, "Velocity to target gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_VACCL, "Vertical acceleration gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_MASS, "Vessel mass gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_VSI, "VSI (vertical speed indicator) gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_VVI, "VVI (vertical velocity indicator) gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_WASTE, "Waste gauge enabled (TAC life suppord required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_WH2O, "Wastewater gauge enabled (TAC life suppord required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_H2O, "Water gauge enabled (TAC life suppord required)");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_XENON, "Xenon gauge enabled");
                GUILayout.Label("", STYLE_LINE);
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_BIOME, "Biome gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_LATITUDE, "Latitude gauge enabled");
                GaugeEnabledToggle(Constants.WINDOW_ID_GAUGE_LONGITUDE, "Longitude gauge enabled");
                GUILayout.EndScrollView();

                GUILayout.EndVertical();
                DragWindow();
            }
Ejemplo n.º 6
0
            public void Load()
            {
                String filename = CONFIG_BASE_FOLDER + FILE_NAME;

                try
                {
                    if (File.Exists(filename))
                    {
                        Log.Info("loading configuration from " + filename);
                        using (BinaryReader reader = new BinaryReader(File.OpenRead(filename)))
                        {
                            logLevel = (Log.LEVEL)reader.ReadInt16();
                            Log.Info("log level loaded: " + logLevel);
                            // File Version
                            Int16 marker = reader.ReadInt16();
                            if (marker != FILE_MARKER)
                            {
                                Log.Error("invalid file structure");
                                throw new IOException("invalid file structure");
                            }
                            Int16 version = reader.ReadInt16();
                            if (version != FILE_VERSION)
                            {
                                Log.Error("incompatible file version");
                                throw new IOException("incompatible file version");
                            }
                            //
                            gaugePositionsLocked = reader.ReadBoolean();
                            ReadGaugeSets(reader);
                            //
                            gaugeMarkerEnabled = reader.ReadBoolean();
                            //
                            hotkeyCloseButtons = (KeyCode)reader.ReadUInt16();
                            //
                            gaugesInFlightEnabled = reader.ReadBoolean();
                            gaugesInMapEnabled    = reader.ReadBoolean();
                            gaugesInIvaEnabled    = reader.ReadBoolean();
                            gaugesInEvaEnabled    = reader.ReadBoolean();
                            //
                            snapinEnabled = reader.ReadBoolean();
                            //
                            useStockToolbar = reader.ReadBoolean() || !ToolbarManager.ToolbarAvailable;
                            //
                            trimIndicatorsEnabled = reader.ReadBoolean();
                            //
                            exactReadoutEnabled = reader.ReadBoolean();
                            //
                            tooltipsEnabled = reader.ReadBoolean();
                            //
                            gaugeScaling          = reader.ReadDouble();
                            verticalGaugeWidth    = (int)(UNSCALED_VERTICAL_GAUGE_WIDTH * gaugeScaling);
                            verticalGaugeHeight   = (int)(UNSCALED_VERTICAL_GAUGE_HEIGHT * gaugeScaling);
                            horizontalGaugeWidth  = (int)(UNSCALED_HORIZONTAL_GAUGE_WIDTH * gaugeScaling);
                            horizontalGaugeHeight = (int)(UNSCALED_HORIZONTAL_GAUGE_HEIGHT * gaugeScaling);
                            //
                            disableStockHeatIndicators = reader.ReadBoolean();
                        }
                    }
                    else
                    {
                        Log.Info("no config file: default configuration");
                    }
                }
                catch
                {
                    Log.Warning("loading configuration failed or incompatible file");
                }
                finally
                {
                    // enabling both won't make sense
                    if (tooltipsEnabled)
                    {
                        exactReadoutEnabled = false;
                    }
                }
            }
Ejemplo n.º 7
0
 public void SetLogLevel(Log.LEVEL level)
 {
     logLevel = level;
 }
Ejemplo n.º 8
0
            public void Load()
            {
                String filename = CONFIG_BASE_FOLDER + FILE_NAME;

                try
                {
                    if (File.Exists(filename))
                    {
                        Log.Info("loading configuration from " + filename);
                        using (BinaryReader reader = new BinaryReader(File.OpenRead(filename)))
                        {
                            logLevel = (Log.LEVEL)reader.ReadInt16();
                            Log.SetLevel(logLevel);
                            Log.Info("log level loaded: " + logLevel);
                            // File Version
                            Int16 marker = reader.ReadInt16();
                            if (marker != FILE_MARKER)
                            {
                                Log.Error("invalid file structure");
                                throw new IOException("invalid file structure");
                            }
                            Int16 version = reader.ReadInt16();
                            if (version != FILE_VERSION)
                            {
                                Log.Error("incompatible file version");
                                throw new IOException("incompatible file version");
                            }
                            //
                            gaugePositionsLocked = reader.ReadBoolean();
                            ReadGaugeSets(reader);
                            //
                            gaugeMarkerEnabled = reader.ReadBoolean();
                            //
                            // not used
                            reader.ReadUInt16();
                            //
                            gaugesInFlightEnabled = reader.ReadBoolean();
                            gaugesInMapEnabled    = reader.ReadBoolean();
                            gaugesInIvaEnabled    = reader.ReadBoolean();
                            gaugesInEvaEnabled    = reader.ReadBoolean();
                            //
                            snapinEnabled = reader.ReadBoolean();
                            //
                            useStockToolbar = reader.ReadBoolean() || !ToolbarManager.ToolbarAvailable;
                            //
                            // currently not used
                            trimIndicatorsEnabled = reader.ReadBoolean();
                            //
                            exactReadoutEnabled = reader.ReadBoolean();
                            //
                            tooltipsEnabled = reader.ReadBoolean();
                            //
                            ChangeGaugeScaling(reader.ReadDouble());
                            //
                            performanceStatisticsEnabled = reader.ReadBoolean();
                            //
                            // ProfileManager
                            NanoGauges.profileManager.Read(reader);
                            //
                            // HotkeyManager
                            NanoGauges.hotkeyManager.Read(reader);
                            //
                            minProfileInterval = reader.ReadInt16();
                            //
                            declutterEnabled = reader.ReadBoolean();
                        }
                    }
                    else
                    {
                        Log.Info("no config file: default configuration");
                    }
                }
                catch
                {
                    Log.Warning("loading configuration failed or incompatible file");
                }
                finally
                {
                    // enabling both won't make sense
                    if (tooltipsEnabled)
                    {
                        exactReadoutEnabled = false;
                    }
                    Log.Detail("loading of configuration done");
                }
            }