Exemple #1
0
        private void AddLauncher()
        {
            if (ApplicationLauncher.Ready && launcher == null)
            {
                launcher = ApplicationLauncher.Instance.AddModApplication(
                    onAppLaunchToggleOn, onAppLaunchToggleOff,
                    null, null,
                    null, null,
                    inToolbars,
                    AppIcon);

                if (!CanEdit && PlanningNodesManager.Instance.NodesFor(null, true).Count < 1)
                {
                    // No nodes, can't make any; disable
                    launcher?.Disable(true);
                }

                string lockReason;
                if (!unlocked(out lockReason))
                {
                    launcher?.Disable(true);
                }

                launcher?.gameObject?.SetTooltip(
                    "PlanningNode_mainTitle",
                    launcher.IsEnabled
                                                ? "PlanningNode_mainTooltip"
                                                : string.IsNullOrEmpty(lockReason)
                                                        ? "PlanningNode_viewOnlyTooltip"
                                                        : lockReason
                    );
            }
        }
Exemple #2
0
 public void Disable()
 {
     if (appButton != null && appButton.toggleButton.Interactable)
     {
         appButton.Disable();
     }
 }
Exemple #3
0
        private IEnumerator AddButton()
        {
            while (!ApplicationLauncher.Ready)
            {
                yield return(null);
            }

            while (ApplicationLauncher.Instance == null)
            {
                yield return(null);
            }

            button = ApplicationLauncher.Instance.AddModApplication(OnTrue, OnFalse, OnHover, OnHoverOut, null, null, ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.FLIGHT, icon);

            ApplicationLauncher.Instance.EnableMutuallyExclusive(button);

            GameEvents.onGUIApplicationLauncherUnreadifying.Add(RemoveButton);

            button.onRightClick = (Callback)Delegate.Combine(button.onRightClick, new Callback(OnRightClick));

            if (HighLogic.LoadedSceneIsEditor)
            {
                button.toggleButton.onClick.RemoveAllListeners();
                button.toggleButton.onClick.AddListener(new UnityEngine.Events.UnityAction <PointerEventData, UIRadioButton.State, UIRadioButton.CallType>(OnClick));
            }

            if (!BasicDeltaV.ReadoutsAvailable)
            {
                button.Disable();
            }

            buttonAdder = null;
        }
Exemple #4
0
 /// <summary>
 ///     Disables the button if not already disabled.
 /// </summary>
 public void Disable()
 {
     if (m_Button != null && m_Button.IsEnabled)
     {
         m_Button.Disable();
     }
 }
 /// <summary>
 ///     Disables the button if not already disabled.
 /// </summary>
 public void Disable()
 {
     if (button != null && button.IsEnabled)
     {
         button.Disable();
     }
 }
Exemple #6
0
 private void OnNodeDeleted()
 {
     // Unclick the button when the user deletes our node
     launcher.SetFalse(true);
     if (!CanEdit && PlanningNodesManager.Instance.NodesFor(renderer.vessel, true).Count < 1)
     {
         // Can't do much more if we delete our last node in the tracking station
         launcher?.Disable(true);
     }
 }
 /// <summary>
 /// Setup app launcher button when the GUI is ready
 /// </summary>
 private void onGUIApplicationLauncherReady()
 {
     if (!AppLauncher)
     {
         appLauncherButton = InitializeApplicationButton();
         AppLauncher       = true;
         if (!canPCRIVA)
         {
             appLauncherButton.Disable();
         }
     }
 }
Exemple #8
0
        public void ToggleButtonState(bool isOn)
        {
            if (isOn)
            {
                button.Enable();
            }
            else
            {
                Close();

                button.Disable();
            }
        }
Exemple #9
0
        public void SetToolbarEnabled(bool isOn)
        {
            if (button == null)
            {
                return;
            }

            if (isOn)
            {
                button.Enable(false);
            }
            else
            {
                button.Disable(false);
            }
        }
        private IEnumerator onReadyWait()
        {
            while (!ApplicationLauncher.Ready)
            {
                yield return(null);
            }

            while (ApplicationLauncher.Instance == null)
            {
                yield return(null);
            }

            button = ApplicationLauncher.Instance.AddModApplication(onTrue, onFalse, onHover, onHoverOut, null, null, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.TRACKSTATION, icon);

            if (!processed)
            {
                button.Disable(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;
        }