Exemple #1
0
 void Lock(bool activate, ControlTypes Ctrl)
 {
     if (HighLogic.LoadedSceneIsEditor)
     {
         if (activate)
         {
             EditorLogic.fetch.Lock(true, true, true, "EditorLock" + RegisterToolbar.MOD);
         }
         else
         {
             EditorLogic.fetch.Unlock("EditorLock" + RegisterToolbar.MOD);
         }
     }
     if (activate)
     {
         InputLockManager.SetControlLock(Ctrl, "Lock" + RegisterToolbar.MOD);
     }
     else
     {
         InputLockManager.RemoveControlLock("Lock" + RegisterToolbar.MOD);
     }
     if (InputLockManager.GetControlLock("Lock" + RegisterToolbar.MOD) != ControlTypes.None)
     {
         InputLockManager.RemoveControlLock("Lock" + RegisterToolbar.MOD);
     }
     if (InputLockManager.GetControlLock("EditorLock" + RegisterToolbar.MOD) != ControlTypes.None)
     {
         InputLockManager.RemoveControlLock("EditorLock" + RegisterToolbar.MOD);
     }
     Log("Lock " + activate, "QGUI");
 }
Exemple #2
0
        /// <summary>
        /// Call to each IFlightControlParameter to update the flight controls.  This is called during OnPreAutopilotUpdate
        /// </summary>
        /// <param name="c"></param>
        private void UpdateAutopilot(FlightCtrlState c)
        {
            // Lock out controls if insufficient avionics in RP-0.
            ControlTypes RP0Lock = InputLockManager.GetControlLock("RP0ControlLocker");

            if (RP0Lock != 0)
            {
                return;
            }

            if (Vessel != null)
            {
                if (childParts.Count > 0)
                {
                    foreach (var parameter in flightControlParameters.Values)
                    {
                        if (parameter.Enabled && parameter.IsAutopilot)
                        {
                            Vessel ves = parameter.GetResponsibleVessel();
                            if (ves != null && ves.id != Vessel.id)
                            {
                                // This is a "should never see this" error - being logged in case a user
                                // has problems and reports a bug.
                                SafeHouse.Logger.LogError(string.Format("kOS Autopilot on wrong vessel: {0} != {1}",
                                                                        parameter.GetShared().Vessel.id, Vessel.id));
                                foundWrongVesselAutopilot = true;
                            }
                            parameter.UpdateAutopilot(c);
                        }
                    }
                }
            }
        }
        public void OnDestroy()
        {
            //if (!CompatibilityChecker.IsCompatible())
            //return;

            GameEvents.onVesselCreate.Remove(OnVesselCreate);
            GameEvents.onVesselWasModified.Remove(OnVesselWasModified);

            GameEvents.onVesselGoOffRails.Remove(OnVesselOffRails);

            GameEvents.onVesselGoOnRails.Remove(OnVesselOnRails);
            GameEvents.onVesselDestroy.Remove(OnVesselOnRails);

            GameEvents.onPartDestroyed.Remove(OnPartDestroyed);
            GameEvents.onPartDie.Remove(OnPartDestroyed);

            if (InputLockManager.GetControlLock("KJRLoadLock") == ControlTypes.ALL_SHIP_CONTROLS)
            {
                InputLockManager.RemoveControlLock("KJRLoadLock");
            }

            updatedVessels          = null;
            vesselOffRails          = null;
            vesselJointStrengthened = null;
            multiJointManager       = null;
        }
Exemple #4
0
        /// <summary>
        /// Applies or removes the lock
        /// </summary>
        /// <param name="Apply">Which way are we going</param>
        internal 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("IRGUILockOfEditor") == ControlTypes.EDITOR_LOCK))
                {
#if DEBUG
                    Debug.Log(String.Format("[IR GUI] AddingLock-{0}", "IRGUILockOfEditor"));
#endif
                    InputLockManager.SetControlLock(ControlTypes.EDITOR_LOCK, "IRGUILockOfEditor");
                }
            }
            //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("IRGUILockOfEditor") == ControlTypes.EDITOR_LOCK)
                {
#if DEBUG
                    Debug.Log(String.Format("[IR GUI] Removing-{0}", "IRGUILockOfEditor"));
#endif
                    InputLockManager.RemoveControlLock("IRGUILockOfEditor");
                }
            }
        }
