public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate) { base.HandleInput(input, receivedFocusInThisUpdate); if (MyGuiInput.ENABLE_DEVELOPER_KEYS) { if (input.IsNewKeyPress(Keys.C) && input.IsAnyCtrlKeyPressed()) { CopySector(); } if (input.IsNewKeyPress(Keys.V) && input.IsAnyCtrlKeyPressed()) { PasteSector(); } } if (MyFakes.DRAW_FACTION_AREAS_IN_SOLAR_MAP) { MySolarMapAreaInput.HandleInput(m_solarMapRender, input, receivedFocusInThisUpdate); } float rollIndicator = input.GetRoll(); Vector2 rotationIndicator = Vector2.Zero; if (input.IsNewRightMousePressed() && MyVideoModeManager.IsHardwareCursorUsed()) { m_oldRotationIndicator = input.GetRotation(); } if (input.IsRightMousePressed()) { if (MyVideoModeManager.IsHardwareCursorUsed()) { rotationIndicator = m_oldRotationIndicator - input.GetRotation(); m_oldRotationIndicator = input.GetRotation(); } else rotationIndicator = input.GetRotation(); } Vector3 moveIndicator = input.GetPositionDelta(); if (input.IsKeyPress(Keys.Left)) moveIndicator.X = -1; if (input.IsKeyPress(Keys.Right)) moveIndicator.X = 1; if (input.IsKeyPress(Keys.Up)) moveIndicator.Z = -1; if (input.IsKeyPress(Keys.Down)) moveIndicator.Z = 1; m_camera.Zoom(input.DeltaMouseScrollWheelValue()); m_camera.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, 1); bool sectorChanged = false; if (m_lastSector != m_camera.TargetSector) { sectorChanged = true; m_lastSector = m_camera.TargetSector; } MySolarSystemMapNavigationMark navigationMarkUnderMouse = GetNearestNavigationMarkUnderMouseCursor(); const float maxHeightForEnter = MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS * 16; if (sectorChanged) // we have moved camera so deselect sector { m_selectedSector = null; } // tool tips if (m_lastNavigationMarkUnderMouse != navigationMarkUnderMouse) { m_toolTip.ClearToolTips(); if (navigationMarkUnderMouse != null) { m_toolTip.AddToolTip(new StringBuilder(GetSectorName(navigationMarkUnderMouse))); if (!String.IsNullOrEmpty(navigationMarkUnderMouse.Description)) { m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Description), Color.LightGray); } m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Sector.ToString()), Color.LightGray); } m_lastNavigationMarkUnderMouse = navigationMarkUnderMouse; } if (navigationMarkUnderMouse != null) { MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture()); if (input.IsNewLeftMousePressed() && !m_travelButton.IsMouseOver()) { MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick); if (m_selectedNavigationMark != null) m_selectedNavigationMark.Highlight = false; m_selectedNavigationMark = navigationMarkUnderMouse; m_selectedNavigationMark.Highlight = true; sectorChanged = true; m_slectionLocked = true; m_travelButton.Visible = false; } if (input.IsNewLeftMouseDoubleClick()) { TravelToSector(navigationMarkUnderMouse.Sector, navigationMarkUnderMouse.MissionID); } } else if (m_camera.CameraDistance < maxHeightForEnter && !m_slectionLocked) { if (MyGuiScreenGamePlay.CanTravelToSector(m_camera.TargetSector)) { //MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture()); if (m_selectedNavigationMark != null) m_selectedNavigationMark.Highlight = false; var navigationMarkUnderCamera = GetNavigationMarkUnderCamera(); if (navigationMarkUnderCamera != null && navigationMarkUnderCamera.Sector == m_camera.TargetSector) { m_selectedNavigationMark = navigationMarkUnderCamera; } else { m_selectedNavigationMark = new MySolarSystemMapNavigationMark(m_camera.TargetSector, ""); m_travelButton.Visible = false; } } else { m_selectedNavigationMark = null; } } else if (input.IsNewLeftMousePressed()) { if (m_selectedNavigationMark != null) m_selectedNavigationMark.Highlight = false; if (!m_travelButton.IsMouseOver()) { m_selectedNavigationMark = null; } m_slectionLocked = false; } else if (sectorChanged && m_camera.CameraDistance > maxHeightForEnter && !m_slectionLocked) { m_selectedNavigationMark = null; } else { MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorArrowTexture()); } if (m_selectedNavigationMark != null) { if (!m_travelButton.Visible) { m_travelButton.Text.Clear(); string text = GetSectorName(m_selectedNavigationMark); if (text.Length > 21) { text = text.Substring(0, 20); text += "…"; } m_travelButton.Text.Append(MyTextsWrapper.GetFormatString(MyTextsWrapperEnum.TravelTo, text)); // float width = MyGuiManager.GetNormalizedSize( MyGuiManager.GetFontMinerWarsBlue(), m_travelButton.Text, 1).X + 0.05f; // m_travelButton.SetSize(new Vector2(width, MyGuiConstants.BACK_BUTTON_SIZE.Y)); m_travelButton.Visible = true; } } else { m_travelButton.Visible = false; } }
//Game and editor shares this method public void MoveAndRotatePlayerOrCamera(MyGuiInput input) { // Don't move camera on screenshot if (MyGuiManager.GetScreenshot() != null) return; bool afterburner = false; float rollIndicator = input.GetRoll(); Vector2 rotationIndicator = input.GetRotation(); Vector3 moveIndicator = input.GetPositionDelta(); if (MyVideoModeManager.IsHardwareCursorUsed() && MyMinerGame.Static.IsMouseVisible) rotationIndicator = Vector2.Zero; if (IsGameActive()) if (input.IsGameControlPressed(MyGameControlEnums.AFTERBURNER)) afterburner = true; //////////////////////////////////////////////////////////////////////////////////////////////////////////// // Decide who is moving //////////////////////////////////////////////////////////////////////////////////////////////////////////// if (CameraAttachedTo == MyCameraAttachedToEnum.Spectator) { if (IsEditorActive()) { //DrawMouseCursor = false; if (MyConfig.EditorUseCameraCrosshair == false) { if (input.IsRightMousePressed() == false) { rotationIndicator = Vector2.Zero; //Summary 0000835: Editor - camera / spectator - different rotation equations -- rotate even when button is not pressed //rollIndicator = 0f; DrawMouseCursor = true; } else { if (input.IsNewRightMousePressed() && MyVideoModeManager.IsHardwareCursorUsed()) rotationIndicator = Vector2.Zero; DrawMouseCursor = false; if (MyVideoModeManager.IsHardwareCursorUsed()) MyGuiInput.SetMouseToScreenCenter(); } } else { if (input.IsNewMiddleMousePressed() && MyVideoModeManager.IsHardwareCursorUsed()) rotationIndicator = Vector2.Zero; if (MyEditorGizmo.IsRotationActive()) { rotationIndicator = Vector2.Zero; rollIndicator = 0f; DrawMouseCursor = true; } else { DrawMouseCursor = false; MyGuiInput.SetMouseToScreenCenter(); } } } MySpectator.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, (afterburner ? 1.0f : 0.35f) * (input.IsAnyCtrlKeyPressed() ? 0.3f : 1)); } if (CameraAttachedTo == MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonDynamic) { MyThirdPersonSpectator.SetState(moveIndicator, rotationIndicator, rollIndicator); MyThirdPersonSpectator.QuickZoom = input.IsAnyAltKeyPressed(); } // disable mouse rotation if we are in weapon select mode(cursor on) if ((m_selectAmmoMenu.IsEnabled && IsSelectAmmoVisible() || GetDrawMouseCursor())) rotationIndicator = Vector2.Zero; if (MySession.Static != null && MySession.Static.Player != null && !MySession.Static.Player.IsDead()) { switch (CameraAttachedTo) { case MyCameraAttachedToEnum.BotMinerShip: if (ShipForSimpleTesting != null) ShipForSimpleTesting.MoveAndRotate(moveIndicator, rotationIndicator, 0f, afterburner); break; case MyCameraAttachedToEnum.Drone: ControlledDrone.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, afterburner); break; case MyCameraAttachedToEnum.Camera: { ControlledCamera.HandleInput(rotationIndicator); } break; case MyCameraAttachedToEnum.LargeWeapon: { ControlledLargeWeapon.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, afterburner); } break; case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonDynamic: case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonStatic: case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonFollowing: case MyCameraAttachedToEnum.PlayerMinerShip: if (MySession.PlayerShip != null) MySession.PlayerShip.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, afterburner); break; } } if (MyVideoModeManager.IsHardwareCursorUsed() && GetDrawMouseCursor() == false && !MyMinerGame.Static.IsMouseVisible) MyGuiInput.SetMouseToScreenCenter(); }