示例#1
0
        /// <summary>
        /// Cleanup on destruction.
        /// </summary>
        public void OnDestroy()
        {
            GameEvents.onGUIApplicationLauncherReady.Remove(onGUIApplicationLauncherReady);
            GameEvents.onGameSceneSwitchRequested.Remove(onGameSceneSwitchRequested);
            GameEvents.onLevelWasLoaded.Remove(onLevelWasLoaded);
            GameEvents.onVesselChange.Remove(onVesselChange);
            GameEvents.onHideUI.Remove(onHideUI);
            GameEvents.onShowUI.Remove(onShowUI);
            GameEvents.onGamePause.Remove(onGamePause);
            GameEvents.onGameUnpause.Remove(onGameUnpause);

            DestroyLauncher();

            config.SetValue("autoDewarp", autoDewarp);
            config.SetValue("guiRect", guiRect);
            config.SetValue("rcRect", rcRect);
            config.SetValue("useKSPSkin", useKSPSkin);
            config.SetValue("useToolbar", useToolbar);
            config.save();
            InputLockManager.RemoveControlLock("BonVoyageInputLock");
        }
示例#2
0
 public static void Reset()
 {
     lock (Client.eventLock)
     {
         if (singleton != null)
         {
             singleton.workerEnabled = false;
             singleton.RemoveWindowLock();
             Client.updateEvent.Remove(singleton.Update);
             Client.drawEvent.Remove(singleton.Draw);
             if (singleton.chatLocked)
             {
                 singleton.chatLocked = false;
                 InputLockManager.RemoveControlLock(DMP_CHAT_LOCK);
             }
         }
         singleton = new ChatWorker();
         Client.updateEvent.Add(singleton.Update);
         Client.drawEvent.Add(singleton.Draw);
     }
 }
示例#3
0
 private void UpdateLock()
 {
     if (ShouldBeLocked())
     {
         if (!inputLockActive)
         {
             Debug.Log("[NH] lock input");
             InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, this.inputLock);
             inputLockActive = true;
         }
     }
     else
     {
         if (inputLockActive)
         {
             Debug.Log("[NH] unlock input");
             InputLockManager.RemoveControlLock(this.inputLock);
             inputLockActive = false;
         }
     }
 }
示例#4
0
        void UpdateLock()
        {
            if (ShouldBeLocked())
            {
                if (!inputLockActive)
                {
                    InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, inputLock);

                    inputLockActive = true;
                }
            }
            else
            {
                if (inputLockActive)
                {
                    InputLockManager.RemoveControlLock(inputLock);

                    inputLockActive = false;
                }
            }
        }
        public void OnGUI()
        {
            if (HighLogic.LoadedScene != GameScenes.SPACECENTER)
            {
                debugMenu = false;
                if (!inputLocked)
                {
                    return;
                }
                InputLockManager.RemoveControlLock("FARDebugLock");
                inputLocked = false;
                return;
            }

            GUI.skin = HighLogic.Skin;
            if (debugMenu)
            {
                debugWinPos = GUILayout.Window("FARDebug".GetHashCode(),
                                               debugWinPos,
                                               debugWindow,
                                               "FAR Debug Options, " + FARVersion.VersionString,
                                               GUILayout.ExpandWidth(true),
                                               GUILayout.ExpandHeight(true));
                if (!inputLocked && debugWinPos.Contains(GUIUtils.GetMousePos()))
                {
                    InputLockManager.SetControlLock(ControlTypes.KSC_ALL, "FARDebugLock");
                    inputLocked = true;
                }
                else if (inputLocked && !debugWinPos.Contains(GUIUtils.GetMousePos()))
                {
                    InputLockManager.RemoveControlLock("FARDebugLock");
                    inputLocked = false;
                }
            }
            else if (inputLocked)
            {
                InputLockManager.RemoveControlLock("FARDebugLock");
                inputLocked = false;
            }
        }