Exemple #5
0
 internal static void Lock(bool activate, ControlTypes Ctrl)
 {
     if (HighLogic.LoadedSceneIsEditor)
     {
         if (activate)
         {
             if (InputLockManager.GetControlLock("EditorLock" + QVars.MOD) == ControlTypes.None)
             {
                 EditorLogic.fetch.Lock(true, true, true, "EditorLock" + QVars.MOD);
             }
         }
         else
         {
             if (InputLockManager.GetControlLock("EditorLock" + QVars.MOD) != ControlTypes.None)
             {
                 EditorLogic.fetch.Unlock("EditorLock" + QVars.MOD);
             }
         }
     }
     if (activate)
     {
         if (InputLockManager.GetControlLock("Lock" + QVars.MOD) == ControlTypes.None)
         {
             InputLockManager.SetControlLock(Ctrl, "Lock" + QVars.MOD);
         }
         return;
     }
     if (InputLockManager.GetControlLock("Lock" + QVars.MOD) != ControlTypes.None)
     {
         InputLockManager.RemoveControlLock("Lock" + QVars.MOD);
     }
 }
Exemple #6
0
        public virtual void SetVisible(bool newValue)
        {
            this.visible = newValue;

            if (newValue)
            {
                DialogManager.Instance.RegisterWindow(this);
                InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, "WindowLock" + this.windowId);
                if (HighLogic.LoadedSceneIsEditor)
                {
                    EditorLogic.fetch.Lock(true, true, true, "WindowLock" + this.windowId);
                    InputLockManager.SetControlLock(ControlTypes.EDITOR_ICON_HOVER |
                                                    ControlTypes.EDITOR_ICON_PICK |
                                                    ControlTypes.EDITOR_TAB_SWITCH |
                                                    ControlTypes.EDITOR_PAD_PICK_PLACE |
                                                    ControlTypes.EDITOR_PAD_PICK_COPY |
                                                    ControlTypes.EDITOR_GIZMO_TOOLS |
                                                    ControlTypes.EDITOR_ROOT_REFLOW |
                                                    ControlTypes.EDITOR_SYM_SNAP_UI |
                                                    ControlTypes.EDITOR_UNDO_REDO, "EditorLock" + this.windowId);
                }
            }
            else
            {
                DialogManager.Instance.UnregisterWindow(this);
                if (InputLockManager.GetControlLock("WindowLock" + this.windowId) != ControlTypes.None)
                {
                    InputLockManager.RemoveControlLock("WindowLock" + this.windowId);
                }
                if (InputLockManager.GetControlLock("EditorLock" + this.windowId) != ControlTypes.None)
                {
                    InputLockManager.RemoveControlLock("EditorLock" + this.windowId);
                }
            }
        }
Exemple #7
0
 internal void RemoveInputLock()
 {
     if (InputLockManager.GetControlLock("KSPTipsControlLock") != ControlTypes.None)
     {
         LogFormatted_DebugOnly("Removing-{0}", "KSPTipsControlLock");
         InputLockManager.RemoveControlLock("KSPTipsControlLock");
     }
     InputLockExists = false;
 }
Exemple #8
0
 /// <summary>
 /// Set a input lock to keep typing to this window
 /// </summary>
 public void setWindowCtrlLock()
 {
     // only if we are enabled and the controllock is not set
     if (Enabled && InputLockManager.GetControlLock("RISLockControlForWindows") == ControlTypes.None)
     {
         InputLockManager.SetControlLock(ControlTypes.ALL_SHIP_CONTROLS, "RISLockControlForWindows");
         InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS, "RISLockControlCamForWindows");
     }
 }
