Exemplo n.º 1
0
 public override void OnUpdate()
 {
     if (!this.vessel.isActiveVessel || this.part == null)
     {
         RenderingManager.RemoveFromPostDrawQueue(0, OnGUI);
     }
 }
Exemplo n.º 2
0
        public void OnGUI()
        {
            //var texture2D = FlightGlobals.Bodies[1].BiomeMap.Map;
            //GUI.DrawTexture(new Rect(0, 0, Screen.height, Screen.width), texture2D);


            //Do the GUI Stuff - basically get the workers draw stuff into the postrendering queue
            //If the two flags are different are we going in or out of the queue
            if (_shouldBeInPostDrawQueue != _isInPostDrawQueue)
            {
                if (_shouldBeInPostDrawQueue && !_isInPostDrawQueue)
                {
                    Utilities.DebugLogFormatted(LogLevel.Diagnostic, "Adding DrawGUI to PostRender Queue");

                    //reset any existing pane display
                    //WorkerObjectInstance.ResetPanes();

                    //Add to the queue
                    RenderingManager.AddToPostDrawQueue(5, DrawGUI);
                    _isInPostDrawQueue = true;

                    //if we are adding the renderer and we are in flight then do the daily version check if required
                    //if (HighLogic.LoadedScene == GameScenes.FLIGHT && Settings.DailyVersionCheck)
                    //    Settings.VersionCheck(false);
                }
                else
                {
                    Utilities.DebugLogFormatted(LogLevel.Diagnostic, "Removing DrawGUI from PostRender Queue");
                    RenderingManager.RemoveFromPostDrawQueue(5, DrawGUI);
                    _isInPostDrawQueue = false;
                }
            }
        }
Exemplo n.º 3
0
 /**
  * Remove the GUI, remove the flight control callback, set the global isActiveInstance to false.
  */
 private void doASATShutdown()
 {
     Destroy(targetingLaser);
     RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI));                                  //close the GUI
     FlightInputHandler.OnFlyByWire     -= new FlightInputHandler.FlightInputCallback(interceptCallback); //Remove the flight control override
     AsatGuidanceModule.isActiveInstance = false;                                                         //Allow another ASAT to work.
 }
Exemplo n.º 4
0
 private void InvoiceWindow(int windowId)
 {
     GUILayout.BeginHorizontal();
     GUILayout.Label("Amount Due: " + bills);
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Payment: ");
     GUILayout.FlexibleSpace();
     pmt = Convert.ToDouble(GUILayout.TextField(pmt.ToString(), 7, GUILayout.Width(75)));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     if (GUILayout.Button("Pay", GUILayout.Width(75)))
     {
         Funding.Instance.AddFunds(-pmt, 0);
         bills = bills - pmt;
         SaveData();
         RenderingManager.RemoveFromPostDrawQueue(0, DrawInvoiceWindow);
     }
     GUILayout.FlexibleSpace();
     if (GUILayout.Button("Close", GUILayout.Width(75)))
     {
         RenderingManager.RemoveFromPostDrawQueue(0, DrawInvoiceWindow);
     }
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     GUI.DragWindow();
 }
Exemplo n.º 5
0
 public void HailerGUIClose()
 {
     RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI));
     Events["HailerGUIClose"].active = false;
     Events["HailerGUIOpen"].active  = true;
     guiopen = false;
 }
Exemplo n.º 6
0
    public void OnDestroy()
    {
        //MonoBehaviour.print("Destroy Science Settings");
        SaveSettings();

        RenderingManager.RemoveFromPostDrawQueue(3, OnDraw);
    }
        public void onTargetSelectionWindow(int windowId)
        {
            GUILayout.BeginVertical();

            for (int x = 0; x < PlanetList.Length; x++)
            {
                if (GUILayout.Button(PlanetList[x][0]))
                {
                    SelectedItem = PlanetList[x][0];
                    RenderingManager.RemoveFromPostDrawQueue(1, DrawTargetSelection);
                    isChosing = false;
                }

                for (int x1 = 1; x1 < PlanetList[x].Length; x1++)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(30);
                    if (GUILayout.Button(PlanetList[x][x1]))
                    {
                        SelectedItem = PlanetList[x][x1];
                        RenderingManager.RemoveFromPostDrawQueue(1, DrawTargetSelection);
                        isChosing = false;
                    }
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.EndVertical();
        }
 private void OnEditorDestroy()
 {
     if (this.part.IsPrimaryEditor(this.ClassID))
     {
         RenderingManager.RemoveFromPostDrawQueue(0, onDraw);
     }
 }
Exemplo n.º 9
0
 public void SetVisible(bool visible)
 {
     if (!this.visible && visible)
     {
         OnOpen();
     }
     if (this.visible && !visible)
     {
         OnClose();
     }
     if (this.visible && !visible && onWindowClose != null)
     {
         onWindowClose();
     }
     this.visible = visible;
     if (Log.IsLogable(Log.LEVEL.TRACE) && visible)
     {
         Log.Trace("set window ID " + id + " to visible");
     }
     try
     {
         if (visible)
         {
             RenderingManager.AddToPostDrawQueue(0, OnDraw);
         }
         else
         {
             RenderingManager.RemoveFromPostDrawQueue(0, OnDraw);
         }
     }
     catch
     {
         Log.Error("failed to change window visibility for id " + id + ": " + title);
     }
 }
Exemplo n.º 10
0
 protected override void onPartDestroy()
 {
     if (ping != null)
     {
         RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI));
     }
     base.onPartDestroy();
 }
