/// <summary> /// Lock the model if our own window is shown and has cursor focus to prevent click-through. /// Code adapted from FAR Editor GUI /// </summary> private void PreventClickThrough() { bool cursorInGUI = false; EditorLogic EdLogInstance = EditorLogic.fetch; if (!EdLogInstance) { return; } if (showRcsWindow) { cursorInGUI = windowRect.Contains(GetMousePos()); } if (cursorInGUI) { if (!CameraMouseLook.GetMouseLook()) { EdLogInstance.Lock(false, false, false, "BDARCSLOCK"); } else { EdLogInstance.Unlock("BDARCSLOCK"); } } else if (!cursorInGUI) { EdLogInstance.Unlock("BDARCSLOCK"); } }
/// <summary> Lock the model if our own window is shown and has cursor focus to prevent click-through. </summary> private void PreventClickThrough() { bool cursorInGUI = false; EditorLogic EdLogInstance = EditorLogic.fetch; if (!EdLogInstance) { return; } if (showGUI) { guiRect = GUILayout.Window(this.GetHashCode(), guiRect, OverallSelectionGUI, Localizer.Format("FAREditorTitle")); guiRect = GUIUtils.ClampToScreen(guiRect); cursorInGUI = guiRect.Contains(GUIUtils.GetMousePos()); } if (cursorInGUI) { // TODO 1.2: verify what EditorTooltip is/was, it cannot be found //if (EditorTooltip.Instance) // EditorTooltip.Instance.HideToolTip(); if (!CameraMouseLook.GetMouseLook()) { EdLogInstance.Lock(false, false, false, "FAREdLock"); } else { EdLogInstance.Unlock("FAREdLock"); } } else if (!cursorInGUI) { EdLogInstance.Unlock("FAREdLock"); } }
void OnGUI() { //Make this an option if (useKSPSkin) { GUI.skin = HighLogic.Skin; } bool cursorInGUI = false; EditorLogic EdLogInstance = EditorLogic.fetch; if (showGUI) { guiRect = GUILayout.Window(this.GetHashCode(), guiRect, OverallSelectionGUI, "FAR Analysis"); guiRect = GUIUtils.ClampToScreen(guiRect); cursorInGUI = guiRect.Contains(GUIUtils.GetMousePos()); } if (cursorInGUI) { EditorTooltip.Instance.HideToolTip(); if (!CameraMouseLook.GetMouseLook()) { EdLogInstance.Lock(false, false, false, "FAREdLock"); } else { EdLogInstance.Unlock("FAREdLock"); } } else if (!cursorInGUI) { EdLogInstance.Unlock("FAREdLock"); } }
/// <summary> Lock the model if our own window is shown and has cursor focus to prevent click-through. </summary> private void PreventClickThrough() { bool cursorInGUI = false; EditorLogic EdLogInstance = EditorLogic.fetch; if (!EdLogInstance) { return; } if (showGUI) { guiRect = GUILayout.Window(GetHashCode(), guiRect, OverallSelectionGUI, Localizer.Format("FAREditorTitle")); guiRect = GUIUtils.ClampToScreen(guiRect); cursorInGUI = guiRect.Contains(GUIUtils.GetMousePos()); } if (cursorInGUI) { if (!CameraMouseLook.GetMouseLook()) { EdLogInstance.Lock(false, false, false, "FAREdLock"); } else { EdLogInstance.Unlock("FAREdLock"); } } else { EdLogInstance.Unlock("FAREdLock"); } }
void OnGUI() { if (!HighLogic.LoadedSceneIsEditor || BDACategory == null) { return; } bool shouldOpen = BDArmorySettings.SHOW_CATEGORIES && FilterByFunctionCategory.button.activeButton.Value && BDACategory.button.activeButton.Value; if (shouldOpen && !expanded) { ExpandPartSelector(offset); expanded = true; } else if (!shouldOpen && expanded) { ExpandPartSelector(-offset); expanded = false; } if (SettingsOpen && Event.current.type == EventType.MouseDown && !SettingsWindow.Contains(Event.current.mousePosition)) { SettingsOpen = false; BDArmorySetup.SaveConfig(); } if (SettingsOpen) { SettingsWindow = GUI.Window(9476026, SettingsWindow, DrawSettingsWindow, "", BDArmorySetup.BDGuiSkin.window); } if (EditorLogic.fetch != null) { if (SettingsOpen && SettingsWindow.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)) && !CameraMouseLook.GetMouseLook()) { EditorLogic.fetch.Lock(false, false, false, "BDA_CATEGORY_LOCK"); } else { EditorLogic.fetch.Unlock("BDA_CATEGORY_LOCK"); } } }
public void LateUpdate() { if (!cameraObject && Input.GetKeyDown(KeyCode.Keypad0)) { Init(); } if (cameraObject) { if (Input.GetKeyDown(KeyCode.Keypad0)) { isInMap = !isInMap; if (isInMap) { InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS, "SideView"); } else { InputLockManager.RemoveControlLock("SideView"); } } int prevTargetIdx = targetIdx; if (isInMap && GameSettings.CAMERA_RESET.GetKeyDown()) { ResetTarget(); } if (isInMap && Input.GetKeyDown(KeyCode.Tab) && !Input.GetKey(KeyCode.LeftShift)) { targetIdx = (targetIdx + 1) % PlanetariumCamera.fetch.targets.Count; } if (isInMap && Input.GetKeyDown(KeyCode.Tab) && Input.GetKey(KeyCode.LeftShift)) { targetIdx = (targetIdx - 1) % PlanetariumCamera.fetch.targets.Count; } if (targetIdx < 0 || targetIdx >= PlanetariumCamera.fetch.targets.Count) { ResetTarget(); } if (prevTargetIdx != targetIdx || focus.transform.parent == null) { MapObject target = PlanetariumCamera.fetch.targets[targetIdx]; focus.transform.parent = target.transform; if (target.vessel != null) { minDistance = (float)(0.5 * target.vessel.orbit.semiMajorAxis * ScaledSpace.InverseScaleFactor); } if (target.celestialBody != null) { minDistance = (float)(1.5 * target.celestialBody.sphereOfInfluence * ScaledSpace.InverseScaleFactor); } minDistance = Mathf.Max(minDistance, PlanetariumCamera.fetch.minDistance); } focus.transform.localPosition = Vector3.zero; if (isInMap && GameSettings.AXIS_MOUSEWHEEL.GetAxis() != 0.0f) { distance = distance * (1f - (GameSettings.AXIS_MOUSEWHEEL.GetAxis() * 1.2f)); } distance = Mathf.Clamp(distance, minDistance, PlanetariumCamera.fetch.maxDistance); cameraObject.transform.localPosition = distance * Vector3.back; cameraObject.transform.localRotation = Quaternion.identity; if (isInMap && CameraMouseLook.GetMouseLook()) { camHdg = camHdg + Input.GetAxis("Mouse X") * PlanetariumCamera.fetch.orbitSensitivity; camPitch = camPitch - Input.GetAxis("Mouse Y") * PlanetariumCamera.fetch.orbitSensitivity; } camPitch = Mathf.Clamp(camPitch, -0.5f * Mathf.PI, 0.5f * Mathf.PI); Quaternion hdgRot = Quaternion.AngleAxis(camHdg * Mathf.Rad2Deg + (float)Planetarium.InverseRotAngle, Vector3.up); Quaternion pitchRot = Quaternion.AngleAxis(camPitch * Mathf.Rad2Deg, Vector3.right); focus.transform.rotation = hdgRot * pitchRot; } }
private void EnableMouseLook() { _mouseLook = new CameraMouseLook(); _mouseLook.Init(); }