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(); }
public void Update() { UpdateGauges(); updateTimer.Start(); try { // if log level is at least INFO and performance statistics are enabled // write statistical data in the log every 10 seconds if (configuration.performanceStatisticsEnabled && Log.IsLogable(Log.LEVEL.INFO) && HighLogic.LoadedSceneIsFlight) { if (lastPerformanceLog + 10000 < timer.ElapsedMilliseconds) { lastPerformanceLog = timer.ElapsedMilliseconds; Log.Info("Nanogauges performance statistics:\n" + TimedStatistics.instance.ToString()); } } // check for Profile Hotkeys profileManager.Update(); // check for keys // gauges.ShowCloseButtons(hotkeyManager.GetKey(HotkeyManager.HOTKEY_CLOSE_AND_DRAG)); // bool hotkeyPressed = hotkeyManager.GetKey(HotkeyManager.HOTKEY_MAIN); // Input.GetKey(hotkey); // Hotkeys for Gaugesets if (!hotkeyPressed) { // simple Hotkeys if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_HIDE)) { if (gauges.Hidden()) { gauges.Unhide(); } else { gauges.Hide(); } } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_PREVSET)) { SetGaugeSet(configuration.GetGaugeSetId().decrement()); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_NEXTSET)) { SetGaugeSet(configuration.GetGaugeSetId().increment()); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_LOCK_PROFILE)) { profileManager.ToggleLock(); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SELECT_NAV)) { NavGlobals.SelectNextAirfield(); } } else { // Hotkeys in chord with main hotkey // if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_STANDARD)) { SetGaugeSet(GaugeSet.ID.STANDARD); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_LAUNCH)) { SetGaugeSet(GaugeSet.ID.LAUNCH); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_LAND)) { SetGaugeSet(GaugeSet.ID.LAND); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_DOCK)) { SetGaugeSet(GaugeSet.ID.DOCK); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_ORBIT)) { SetGaugeSet(GaugeSet.ID.ORBIT); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_FLIGHT)) { SetGaugeSet(GaugeSet.ID.FLIGHT); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_SET1)) { SetGaugeSet(GaugeSet.ID.SET1); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_SET2)) { SetGaugeSet(GaugeSet.ID.SET2); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_SET3)) { SetGaugeSet(GaugeSet.ID.SET3); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_SET_ENABLE_ALL)) { configuration.EnableAllGauges(gauges); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_WINDOW_CONFIG)) { createConfigOnce(); toggleConfigVisibility(); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_STANDARDLAYOUT)) { gauges.LayoutCurrentGaugeSet(new StandardLayout(NanoGauges.gauges, configuration)); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_ALT_HIDE)) { if (gauges.Hidden()) { gauges.Unhide(); } else { gauges.Hide(); } } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_AUTOLAYOUT)) { gauges.AutoLayout(); } else if (hotkeyManager.GetKeyDown(HotkeyManager.HOTKEY_ALIGNMENT_GAUGE)) { gauges.ShowAligmentGauge(!gauges.IsAligmentGaugeVisible()); } } } finally { updateTimer.Stop(); } hotkeyManager.ignoring = false; }
public void Update() { if (trimIndicatorsEnabled) { trimIndicators.Update(); } gauges.Update(); // check for keys // KeyCode hotkey = configuration.GetKeyCodeForHotkey(); bool hotkeyPressed = Input.GetKey(hotkey); gauges.ShowCloseButtons(hotkeyPressed); if (hotkeyPressed) { AbstractGauge g = gauges.GetGauge(Constants.WINDOW_ID_GAUGE_AOA); } // Hotkeys for Gaugesets if (Input.GetKeyDown(KeyCode.Numlock)) { if (gauges.Hidden()) { gauges.Unhide(); } else { gauges.Hide(); } } if (hotkeyPressed) { if (Input.GetKeyDown(KeyCode.Alpha1)) { SetGaugeSet(GaugeSet.ID.STANDARD); } else if (Input.GetKeyDown(KeyCode.Alpha2)) { SetGaugeSet(GaugeSet.ID.LAUNCH); } else if (Input.GetKeyDown(KeyCode.Alpha3)) { SetGaugeSet(GaugeSet.ID.LAND); } else if (Input.GetKeyDown(KeyCode.Alpha4)) { SetGaugeSet(GaugeSet.ID.DOCK); } else if (Input.GetKeyDown(KeyCode.Alpha5)) { SetGaugeSet(GaugeSet.ID.ORBIT); } else if (Input.GetKeyDown(KeyCode.Alpha6)) { SetGaugeSet(GaugeSet.ID.FLIGHT); } else if (Input.GetKeyDown(KeyCode.Alpha7)) { SetGaugeSet(GaugeSet.ID.SET1); } else if (Input.GetKeyDown(KeyCode.Alpha8)) { SetGaugeSet(GaugeSet.ID.SET2); } else if (Input.GetKeyDown(KeyCode.Alpha9)) { SetGaugeSet(GaugeSet.ID.SET3); } else if (Input.GetKeyDown(KeyCode.Alpha0)) { gauges.EnableAllGauges(); } else if (Input.GetKeyDown(KeyCode.KeypadEnter)) { createConfigOnce(); toggleConfigVisibility(); } else if (Input.GetKeyDown(KeyCode.Backspace)) { gauges.LayoutCurrentGaugeSet(new StandardLayout(NanoGauges.gauges, configuration)); } else if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.Delete) || Input.GetKeyDown(KeyCode.KeypadDivide)) { if (gauges.Hidden()) { gauges.Unhide(); } else { gauges.Hide(); } } else if (Input.GetKeyDown(KeyCode.KeypadMultiply) || Input.GetKeyDown(KeyCode.Insert)) { gauges.AutoLayout(); } } }