示例#6
0
        public void gameSceneEvent(GameScenes scene)
        {
            if (!KCT_GameStates.settings.enabledForSave)
            {
                return;
            }
            List <GameScenes> validScenes = new List <GameScenes> {
                GameScenes.SPACECENTER, GameScenes.TRACKSTATION, GameScenes.SPH, GameScenes.EDITOR
            };

            if (validScenes.Contains(scene))
            {
                //Check for simulation save and load it.
                if (System.IO.File.Exists(KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/KCT_simulation_backup.sfs"))
                {
                    KCT_Utilities.LoadSimulationSave();
                }
            }
            if (!HighLogic.LoadedSceneIsFlight && scene == GameScenes.FLIGHT && KCT_GameStates.flightSimulated) //Backup save at simulation start
            {
                KCT_Utilities.MakeSimulationSave();
            }

            if (HighLogic.LoadedScene == scene && (scene == GameScenes.EDITOR || scene == GameScenes.SPH)) //Fix for null reference when using new or load buttons in editor
            {
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            }

            if (scene == GameScenes.MAINMENU)
            {
                KCT_GameStates.reset();
                KCT_GameStates.firstStart = true;
                KCT_Utilities.disableSimulationLocks();
                InputLockManager.RemoveControlLock("KCTLaunchLock");
            }
            if (HighLogic.LoadedSceneIsEditor)
            {
                EditorLogic.fetch.Unlock("KCTEditorMouseLock");
            }
        }
        public void OnGUI()
        {
            if (m_Controller.iface == null)
            {
                shouldBeDestroyed = true;
                return;
            }

            if (m_ClickSleepTimer > 0.0f)
            {
                m_ClickSleepTimer -= Time.unscaledDeltaTime;
                if (m_ClickSleepTimer < 0.0f)
                {
                    m_CurrentMask     = null;
                    m_ClickSleepTimer = 0.0f;
                }
            }

            if (m_DestructiveActionTimer > 0.0f)
            {
                m_DestructiveActionTimer -= Time.unscaledDeltaTime;
                if (m_DestructiveActionTimer < 0.0f)
                {
                    m_DestructiveActionWait  = false;
                    m_DestructiveActionTimer = 0.0f;
                }
            }

            if (windowRect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)))
            {
                InputLockManager.SetControlLock(inputLockHash);
            }
            else
            {
                InputLockManager.RemoveControlLock(inputLockHash);
            }

            windowRect = GUI.Window(1337 + m_EditorId, windowRect, DoWindow, "Fly-By-Wire Preset Editor");
            windowRect = Utility.ClampRect(windowRect, new Rect(0, 0, Screen.width, Screen.height));
        }
 private static void OnWindow(int windowID)
 {
     // Start a new GUILayout
     GUILayout.BeginVertical(GUILayout.Width(250.0f));
     // Create the text field
     GUI.SetNextControlName("Warp TextField");
     currentSeed = GUILayout.TextField(currentSeed);
     // Select the text in the text field
     GUI.FocusControl("Warp TextField");
     // Make the button
     if (GUILayout.Button("Start Warp Drive") || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
     {
         // User has hit the button or pressed enter
         Warp(true, currentSeed, false);
         PersistenceGenerator.WarpSingleVessel(lastSeed, seedString, FlightGlobals.ActiveVessel);
         RenderingManager.RemoveFromPostDrawQueue(0, OnDraw);
         InputLockManager.RemoveControlLock(CONTROL_LOCK_ID);
     }
     GUILayout.EndVertical();
     // Allow the window to be draggable
     GUI.DragWindow();
 }
        public void Awake()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                return;
            }

            LoadConfigs();
            if (FARDebugValues.useBlizzyToolbar)
            {
                FARFlightButtonBlizzy             = ToolbarManager.Instance.add("ferram4", "FAREditorButton");
                FARFlightButtonBlizzy.TexturePath = "FerramAerospaceResearch/Textures/icon_button_blizzy";
                FARFlightButtonBlizzy.ToolTip     = "FAR Flight Systems";
                FARFlightButtonBlizzy.OnClick    += (e) => FARControlSys.minimize = !FARControlSys.minimize;
            }
            else
            {
                GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
            }

            InputLockManager.RemoveControlLock("FAREdLock");
        }
示例#10
0
        private void FallthroughCheck()
        {
            if (FreeIva.CurrentPart != null && FreeIva.CurrentPart.Rigidbody != null)
            {
                var velocityRelativeToPart = (FreeIva.CurrentPart.Rigidbody.velocity - KerbalRigidbody.velocity).magnitude;
                if (velocityRelativeToPart > Settings.MaxVelocityRelativeToPart)
                {
                    buckled = true;
                    InternalCamera.Instance.transform.parent = ActiveKerbal.KerbalRef.eyeTransform;
                    CameraManager.Instance.SetCameraFlight();
                    KerbalIva.GetComponentCached <Collider>(ref KerbalCollider);
                    KerbalCollider.enabled = false;
                    HideCurrentKerbal(false);
                    DisablePartHighlighting(false);
                    InputLockManager.RemoveControlLock("FreeIVA");

                    Gravity = false;
                    KerbalCollider.enabled = true;
                    ScreenMessages.PostScreenMessage("It was all just a dream...", 3f, ScreenMessageStyle.LOWER_CENTER);
                }
            }
        }