Exemplo n.º 11
0
 public override void onPartDelete()
 {
     if (buildSceneDrawer == this)
     {
         buildSceneDrawer = null;
     }
     RenderingManager.RemoveFromPostDrawQueue(0, drawBuildSceneGUI);
 }
Exemplo n.º 12
0
 protected void OnDestroy()
 {
     RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGEffects));
     GameEvents.onGamePause.Remove(onPause);
     GameEvents.onGameUnpause.Remove(onUnPause);
     GameEvents.onCrewKilled.Remove(onCrewKilled);
     GameEvents.onVesselChange.Remove(onVesselChange);
 }
Exemplo n.º 13
0
    public static void Hide()
    {
//         if (null == settings)
//             settings = new KSPScienceSettings();
        settings.shown = false;
        settings.SaveSettings();
        RenderingManager.RemoveFromPostDrawQueue(3, settings.OnDraw);
    }
        private void OnDestroy()
        {
            GameEvents.onVesselWasModified.Remove(vesselCheck);
            GameEvents.onVesselChange.Remove(vesselCheck);
            GameEvents.OnMapExited.Remove(mapTimer);

            RenderingManager.RemoveFromPostDrawQueue(5, drawLabels);
        }
Exemplo n.º 15
0
 public void OnDestroy()
 {
     RenderingManager.RemoveFromPostDrawQueue(5, drawGUI);
     GameEvents.onVesselChange.Remove(vesselSwitch);
     PresetManager.saveToFile();
     bHdgActive  = false;
     bVertActive = false;
 }
