Ejemplo n.º 1
0
 private void UpdateNavGlobals()
 {
     navUpdateTimer.Start();
     try
     {
         NavGlobals.Update();
     }
     finally
     {
         navUpdateTimer.Stop();
     }
 }
Ejemplo n.º 2
0
 private void UpdateGauges()
 {
     gaugeUpdateTimer.Start();
     try
     {
         gauges.Update();
     }
     finally
     {
         gaugeUpdateTimer.Stop();
     }
 }
Ejemplo n.º 3
0
 public void OnGUI()
 {
     windowTimer.Start();
     if (Event.current.type == EventType.Layout)
     {
         foreach (AbstractWindow window in windows)
         {
             // draw a window only if its visible
             if (window.IsVisible())
             {
                 window.OnGUI();
             }
         }
     }
     windowTimer.Stop();
 }
Ejemplo n.º 4
0
            public void Update()
            {
                if (updateCycle % cycleInterval == 0)
                {
                    Vessel active = FlightGlobals.ActiveVessel;
                    if (active != null)
                    {
                        if (forceRescan || vessel == null || active != vessel || CountParts(vessel) != partCount)
                        {
                            // rescan when physics are in place only
                            if (!active.HoldPhysics)
                            {
                                partCount = CountParts(active);
                                vessel    = active;
                                scanTimer.Start();
                                ReScanVessel();
                                scanTimer.Stop();
                            }
                        }

                        // don't update anything if the game is paused
                        if (!Planetarium.Pause)
                        {
                            inspectTimer.Start();
                            Inspect(vessel);
                            inspectTimer.Stop();
                            //
                            lastInspectTime = Planetarium.GetUniversalTime();
                        }
                    }
                    else
                    {
                        vessel          = null;
                        partCount       = 0;
                        lastInspectTime = 0;
                        Reset();
                    }
                }
                updateCycle++;
            }
Ejemplo n.º 5
0
 public void DrawGauges()
 {
     guiTimer.Start();
     CheckCamera();
     if (!hidden && IsEnabledInCamera(this.currentCamMode, this.isEvaCam))
     {
         foreach (AbstractGauge gauge in gauges.Values)
         {
             try
             {
                 if (NanoGauges.configuration.IsGaugeEnabled(gauge.GetWindowId()))
                 {
                     gauge.OnDraw();
                 }
             }
             catch
             {
                 Log.Error("Exception in OnDraw() in " + gauge.GetType());
             }
         }
     }
     guiTimer.Stop();
 }
Ejemplo n.º 6
0
 private void OnPartUnpack(Part part)
 {
     unpackTimer.Start();
     try
     {
         Vessel vessel = FlightGlobals.ActiveVessel;
         if (vessel == null)
         {
             return;
         }
         if (part != null && part.vessel == vessel)
         {
             if (Log.IsLogable(Log.LEVEL.DETAIL))
             {
                 Log.Detail("part unpacked " + part.name);
             }
             PartUnpacked(part);
         }
     }
     finally
     {
         unpackTimer.Stop();
     }
 }
Ejemplo n.º 7
0
            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;
            }