示例#11
0
 internal static void RepairAllBuildings()
 {
     foreach (StaticInstance instance in StaticDatabase.allStaticInstances)
     {
         foreach (DestructibleBuilding building in instance.transform.gameObject.GetComponentsInChildren <DestructibleBuilding>(true))
         {
             if (building.IsDestroyed)
             {
                 //building.RepairCost = 0;
                 //building.Repair();
                 building.Reset();
                 // reactivate the Building Spawn if the building was active before
                 if (instance.isActive)
                 {
                     instance.Activate();
                 }
                 instance.isDestroyed = false;
             }
         }
     }
     InputLockManager.RemoveControlLock("KK_KSC");
 }
示例#12
0
        //private bool _reseatingCrew = false;
        public void Buckle()
        {
            if (TargetedSeat == null)
            {
                return;
            }

            Debug.Log(ActiveKerbal.name + " is entering seat " + TargetedSeat.transform.name + " in part " + FreeIva.CurrentPart);

            //InitialPart.RemoveCrewmember(ActiveKerbal); // Don't do this on unbuckle or we lose the InternalCamera.

            /*TargetedSeat.part.AddCrewmemberAt(ActiveKerbal, TargetedSeatIndex);
             * CurrentPart.SpawnCrew();*/

            HideCurrentKerbal(false);

            if (FreeIva.InitialPart != FreeIva.CurrentPart)
            {
                GameEvents.onCrewTransferred.Fire(new GameEvents.HostedFromToAction <ProtoCrewMember, Part>(ActiveKerbal, FreeIva.InitialPart, FreeIva.CurrentPart));
                GameEvents.onVesselChange.Fire(FlightGlobals.ActiveVessel);

                /*InitialPart.SpawnCrew();
                 * CurrentPart.SpawnCrew();
                 * InitialPart.RegisterCrew();
                 * CurrentPart.RegisterCrew();
                 * FlightGlobals.ActiveVessel.SpawnCrew();*/
            }
            //_reseatingCrew = true;
            FreeIva.EnableInternals();

            KerbalCollider.collider.enabled = false;
            // InternalSpace.Instance is the InternalCamera's parent normally.
            InternalCamera.Instance.transform.parent = InternalSpace.Instance.transform;

            InputLockManager.RemoveControlLock("FreeIVA");
            //ActiveKerbal.flightLog.AddEntry("Buckled");
            ScreenMessages.PostScreenMessage("Buckled", 1f, ScreenMessageStyle.LOWER_CENTER);
            buckled = true;
        }
示例#13
0
        public void Update()
        {
            if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready)
            {
                InputLockManager.RemoveControlLock(lockID);
                return;
            }

            bool doLock = ShouldLock();

            if (doLock != wasLocked)
            {
                if (wasLocked)
                {
                    InputLockManager.RemoveControlLock(lockID);
                    message.message = "Avionics: Unlocking Controls";
                }
                else
                {
                    InputLockManager.SetControlLock(lockmask, lockID);
                    vessel.Autopilot.Disable();
                    vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, false);
                    message.message = $"Insufficient Avionics, Locking Controls (supports {maxMass:N3}t, vessel {vesselMass:N3}t)";
                }
                ScreenMessages.PostScreenMessage(message);
                FlightLogger.fetch.LogEvent(message.message);
                wasLocked = doLock;
            }

            if (masterMechJeb == null && getMasterMechJeb != null)
            {
                masterMechJeb = getMasterMechJeb.Invoke(null, new object[] { FlightGlobals.ActiveVessel });
            }
            if (masterMechJeb != null && mjDeactivateControl != null)
            {
                // Update MJ every tick, to make sure it gets correct state after separation / docking.
                mjDeactivateControl.SetValue(masterMechJeb, doLock, index: null);
            }
        }