Exemple #9
0
 /// <summary>
 /// Remove the input lock
 /// </summary>
 public void removeWindowCtrlLock()
 {
     // only if the controllock is set
     if (InputLockManager.GetControlLock("KPULockControlForWindows") != ControlTypes.None)
     {
         InputLockManager.RemoveControlLock("KPULockControlForWindows");
         InputLockManager.RemoveControlLock("KPULockControlCamForWindows");
     }
 }
Exemple #10
0
 internal void RemoveInputLock()
 {
     Log.Info("RemoveInputLock");
     if (InputLockManager.GetControlLock("CraftImportLock") != ControlTypes.None)
     {
         //LogFormatted_DebugOnly("Removing-{0}", "TWPControlLock");
         InputLockManager.RemoveControlLock("CraftImportLock");
     }
     Input.ResetInputAxes();
     //InputLockExists = false;
 }
 protected override void Update()
 {
     if (Visible && InputLockManager.GetControlLock("SettingsWindowMain") == ControlTypes.None)
     {
         InputLockManager.SetControlLock(ControlTypes.KSC_ALL, "SettingsWindowMain");
     }
     else if (!Visible)
     {
         InputLockManager.RemoveControlLock("SettingsWindowMain");
     }
 }
Exemple #12
0
 //modified from Kerbal Alarm Clock mod
 public static void LockControls(string LockName, bool Lock = true)
 {
     if (Lock && InputLockManager.GetControlLock(LockName) != ControlTypes.ALLBUTCAMERAS)
     {
         InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, LockName);
     }
     else if (!Lock && InputLockManager.GetControlLock(LockName) == ControlTypes.ALLBUTCAMERAS)
     {
         InputLockManager.RemoveControlLock(LockName);
     }
 }
        void OnDestroy()
        {
            this.Log("OnDestroy");
            button.Destroy();

            // Make sure we remove our locks
            if (InputLockManager.GetControlLock(lockName) == desiredLock)
            {
                InputLockManager.RemoveControlLock(lockName);
            }
        }
Exemple #14
0
 void Update()
 {
     // If the LaunchDialog isn't being displayed, but the Controls are locked
     // The reason we are doing this instead of just releasing the locks directly is so that the user doesn't
     // 'click-through' to any parts underneath the popup window
     if (LaunchDialog == null && InputLockManager.GetControlLock("KCT_EDITOR_LAUNCH_B") != ControlTypes.None)
     {
         // Release the locks
         ReleaseControlLock();
     }
 }
Exemple #15
0
        /// <summary>
        /// Draw UI
        /// </summary>
        public void OnGUI()
        {
            if (gamePaused || globalHidden)
            {
                return;
            }

            if (MapView.MapIsEnabled && HighLogic.LoadedSceneIsFlight && wayPoints.Count > 0)
            {
                GLUtils.DrawCurve(wayPoints);
            }

            if (InputLockManager.GetControlLock("BonVoyageInputLock") != 0)
            {
                GUILayout.BeginArea(labelRect);
                GUILayout.Label("Bon Voyage control lock active", labelStyle);
                GUILayout.EndArea();
            }

            if (!guiVisible && !rcVisible)
            {
                return;
            }

            if (useKSPSkin)
            {
                GUI.skin = HighLogic.Skin;
            }
            else
            {
                GUI.skin = UnityEngine.GUI.skin;
            }

            if (guiVisible)
            {
                guiRect = Layout.Window(
                    guiId,
                    guiRect,
                    DrawGUI,
                    "Bon Voyage powered rovers"
                    );
            }

            if (rcVisible)
            {
                rcRect = Layout.Window(
                    rcGuiId,
                    rcRect,
                    DrawRcGUI,
                    "Bon Voyage control"
                    );
            }
        }
