void FixedUpdate()
        {
            globalTimeTics++;

            if (HighLogic.CurrentGame.Parameters.CustomParams <CTB>().focusFollowsclick)
            {
                foreach (var w in FocusLock.focusLockDict)
                {
                    if (w.Value.win.lastUpdated < globalTimeTics - 4)
                    {
                        FocusLock.FreeLock(w.Key, 1);
                        w.Value.win.OnDestroy();
                        break;
                    }
                }
            }
        }
Beispiel #2
0
        void FixedUpdate()
        {
            globalTimeTics++;

            if (ClearInputLocks.focusFollowsclick)
            {
                foreach (var w in FocusLock.focusLockDict)
                {
                    if (w.Value.win.lastUpdated < globalTimeTics - 4)
                    {
                        FocusLock.FreeLock(w.Key, 1);
                        w.Value.win.OnDestroy();
                        break;
                    }
                }
            }
        }
        void FixedUpdate()
        {
            globalTimeTics++;

            if (HighLogic.CurrentGame.Parameters.CustomParams <CTB>().focusFollowsclick)
            {
                if (FocusLock.focusLockDict.Count > 0)
                {
                    //Log.Info("CBTGlobalMonitor.FixedUpate, focusFollowsClick, count: " + ClickThruBlocker.focusLockDict.Count + ", timeTics: " + timeTics);
                    foreach (var w in FocusLock.focusLockDict)
                    {
                        // Log.Info("CBTGlobalMonitor.FixedUpate,  lockName: " + w.Key + ", lastUpdated: " + w.Value.win.lastUpdated);
                        if (w.Value.win.lastUpdated < globalTimeTics - 4)
                        {
                            Log.Info("CBTGlobalMonitor.FixedUpate, FreeLock  lockName: " + w.Key + ", lastUpdated: " + w.Value.win.lastUpdated);
                            FocusLock.FreeLock(w.Key, 1);
                            w.Value.win.OnDestroy();
                            break;
                        }
                    }
                }
            }
        }
            //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
            }