示例#14
0
        //prevents mouse actions on the GUI window from affecting things behind it.
        protected void prevent_ui_click_through()
        {
            Vector2 mouse_pos = Input.mousePosition;

            mouse_pos.y = Screen.height - mouse_pos.y;
            if (window_pos.Contains(mouse_pos))
            {
                if (!interface_locked)
                {
                    InputLockManager.SetControlLock(window_id.ToString());
                    interface_locked = true;
                }
            }
            else
            {
                if (interface_locked)
                {
                    InputLockManager.RemoveControlLock(window_id.ToString());
                    interface_locked = false;
                }
            }
        }
示例#15
0
        public void OnDestroy()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                return;
            }

            GameEvents.onVesselWasModified.Remove(OnVesselWasModified);
            GameEvents.onVesselGoOffRails.Remove(OnVesselOffRails);
            GameEvents.onVesselGoOnRails.Remove(OnVesselOnRails);

            if (InputLockManager.GetControlLock("KJRLoadLock") == ControlTypes.ALL_SHIP_CONTROLS)
            {
                InputLockManager.RemoveControlLock("KJRLoadLock");
            }
            updatedVessels          = null;
            vesselOffRailsTick      = null;
            vesselJointStrengthened = null;

            multiJointManager.OnDestroy();
            multiJointManager = null;
        }
示例#16
0
        //Note: parent object needs to call DrawWindow in its OnGUI method.
        public virtual void DrawWindow()
        {
            if (visible)
            {
                bool paused = false;
                if (HighLogic.LoadedSceneIsFlight)
                {
                    try
                    {
                        paused = PauseMenu.isOpen || FlightResultsDialog.isDisplaying;
                    }
                    catch (Exception)
                    {
                        // ignore the error and assume the pause menu is not open
                    }
                }

                if (!paused)
                {
                    GUI.skin = HighLogic.Skin;
                    ConfigureStyles();

                    windowPos = DialogUtils.EnsureVisible(windowPos);
                    windowPos = GUILayout.Window(windowId, windowPos, PreDrawWindowContents, WindowTitle, GUILayout.ExpandWidth(true),
                                                 GUILayout.ExpandHeight(true), GUILayout.MinWidth(64), GUILayout.MinHeight(64));
                }

                Vector3 mousePosition = Input.mousePosition;
                if (windowPos.Contains(mousePosition))
                {
                    InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, "WindowLock" + this.windowId);
                }
                else
                {
                    InputLockManager.RemoveControlLock("WindowLock" + this.windowId);
                }
            }
        }
示例#17
0
 internal static void CreatePopUp()
 {
     dialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f),
                                           new Vector2(0.5f, 0.5f),
                                           new MultiOptionDialog("Name",
                                                                 "Press the button to repair all Buildings",
                                                                 "Kerbal Konstructs",
                                                                 HighLogic.UISkin,
                                                                 new Rect(0.5f, 0.5f, 150f, 60f),
                                                                 new DialogGUIFlexibleSpace(),
                                                                 new DialogGUIVerticalLayout(
                                                                     new DialogGUIFlexibleSpace(),
                                                                     new DialogGUIButton("Repair All Buildings", RepairAllBuildings, 140.0f, 30.0f, true),
                                                                     new DialogGUIButton("Spawn Worker", SpawnWorker, 140.0f, 30.0f, false),
                                                                     new DialogGUIButton("Close", () =>
     {
         InputLockManager.RemoveControlLock("KK_KSC");
     }, 140.0f, 30.0f, true)
                                                                     )),
                                           false,
                                           HighLogic.UISkin,
                                           false);
 }
 public void Update()
 {
     if (GameSettings.MODIFIER_KEY.GetKey() && Input.GetKeyDown(KeyCode.O))
     {
         if (window)
         {
             InputLockManager.RemoveControlLock("LockGizmosWhileVisualWingConfiguratorIsOpen");
             InputLockManager.RemoveControlLock("LockRerootWhileVisualWingConfiguratorIsOpen");
             window.Dismiss();
             window = null;
         }
         else
         {
             InputLockManager.SetControlLock(ControlTypes.EDITOR_GIZMO_TOOLS, "LockGizmosWhileVisualWingConfiguratorIsOpen");
             InputLockManager.SetControlLock(ControlTypes.EDITOR_ROOT_REFLOW, "LockRerootWhileVisualWingConfiguratorIsOpen");
             window = BuildWindow();
         }
     }
     if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
     {
         currentPart = Mouse.HoveredPart;
     }
 }