Exemple #16
0
        /// <summary>
        /// Call to each IFlightControlParameter to update the flight controls.  This is called during OnPreAutopilotUpdate
        /// </summary>
        /// <param name="c"></param>
        private void UpdateAutopilot(FlightCtrlState c)
        {
            // Lock out controls if insufficient avionics in RP-0.
            ControlTypes RP0Lock = InputLockManager.GetControlLock("RP0ControlLocker");

            if (RP0Lock != 0)
            {
                return;
            }

            bool isSuppressing = SafeHouse.Config.SuppressAutopilot;

            AutopilotMsgManager.Instance.TurnOffSuppressMessage(this);
            AutopilotMsgManager.Instance.TurnOffSasMessage(this);

            if (Vessel != null)
            {
                if (childParts.Count > 0)
                {
                    foreach (var parameter in flightControlParameters.Values)
                    {
                        if (parameter.Enabled && parameter.IsAutopilot)
                        {
                            Vessel ves = parameter.GetResponsibleVessel();
                            if (ves != null && ves.id != Vessel.id)
                            {
                                // This is a "should never see this" error - being logged in case a user
                                // has problems and reports a bug.
                                SafeHouse.Logger.LogError(string.Format("kOS Autopilot on wrong vessel: {0} != {1}",
                                                                        parameter.GetShared().Vessel.id, Vessel.id));
                                foundWrongVesselAutopilot = true;
                            }
                            if (isSuppressing)
                            {
                                if (parameter.SuppressAutopilot(c))
                                {
                                    AutopilotMsgManager.Instance.TurnOnSuppressMessage(this);
                                }
                            }
                            else
                            {
                                parameter.UpdateAutopilot(c);

                                if (parameter.FightsWithSas && vessel.ActionGroups[KSPActionGroup.SAS])
                                {
                                    AutopilotMsgManager.Instance.TurnOnSasMessage(this);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #17
0
        void OnDestroy()
        {
            this.Log("OnDestroy");

            GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady);
            ApplicationLauncher.Instance.RemoveModApplication(_appLauncherButton);

            // Make sure we remove our locks
            if (InputLockManager.GetControlLock(lockName) == desiredLock)
            {
                InputLockManager.RemoveControlLock(lockName);
            }
        }
Exemple #18
0
        void OnMouseEnter()
        {
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }
            if (!initialized)
            {
                Initialize();
            }

            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                if (!KerbalKonstructs.enableInflightHighlight && facType != KKFacilityType.Merchant)
                {
                    return;
                }
                try
                {
                    if (staticInstance.myFacilities.First().isOpen)
                    {
                        staticInstance.HighlightObject(new Color(0.4f, 0.9f, 0.4f, 0.5f));
                    }
                    else
                    {
                        staticInstance.HighlightObject(new Color(0.9f, 0.4f, 0.4f, 0.5f));
                    }
                }
                catch
                {
                    Destroy(this);
                }
            }

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER && !(InputLockManager.GetControlLock("KK_KSC") == ControlTypes.UI))
            {
                if (spaceCenterBlackList.Contains(facType))
                {
                    return;
                }

                try
                {
                    staticInstance.HighlightObject(new Color(0.7f, 0.7f, 0.7f));
                }
                catch
                {
                    Destroy(this);
                }
            }
        }
Exemple #19
0
        /// <summary>
        /// Set a input lock to keep typing to this window
        /// </summary>
        public void setWindowCtrlLock()
        {
            // only if we are enabled and the controllock is not set
            if (Enabled && InputLockManager.GetControlLock("KPULockControlForWindows") == ControlTypes.None)
            {
                InputLockManager.SetControlLock(ControlTypes.ALL_SHIP_CONTROLS, "KPULockControlForWindows");
                InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS, "KPULockControlCamForWindows");

                if (!KPUCore.Instance.ctrlLockAddon.IsLockSet())
                {
                    KPUCore.Instance.ctrlLockAddon.SetFullLock("KPU");
                }
            }
        }
Exemple #20
0
        /// <summary>
        /// Remove the input lock
        /// </summary>
        public void removeWindowCtrlLock()
        {
            // only if the controllock is set
            if (InputLockManager.GetControlLock("KPULockControlForWindows") != ControlTypes.None)
            {
                InputLockManager.RemoveControlLock("KPULockControlForWindows");
                InputLockManager.RemoveControlLock("KPULockControlCamForWindows");

                if (KPUCore.Instance.ctrlLockAddon.IsLockSet("KPU"))
                {
                    KPUCore.Instance.ctrlLockAddon.UnsetFullLock("KPU");
                }
            }
        }
Exemple #21
0
 private void Lock(bool activate, ControlTypes Ctrl = 0)
 {
     if (activate)
     {
         InputLockManager.SetControlLock(Ctrl, "Lock" + MOD);
         return;
     }
     InputLockManager.RemoveControlLock("Lock" + MOD);
     if (InputLockManager.GetControlLock("Lock" + MOD) != 0)
     {
         InputLockManager.RemoveControlLock("Lock" + MOD);
     }
     Log("Lock: " + activate, "QGUI");
 }
Exemple #22
0
        public void OnDestroy()
        {
            Log.Info("destroying CraftImport");

            if (InputLockManager.GetControlLock("CraftImportLock") != ControlTypes.None)
            {
                InputLockManager.RemoveControlLock("CraftImportLock");
            }

            MainMenuGui.Instance.toolbarControl.OnDestroy();
            Destroy(MainMenuGui.Instance.toolbarControl);

            configuration.Save();
        }
Exemple #23
0
        void InputLockMonitor()
        {
            MouseOverWindow = Visible && WindowRect.Contains(Event.current.mousePosition);

            //If the setting is on and the mouse is over any window then lock it
            if (MouseOverWindow && !InputLockExists)
            {
                Boolean AddLock = false;
                switch (HighLogic.LoadedScene)
                {
                case GameScenes.SPACECENTER: AddLock = !(InputLockManager.GetControlLock("KSPTipsControlLock") != ControlTypes.None); break;

                case GameScenes.EDITOR: AddLock = !(InputLockManager.GetControlLock("KSPTipsControlLock") != ControlTypes.None); break;

                case GameScenes.FLIGHT: AddLock = !(InputLockManager.GetControlLock("KSPTipsControlLock") != ControlTypes.None); break;

                case GameScenes.TRACKSTATION:
                    break;

                default:
                    break;
                }
                if (AddLock)
                {
                    LogFormatted_DebugOnly("AddingLock-{0}", "KSPTipsControlLock");

                    switch (HighLogic.LoadedScene)
                    {
                    case GameScenes.SPACECENTER: InputLockManager.SetControlLock(ControlTypes.KSC_FACILITIES, "KSPTipsControlLock"); break;

                    case GameScenes.EDITOR: InputLockManager.SetControlLock(ControlTypes.EDITOR_LOCK, "KSPTipsControlLock"); break;

                    case GameScenes.FLIGHT: InputLockManager.SetControlLock(ControlTypes.ALL_SHIP_CONTROLS, "KSPTipsControlLock"); break;

                    case GameScenes.TRACKSTATION:
                        break;

                    default:
                        break;
                    }
                    InputLockExists = true;
                }
            }
            //Otherwise make sure the lock is removed
            else if (!MouseOverWindow && InputLockExists)
            {
                RemoveInputLock();
            }
        }
Exemple #24
0
        private void OnInputLocksModified(GameEvents.FromToAction <ControlTypes, ControlTypes> data)
        {
            // Detect if a control lock is active
            bool controlIsLocked = InputLockManager.GetControlLock("RP0ControlLocker") != 0;

            // Keeps track if we've ever lost control
            controlHasLapsed |= controlIsLocked;

            // Differing logic depending on parameter properties
            parameterIsSatisified = continuousControlRequired ? !controlHasLapsed && !controlIsLocked : !controlIsLocked;

            // Refresh title in contracts screen in case we've had a lapse of control with continousControlRequired true
            GetTitle();

            // Have CC re-evaluate the parameter state (will call VesselMeetsCondition() internally)
            CheckVessel(FlightGlobals.ActiveVessel);
        }
 void Update()
 {
     if (window.IsVisible() && window.Contains(Event.current.mousePosition))
     {
         if (InputLockManager.GetControlLock(lockName) != desiredLock)
         {
             InputLockManager.SetControlLock(desiredLock, lockName);
         }
     }
     else
     {
         if (InputLockManager.GetControlLock(lockName) == desiredLock)
         {
             InputLockManager.RemoveControlLock(lockName);
         }
     }
 }
Exemple #26
0
        public void OnDestroy()
        {
            GameEvents.onVesselWasModified.Remove(OnVesselWasModified);
            GameEvents.onVesselGoOffRails.Remove(OnVesselOffRails);
            GameEvents.onVesselGoOnRails.Remove(OnVesselOnRails);
            GameEvents.onVesselDestroy.Remove(OnVesselOnRails);

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

            multiJointManager.OnDestroy();
            multiJointManager = null;
        }
Exemple #27
0
        static void Lock(bool activate, ControlTypes Ctrl = ControlTypes.None)
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                FlightDriver.SetPause(activate);
                if (activate)
                {
                    InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.MAP, "Lock" + RegisterToolbar.MOD);
                    return;
                }
            }
            else if (HighLogic.LoadedSceneIsEditor)
            {
                if (activate)
                {
                    EditorLogic.fetch.Lock(true, true, true, "EditorLock" + RegisterToolbar.MOD);
                    return;
                }
                else
                {
                    EditorLogic.fetch.Unlock("EditorLock" + RegisterToolbar.MOD);
                }
            }
            if (activate)
            {
                InputLockManager.SetControlLock(Ctrl, "Lock" + RegisterToolbar.MOD);
                return;
            }
            else
            {
                InputLockManager.RemoveControlLock("Lock" + RegisterToolbar.MOD);

                if (InputLockManager.GetControlLock("Lock" + RegisterToolbar.MOD) != ControlTypes.None)
                {
                    InputLockManager.RemoveControlLock("Lock" + RegisterToolbar.MOD);
                }
                if (InputLockManager.GetControlLock("EditorLock" + RegisterToolbar.MOD) != ControlTypes.None)
                {
                    InputLockManager.RemoveControlLock("EditorLock" + RegisterToolbar.MOD);
                }
                Log("Lock: " + activate, "QGUI");
            }
        }
 void Update()
 {
     if (_visible)
     {
         GUI.FocusControl("kalculator");
         InputLockManager.SetControlLock(BLOCK_ALL_CONTROLS, "kalculator");
         GetInputFromCalc();
     }
     else
     {
         if (InputLockManager.GetControlLock("kalculator") == (BLOCK_ALL_CONTROLS))
         {
             InputLockManager.RemoveControlLock("kalculator");
         }
     }
     if (Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(_keybind))
     {
         Toggle();
     }
 }
        void Update()
        {
            const string       lockName    = "TACLS_EditorLock";
            const ControlTypes desiredLock = ControlTypes.EDITOR_SOFT_LOCK | ControlTypes.EDITOR_UI | ControlTypes.EDITOR_LAUNCH;

            if (window.IsVisible() && window.Contains(Event.current.mousePosition))
            {
                if (InputLockManager.GetControlLock(lockName) != desiredLock)
                {
                    InputLockManager.SetControlLock(desiredLock, lockName);
                }
            }
            else
            {
                if (InputLockManager.GetControlLock(lockName) == desiredLock)
                {
                    InputLockManager.RemoveControlLock(lockName);
                }
            }
        }
        void Update()
        {
            const string       lockName    = "TACLS_SpaceCenterLock";
            const ControlTypes desiredLock = ControlTypes.KSC_FACILITIES;

            if (configWindow.IsVisible() && configWindow.Contains(Event.current.mousePosition))
            {
                if (InputLockManager.GetControlLock(lockName) != desiredLock)
                {
                    InputLockManager.SetControlLock(desiredLock, lockName);
                }
            }
            else
            {
                if (InputLockManager.GetControlLock(lockName) == desiredLock)
                {
                    InputLockManager.RemoveControlLock(lockName);
                }
            }
        }