// Following lifted from MechJeb internal void PreventInFlightClickthrough(Rect r) { #if !DUMMY //Log.Info("ClickThruBlocker: PreventInFlightClickthrough"); bool mouseOverWindow = MouseIsOverWindow(r); if (mouseOverWindow) { if (!weLockedFlightInputs && !Input.GetMouseButton(1) && lockName != null) { //Log.Info("PreventInFlightClickthrough, locking on window: " + windowName); ; InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, lockName); weLockedFlightInputs = true; } if (weLockedFlightInputs) lastLockCycle = OnGUILoopCount.GetOnGUICnt(); } if (weLockedFlightInputs && !mouseOverWindow && lockName != null) { //Log.Info("PreventInFlightClickthrough, unlocking on window: " + windowName); InputLockManager.RemoveControlLock(lockName); weLockedFlightInputs = false; } #endif }
//Lifted this more or less directly from the Kerbal Engineer source. Thanks cybutek! internal void PreventEditorClickthrough(Rect r) { #if DUMMY return; #else if (lockName == null || EditorLogic.fetch == null) return; //Log.Info("ClickThruBlocker: PreventEditorClickthrough"); bool mouseOverWindow = MouseIsOverWindow(r); //Log.Info("PreventEditorClickthrough, mouseOverWindow: " + mouseOverWindow); if (mouseOverWindow) { if (!weLockedEditorInputs) { //Log.Info("PreventEditorClickthrough, locking on window: " + windowName); EditorLogic.fetch.Lock(true, true, true, lockName); weLockedEditorInputs = true; activeBlockerCnt++; selectedParts = EditorActionGroups.Instance.GetSelectedParts(); } lastLockCycle = OnGUILoopCount.GetOnGUICnt(); return; } if (!weLockedEditorInputs) return; //Log.Info("PreventEditorClickthrough, unlocking on window: " + windowName); EditorLogic.fetch.Unlock(lockName); weLockedEditorInputs = false; activeBlockerCnt--; #endif }
//Lifted this more or less directly from the Kerbal Engineer source. Thanks cybutek! internal void PreventEditorClickthrough(Rect r) { #if DUMMY return; #else if (lockName == null || EditorLogic.fetch == null) return; //Log.Info("ClickThruBlocker: PreventEditorClickthrough"); bool mouseOverWindow = MouseIsOverWindow(r); //Log.Info("PreventEditorClickthrough, mouseOverWindow: " + mouseOverWindow); if (HighLogic.CurrentGame.Parameters.CustomParams<CTB>().focusFollowsclick) { bool mouseClicked = Input.GetMouseButton(0) || Input.GetMouseButton(1); if (mouseClicked) { if (mouseOverWindow) { if (!weLockedEditorInputs) { //Log.Info("PreventEditorClickthrough, locking on window: " + windowName); //EditorLogic.fetch.Lock(true, true, true, lockName); FocusLock.SetLock(lockName, win, 2); weLockedEditorInputs = true; activeBlockerCnt++; selectedParts = EditorActionGroups.Instance.GetSelectedParts(); } //lastLockCycle = OnGUILoopCount.GetOnGUICnt(); return; } else { if (weLockedEditorInputs) { FocusLock.FreeLock(lockName, 3); weLockedEditorInputs = false; activeBlockerCnt--; } } } } else { if (mouseOverWindow) { if (!weLockedEditorInputs) { //Log.Info("PreventEditorClickthrough, locking on window: " + windowName); //EditorLogic.fetch.Lock(true, true, true, lockName); FocusLock.SetLock(lockName, win, 4); weLockedEditorInputs = true; activeBlockerCnt++; selectedParts = EditorActionGroups.Instance.GetSelectedParts(); } lastLockCycle = OnGUILoopCount.GetOnGUICnt(); return; } if (!weLockedEditorInputs) return; //Log.Info("PreventEditorClickthrough, unlocking on window: " + windowName); //EditorLogic.fetch.Unlock(lockName); FocusLock.FreeLock(lockName, 5); weLockedEditorInputs = false; activeBlockerCnt--; } #endif }
// Following lifted from MechJeb internal void PreventInFlightClickthrough(Rect r) { #if !DUMMY //Log.Info("ClickThruBlocker: PreventInFlightClickthrough"); bool mouseOverWindow = MouseIsOverWindow(r); // // This section for the Click to Focus option // if (HighLogic.CurrentGame.Parameters.CustomParams<CTB>().focusFollowsclick) { bool mouseClicked = Input.GetMouseButton(0) || Input.GetMouseButton(1); if (mouseClicked) { if (mouseOverWindow) { Log.Info("PreventInFlightClickthrough, mouse clicked and over window, weLockedFlightInputs:" + weLockedFlightInputs + ", lockName: " + lockName); if (!weLockedFlightInputs && !Input.GetMouseButton(1) && lockName != null) { //InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, lockName); FocusLock.SetLock(lockName, win, 6); weLockedFlightInputs = true; } } else { Log.Info("PreventInFlightClickthrough, mouse clicked and NOT over window, weLockedFlightInputs:" + weLockedFlightInputs + ", lockName: " + lockName); if (weLockedFlightInputs && lockName != null) { // InputLockManager.RemoveControlLock(lockName); FocusLock.FreeLock(lockName, 7); weLockedFlightInputs = false; } } } } else { // // This section for the Focus Follows Mouse option // if (mouseOverWindow) { if (!weLockedFlightInputs && !Input.GetMouseButton(1) && lockName != null) { //Log.Info("PreventInFlightClickthrough, locking on window: " + windowName); ; //InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, lockName); FocusLock.SetLock(lockName, win, 8); weLockedFlightInputs = true; } if (weLockedFlightInputs) lastLockCycle = OnGUILoopCount.GetOnGUICnt(); } if (weLockedFlightInputs && !mouseOverWindow && lockName != null) { //Log.Info("PreventInFlightClickthrough, unlocking on window: " + windowName); //InputLockManager.RemoveControlLock(lockName); FocusLock.FreeLock(lockName, 9); weLockedFlightInputs = false; } } #endif }