示例#19
0
        void OnDestroy()
        {
            toolbarControl.OnDestroy();
            Destroy(toolbarControl);

            if (InputLockManager.lockStack.ContainsKey("WernherChecker_partSelection"))
            {
                InputLockManager.RemoveControlLock("WernherChecker_partSelection");
                selectionInProgress = false;
            }

            if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                GameEvents.onEditorScreenChange.Remove(onEditorPanelChange);
                GameEvents.onEditorShipModified.Remove(checklistSystem.CheckVessel);
                GameEvents.onEditorRestart.Remove(checklistSystem.CheckVessel);
                GameEvents.onEditorShowPartList.Remove(checklistSystem.CheckVessel);
            }
            Settings.Save();
            GameEvents.onShowUI.Remove(ShowUI);
            GameEvents.onHideUI.Remove(HideUI);
            GameEvents.OnGameSettingsApplied.Remove(ReloadSettings);
        }
示例#20
0
        /// <summary>
        /// Vessel changed. Refresh vessel list in the main window if it's still visible and hide control window (scene was not switched)
        /// </summary>
        /// <param name="vessel"></param>
        public void OnVesselChange(Vessel vessel)
        {
            if (MainView != null)
            {
                MainModel.RefreshVesselListLayout();
            }
            if (controlViewVisible)
            {
                ToggleControlWindow();
            }

            BonVoyageModule currentModule = vessel.FindPartModuleImplementing <BonVoyageModule>();

            if (currentModule != null)
            {
                if (currentModule.active)
                {
                    InputLockManager.SetControlLock(lockMask, "BonVoyageInputLock");
                    return;
                }
            }
            InputLockManager.RemoveControlLock("BonVoyageInputLock");
        }
 public void OnGUI()
 {
     GUI.skin = HighLogic.Skin;
     if (debugMenu)
     {
         debugWinPos = GUILayout.Window("FARDebug".GetHashCode(), debugWinPos, debugWindow, "FAR Debug Options, v0.14.6", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
         if (!inputLocked && debugWinPos.Contains(FARGUIUtils.GetMousePos()))
         {
             InputLockManager.SetControlLock(ControlTypes.KSC_ALL, "FARDebugLock");
             inputLocked = true;
         }
         else if (inputLocked && !debugWinPos.Contains(FARGUIUtils.GetMousePos()))
         {
             InputLockManager.RemoveControlLock("FARDebugLock");
             inputLocked = false;
         }
     }
     else if (inputLocked)
     {
         InputLockManager.RemoveControlLock("FARDebugLock");
         inputLocked = false;
     }
 }
示例#22
0
 public void Close()
 {
     if (_activePopup != null)
     {
         _activePopup.Dismiss();
         _activePopup = null;
         Unhide();
     }
     else if (_miniSettings != null)
     {
         // WTF SQUAD?
         _miniSettings.GetType().GetMethod("Dismiss", BindingFlags.NonPublic | BindingFlags.Instance);
     }
     else
     {
         isOpen = false;
         //_display = false;
         InputLockManager.RemoveControlLock("KRASHSimPauseMenu");
         Log.Info("Close:  FlightDriver.SetPause (false)");
         FlightDriver.SetPause(false);
         Log.Info("FlightDriver.Pause: " + FlightDriver.Pause.ToString());
     }
 }
示例#23
0
        /// <summary>
        /// Initial start
        /// </summary>
        public void Start()
        {
            DontDestroyOnLoad(this);
            GameEvents.onGUIApplicationLauncherReady.Add(AddLauncher);
            GameEvents.onGUIApplicationLauncherDestroyed.Add(RemoveLauncher);
            GameEvents.onGameSceneSwitchRequested.Add(OnGameSceneSwitchRequested);
            GameEvents.onVesselChange.Add(OnVesselChange);
            GameEvents.onLevelWasLoaded.Add(OnLevelWasLoaded);
            GameEvents.onVesselGoOffRails.Add(OnVesselGoOffRails);
            GameEvents.onHideUI.Add(OnHideUI);
            GameEvents.onShowUI.Add(OnShowUI);
            GameEvents.onGamePause.Add(OnGamePause);
            GameEvents.onGameUnpause.Add(OnGameUnpause);

            LoadControllers();

            // After BonVoyage was runned for the first time, set FirstRun to false, because we don't need to reset path and target lat/lon
            Configuration.FirstRun = false;

            InputLockManager.RemoveControlLock("BonVoyageInputLock");

            otherStabilizerPresent = (Tools.AssemblyIsLoaded("WorldStabilizer") || Tools.AssemblyIsLoaded("BDArmory"));
        }
示例#24
0
        /// <summary>
        /// Active vessel changed, deal with it.
        /// </summary>
        /// <param name="vessel">Vessel.</param>
        public void onVesselChange(Vessel vessel)
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            currentModule = vessel.FindPartModuleImplementing <BonVoyageModule> ();
//			if (wayPoints != null)
//				wayPoints.Clear ();
            if (currentModule != null)
            {
                currentModule.SystemCheck();
                UpdateWayPoints();
//				wayPoints = PathUtils.DecodePath (currentModule.pathEncoded, currentModule.vessel.mainBody);
                if (currentModule.isActive)
                {
                    InputLockManager.SetControlLock(lockMask, "BonVoyageInputLock");
                    return;
                }
            }

//			currentModule = null;
//			foreach (var rover in activeRovers)
//			{
//				if (rover.vessel == vessel)
////					ControlThis (rover.vessel.FindPartModuleImplementing<BonVoyageModule> (), false);
//					currentModule = rover.vessel.FindPartModuleImplementing<BonVoyageModule>();
//
//				if (rover.vessel == vessel && rover.bvActive)
//				{
//					InputLockManager.SetControlLock(lockMask, "BonVoyageInputLock");
//					return;
//				}
//			}
            InputLockManager.RemoveControlLock("BonVoyageInputLock");
        }
