Exemplo n.º 1
0
 public void Enable()
 {
     if (appButton != null && appButton.toggleButton.Interactable == false)
     {
         appButton.Enable();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Enables the button if not already enabled.
 /// </summary>
 public void Enable()
 {
     if (m_Button != null && !m_Button.IsEnabled)
     {
         m_Button.Enable();
     }
 }
        private IEnumerator getVessels()
        {
            while (SEP_Controller.Instance == null)
            {
                yield return(null);
            }

            while (!SEP_Controller.Instance.Setup)
            {
                yield return(null);
            }

            processVesselSections();

            processed = true;

            if (button != null)
            {
                button.Enable(false);
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                if (GetBodies.Contains(FlightGlobals.currentMainBody.bodyName))
                {
                    _currentBody = FlightGlobals.currentMainBody.bodyName;
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Enables the button if not already enabled.
 /// </summary>
 public void Enable()
 {
     if (button != null && !button.IsEnabled)
     {
         button.Enable();
     }
 }
Exemplo n.º 5
0
        public void ToggleButtonState(bool isOn)
        {
            if (isOn)
            {
                button.Enable();
            }
            else
            {
                Close();

                button.Disable();
            }
        }
Exemplo n.º 6
0
        public void SetToolbarEnabled(bool isOn)
        {
            if (button == null)
            {
                return;
            }

            if (isOn)
            {
                button.Enable(false);
            }
            else
            {
                button.Disable(false);
            }
        }
Exemplo n.º 7
0
        private IEnumerator getVessels()
        {
            while (SEP_Controller.Instance == null)
            {
                yield return(null);
            }

            while (!SEP_Controller.Instance.Setup)
            {
                yield return(null);
            }

            processVesselSections();

            processed = true;

            button.Enable(false);
        }
        /// <summary>
        /// Scans vessel for usable IVA rooms and PCR rooms and initializes them as neccessary
        /// </summary>
        private void refreshVesselRooms()
        {
            ProbeControlRoomUtils.Logger.debug("refreshVesselRooms()");

            Vessel vessel = FlightGlobals.ActiveVessel;

            //If the vessel is null, there is something wrong and no reason to continue scan
            if (vessel == null)
            {
                canStockIVA = false;
                aPart       = null;
                aModule     = null;
                ProbeControlRoomUtils.Logger.error("refreshVesselRooms() - ERROR: FlightGlobals.activeVessel is NULL");
                return;
            }

            // If our current vessel still has the old PCR part, keep it active
            if (vessel.parts.Contains(aPart))
            {
                ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - Old part still there, cleaning up extra rooms and returning");
                //Our old part is still there and active. Clean up extras as needed and return
                for (int i = 0; i < vessel.parts.Count; i++)
                {
                    Part p = vessel.parts[i];
                    if (p.GetComponent <ProbeControlRoomPart>() != null && aPart != p && p.protoModuleCrew.Count == 0 && p.internalModel != null)
                    {
                        ProbeControlRoomUtils.Logger.debug("refreshRooms() Found and destroying old PCR in " + p.ToString());
                        p.internalModel.gameObject.DestroyGameObject();
                        p.internalModel = null;
                    }
                }
                return;
            }

            //No current active PCR found, time to create a new one
            canStockIVA = false;
            canPCRIVA   = false;
            List <Part> rooms      = new List <Part>();
            List <Part> pcrNoModel = new List <Part>();

            ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - scanning vessel: " + vessel.ToString());


            //Look throught the list of parts and save those that have probe control room modules on them based on available internal models
            for (int i = 0; i < vessel.parts.Count; i++)
            {
                Part p = vessel.parts[i];
                ProbeControlRoomPart room = p.GetComponent <ProbeControlRoomPart>();
                if (room != null)
                {
                    if (p.internalModel != null)
                    {
                        //Check for stock IVA
                        if (p.protoModuleCrew.Count > 0)
                        {
                            ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Found Stock IVA with crew: " + p.ToString());
                            canStockIVA = true;
                        }
                        else
                        {
                            //No stock IVA possible, PCR model found
                            ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Found part with PCR IVA model: " + p.ToString());
                            rooms.Add(p);
                        }
                    }
                    else
                    {
                        //PCR Module noted but no active internal model found
                        ProbeControlRoomUtils.Logger.message("refreshVesselrooms() - Found PCR part but it has no model: " + p.ToString());
                        pcrNoModel.Add(p);
                    }
                }
            }

            //Clean up and specifiy active rooms
            if (rooms.Count > 0)
            {
                ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Cleaning up pcrNoModel List");
                pcrNoModel.Clear();
                pcrNoModel = null;


                //Select primary part for use and verify it's initialized
                ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - Initializing room in " + aPart.ToString());
                aPart = rooms[0];
                aPart.internalModel.Initialize(aPart);
                aPart.internalModel.SetVisible(false);

                //Remove Excess internal models
                if (rooms.Count > 1)
                {
                    ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - Removing " + (rooms.Count - 1) + " Rooms");
                    for (int i = 1; i < rooms.Count; i++)
                    {
                        rooms[i].internalModel.gameObject.DestroyGameObject();
                        rooms[i].internalModel = null;
                    }
                }
                canPCRIVA = true;
                rooms.Clear();
                rooms = null;
            }
            else if (pcrNoModel.Count > 0)
            {
                // No parts with an available internal model were found, attempting to create one
                aPart = pcrNoModel[0];
                aPart.CreateInternalModel();
                ProbeControlRoomUtils.Logger.debug("refreshVesselRooms() - No active room with a model found, creating now in " + aPart.ToString());
                if (aPart.internalModel == null)
                {
                    //Something went wrong creating the model
                    ProbeControlRoomUtils.Logger.message("refreshVesselRooms() - ERROR creating internal model");
                    return;
                }
                aPart.internalModel.Initialize(aPart);
                aPart.internalModel.SetVisible(false);
                canPCRIVA = true;
            }

            pcrNoModel.Clear();
            pcrNoModel = null;

            // Set app launcher availability based on current layout.
            if (AppLauncher)
            {
                if (canPCRIVA)
                {
                    appLauncherButton.Enable();
                }
                else
                {
                    appLauncherButton.Disable();
                }
            }
            return;
        }