Exemplo n.º 16
0
 private void OnEditorDestroy()
 {
     if (IsPrimary)
     {
         RenderingManager.RemoveFromPostDrawQueue(0, DrawGUI);
         print("BuildEngineer: OnEditorDestroy");
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Hide the launcher.
 /// </summary>
 public void onDeactivate()
 {
     Debug.Log("KompLog App Launch Deactivate");
     _active       = false;
     _autoHideTime = 0.0f;
     RenderingManager.RemoveFromPostDrawQueue(0, OnDraw);
     ControlUnlock();
 }
Exemplo n.º 18
0
 /// <summary>
 /// De-queues windows rendering from the post-draw queue.
 /// </summary>
 public void EndPostDisplay()
 {
     if (!RenderEnabled)
     {
         return;
     }
     RenderingManager.RemoveFromPostDrawQueue(_queuePriority, Show);
     RenderEnabled = false;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Callback when this instance is destroyed.
 /// </summary>
 public void OnDestroy()
 {
     RenderingManager.RemoveFromPostDrawQueue(0, OnDraw);
     ControlUnlock();
     if (_instance == this)
     {
         _instance = null;
     }
 }
 public override void OnUpdate()
 {
     Events["showWindow"].active = !render_window;
     Events["hideWindow"].active = render_window;
     if (!vessel.isActiveVessel || part == null)
     {
         RenderingManager.RemoveFromPostDrawQueue(0, OnGUI);
     }
 }
Exemplo n.º 21
0
 private void OnEditorDetach()
 {
     if (IsPrimary)
     {
         OnSave(null);
         RenderingManager.RemoveFromPostDrawQueue(0, DrawGUI);
         print("BuildEngineer: OnEditorDetach");
     }
 }
Exemplo n.º 22
0
 public void OnDestroy()
 {
     if (!isCompatible)
     {
         return;
     }
     RenderingManager.RemoveFromPostDrawQueue(2, this.onDraw);
     RenderingManager.RemoveFromPostDrawQueue(3, this.onDrawGUI);
 }
Exemplo n.º 23
0
        public override void OnUpdate()
        {
            //Update Events
            Events["ActivateReactor"].active   = !IsEnabled && !IsNuclear;
            Events["DeactivateReactor"].active = IsEnabled && !IsNuclear;
            Events["BreedTritium"].active      = !breedtritium && IsNeutronRich && IsEnabled;
            Events["StopBreedTritium"].active  = breedtritium && IsNeutronRich && IsEnabled;
            Events["RetrofitReactor"].active   = ResearchAndDevelopment.Instance != null ? !isupgraded && ResearchAndDevelopment.Instance.Science >= upgradeCost && hasrequiredupgrade : false;
            //Update Fields
            Fields["currentTPwr"].guiActive = IsEnabled && (ongoing_thermal_power_f > 0);
            Fields["currentCPwr"].guiActive = IsEnabled && (ongoing_charged_power_f > 0);
            fuelModeStr = current_fuel_mode != null ? current_fuel_mode.ModeGUIName : "";
            //
            reactorTypeStr = isupgraded ? upgradedName != "" ? upgradedName : originalName : originalName;
            coretempStr    = CoreTemperature.ToString("0") + " K";
            if (update_count - last_draw_update > 10)
            {
                if (IsEnabled)
                {
                    if (current_fuel_mode != null && !current_fuel_mode.ReactorFuels.Any(fuel => getFuelAvailability(fuel) <= 0))
                    {
                        if (ongoing_thermal_power_f > 0)
                        {
                            currentTPwr = PluginHelper.getFormattedPowerString(ongoing_thermal_power_f) + "_th";
                        }
                        if (ongoing_charged_power_f > 0)
                        {
                            currentCPwr = PluginHelper.getFormattedPowerString(ongoing_charged_power_f) + "_cp";
                        }
                        statusStr = "Active (" + powerPcnt.ToString("0.00") + "%)";
                    }
                    else if (current_fuel_mode != null)
                    {
                        statusStr = current_fuel_mode.ReactorFuels.FirstOrDefault(fuel => getFuelAvailability(fuel) <= 0).FuelName + " Deprived";
                    }
                }
                else
                {
                    if (powerPcnt > 0)
                    {
                        statusStr = "Decay Heating (" + powerPcnt.ToString("0.00") + "%)";
                    }
                    else
                    {
                        statusStr = "Offline";
                    }
                }

                last_draw_update = update_count;
            }
            if (!vessel.isActiveVessel || part == null)
            {
                RenderingManager.RemoveFromPostDrawQueue(0, OnGUI);
            }
            update_count++;
        }
 private void DeleteGUI()
 {
     Debug.Log("DeleteGUI");
     if (editorLocked)
     {
         EditorLogic.fetch.Unlock("ETC");
         editorLocked = false;
     }
     RenderingManager.RemoveFromPostDrawQueue(3, DrawGUI);
 }
Exemplo n.º 25
0
        public void OnDestroy()
        {
            bInit  = false;
            bArmed = false;
            ActivitySwitch(false);

            RenderingManager.RemoveFromPostDrawQueue(5, drawGUI);
            FlightData.thisVessel.OnAutopilotUpdate -= new FlightInputCallback(SurfaceSAS);
            GameEvents.onVesselChange.Remove(vesselSwitch);
        }
Exemplo n.º 26
0
 public virtual void Hide()
 {
     if (!Enabled)
     {
         return;
     }
     Enabled = false;
     RenderingManager.RemoveFromPostDrawQueue(0, Draw);
     EZGUIPointerDisablePatcher.Unregister(GetArea);
 }
Exemplo n.º 27
0
    protected override void onDisconnect()
    {
        if ((vessel != null) && vessels.ContainsKey(vessel) && (vessels[vessel].controller == this))
        {
            vessels[vessel].controller = null;
            RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI));
        }

        base.onDisconnect();
    }
Exemplo n.º 28
0
 /// <summary>
 /// Destroy  cameras
 /// </summary>
 public virtual void Deactivate()
 {
     if (!IsActivate)
     {
         return;
     }
     DestroyCameras();
     RenderingManager.RemoveFromPostDrawQueue(0, CamGui);
     IsActivate = false;
 }
Exemplo n.º 29
0
        private void DrawGUI()
        {
            if (!part.isAttached || !IsPrimary)
            {
                print("BuildEngineer: DrawGUI - Not Attached || Not Primary");
                RenderingManager.RemoveFromPostDrawQueue(0, DrawGUI);
                return;
            }

            if (!hasInitStyles)
            {
                InitStyles();
            }

            if (isVisible)
            {
                CheckEditorLock();

                if (!settings.IsDrawing)
                {
                    string title = "";

                    bool compact        = settings.Get <bool>("_SAVEONCHANGE_COMPACT");
                    bool compactChanged = (compact != isCompact);

                    if (!compact)
                    {
                        title = windowTitle;
                        if (compactChanged)
                        {
                            windowPosition.x     -= (740 - 255);
                            windowPosition.width += (740 - 255);
                        }
                    }
                    else
                    {
                        title = windowTitleCompact;
                        if (compactChanged)
                        {
                            windowPosition.x     += (740 - 255);
                            windowPosition.width -= (740 - 255);
                        }
                    }

                    isCompact      = compact;
                    windowPosition = GUILayout.Window(windowID, windowPosition, Window, title, windowStyle);
                }
                else
                {
                    settings.DrawWindow();
                }

                CheckWindowMargin();
            }
        }
Exemplo n.º 30
0
 public void DeregisterGui()
 {
     RenderingManager.RemoveFromPostDrawQueue(3, drawGUI);
     if (highlighted != null)
     {
         highlighted.SetHighlightDefault();
         highlighted.SetHighlight(false);
         highlighted = null;
     }
     guiRegistered = false;
 }