示例#25
0
        public static void SetTarget(ITargetable val, Vessel currentVessel)
        {
            if (val is Vessel && (Vessel)val == currentVessel)
            {
                throw new Safe.Exceptions.KOSInvalidTargetException("A ship cannot set TARGET to itself.");
            }
            else if (val.GetVessel() == currentVessel)
            {
                throw new Safe.Exceptions.KOSInvalidTargetException("A ship cannot set TARGET to a part of itself.");
            }

            // If any kOS terminal (not just the one this CPU uses as its Shared.Window, but ANY kOS terminal
            // from any kOS CPU) is the focused window right now, causing input lockouts, we must
            // temporarily turn off that input lock in order for the main game allow the SetVesselTarget()
            // call in the lines below to perform its task fully:
            //
            // Note the preferred solution would be to walk all control locks and suppress *any* that are turning
            // off the targeting, regardless of whether they're kOS or not, but InputLockManager does not provide
            // any methods for iteratinng the collection of all control lock masks, and it's also not possible to turn
            // a lock OFF by masking it with a new control lock, since all the locks in the stack are OR'ed together.)

            ControlTypes termInputLock = InputLockManager.GetControlLock(Screen.TermWindow.CONTROL_LOCKOUT);

            // (Note, KSP returns ControlTypes.None rather than null when no such lock was found, because it's
            // a non-nullable enum)
            if (termInputLock != ControlTypes.None)
            {
                InputLockManager.RemoveControlLock(Screen.TermWindow.CONTROL_LOCKOUT);
            }

            FlightGlobals.fetch.SetVesselTarget(val, true);

            if (termInputLock != ControlTypes.None)
            {
                InputLockManager.SetControlLock(termInputLock, Screen.TermWindow.CONTROL_LOCKOUT);
            }
        }
示例#26
0
        public void Update()
        {
            if ((Input.GetKeyDown(KeyCode.Escape) && config.enableEscapePause) && (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.EDITOR))
            {
                paused = !paused;
                if (subscene)
                {
                    if (paused)
                    {
                        InputLockManager.SetControlLock(ControlTypes.All, "TotalTime");
                    }
                    else
                    {
                        InputLockManager.RemoveControlLock("TotalTime");
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.F2))
            {
                F2 = !F2;
            }
            if (gui == null)
            {
                gui = this.gameObject.AddComponent <MainMenuGui> ();
                gui.UpdateToolbarStock();
                gui.SetConfigVisible(false);
            }

            if (HighLogic.LoadedScene != GameScenes.MAINMENU)
            {
                if (MainMenuGui.TT_Button == null)
                {
                    GameEvents.onGUIApplicationLauncherReady.Add(gui.OnGUIApplicationLauncherReady);
                }
                gui.OnGUIShowApplicationLauncher();
            }
        }
示例#27
0
        public void drawBaseManager()
        {
            KKWindow         = new GUIStyle(GUI.skin.window);
            KKWindow.padding = new RectOffset(3, 3, 5, 5);

            if (foldedIn)
            {
                if (!doneFold)
                {
                    BaseManagerRect = new Rect(BaseManagerRect.xMin, BaseManagerRect.yMin, BaseManagerRect.width, BaseManagerRect.height - 255);
                }

                doneFold = true;
            }

            if (!foldedIn)
            {
                if (doneFold)
                {
                    BaseManagerRect = new Rect(BaseManagerRect.xMin, BaseManagerRect.yMin, BaseManagerRect.width, BaseManagerRect.height + 255);
                }

                doneFold = false;
            }

            BaseManagerRect = GUI.Window(0xC00B8B7, BaseManagerRect, drawBaseManagerWindow, "", KKWindow);

            if (BaseManagerRect.Contains(Event.current.mousePosition))
            {
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LOCK, "KKEditorLock");
            }
            else
            {
                InputLockManager.RemoveControlLock("KKEditorLock");
            }
        }
示例#28
0
        public void ExitAnimationMode()
        {
            if (FSM.CurrentState.name == "KAS_Animation")
            {
                var exit = FSM.CurrentState.StateEvents.Find(k => k.name == "Exit KAS_Animation");
                if (exit != null)
                {
                    FSM.RunEvent(exit);
                }
                else
                {
                    Debug.LogError("failed to run event: Exit KAS_Animation");
                }
            }

            //set animation settings back to default
            animation.Stop();
            animation.playAutomatically = true;

            //set helmet back to default
            HasHelmet = true;

            //move back down onto ground
            //TODO: use a raycast sanity check
            transform.position -= transform.up * 9.75f;
            foreach (var rb in Part.GetComponents <Rigidbody>())
            {
                rb.velocity    = Vector3.zero;
                rb.constraints = RigidbodyConstraints.None;
            }

            //remove the input lock
            InputLockManager.RemoveControlLock("KerbalAnimationSuite_Lock");

            IsAnimating = false;
        }
示例#29
0
        /*
         * public void OnDestroy()
         * {
         *      EditorLock(false);
         * }
         */
        internal static void EditorLock(Boolean apply)
        {
            //only do this lock in the editor - no point elsewhere
            if (HighLogic.LoadedSceneIsEditor && apply)
            {
                //only add a new lock if there isnt already one there
                if (InputLockManager.GetControlLock("IRSGUILockOfEditor") != ControlTypes.EDITOR_LOCK)
                {
                    Logger.Log(String.Format("[GUI] AddingLock-{0}", "IRSGUILockOfEditor"), Logger.Level.SuperVerbose);

                    InputLockManager.SetControlLock(ControlTypes.EDITOR_LOCK, "IRSGUILockOfEditor");
                }
            }
            //Otherwise make sure the lock is removed
            else
            {
                //Only try and remove it if there was one there in the first place
                if (InputLockManager.GetControlLock("IRSGUILockOfEditor") == ControlTypes.EDITOR_LOCK)
                {
                    Logger.Log(String.Format("[GUI] Removing-{0}", "IRSGUILockOfEditor"), Logger.Level.SuperVerbose);
                    InputLockManager.RemoveControlLock("IRSGUILockOfEditor");
                }
            }
        }
示例#30
0
文件: Utils.cs 项目: kevin-ye/hangar
 public static void LockIfMouseOver(string LockName, Rect WindowRect, bool Lock)
 //taken from Kerbal Alarm Clock mod
 {
     if (Lock && WindowRect.Contains(Event.current.mousePosition))
     {
         if (InputLockManager.GetControlLock(LockName) != ControlTypes.EDITOR_LOCK)
         {
                                 #if DEBUG
             Log("AddingLock: {0}", LockName);
                                 #endif
             InputLockManager.SetControlLock(ControlTypes.EDITOR_LOCK, LockName);
         }
     }
     else
     {
         if (InputLockManager.GetControlLock(LockName) == ControlTypes.EDITOR_LOCK)
         {
                                 #if DEBUG
             Log("RemovingLock: {0}", LockName);
                                 #endif
             InputLockManager.RemoveControlLock(LockName);
         }
     }
 }