コード例 #1
0
        public void HandleInput(MyGuiInput input)
        {
            if (!m_bHandleInput)
                return;

            Vector2 currPos = MyGuiManager.MouseCursorPosition;// new MyPoint(input.GetMouseX(), input.GetMouseY());

            if (currPos == m_lastPos && MyConfig.EditorUseCameraCrosshair == false)
                return;

            m_lastPos = currPos;

            MyEntity entity = GetIntersectedEntity();
            if (entity == null && m_mouseOverEntity != null)
            {
                //@ TurnOff highlightning
                HighlightEntity(m_mouseOverEntity, false);
                return;
            }

            entity = MySelectionTool.GetSelectableEntity(entity);   //this needs to be tweaked

            //@ entity is selected do not highlight!
            foreach (MyEntity sel in MyEditorGizmo.SelectedEntities)
            {
                if (sel == entity)
                    return;
            }

            //@ filter - if editor is in mode EditPrefabContainer (so it's not allowed to select other entity outside container)
            //@ i do not allow highlight entity outside of prefab container
            //@ - when editor ingamemode - dont allow to select/mouseover anything except my own container or entities in it
            MyPrefabContainer container = MyEditor.Static.GetEditedPrefabContainer();
            if (container != null && entity != null)
            {
                if (container.IsEntityFromContainer(entity) == false)
                {
                    BoundingSphere sphere = entity.WorldVolume;
                    if (container.GetIntersectionWithMaximumBoundingBox(ref sphere) == false)
                        return;
                }
            }

            if (entity == null)
            {
                //@ TurnOff highlightning
                HighlightEntity(m_mouseOverEntity, false);
                return;
            }

            if (entity != m_mouseOverEntity)
            {
                if (m_mouseOverEntity != null)
                    HighlightEntity(m_mouseOverEntity, false);
                HighlightEntity(entity, true);
            }
        }
コード例 #2
0
 public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
 {
     base.HandleInput(input, receivedFocusInThisUpdate);
     if (!input.IsGameControlPressed(m_gameControl) && m_time >= m_closeTime)
     {
         if (OnCanceled != null)
         {
             OnCanceled(this, EventArgs.Empty);
         }
         CloseScreenNow();
     }            
 }
コード例 #3
0
        public static void HandleInput(MyGuiInput input)
        {
            if (input.IsAnyAltPress())
            {
                for (int i = 0; i <= 9; i++)
                {
                    var key = (Keys)((int)Keys.NumPad0 + i);
                    if (input.IsNewKeyPress(key))
                    {
                        PressedKey(key, input.IsAnyCtrlKeyPressed());
                    }
                }

                if (input.IsNewKeyPress(Keys.Add))
                    PressedKey(Keys.Add);

                if (input.IsNewKeyPress(Keys.Subtract))
                    PressedKey(Keys.Subtract);

                if (input.IsNewKeyPress(Keys.Enter))
                    PressedKey(Keys.Enter);

                if (input.IsNewKeyPress(Keys.Delete))
                    PressedKey(Keys.Delete);

                if (input.IsKeyPress(Keys.PageDown))
                    MyRenderProfiler.PreviousFrame();

                if (input.IsKeyPress(Keys.PageUp))
                    MyRenderProfiler.NextFrame();

                if (input.IsKeyPress(Keys.Multiply))
                    PressedKey(Keys.Multiply);

                if (input.IsKeyPress(Keys.Divide))
                    PressedKey(Keys.Divide);

                if ((((input.IsKeyPress(Keys.PageDown)) ||
                    (input.IsKeyPress(Keys.PageUp))) && input.IsAnyCtrlKeyPressed())
                    ||
                    (input.IsKeyPress(Keys.Multiply) || input.IsKeyPress(Keys.Divide))
                    )

                {
                    System.Threading.Thread.Sleep(100);
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Use this to give the bot debug screen a reference to our input manager. Why? So that this screen
 /// can see the key presses that we're using to tweak the bot parameters.
 /// </summary>
 /// <param name="m_input"></param>
 internal void SetGuiInput(MyGuiInput m_input)
 {
     this.m_input = m_input;
 }
コード例 #5
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if (input.IsNewKeyPress(Keys.F1))
            {
                OnBackClick(null);
            }
        }
コード例 #6
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if ((input.IsAnyKeyPress() == true) || (input.IsAnyMousePress() == true))
            {
                CloseScreen();
            }
        }
コード例 #7
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if (!input.IsKeyPress(Keys.Tab))
            {
                CloseScreen();
            }
        }
コード例 #8
0
 public static bool HandleInput(MyGuiInput input) 
 {
     return m_screenNotifications[(int)GetCurrentScreen()].HandleInput(input);
 }
コード例 #9
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

        }
コード例 #10
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if (MyGuiScreenGamePlay.Static == null || MyGuiScreenGamePlay.Static.GetGameType() == MyGuiScreenGamePlayType.MAIN_MENU)
            {
                if (input.IsNewKeyPress(Keys.Escape))
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                    OnExitToWindowsClick(null);
                }
            }

            //if (input.IsNewKeyPress(Keys.Enter))
            //{
            //    MyGuiManager.AddScreen(new MyGuiScreenLoading(Vector2.Zero, null, null, null, new MyGuiScreenGamePlay(Vector2.Zero, null, null, null, false), MyGuiScreenGamePlay.Static));
            //    CloseScreen();
            //}

            //if (input.IsNewKeyPress(Keys.Escape))
            //{
            //    CloseScreen();
            //}

            //if (input.IsNewKeyPress(MinerWarsMath.Input.Keys.P))
            //{
            //    MyMinerGame.Static.UnloadContent();
            //}
        }
コード例 #11
0
        //public static event OnVoxelShapeSizeChanged OnVoxelShapeSize;
        //public static event OnVoxelShapeDistanceChanged OnVoxelShapeDistance;
        
        public static void HandleInput(MyGuiInput input)
        {
            // exit voxel hand using this key
            if (input.IsEditorControlNewPressed(MyEditorControlEnums.VOXEL_HAND))
            {
                SwitchEnabled();
            }

            if (m_Enabled == false || !IsAnyEditorActive()) return;

            m_applyToVoxelMap = null;

            //here possible change
            if ((input.IsEditorControlNewPressed(MyEditorControlEnums.PRIMARY_ACTION_KEY)
                || input.IsAnyShiftKeyPressed() && input.IsEditorControlPressed(MyEditorControlEnums.PRIMARY_ACTION_KEY)) &&
                (m_timeFromLastShaping >= MyVoxelConstants.VOXEL_HAND_SHAPING_INTERVAL || MyFakes.RAPID_VOXEL_HAND_SHAPING_ENABLED || MyFakes.MWBUILDER))
            {
                m_timeFromLastShaping = 0;

                if (DetachedVoxelHand != null && !input.IsKeyPress(Keys.Space))
                    return;

                MyVoxelMap voxelMap = null;

                if (VoxelHandShape is MyVoxelHandSphere)
                {
                    MyVoxelHandSphere sphere = (MyVoxelHandSphere)VoxelHandShape;
                    BoundingSphere vol = sphere.WorldVolume;
                    voxelMap = MyVoxelMaps.GetIntersectionWithSphere(ref vol, SelectedVoxelMap);
                }
                else if (VoxelHandShape is MyVoxelHandBox)
                {
                    MyVoxelHandBox box = (MyVoxelHandBox)VoxelHandShape;
                    BoundingBox localBoundingBox = box.GetLocalBoundingBox();
                    Vector3 boxWorldPosition = box.GetPosition();
                    voxelMap = MyVoxelMaps.GetIntersectionWithBox(ref localBoundingBox, ref boxWorldPosition, SelectedVoxelMap);
                }
                else if (VoxelHandShape is MyVoxelHandCuboid)
                {
                    MyVoxelHandCuboid cuboid = (MyVoxelHandCuboid)VoxelHandShape;
                    BoundingBox localBoundingBox = cuboid.GetLocalBoundingBox();
                    Vector3 boxWorldPosition = cuboid.GetPosition();
                    voxelMap = MyVoxelMaps.GetIntersectionWithBox(ref localBoundingBox, ref boxWorldPosition, SelectedVoxelMap);
                }
                else if (VoxelHandShape is MyVoxelHandCylinder)
                {
                    MyVoxelHandCylinder cylinder = (MyVoxelHandCylinder)VoxelHandShape;
                    BoundingBox localBoundingBox = cylinder.GetLocalBoundingBox();
                    Vector3 boxWorldPosition = cylinder.GetPosition();
                    voxelMap = MyVoxelMaps.GetIntersectionWithBox(ref localBoundingBox, ref boxWorldPosition, SelectedVoxelMap);
                }
                else
                {
                    System.Diagnostics.Debug.Assert(false);
                }

                if (voxelMap != null)
                {
                    m_applyToVoxelMap = voxelMap;
                }
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Change size of asteroid tool from camera
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////
                     /*
            if (input.IsAnyShiftKeyPressed())
            {
                if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue())
                {                    
                    SetVoxelSize(MyEditorVoxelHand.VoxelHandShape.GetShapeSize() - MyVoxelConstants.VOXEL_HAND_SIZE_STEP);
                }
                else if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue())
                {                    
                    SetVoxelSize(MyEditorVoxelHand.VoxelHandShape.GetShapeSize() + MyVoxelConstants.VOXEL_HAND_SIZE_STEP);
                }

            }          

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Change distance of asteroid tool from camera
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////

            if (input.IsAnyControlPress())
            {
                if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue())
                {
                    SetShapeDistance(GetShapeDistance() - MyVoxelConstants.VOXEL_HAND_DISTANCE_STEP);

                }
                else if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue())
                {
                    SetShapeDistance(GetShapeDistance() + MyVoxelConstants.VOXEL_HAND_DISTANCE_STEP);
                }
            } */
        }        
コード例 #12
0
        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;
            }

        }
コード例 #13
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            //  If autologin is true then we always must remember the login and password, otherwise autologin won't work
            if (m_autologinCheckbox.Checked) m_rememberCheckbox.Checked = true;
        }
コード例 #14
0
        public static void HandleInput(MyGuiInput input)
        {
            // -- Select Gizmo Mode -- //
            if (input.IsEditorControlNewPressed(MyEditorControlEnums.SWITCH_GIZMO_MODE) && !input.IsAnyCtrlKeyPressed())
            {
                SwitchGizmoMode();
            }

            // -- Select Gizmo Mode -- //
            if (input.IsEditorControlNewPressed(MyEditorControlEnums.SWITCH_GIZMO_MODE) && input.IsAnyCtrlKeyPressed() )
            {
                SwitchRotateSnapping();
            }



            // -- Cycle TransformationSpaces -- //
            if (input.IsEditorControlNewPressed(MyEditorControlEnums.SWITCH_GIZMO_SPACE))
            {
                if (ActiveSpace == TransformSpace.LOCAL)
                    ActiveSpace = TransformSpace.WORLD;
                else
                {
                    ActiveSpace = TransformSpace.LOCAL;
                }
            }

            // Below are options, that we can add later, but gizmo is prepared for them
            // however, key mappings will be probably changed
            // -- Cycle PivotTypes -- //
            //if (input.IsNewKeyPress(Keys.P))
            //{
            //    ActivePivot++;
            //}

            // -- Toggle PrecisionMode -- //
            //if (input.IsKeyPress(Keys.K))
            //{
            //    m_precisionMode = true;
            //}
            //else
            //{
            //    m_precisionMode = false;
            //}

            // -- Toggle Snapping -- //
            //if (MyEditor.Static.IsEditingPrefabContainer() == false)
            //{
            if (input.IsNewKeyPress(Keys.G))            
            {
                SnapEnabled = !SnapEnabled;
            }
            //}

            if (Enabled)
            {
                if (input.IsEditorControlNewPressed(MyEditorControlEnums.PRIMARY_ACTION_KEY))
                {
                    // reset for intersection (plane vs. ray)
                    m_translationDelta = Vector3.Zero;
                    m_intersectPosition = Vector3.Zero;
                    // reset for snapping
                    m_translationScaleSnapDelta = Vector3.Zero;
                    m_rotationSnapDelta = 0;
                    m_lastCursorPosition = MyGuiManager.MouseCursorPosition;
                    m_oldCursorPosition = MyGuiManager.MouseCursorPosition;
                    m_gizmoDelta = null;
                    m_gizmoStartPosition = null;
                    m_mouseStartPosition = m_lastCursorPosition;

                    m_startCameraForward = MyCamera.ForwardVector;
                    m_startCameraUp = MyCamera.UpVector;
                    m_startObjectPosition = Position;
                }

                m_lastIntersectionPosition = m_intersectPosition;
                TransformationActive = false;

                if (input.IsEditorControlPressed(MyEditorControlEnums.PRIMARY_ACTION_KEY))
                {
                    if (MyEditor.TransformLocked)
                    {
                        ActiveAxis = LastActiveAxis;
                    }

                    if (ActiveAxis != GizmoAxis.NONE)
                    {

                        //this will help to disable rectangular selection of multiple objects during object transformation with mouse
                        TransformationActive = true;

                        if (ActiveMode == GizmoMode.TRANSLATE)
                        {
                            #region Translate

                            if (HasTransformationStarted())
                            {
                                StartTransformationData();
                            }
                            //if (input.IsAnyShiftKeyPressed() && input.IsNewLeftMousePressed())
                            //{
                            //    MyEditor.Static.CopySelected(false);
                            //}
                            //else if (HasTransformationStarted())
                            //{
                            //    StartTransformationData();
                            //}

                            Vector3 delta = Vector3.Zero;

                            Vector3 worldPosition = Position;

                            if (ActiveAxis == GizmoAxis.XY)
                            {
                                GizmoTranslation(Vector3.Left, Vector3.Up, ref worldPosition);
                            }
                            else if (ActiveAxis == GizmoAxis.YZ)
                            {
                                GizmoTranslation(Vector3.Up, Vector3.Forward, ref worldPosition);
                            }
                            else if (ActiveAxis == GizmoAxis.ZX)
                            {
                                GizmoTranslation(Vector3.Left, Vector3.Forward, ref worldPosition);
                            }
                            else if (ActiveAxis == GizmoAxis.X)
                            {
                                GizmoTranslation(Vector3.Left, null, ref worldPosition);
                            }
                            else if (ActiveAxis == GizmoAxis.Y)
                            {
                                GizmoTranslation(Vector3.Up, null, ref worldPosition);
                            }
                            else if (ActiveAxis == GizmoAxis.Z)
                            {
                                GizmoTranslation(Vector3.Forward, null, ref worldPosition);
                            }

                            // When object is half distance to far, stop it's movement
                            Plane maxMovePlane = MyCamera.GetBoundingFrustum().Far;
                            maxMovePlane.D *= TRANSLATION_MAX_DISTANCE_FROM_CAMERA / MyCamera.FAR_PLANE_DISTANCE;

                            Vector3 moveVector = worldPosition - Position;
                            Ray moveRay = new Ray(Position, -moveVector);

                            float? intersection = moveRay.Intersects(maxMovePlane);

                            Vector3 cam = MyCamera.Position;

                            // Intersection found and moving object towards far clip plane
                            if (intersection.HasValue && Vector3.Dot(MyCamera.ForwardVector, moveVector) > 0 && (worldPosition - cam).Length() > Math.Abs(maxMovePlane.D))
                            {
                                Vector3 intersectionPoint = (moveRay.Position + (moveRay.Direction * intersection.Value));
                                worldPosition = intersectionPoint;
                            }

                            moveVector = worldPosition - Position;

                            // copy selected object only when moved from his original position + LMB + Shift
                            bool copySelected = (moveVector.LengthSquared() >= 0f &&
                                input.IsAnyShiftKeyPressed() &&
                                input.IsNewLeftMousePressed());

                            if (copySelected)
                            {
                                MyEditor.Static.CopySelected(false);
                            }

                            bool applyTranslation = true;

                            PrepareSafeSelectedEntitiesIterationHelper();
                            foreach (var entity in m_safeIterationHelper)
                            {
                                Vector3 newPosition = entity.GetPosition() + moveVector;

                                BoundingSphere sphere = new BoundingSphere(newPosition + entity.LocalVolumeOffset, entity.WorldVolume.Radius);
                                if (!entity.CanMoveAndRotate(newPosition, entity.GetWorldRotation()) || MyMwcSectorConstants.SECTOR_SIZE_FOR_PHYS_OBJECTS_BOUNDING_BOX.Contains(sphere) != MinerWarsMath.ContainmentType.Contains)
                                {
                                    applyTranslation = false;
                                    break;
                                }
                            }

                            if (applyTranslation)
                            {
                                PrepareSafeSelectedEntitiesIterationHelper();

                                List<MyEntity> transformedEntities = new List<MyEntity>();

                                // apply
                                foreach (MyEntity entity in m_safeIterationHelper)
                                {
                                    // skip already transformed linked entities
                                    if (transformedEntities.Contains(entity))
                                    {
                                        continue;
                                    }

                                    Vector3 newPosition = entity.GetPosition() + moveVector;

                                    //snaping after mouse over
                                    /*
                                    // Snap to grid
                                    if (SnapEnabled && ActiveSpace == TransformSpace.WORLD && !MyEditor.Static.IsLinked(entity))
                                    {
                                        SnapToGrid(ref newPosition, TranslationSnapValue);
                                    }
                                    */


                                    MoveAndRotateObject(newPosition, entity.GetWorldRotation(), entity);

                                    MyEditor.Static.FixLinkedEntities(entity, transformedEntities, null);
                                    transformedEntities.Add(entity);
                                }

                                // test if some entities are intersection
                                //CheckCollisions(m_safeIterationHelper); 
                                //MyEditor.Static.CheckAllCollidingObjects();                                
                                MyEditor.Static.HighlightCollisions(m_safeIterationHelper);

                            }

                            #endregion
                        }
                        else if (ActiveMode == GizmoMode.ROTATE)
                        {
                            #region Rotate

                            if (HasTransformationStarted()) StartTransformationData();
                            Vector2 deltaCursorPosition;
                            float delta;
                            if (!MyVideoModeManager.IsHardwareCursorUsed())
                            {
                                Vector2 minMouseCoord = MyGuiManager.GetMinMouseCoord();
                                Vector2 maxMouseCoord = MyGuiManager.GetMaxMouseCoord();

                                Vector2 newCursorPosition = MyGuiManager.MouseCursorPosition;
                                if (MyGuiManager.MouseCursorPosition.X <= minMouseCoord.X) newCursorPosition = new Vector2(maxMouseCoord.X, MyGuiManager.MouseCursorPosition.Y);
                                if (MyGuiManager.MouseCursorPosition.X >= maxMouseCoord.X) newCursorPosition = new Vector2(minMouseCoord.X, MyGuiManager.MouseCursorPosition.Y);
                                if (MyGuiManager.MouseCursorPosition.Y <= minMouseCoord.Y) newCursorPosition = new Vector2(MyGuiManager.MouseCursorPosition.X, maxMouseCoord.Y);
                                if (MyGuiManager.MouseCursorPosition.Y >= maxMouseCoord.Y) newCursorPosition = new Vector2(MyGuiManager.MouseCursorPosition.X, minMouseCoord.Y);
                                MyGuiManager.MouseCursorPosition = newCursorPosition;
                                //KeenSoftwareHouse.Library.Trace.Trace.SendMsgLastCall(MyGuiManager.MouseCursorPosition.ToString() + " " + MyGuiManager.MouseCursorPosition.ToString());

                                float deltaX = MathHelper.ToRadians(input.GetMouseXForGamePlay() - MyMinerGame.ScreenSizeHalf.X);
                                float deltaY = MathHelper.ToRadians(input.GetMouseYForGamePlay() - MyMinerGame.ScreenSizeHalf.Y);

                                deltaX = MathHelper.Clamp(deltaX, -1, 1);
                                deltaY = MathHelper.Clamp(deltaY, -1, 1);

                                delta = deltaY + deltaX;
                                Vector2 cursorDelta = Vector2.Zero;
                                if (MyGuiManager.MouseCursorPosition.Y != 0.0 && MyGuiManager.MouseCursorPosition.Y != 1.0)
                                {
                                    cursorDelta = MyGuiManager.MouseCursorPosition - m_lastCursorPosition;
                                }
                                m_inputScale = MathHelper.Clamp(Math.Abs(cursorDelta.Y) * 100, 0, 1);
                                delta *= m_inputScale;
                                m_oldCursorPosition = MyGuiManager.MouseCursorPosition;

                            }
                            else
                            {

                                Vector2 minMouseCoord = MyGuiManager.GetMinMouseCoord();
                                Vector2 maxMouseCoord = MyGuiManager.GetMaxMouseCoord();
                                Vector2 newCursorPosition = MyGuiManager.MouseCursorPosition;

                                deltaCursorPosition = MyGuiManager.MouseCursorPosition - m_oldCursorPosition;

                                if (MyGuiManager.MouseCursorPosition.X - 0.03f <= minMouseCoord.X)
                                {
                                    deltaCursorPosition = new Vector2(0, 0);
                                    newCursorPosition = new Vector2(maxMouseCoord.X - 0.05f, MyGuiManager.MouseCursorPosition.Y);
                                }
                                if (MyGuiManager.MouseCursorPosition.X + 0.03f >= maxMouseCoord.X * 0.98f)
                                {
                                    deltaCursorPosition = new Vector2(0, 0);
                                    newCursorPosition = new Vector2(minMouseCoord.X + 0.05f, MyGuiManager.MouseCursorPosition.Y);
                                }
                                if (MyGuiManager.MouseCursorPosition.Y - 0.03f <= minMouseCoord.Y)
                                {
                                    deltaCursorPosition = new Vector2(0, 0);
                                    newCursorPosition = new Vector2(MyGuiManager.MouseCursorPosition.X, maxMouseCoord.Y - 0.05f);
                                }
                                if (MyGuiManager.MouseCursorPosition.Y + 0.03f >= maxMouseCoord.Y)
                                {
                                    deltaCursorPosition = new Vector2(0, 0);
                                    newCursorPosition = new Vector2(MyGuiManager.MouseCursorPosition.X, minMouseCoord.Y + 0.05f);
                                }
                                MyGuiManager.MouseCursorPosition = newCursorPosition;

                                delta = (deltaCursorPosition.X + deltaCursorPosition.Y) * 4.0f;
                                delta = MathHelper.Clamp(delta, -2.0f, 2.0f);
                                m_oldCursorPosition = MyGuiManager.MouseCursorPosition;
                            }

                            // Allow snapping of gizmo to make it move depending on the selected grid scale
                            if (ActiveRotateSnapping!=RotateSnapping.NONE)
                            {
                                float snapValue = MathHelper.ToRadians(GetRotateSnapValue());
                                if (m_precisionMode)
                                {
                                    delta *= m_precisionModeScale;
                                    snapValue *= m_precisionModeScale;
                                }

                                m_rotationSnapDelta += delta;

                                float snapped = (int)(m_rotationSnapDelta / snapValue) * snapValue;
                                m_rotationSnapDelta -= snapped;
                                delta = snapped;
                            }
                            else if (m_precisionMode)
                            {
                                delta *= m_precisionModeScale;
                            }

                            // rotation matrix to transform - if more than one objects selected, always use world-space.
                            Matrix rot = Matrix.Identity;
                            rot.Forward = m_sceneWorld.Forward;
                            rot.Up = m_sceneWorld.Up;
                            rot.Right = m_sceneWorld.Right;

                            // Create rotation delta matrix
                            if (ActiveAxis == GizmoAxis.X)
                            {
                                rot *= Matrix.CreateFromAxisAngle(Rotation.Right, delta);
                            }
                            else if (ActiveAxis == GizmoAxis.Y)
                            {
                                rot *= Matrix.CreateFromAxisAngle(Rotation.Up, delta);
                            }
                            else if (ActiveAxis == GizmoAxis.Z)
                            {
                                rot *= Matrix.CreateFromAxisAngle(Rotation.Forward, delta);
                            }

                            // store rotation parameters so that we can calculate the difference in rotation of "before" rotation and "after"
                            CalculateYawPitchRollFromRotationDelta(rot);

                            PrepareSafeSelectedEntitiesIterationHelper();

                            List<MyEntity> transformedEntities = new List<MyEntity>();

                            // -- Apply rotation -- //
                            foreach (MyEntity entity in m_safeIterationHelper)
                            {
                                // skip already transformed linked entities
                                if (transformedEntities.Contains(entity))
                                {
                                    continue;
                                }

                                // VoxelMaps cannot be rotated
                                if (entity is MyVoxelMap == false)
                                {
                                    // use gizmo position for all PivotTypes except for object-center, it should use the entity.position instead.
                                    Vector3 newPosition;
                                    Matrix newRotation;
                                    GetRotationAndPosition(entity, rot, out newPosition, out newRotation);


                                    Matrix normalizedMat = new Matrix();
                                    normalizedMat.Right = Vector3.Normalize(newRotation.Right);
                                    normalizedMat.Forward = Vector3.Normalize(Vector3.Cross(Vector3.Normalize(newRotation.Up), normalizedMat.Right));
                                    normalizedMat.Up = Vector3.Normalize(Vector3.Cross(normalizedMat.Right, normalizedMat.Forward));
                                    normalizedMat.Translation = newRotation.Translation;
                                    normalizedMat.M44 = newRotation.M44;

                                    //KeenSoftwareHouse.Library.Trace.Trace.SendMsgLastCall("{");
                                    //KeenSoftwareHouse.Library.Trace.Trace.SendMsgLastCall(normalizedMat.ToString());
                                    //KeenSoftwareHouse.Library.Trace.Trace.SendMsgLastCall(newRotation.ToString());
                                    //KeenSoftwareHouse.Library.Trace.Trace.SendMsgLastCall("}");

                                    MoveAndRotateObject(newPosition, normalizedMat, entity);

                                    MyEditor.Static.FixLinkedEntities(entity, transformedEntities, null);
                                    transformedEntities.Add(entity);
                                }
                            }

                            SetPosition();
                            Vector3 moveVector = m_startObjectPosition - Position;
                            PrepareSafeSelectedEntitiesIterationHelper();
                            transformedEntities = new List<MyEntity>();
                            // apply
                            foreach (MyEntity entity in m_safeIterationHelper)
                            {
                                // skip already transformed linked entities
                                if (transformedEntities.Contains(entity))
                                {
                                    continue;
                                }

                                Vector3 newPosition = entity.GetPosition() + moveVector;

                                MoveAndRotateObject(newPosition, entity.GetWorldRotation(), entity);

                                MyEditor.Static.FixLinkedEntities(entity, transformedEntities, null);
                                transformedEntities.Add(entity);
                            }

                            #endregion
                        }
                    }
                }
                else
                {
                    PrepareSafeSelectedEntitiesIterationHelper();

                    foreach (MyEntity entity in m_safeIterationHelper)
                    {

                        float moveObjectDistanceInMeters = MyEditorGrid.GetGridStepInMeters();
                        float rotationAngleInRadians = MathHelper.ToRadians(GetRotationDelta());
                        Matrix entityOrientation = entity.GetWorldRotation();

                        bool isVoxelMap = entity is MyVoxelMap;

                        Vector3 entityPosition = entity.GetPosition();

                        #region Translate and Rotate with keyboard

                        Vector3 newPosition = entityPosition;
                        Matrix newRotation = entityOrientation;

                        // Keyboard translation
                        if (IsTransformationKeyPressed(input, Keys.NumPad1))
                        {
                            newPosition = GetTransformInAxis(GizmoAxis.X, entityPosition, Rotation, -moveObjectDistanceInMeters);
                        }
                        if (IsTransformationKeyPressed(input, Keys.NumPad3))
                        {
                            newPosition = GetTransformInAxis(GizmoAxis.X, entityPosition, Rotation, +moveObjectDistanceInMeters);
                        }
                        if (IsTransformationKeyPressed(input, Keys.NumPad2))
                        {
                            newPosition = GetTransformInAxis(GizmoAxis.Z, entityPosition, Rotation, +moveObjectDistanceInMeters);
                        }
                        if (IsTransformationKeyPressed(input, Keys.NumPad5))
                        {
                            newPosition = GetTransformInAxis(GizmoAxis.Z, entityPosition, Rotation, -moveObjectDistanceInMeters);

                        }
                        if (IsTransformationKeyPressed(input, Keys.NumPad9))
                        {
                            newPosition = GetTransformInAxis(GizmoAxis.Y, entityPosition, Rotation, +moveObjectDistanceInMeters);
                        }
                        if (IsTransformationKeyPressed(input, Keys.NumPad6))
                        {
                            newPosition = GetTransformInAxis(GizmoAxis.Y, entityPosition, Rotation, -moveObjectDistanceInMeters);
                        }

                        // Keyboard rotation
                        Matrix oneStepRotationDelta = Matrix.Identity;
                        if (IsTransformationKeyPressed(input, Keys.NumPad7) && !isVoxelMap)
                        {
                            oneStepRotationDelta = Matrix.CreateFromAxisAngle(Rotation.Right, rotationAngleInRadians);
                            GetRotationAndPosition(entity, oneStepRotationDelta, out newPosition, out newRotation);
                        }
                        if (IsTransformationKeyPressed(input, Keys.NumPad4) && !isVoxelMap)
                        {
                            oneStepRotationDelta = Matrix.CreateFromAxisAngle(Rotation.Up, rotationAngleInRadians);
                            GetRotationAndPosition(entity, oneStepRotationDelta, out newPosition, out newRotation);
                        }
                        if (IsTransformationKeyPressed(input, Keys.NumPad8) && !isVoxelMap)
                        {
                            oneStepRotationDelta = Matrix.CreateFromAxisAngle(Rotation.Forward, rotationAngleInRadians);
                            GetRotationAndPosition(entity, oneStepRotationDelta, out newPosition, out newRotation);
                        }

                        if (HasTransformationStarted()) StartTransformationData();

                        // Transform
                        bool translated = newPosition != entityPosition;
                        bool rotated = newRotation != entityOrientation;

                        if (translated || rotated)
                        {
                            if (translated) ActiveMode = GizmoMode.TRANSLATE;
                            if (rotated)
                            {
                                ActiveMode = GizmoMode.ROTATE;
                                if (IsDelayForSmoothMovementReached())
                                {
                                    RotationAmountInDegrees += (int)GetRotationDelta();
                                }
                                else
                                {
                                    RotationAmountInDegrees = (int)GetRotationDelta();
                                }
                            }

                            MoveAndRotateObject(newPosition, newRotation, entity);
                        }
                        #endregion
                    }


                    UpdateAxisSelection(MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(MyGuiManager.MouseCursorPosition));

                    /*
                    if (GetSnapPoint(true) == null)
                    {
                        
                    }
                    else
                    {
                        ActiveAxis = GizmoAxis.NONE;
                    }
                    */
                }

                if (HasTransformationEnded()) EndTransformationData();

                // previous is used to detect, when is right time to create undo/redo editor action(start of transform, and end of transform)
                TransformationActivePrevious = TransformationActive;
            }
            else
            {
                ActiveAxis = GizmoAxis.NONE;
            }
        }
コード例 #15
0
        /// <summary>
        /// Is any transformation key pressed
        /// </summary>
        /// <param name="input"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        static bool IsTransformationKeyPressed(MyGuiInput input, Keys key)
        {
            bool result = false;
            MyEntity entity = GetFirstSelected();
            //when the key is pressed for a longer period, allow to move object constantly in chosen direction and not only in one step
            if (input.IsKeyPress(key))
            {
                if (input.WasKeyPressed(key) == false)
                {
                    m_delayObjectMovementInMillis = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                    result = input.IsNewKeyPress(key);
                }
                else
                {
                    if (IsDelayForSmoothMovementReached())
                    {
                        result = true;
                    }
                }
            }

            if (result) TransformationActive = true;

            return result;
        }
コード例 #16
0
        /// <summary>
        /// Selects objects under mouse cursor
        /// </summary>
        public static void SelectByIntersectionLine(MyGuiInput input)
        {
            List<MyEntity> beforeSelectionObjects = SelectedEntities;
            MyEntity selectedNow = MyEntities.GetEntityUnderMouseCursor();

            //TODO solve better
            if (selectedNow != null && selectedNow.Parent is MyPrefabBase && !(selectedNow is MyWayPoint))
            {
                selectedNow = selectedNow.Parent;
            }

            //while transforming objects with mouse(using gizmo), do not deselect current selection
            if (TransformationActive == false && ActiveAxis == GizmoAxis.NONE  && !(MyGuiScreenGamePlay.Static.IsIngameEditorActive() && MyEditor.Static.GetEditedPrefabContainer() == null))
            {
                
                //Get selected prefab snap point
                // IMPORTANT: first assign snap point to local field because setter affects highlighting (ClearSelection clears highlight)
                var snapPoint = GetSnapPoint(false);
                if (snapPoint != null)
                {
                    ClearSelection();
                    SelectedSnapPoint = snapPoint;
                    return;
                }
                else
                {
                    SelectedSnapPoint = snapPoint;
                }
                
                //if nothing is selected now, clear selection
                if (selectedNow == null && !input.IsAnyCtrlKeyPressed() && !input.IsAnyShiftKeyPressed())
                {
                    ClearSelection();
                }
                else
                {
                    //if we are in conteiner editing  dont allow changes to selection outside the prefab container
                    //allow selection of container if exit is allowed
                    if (MyEditor.Static.IsEditingPrefabContainer())
                    {
                        if (selectedNow is MyPrefabBase)
                        {
                            if ((selectedNow as MyPrefabBase).Parent != MyEditor.Static.GetEditedPrefabContainer())
                            {
                                return;
                            }
                        }
                        else if (!(MyEditor.Static.GetEditedPrefabContainer() == selectedNow && !MyGuiScreenGamePlay.Static.IsIngameEditorActive()))
                        {
                            return;
                        }
                    }

                    // if CTRL isn't held, clear selection (otherwise add/remove from selection)
                    if (input.IsAnyControlPress() == false && input.IsAnyShiftPress() == false)
                    {
                        // click a waypoint multiple times: cycle among paths
                        if (selectedNow is MyWayPoint && beforeSelectionObjects.Contains(selectedNow))
                        {
                            var pathsContainingSelectedWayPoint = (selectedNow as MyWayPoint).Paths();
                            int indexOfLastPath = pathsContainingSelectedWayPoint.IndexOf(MyWayPointGraph.SelectedPath);
                            
                            ClearSelection();

                            if (pathsContainingSelectedWayPoint.Count == 0)
                            {
                                MyWayPointGraph.SelectedPath = null;
                            }
                            else
                            {
                                // select next path (or, if it was the last one, select just the vertex)
                                if (indexOfLastPath == pathsContainingSelectedWayPoint.Count - 1)
                                    MyWayPointGraph.SelectedPath = null;
                                else if (indexOfLastPath == -1)
                                    MyWayPointGraph.SelectedPath = pathsContainingSelectedWayPoint[0];
                                else
                                    MyWayPointGraph.SelectedPath = pathsContainingSelectedWayPoint[indexOfLastPath + 1];
                            }

                            if (MyWayPointGraph.SelectedPath != null)
                            {
                                // a path is selected: select waypoints from path in the correct order
                                // the clicked waypoint will try to be added again later, but will be prevented from it
                                AddEntitiesToSelection(MyWayPointGraph.SelectedPath.WayPoints);
                            }
                        }
                        else
                        {
                            ClearSelection();
                        }
                    }

                    //When editing container(selecting prefabs inside it), it should not be possible to select any objects outside container
                    if (MyEditor.Static.IsEditingPrefabContainer())
                    {
                        //Allow selection of objects inside container, but disallow all outside
                        BoundingSphere vol = selectedNow.WorldVolume;
                        if (MyEditor.Static.GetEditedPrefabContainer().GetIntersectionWithMaximumBoundingBox(ref vol) == false && (selectedNow is MyPrefabBase == false))
                        {
                            selectedNow = null;
                        }

                        // Allow selection of edited container only if exit editing mode action is allowed
                        if (selectedNow == MyEditor.Static.GetEditedPrefabContainer())
                        {
                            MyEditor.Static.ExitActivePrefabContainer();
                            AddEntityToSelection(selectedNow);
                            return;
                        }
                    }


                    // If selected item is child of the prefab and is not a prefab switch selection to the parent prefab:
                    // for weapon case:
                    if (selectedNow is MyLargeShipGunBase || selectedNow is MyLargeShipBarrelBase)
                    {
                        //selectedNow = ((MyLargeShipGunBase)selectedNow).PrefabParent;
                        selectedNow = MySelectionTool.GetSelectableEntity(selectedNow);
                    }

                    // When selected object is prefab, switch to edit mode of prefab container immediately
                    if (selectedNow is MyPrefabBase)
                    {
                        MyPrefabContainer parentContainer = (MyPrefabContainer)selectedNow.Parent;
                        MyEditor.Static.EditPrefabContainer(parentContainer);
                    }                    

                    // CTRL held: add/remove entities to/from selection
                    if (input.IsAnyControlPress() == true)
                    {
                        if (selectedNow != null)
                        {
                            if (IsEntitySelected(selectedNow))
                            {
                                RemoveEntityFromSelection(selectedNow);
                            }
                            else
                            {
                                AddEntityToSelection(selectedNow);
                            }

                            // add/remove waypoints from selected waypoint path
                            MyWayPointGraph.UpdateSelectedPath();
                        }
                    }
                    else if (!input.IsAnyShiftPress())
                    {
                        if (selectedNow != null)
                        {
                            AddEntityToSelection(selectedNow);
                            /*
                            if (selectedNow is MyPrefabLargeWeapon)
                            {
                                AddEntityToSelection(((MyPrefabLargeWeapon)selectedNow).GetGun());
                            } */
                        }
                    }
                }
                // play sound:
                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectSelect);
            }


            //There is new selection made compared to previous selection, reload control buttons
            if ((beforeSelectionObjects.Count > 0 && beforeSelectionObjects.Contains(selectedNow) == false) ||
                (beforeSelectionObjects.Count == 0 && selectedNow != null) ||
                (beforeSelectionObjects.Count > 0 && selectedNow == null))
            {
                MyEditor.Static.ReloadEditorControls = true;
            }
        }
コード例 #17
0
 public bool HandleInput(MyGuiInput input) 
 {
     bool result = false;
     foreach (MyHudNotification.MyNotification notification in m_notifications) 
     {
         if(notification.HasDefaultDisappearMessage() && input.IsGameControlPressed(MyGameControlEnums.USE))
         {
             notification.Disappear();
             result = true;
         }
     }
     return result;
 }
コード例 #18
0
    internal static void HandleInput(MySolarMapRenderer renderer, MyGuiInput input, bool receivedFocusInThisUpdate)
    {
        if (input.IsNewKeyPress(Keys.NumPad7))
        {
            center = renderer.GetTargetSector();
        }

        if (input.IsNewKeyPress(Keys.NumPad9))
        {
            point = renderer.GetTargetSector();
        }

        if (input.IsNewKeyPress(Keys.NumPad8))
        {
            System.Diagnostics.Debug.WriteLine(string.Format("MyFactions.AddFactionArea(MyMwcObjectBuilder_FactionEnum.China, new MyMwcVector3Int({0}), new MyMwcVector3Int({1}));", center, point));
            MyFactions.AddFactionArea(MyMwcObjectBuilder_FactionEnum.China, center, point);
        }

        if (input.IsNewKeyPress(Keys.NumPad4))
        {
            Debug.WriteLine(MyFactions.GetFactionBySector(renderer.GetTargetSector()));
        }
    }
コード例 #19
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            //Journal removed
            /*if (input.IsNewGameControlPressed(MyGameControlEnums.MISSION_DIALOG))
            {
                CloseScreen();
            } */
        }
コード例 #20
0
        public void Update(MyDebugSystem system, MyGuiInput input)
        {
            input.GetPressedKeys(m_pressedKeys);
            short modifier = 0;
            if (input.IsAnyAltKeyPressed()) modifier |= (short)MyShortcut.ModifierValue.Alt;
            if (input.IsAnyShiftKeyPressed()) modifier |= (short)MyShortcut.ModifierValue.Shift;
            if (input.IsAnyCtrlKeyPressed()) modifier |= (short)MyShortcut.ModifierValue.Control;

            foreach(Keys k in m_pressedKeys)
            {
                var key = (Keys)k;
                if (key == Keys.LeftAlt || key == Keys.RightAlt || key == Keys.LeftShift || key == Keys.RightShift || key == Keys.LeftControl || key == Keys.RightControl)
                    continue;

                if (input.IsNewKeyPress(key))
                    OnKeyPressed(system, key, modifier);
            }
        }
コード例 #21
0
        //  This method is called every update (but only if application has focus)
        public override void HandleUnhandledInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            //  This is protection against situation when user clicks on CONTINUE in menu, but don't release the button quickly, so in gameplay screen
            //  it continues with shoting. So in this case he must release buttons and then press again if he want to shot.
            if (m_handleInputMouseKeysReleased == false)
            {
                if ((input.IsLeftMouseReleased()) && (input.IsRightMouseReleased()))
                {
                    m_handleInputMouseKeysReleased = true;
                }
            }

            //Set if ammo select menu or config menu is enable
            m_selectAmmoMenu.IsEnabled = !m_wheelControlMenu.Visible && IsControlledPlayerShip;
            m_wheelControlMenu.IsEnable = !m_selectAmmoMenu.Visible && IsControlledPlayerShip;

            if (IsControlledPlayerShip && !m_selectAmmoMenu.IsEnabled && !m_wheelControlMenu.IsEnable)
            {
                m_selectAmmoMenu.IsEnabled = true;
            }

            //  Launch main menu
            if (!m_wheelControlMenu.Visible && !IsSelectAmmoVisible() && input.IsNewKeyPress(Keys.Escape) && !(IsEditorActive() && (EditorControls.TryExitSelected() || EditorControls.TryExitSelectionMode())))
            {
                MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);

                //Allow changing video options from game in DX version
                MyGuiScreenMainMenu.AddMainMenu(true);
                //MyGuiScreenMainMenu.AddMainMenu(false);

                DrawHud = false;

                MySystemTimer.SetMinimalResolution();
            }


            MyHudSectorBorder.SwitchToDraw();

            // Switch from player ship to ingame editor and back
            if (IsGameActive() || IsEditorActive())
            {
                if (!input.IsAnyAltPress())
                {
                    if ((input.IsNewKeyPress(Keys.NumPad0) || input.IsNewKeyPress(Keys.D0)) && (GetSessionType() == MyMwcStartSessionRequestTypeEnum.EDITOR_STORY || GetSessionType() == MyMwcStartSessionRequestTypeEnum.EDITOR_SANDBOX || GetSessionType() == MyMwcStartSessionRequestTypeEnum.EDITOR_MMO))
                    {
                        ReturnControlToPlayerShip();
                        m_invokeGameEditorSwitch = true;
                    }
                }
            }

            if (CameraAttachedTo == MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonFollowing)
            {
                if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue())
                {
                    ThirdPersonCameraDelta /= 1.1f;
                }
                else if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue())
                {
                    ThirdPersonCameraDelta *= 1.1f;
                }
            }

            if (CameraAttachedTo == MyCameraAttachedToEnum.Spectator)
            {
                if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue())
                {
                    MySpectator.SpeedMode = Math.Min(MySpectator.SpeedMode * 1.5f, MyEditorConstants.MAX_EDITOR_CAMERA_MOVE_MULTIPLIER);
                }
                else if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue())
                {
                    MySpectator.SpeedMode = Math.Max(MySpectator.SpeedMode / 1.5f, MyEditorConstants.MIN_EDITOR_CAMERA_MOVE_MULTIPLIER);
                }
            }

            if (CameraAttachedTo == MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonDynamic &&
                !m_wheelControlMenu.Visible && !IsSelectAmmoVisible())  // don't zoom if wheel or ammo menu is visible
            {
                float distance = MyThirdPersonSpectator.LookAt.Length();
                float currentDistance = (MyThirdPersonSpectator.Target - MyThirdPersonSpectator.DesiredPosition).Length();
                float newDistance = 0;

                if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue())
                {
                    newDistance = currentDistance / 1.2f;
                }
                else if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue())
                {
                    newDistance = distance * 1.2f;
                }

                if (newDistance > 0)
                {
                    // Limit distance from ship
                    newDistance = MathHelper.Clamp(newDistance, MyThirdPersonSpectator.GetMinDistance(), MyThirdPersonSpectator.MAX_DISTANCE);
                    MyThirdPersonSpectator.LookAt *= newDistance / distance;
                }

                //MyThirdPersonSpectator.LookAt = new Vector3(0, 130, 65);
            }

            #region Universal developer keys

            if (MyGuiInput.ENABLE_DEVELOPER_KEYS)
            {
                if (input.IsNewKeyPress(Keys.Multiply))
                {
                    //MyHudNotification.AddNotification(new MyHudNotification.MyNotification("Searching for most complex region..." , 3000));
                    //int[] res = MyEntities.getMostComplexCameraView(128);
                    //MyHudNotification.AddNotification(new MyHudNotification.MyNotification("X " + res[0] + " Y" + res[1] + " Z" + res[2], 3000));
                    //MyEntities.getMostComplexCameraView(128);
                }
                //if (MyFakes.ENABLE_MULTIPLAYER && input.IsAnyShiftKeyPressed() && input.IsNewKeyPress(Keys.PageUp))
                //{
                //    MyMultiplayer.HostGame(null);
                //    MyMultiplayer.Static.OnNotification = new Action<MyTextsWrapperEnum, object[]>(Static_OnNotification);
                //}

                if (MyMwcFinalBuildConstants.IS_DEVELOP && input.IsNewKeyPress(Keys.F5) && input.IsAnyCtrlKeyPressed())
                {
                    MySession.Static.SaveLastCheckpoint(false);
                }

                //  Show sector border
                if (MyMwcFinalBuildConstants.IS_DEVELOP && input.IsNewKeyPress(Keys.U))
                {
                    if (MyFakes.MWBUILDER)
                    {
                        if (input.IsAnyShiftKeyPressed())
                        {
                            MyEditorGrid.SwitchGridOrientation();
                        }
                        else
                        {
                            MyEditorGrid.IsGridActive = !MyEditorGrid.IsGridActive;
                        }
                    }
                    else
                    {
                        MyHudSectorBorder.SwitchSectorBorderVisibility();
                    }
                }

                if (MyMwcFinalBuildConstants.ENABLE_TRAILER_SAVE && (MyGuiScreenGamePlay.Static.IsGameActive() || MyGuiScreenGamePlay.Static.IsEditorActive())) // Trailer controls
                {
                    //if (input.IsKeyPress(Keys.NumPad5) && input.IsAnyShiftKeyPressed()) // SHIFT + Num5 - Set trailer start position
                    //{
                    //    MyHudNotification.AddNotification(new MyHudNotification.MyNotification("Trailer start set", 5));
                    //    trailerStartPosition = MySession.PlayerShip.WorldMatrix;
                    //}

                    if (input.IsNewKeyPress(Keys.NumPad5) && !input.IsAnyShiftKeyPressed()) // Num5 - Restart & record...
                    {
                        RestartTrailer(false, false);
                    }

                    if (input.IsNewKeyPress(Keys.NumPad7) && !input.IsAnyShiftKeyPressed()) // Num7 - Restart & teleport & record...
                    {
                        RestartTrailer(false, true);
                        //var translation = Matrix.CreateTranslation(MySession.PlayerShip.WorldMatrix.Translation + MyMwcUtils.Normalize(MySession.PlayerShip.WorldMatrix.Backward) * 10);
                        //MySession.PlayerShip.WorldMatrix *= translation;
                    }

                    if (input.IsNewKeyPress(Keys.NumPad9) && !input.IsAnyShiftKeyPressed()) // Num9 - Restart save & record...
                    {
                        RestartTrailer(true, true);
                    }
                }

                if (input.IsNewKeyPress(Keys.S) && input.IsAnyAltKeyPressed() && input.IsAnyCtrlKeyPressed())
                {
                    MyEditor.SaveSelectedVoxelMap(input.IsAnyShiftKeyPressed());
                }

                if (input.IsNewKeyPress(Keys.Delete) && input.IsAnyCtrlKeyPressed())
                {
                    if (MyMissions.ActiveMission != null)
                    {
                        MyObjective.SkipSubmission = true;
                    }
                }

                if (input.IsNewKeyPress(Keys.End) && input.IsAnyCtrlKeyPressed())
                {
                    if (MyMissions.ActiveMission != null && MyMissions.ActiveMission.ActiveObjectives.Count > 0)
                    {
                        var entityId = MyMissions.ActiveMission.ActiveObjectives[0].Location.LocationEntityIdentifier.LocationEntityId;
                        MyEntity entity;
                        if (entityId.HasValue && MyEntities.TryGetEntityById(entityId.ToEntityId().Value, out entity))
                        {
                            MySession.PlayerShip.SetPosition(entity.GetPosition());
                        }
                    }
                    else
                    {
                        MyEntity entity;
                        //if (MyEntities.TryGetEntityByName(MyMissionBase.MyMissionLocation.MADELYN_HANGAR, out entity))
                        if (MyEntities.TryGetEntityByName("Madelyn", out entity))
                        {
                            MySession.PlayerShip.SetPosition(entity.GetPosition());
                        }
                    }
                }

                if (input.IsNewKeyPress(Keys.OemTilde) && input.IsAnyCtrlKeyPressed())
                {
                    var ship = MySession.Static.Player.Ship as MySmallShip;
                    ship.DoDamage(1000, 1000, 0, MyDamageType.Explosion, MyAmmoType.Unknown, null);
                    MySession.Static.Player.AddHealth(-MySession.Static.Player.Health, null);
                }

                if ((input.IsNewKeyPress(Keys.OemBackslash) || input.IsNewKeyPress(Keys.OemPipe)) && input.IsAnyShiftKeyPressed())
                {
                    MyLine line = new MyLine(MyCamera.Position, MyCamera.Position + MyCamera.ForwardVector * 25000, false);
                    var intersection = MyEntities.GetIntersectionWithLine(ref line, MySession.Static.Player.Ship, null, true);
                    if (intersection.HasValue)
                    {
                        var target = intersection.Value.IntersectionPointInWorldSpace;
                        target -= MyCamera.ForwardVector * MySession.Static.Player.Ship.LocalVolume.Radius * 20;
                        MySession.Static.Player.Ship.SetPosition(target);
                    }
                }

                if (input.IsNewKeyPress(Keys.NumLock))
                {
                    var player = MySession.Static.Player;

                    player.RestoreHealth();

                    var ship = MySession.Static.Player.Ship as MySmallShip;
                    if (ship != null)
                    {
                        ship.AddHealth(ship.MaxHealth);
                        ship.ArmorHealth = ship.MaxArmorHealth;

                        ship.Oxygen = ship.MaxOxygen;
                        ship.Fuel = ship.MaxFuel;
                        ship.AfterburnerStatus = 1;

                        foreach (Inventory.MyInventoryItem item in ship.Weapons.AmmoInventoryItems.GetAmmoInventoryItems())
                        {
                            item.Amount = item.MaxAmount;
                        }
                    }
                }

                if (input.IsAnyControlPress() && input.IsAnyShiftPress() && input.IsNewKeyPress(Keys.F8))
                {
                    MyGuiPreviewRenderer renderer = MyGuiManager.GetPreviewRenderer();
                    renderer.CreatePreviewsToFiles(@"C:\Temp", MyHudConstants.PREFAB_PREVIEW_SIZE);
                }

                if (input.IsNewKeyPress(Keys.Space) && input.IsAnyCtrlKeyPressed())
                {
                    if (CameraAttachedTo == MyCameraAttachedToEnum.Spectator)
                    {
                        // we try to move ship to the spot, then we check if it colides if yes we move it back.
                        //
                        Vector3 oldPos = MySession.PlayerShip.GetPosition();
                        MySession.PlayerShip.SetPosition(MySpectator.Position);

                        //Move player ship to camera position
                        MyEntities.CollisionsElements.Clear();
                        MinerWars.AppCode.Game.Physics.MyPhysicsBody rBody = MySession.PlayerShip.Physics;
                        if (rBody.GetRBElementList().Count > 0)
                        {
                            // we expect only one rigid body (box)
                            MyEntities.GetCollisionListForElement(rBody.GetRBElementList().First());
                            BoundingSphere bsphere = MySession.PlayerShip.WorldVolume;

                            if (MyEntities.CollisionsElements.Count > 0 || MyVoxelMaps.GetOverlappingWithSphere(ref bsphere) != null)
                            {

                                MySession.PlayerShip.SetPosition(oldPos);
                                //maybe warning here or sound is enough? 
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectMoveInvalid);
                            }

                        }
                        else
                            Debug.Assert(false);// no physical box in player ship
                    }
                }

                if (input.IsNewKeyPress(Keys.Space) && input.IsAnyShiftKeyPressed())
                {
                    if (CameraAttachedTo == MyCameraAttachedToEnum.Spectator)
                    {
                        MySmallShip playerShip = MySession.PlayerShip;

                        //Move Spectator to player ship position                        
                        MySpectator.Position = playerShip.GetPosition() +
                            ThirdPersonCameraDelta * playerShip.GetWorldRotation().Up +
                            ThirdPersonCameraDelta * -playerShip.GetWorldRotation().Forward;
                        MySpectator.Target = playerShip.GetPosition();
                    }
                }

                //  Save check point - allowed only for story editors
                // DISABLED, now done automatically
                //if (IsGameActive() && input.IsKeyPress(Keys.RightShift) && input.IsNewKeyPress(Keys.F2) &&
                //    MyClientServer.LoggedPlayer != null && MyClientServer.LoggedPlayer.GetCanAccessEditorForStory())
                //{
                //    MyGuiManager.AddScreen(new MyGuiScreenSaveCheckpoint());
                //}

                if (!MyModelsStatisticsConstants.GET_MODEL_STATISTICS_AUTOMATICALLY && input.IsNewKeyPress(Keys.F10) && input.IsAnyShiftKeyPressed())
                {
                    MyModels.LogUsageInformation();
                }
                if (!MyModelsStatisticsConstants.GET_MODEL_STATISTICS_AUTOMATICALLY && input.IsNewKeyPress(Keys.F10) && input.IsAnyAltKeyPressed())
                {
                    MyModels.CheckAllModels();
                    //MyModels.MergeLogFiles();
                }

                /*if (input.IsNewKeyPress(Keys.F10) && input.IsAnyCtrlKeyPressed() && !MyModelsStatisticsConstants.GET_MODEL_STATISTICS_AUTOMATICALLY)
                {
                    MyModelsStatisticsConstants.GET_MODEL_STATISTICS_AUTOMATICALLY = true;
                    if (MyModelsStatisticsConstants.MISSIONS_TO_GET_MODEL_STATISTICS_FROM.Length == 0)
                    {
                        int i = 0;
                        MyModelsStatisticsConstants.MISSIONS_TO_GET_MODEL_STATISTICS_FROM = new Missions.MyMissionID[Missions.MyMissions.Missions.Count];
                        foreach (var mission in MyMissions.Missions.Values.OfType<MyMission>().OrderBy(x => x.Name.ToString()))
                        {
                            if (i >= 12)
                                MyModelsStatisticsConstants.MISSIONS_TO_GET_MODEL_STATISTICS_FROM[i] = mission.ID;
                            i++;
                        }
                    }
                    GUI.MyGuiScreenMainMenu.StartMission(MyModelsStatisticsConstants.MISSIONS_TO_GET_MODEL_STATISTICS_FROM[0]);
                }*/

                // Voxel import
                if (MyFakes.VOXEL_IMPORT && input.IsNewKeyPress(Keys.PageUp))
                {
                    if (!input.IsAnyShiftKeyPressed())
                    {
                        MyVoxelMap voxelMap = new MyVoxelMap();
                        //{
                        //    // TODO: merge
                        //    //VoxelMaterial = MyMwcVoxelMaterialsEnum.Stone_01,
                        //    Size = MyFakes.VOXEL_IMPORT_SIZE
                        //};
                        voxelMap.Init(Vector3.Zero, MyFakes.VOXEL_IMPORT_SIZE, MyMwcVoxelMaterialsEnum.Stone_01);

                        MyModel model = new MyModel(MyFakes.VOXEL_IMPORT_MODEL, MyMeshDrawTechnique.MESH, MyModelsEnum.ExplosionDebrisVoxel);
                        model.LoadData();

                        MyVoxelImport.Run(voxelMap, model, MyVoxelImportOptions.KeepAspectRatio);
                        voxelMap.SaveVoxelContents(Path.Combine(MyMinerGame.Static.RootDirectory, "VoxelMaps", MyVoxelFiles.ExportFile + ".vox"));

                        // Reload sector
                        MyGuiScreenGamePlay.Static.Restart();
                    }
                    else
                    {
                        int[] sizes = new int[] { 64, 128, 256, 512 };

                        List<MyMwcVector3Int> voxelSizes = new List<MyMwcVector3Int>();

                        for (int x = 0; x < sizes.Length; x++)
                        {
                            int lo = Math.Max(x - 1, 0);
                            int hi = Math.Min(x + 2, sizes.Length);

                            for (int y = lo; y < hi; y++)
                            {
                                for (int z = lo; z < hi; z++)
                                {
                                    voxelSizes.Add(new MyMwcVector3Int(sizes[x], sizes[y], sizes[z]));
                                }
                            }
                        }

                        foreach (var size in voxelSizes)
                        {
                            MyVoxelMap voxelMap = new MyVoxelMap();
                            voxelMap.Init(Vector3.Zero, size, MyMwcVoxelMaterialsEnum.Stone_01);

                            MyVoxelImport.Fill(voxelMap);
                            voxelMap.SaveVoxelContents(Path.Combine(MyMinerGame.Static.RootDirectory, "VoxelMaps", String.Format("Cube_{0}x{1}x{2}.vox", size.X, size.Y, size.Z)));
                            MyEntities.Remove(voxelMap);
                            voxelMap.MarkForClose();
                            GC.Collect();
                        }

                        // Reload sector
                        MyGuiScreenGamePlay.Static.Restart();
                    }
                }


                if (input.IsNewKeyPress(Keys.L) && input.IsAnyCtrlKeyPressed() && input.IsAnyShiftKeyPressed())
                {
                    if (MyMissions.ActiveMission != null && MyMissions.ActiveMission.ActiveObjectives.Count > 0 && MyMissions.ActiveMission.ActiveObjectives[0].Location != null && MyMissions.ActiveMission.ActiveObjectives[0].Location.Entity != null)
                    {
                        MySpectator.Position = MyMissions.ActiveMission.ActiveObjectives[0].Location.Entity.GetPosition();

                    }
                }

                //  Start sun wind
                if (input.IsNewKeyPress(Keys.F3))
                {
                    //Multiplayer_EnterGame(new MyEventEnterGame() { PlayerInfo = new MyPlayerInfo() { DisplayName = "Test" } });
                    //MyDialogues.Play(Audio.Dialogues.MyDialogueEnum.TEST);
                    MyGlobalEvents.StartGlobalEvent(MyGlobalEventEnum.SunWind);
                    //MyGuiManager.AddScreen(new MyGuiScreenMission(MyMissions.ActiveMission));
                    //MySession.PlayerShip.DoDamage(0, 1000000, 0, MyDamageType.Unknown, MyAmmoType.Unknown, null);
                    //MyInventory.GenerateDebugInventoryItemsInfo();
                    //MyAmmoConstants.GenerateDebugAmmoTypeInfo();
                    if (MyFakes.ENABLE_DEBUG_INFLUENCE_SPHERES_SOUNDS)
                    {
                        if (input.IsKeyPress(Keys.LeftAlt))
                        {
                            MyInfluenceSphere.UpdateMaxVolume(false);
                        }
                        else if (input.IsKeyPress(Keys.RightAlt))
                        {
                            MyInfluenceSphere.UpdateMaxVolume(true);
                        }
                        else
                        {
                            MyInfluenceSphere.SwitchToNextSound(!input.IsAnyShiftKeyPressed());
                        }
                    }
                }

                //Set camera to player
                if (input.IsNewKeyPress(Keys.F6))
                {
                    TryChangeCameraAttachedTo(MyCameraAttachedToEnum.PlayerMinerShip);
                }

                //Set camera to following third person
                if (input.IsNewKeyPress(Keys.F7))
                {
                    TryChangeCameraAttachedTo(MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonFollowing);
                }

                //Set camera to spectator
                if (input.IsNewKeyPress(Keys.F8))//&& TryChangeCameraAttachedTo(MyCameraAttachedToEnum.Spectator))
                {
                    CameraAttachedTo = MyCameraAttachedToEnum.Spectator;
                    if (input.IsAnyCtrlKeyPressed())
                    {
                        MySpectator.Position = MySession.PlayerShip.GetPosition() + ThirdPersonCameraDelta;
                        MySpectator.Target = MySession.PlayerShip.GetPosition();
                    }
                }

                //Set camera to static third person
                if (input.IsNewKeyPress(Keys.F9) && TryChangeCameraAttachedTo(MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonStatic))
                {
                    if (input.IsAnyCtrlKeyPressed())
                    {
                        MySpectator.Position = MySession.PlayerShip.GetPosition() + ThirdPersonCameraDelta;
                        MySpectator.Target = MySession.PlayerShip.GetPosition();
                    }
                }

                if (input.IsNewKeyPress(Keys.F10) /*&& input.IsAnyCtrlKeyPressed()*/ && TryChangeCameraAttachedTo(MyCameraAttachedToEnum.BotMinerShip))
                {
                    //Find nearest bot and attach him
                    BoundingFrustum boundingFrustum = MyCamera.GetBoundingFrustum();
                    List<MyEntity> entities = new List<MyEntity>();
                    MyEntities.GetAllIntersectionWithBoundingFrustum_UNOPTIMIZED(ref boundingFrustum, entities);
                    MySmallShipBot closestBot = null;
                    foreach (MyEntity entity in entities)
                    {
                        if (entity is MySmallShipBot)
                        {
                            if (closestBot == null)
                            {
                                closestBot = entity as MySmallShipBot;
                                continue;
                            }

                            if (Vector3.Distance(MyCamera.Position, entity.GetPosition()) < Vector3.Distance(MyCamera.Position, closestBot.GetPosition()))
                            {
                                closestBot = entity as MySmallShipBot;
                            }
                        }
                    }
                    MyGuiScreenGamePlay.Static.ShipForSimpleTesting = closestBot;
                }
            }

            #endregion

            #region Game/editor keys

            if ((IsGameActive() || IsEditorActive()) && !MyEditorBase.IsEditorActive)
            {
                //  Turn reflector on/off
                if (input.IsNewGameControlPressed(MyGameControlEnums.HEADLIGHTS))
                {
                    if (IsControlledPlayerShip)
                    {
                        MySession.PlayerShip.Config.ReflectorLight.ChangeValueUp();
                    }

                    if (IsControlledDrone)
                    {
                        ControlledDrone.Config.ReflectorLight.ChangeValueUp();
                    }
                }

                //  Move and rotate player or camera
                MoveAndRotatePlayerOrCamera(input);
            }

            #endregion

            #region Game keys that work only when player is alive

            if (IsGameActive() && IsFlyThroughActive() == false && MySession.Static != null && MySession.Static.Player != null && !MySession.Static.Player.IsDead())
            {
                //  Open inventory
                if (input.IsNewGameControlPressed(MyGameControlEnums.INVENTORY))
                {
                    if (IsControlledPlayerShip && !MySession.PlayerShip.IsDead() && !MySession.PlayerShip.IsPilotDead())
                    {
                        MyGuiScreenInventoryType inventoryType;
                        if (IsTypeEditorGodMode(m_previousType) &&
                            MySession.PlayerShip.TradeDetector.GetNearestEntity() == null ||
                            Static.IsCheatEnabled(MyGameplayCheatsEnum.UNLIMITED_TRADING))
                        {
                            inventoryType = MyGuiScreenInventoryType.GodEditor;
                        }
                        else
                        {
                            inventoryType = MyGuiScreenInventoryType.Game;
                        }
                        if (!MyMultiplayerGameplay.IsRunning)
                        {
                            var inventoryScreen = MyGuiScreenInventoryManagerForGame.OpenInventory(inventoryType);
                            MyGuiManager.AddScreen(inventoryScreen);
                        }
                        else
                        {
                            OpenInventoryMultiplayer(inventoryType);
                        }
                    }
                }

                // Target locking
                if (input.IsNewGameControlPressed(MyGameControlEnums.PREV_TARGET))
                    MyEnemyTargeting.SwitchNextTarget(false);
                if (input.IsNewGameControlPressed(MyGameControlEnums.NEXT_TARGET))
                    MyEnemyTargeting.SwitchNextTarget(true);

                // Bot follow / hold position
                if (input.IsNewGameControlPressed(MyGameControlEnums.CHANGE_DRONE_MODE))
                {
                    if (IsControlledDrone)
                        ControlledDrone.HoldPosition = !ControlledDrone.HoldPosition;
                }

                if (input.IsNewGameControlPressed(MyGameControlEnums.QUICK_ZOOM)
                    && !MyCamera.Zoom.IsZooming()
                    && MyCamera.Zoom.GetZoomLevel() < 1.0f && !m_wheelControlMenu.Visible)
                {
                    m_quickZoomOut = true;
                    MyCamera.Zoom.SetZoom(MyCameraZoomOperationType.ZoomOut);
                }

                if (!m_quickZoomOut)
                {
                    if (input.IsGameControlPressed(MyGameControlEnums.QUICK_ZOOM))
                    {
                        MyCamera.Zoom.SetZoom(MyCameraZoomOperationType.ZoomIn);
                        m_quickZoomWasUsed = true;
                    }
                    else if (m_quickZoomWasUsed)
                    {
                        MyCamera.Zoom.SetZoom(MyCameraZoomOperationType.ZoomOut);
                    }
                }

                if (input.IsNewGameControlPressed(MyGameControlEnums.ZOOM_IN) ||
                    input.IsNewGameControlPressed(MyGameControlEnums.ZOOM_OUT))
                {
                    m_quickZoomOut = false;
                }

                if (!input.IsGameControlPressed(MyGameControlEnums.ZOOM_IN))
                {
                    if (input.IsGameControlPressed(MyGameControlEnums.ZOOM_OUT))
                    {
                        MyCamera.Zoom.SetZoom(MyCameraZoomOperationType.ZoomOut);
                        m_quickZoomWasUsed = false;
                    }
                    else if (!m_quickZoomWasUsed && !m_quickZoomOut)
                    {
                        MyCamera.Zoom.SetZoom(MyCameraZoomOperationType.NoZoom);
                    }
                }
                else if (input.IsGameControlPressed(MyGameControlEnums.ZOOM_IN))
                {
                    MyCamera.Zoom.SetZoom(MyCameraZoomOperationType.ZoomIn);
                    m_quickZoomWasUsed = false;
                }

                // Drone manipulation
                if (input.IsGameControlPressed(MyGameControlEnums.DRONE_DEPLOY))
                    DroneDeployKeyPressed();
                if (input.IsGameControlPressed(MyGameControlEnums.DRONE_CONTROL))
                    DroneControlKeyPressed();

                // Roll callbacks (movement is handled in MoveAndRotatePlayerOrCamera)
                if (input.IsNewGameControlPressed(MyGameControlEnums.ROLL_LEFT))
                {
                    OnRollLeftPressed();
                    MyScriptWrapper.RollLeftPressed();
                }
                if (input.IsNewGameControlPressed(MyGameControlEnums.ROLL_RIGHT))
                {
                    OnRollRightPressed();
                    MyScriptWrapper.RollRightPressed();
                }

                // Turn deceleration on/off
                if (input.IsNewGameControlPressed(MyGameControlEnums.MOVEMENT_SLOWDOWN))
                {
                    if (IsControlledPlayerShip && MySession.PlayerShip.Config.Engine.On)
                        MySession.PlayerShip.Config.MovementSlowdown.ChangeValueUp();
                }

                // Change headlight distance
                if (input.IsNewGameControlPressed(MyGameControlEnums.HEADLIGTHS_DISTANCE))
                {
                    if (IsControlledPlayerShip)
                        MySession.PlayerShip.Config.ReflectorLongRange.ChangeValueUp();
                }

                // Turn auto-leveling on/off
                if (input.IsNewGameControlPressed(MyGameControlEnums.AUTO_LEVEL))
                {
                    if (IsControlledPlayerShip && MySession.PlayerShip.Config.Engine.On)
                        MySession.PlayerShip.Config.AutoLeveling.ChangeValueUp();
                }

                // Turn secondary camera on/off
                if (MyFakes.ENABLE_BACK_CAMERA && !DisableBackCamera)
                {
                    if (input.IsNewGameControlPressed(MyGameControlEnums.REAR_CAM))
                    {
                        if (IsControlledPlayerShip)
                            ControlledShip.Config.BackCamera.ChangeValueUp();
                        if (IsControlledDrone)
                            ControlledDrone.Config.BackCamera.ChangeValueUp();
                    }
                }
                else
                {
                    MySession.PlayerShip.Config.BackCamera.SetOff();

                    if (IsControlledDrone)
                        ControlledDrone.Config.BackCamera.SetOff();
                }

                // Switch view - cockpit on/off, third person
                if (input.IsNewGameControlPressed(MyGameControlEnums.VIEW_MODE))
                {
                    if (IsControlledPlayerShip)
                        MySession.PlayerShip.Config.ViewMode.ChangeValueUp();
                }

                // Secondary camera and remote camera controls
                if (input.IsNewGameControlPressed(MyGameControlEnums.PREVIOUS_CAMERA))
                {
                    if (IsControlledPlayerShip)
                        MySession.PlayerShip.SelectPreviousSecondaryCamera();
                }

                if (input.IsNewGameControlPressed(MyGameControlEnums.NEXT_CAMERA))
                {
                    if (IsControlledPlayerShip)
                        MySession.PlayerShip.SelectNextSecondaryCamera();
                }

                HandleRemoteCameraInput(input);

                // Show GPS
                if (input.IsNewGameControlPressed(MyGameControlEnums.GPS) || (MyFakes.GPS_ALWAYS_ON && Math.Abs(MyHud.LastGPS - MyMinerGame.TotalGamePlayTimeInMilliseconds) > 500))
                {
                    MyHud.ShowGPSPathToNextObjective(true);
                    if (!m_showGPSNotification.IsDisappeared())
                        m_showGPSNotification.Disappear();
                }

                // Harvesting and drilling
                if (input.IsNewGameControlPressed(MyGameControlEnums.HARVEST))
                {
                    if (IsControlledPlayerShip && MySession.PlayerShip.IsEngineWorking() && MySession.PlayerShip.Fuel > 0)
                        MySession.PlayerShip.Weapons.FireHarvester();
                }

                if (input.IsGameControlPressed(MyGameControlEnums.DRILL))
                {
                    if (IsControlledPlayerShip && MySession.PlayerShip.IsEngineWorking() && MySession.PlayerShip.Fuel > 0)
                        MySession.PlayerShip.Weapons.FireDrill();
                }
            }

            #endregion

            #region Game keys that work only when player is alive and action menu is closed (e.g. keys that open a new menu)

            if (IsGameActive() && !m_wheelControlMenu.Visible && IsFlyThroughActive() == false && MySession.Static != null && MySession.Static.Player != null && !MySession.Static.Player.IsDead())
            {
                // Travel
                if (input.IsNewGameControlPressed(MyGameControlEnums.TRAVEL))
                {
                    bool canTravel = true;

                    if (m_type == MyGuiScreenGamePlayType.GAME_SANDBOX)
                    {
                        if (MyGuiScreenGamePlay.Static.GetPreviousGameType() != MyGuiScreenGamePlayType.EDITOR_STORY)
                            canTravel = false;
                    }
                    else if (m_type == MyGuiScreenGamePlayType.GAME_STORY || m_type == MyGuiScreenGamePlayType.GAME_MMO)
                    {
                        if (MySession.PlayerShip.GetNearMotherShipContainer() == null)
                            canTravel = false;
                        else
                            canTravel = CanTravel;
                    }

                    bool canSave = MyClientServer.LoggedPlayer.GetCanSave();
                    canTravel |= MyFakes.ENABLE_SOLAR_MAP;
                    canTravel &= canSave;

                    if (canTravel)
                    {
                        MyMwcSectorIdentifier sector = m_sectorIdentifier;
                        this.HideScreen();
                        MyGuiManager.AddScreen(new MyGuiScreenSolarSystemMap(this, sector));
                    }
                    else if (m_type == MyGuiScreenGamePlayType.GAME_STORY || m_type == MyGuiScreenGamePlayType.GAME_MMO)
                    {
                        if (!canSave)
                            MyGuiManager.AddScreen(new MyGuiScreenMessageBox(MyMessageBoxType.ERROR, MyTextsWrapperEnum.DemoUserCannotTravel, MyTextsWrapperEnum.SolarSystemMap, MyTextsWrapperEnum.Ok, null));
                        else if (CanTravel)
                            MyHudNotification.AddNotification(m_notificationYouHaveToBeNearMothership);
                        else
                            MyHudNotification.AddNotification(m_notificationUnableToLeaveSectorMission);
                    }
                }

                // Use / Hack / Take
                if (input.IsNewGameControlPressed(MyGameControlEnums.USE))
                {
                    bool isHandled = false;
                    // first handled are notifications
                    if (MyHudNotification.HasNotification(MyHudNotification.GetCurrentScreen()))
                        isHandled = MyHudNotification.HandleInput(input);

                    // second handled is take all event
                    if (!isHandled)
                        isHandled = TakeAllItems();

                    // third handled is hacking etc
                    if (!isHandled)
                    {
                        MySmallShip hacker = ControlledDrone ?? MySession.PlayerShip;
                        IMyUseableEntity detectedEntityToUse = hacker.UseableEntityDetector.GetNearestEntity() as IMyUseableEntity;

                        if (ControlledLargeWeapon != null && TryChangeCameraAttachedTo(MyCameraAttachedToEnum.PlayerMinerShip))
                            ReleaseControlOfLargeWeapon();

                        if (ControlledCamera != null)
                            ReleaseControlOfCamera();
                        else if (detectedEntityToUse != null)
                        {
                            MySmallShipInteractionActionEnum detectedAction = (MySmallShipInteractionActionEnum)hacker.UseableEntityDetector.GetNearestEntityCriterias();
                            if (detectedAction == MySmallShipInteractionActionEnum.Use)
                                detectedEntityToUse.Use(hacker);
                            else if (detectedAction == MySmallShipInteractionActionEnum.Hack)
                                hacker.HackingTool.Hack(detectedEntityToUse);
                        }
                        else
                            MyScriptWrapper.UseKeyPressed();
                    }
                }
                       /*  Journal removed
                // Journal
                if (input.IsNewGameControlPressed(MyGameControlEnums.MISSION_DIALOG) && (GetGameType() == MyGuiScreenGamePlayType.GAME_STORY || GetGameType() == MyGuiScreenGamePlayType.GAME_MMO))
                {
                    if (!MyMissions.RequestMissionDialog())
                        MyGuiManager.AddScreen(new MyGuiScreenJournal(MySession.Static.EventLog));
                }        */

                // Chat, multiplayer statistics
                // TODO: prevent dev keys universally, not based on the default mapping
#if !RENDER_PROFILING
                if (MyGuiManager.IsScreenTopMostNonDebug(this))
                {
                    if (input.IsNewGameControlPressed(MyGameControlEnums.CHAT)/* && MyMultiplayerGameplay.IsRunning && (MyMultiplayerGameplay.IsSandBox() || (MyMultiplayerGameplay.IsStory() && MyMultiplayerGameplay.OtherPlayersConnected))*/) //only in deathmatch (all the time) or coop (at least one other player)
                    {
                        MyGuiManager.AddScreen(new MyGuiScreenGameChat(input.IsAnyShiftKeyPressed()));
                    }
                    if (input.IsNewGameControlPressed(MyGameControlEnums.SCORE) && MyMultiplayerGameplay.IsRunning && (MyMultiplayerGameplay.IsSandBox() || (MyMultiplayerGameplay.IsStory() && MyMultiplayerGameplay.OtherPlayersConnected))) //only in deathmatch (all the time) or coop (at least one other player)
                    {
                        MyGuiManager.AddScreen(new MyGuiScreenGameScore());
                    }
                }
#endif
                // Shooting
                // we can be dead in this moment

                if (MyFakes.CUBE_EDITOR && MySession.PlayerShip != null && input.IsNewGameControlPressed(MyGameControlEnums.QUICK_ZOOM))
                    MySession.PlayerShip.CubeBuilder.BuilderActive = !MySession.PlayerShip.CubeBuilder.BuilderActive;

                if (MySession.PlayerShip != null && MySession.PlayerShip.CubeBuilder.BuilderActive)
                {
                    if (input.IsNewGameControlPressed(MyGameControlEnums.FIRE_PRIMARY))
                        MySession.PlayerShip.CubeBuilder.Add();
                    if (input.IsNewGameControlPressed(MyGameControlEnums.FIRE_SECONDARY))
                        MySession.PlayerShip.CubeBuilder.Remove();
                }
                else if (m_handleInputMouseKeysReleased &&
                    (!IsSelectAmmoVisible()) &&
                    (!m_wheelControlMenu.Visible) &&
                    MySession.PlayerShip != null &&
                    !MySession.PlayerShip.IsDead() &&
                    IsFireKeyEnabled())
                {
                    switch (CameraAttachedTo)
                    {
                        case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonDynamic:
                        case MyCameraAttachedToEnum.Spectator:
                        case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonStatic:
                        case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonFollowing:
                        case MyCameraAttachedToEnum.PlayerMinerShip:
                            if (!input.IsAnyCtrlKeyPressed() || CameraAttachedTo == MyCameraAttachedToEnum.PlayerMinerShip)
                            {
                                MySmallShip playerShip = MySession.PlayerShip;

                                if (playerShip.IsEngineWorking())
                                {
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_PRIMARY)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.Primary);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SECONDARY))
                                    {
                                        // TODO: prevent dev keys universally, not based on the default mapping
#if !GPU_PROFILING
                                        playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.Secondary);
#endif
                                    }
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_THIRD)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.Third);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FOURTH)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.Fourth);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FIFTH)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.Fifth);
                                    if (input.IsNewGameControlPressed(MyGameControlEnums.WEAPON_SPECIAL)) playerShip.InvokeAmmoSpecialFunction();
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_HOLOGRAM_FRONT)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.HologramFront);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_HOLOGRAM_BACK)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.HologramBack);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_BASIC_MINE_FRONT)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.BasicMineFront);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_BASIC_MINE_BACK)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.BasicMineBack);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SMART_MINE_FRONT)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.SmartMineFront);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SMART_MINE_BACK)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.SmartMineBack);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FLASH_BOMB_FRONT)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.FlashBombFront);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FLASH_BOMB_BACK)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.FlashBombBack);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_DECOY_FLARE_FRONT)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.DecoyFlareFront);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_DECOY_FLARE_BACK)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.DecoyFlareBack);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SMOKE_BOMB_FRONT)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.SmokeBombFront);
                                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SMOKE_BOMB_BACK)) playerShip.Weapons.Fire(MyMwcObjectBuilder_FireKeyEnum.SmokeBombBack);
                                }
                            }
                            break;
                        case MyCameraAttachedToEnum.Drone:
                            if (input.IsGameControlPressed(MyGameControlEnums.FIRE_PRIMARY) ||
                                input.IsGameControlPressed(MyGameControlEnums.FIRE_SECONDARY) ||
                                input.IsGameControlPressed(MyGameControlEnums.FIRE_THIRD) ||
                                input.IsGameControlPressed(MyGameControlEnums.FIRE_FOURTH) ||
                                input.IsGameControlPressed(MyGameControlEnums.FIRE_FIFTH))
                            {
                                ControlledDrone.Fire();
                                DisableFireKey(new TimeSpan(0, 0, 1));
                            }
                            break;
                        case MyCameraAttachedToEnum.LargeWeapon:
                            if (input.IsGameControlPressed(MyGameControlEnums.FIRE_PRIMARY) ||
                                input.IsGameControlPressed(MyGameControlEnums.FIRE_SECONDARY) ||
                                input.IsGameControlPressed(MyGameControlEnums.FIRE_THIRD) ||
                                input.IsGameControlPressed(MyGameControlEnums.FIRE_FOURTH) ||
                                input.IsGameControlPressed(MyGameControlEnums.FIRE_FIFTH))
                            {
                                ControlledLargeWeapon.Fire();
                            }
                            else
                            {
                                ControlledLargeWeapon.StopFire();
                            }
                            break;
                    }
                }
            }

            #endregion

            #region Game keys that work all the time (even when player is dead)

            if (IsGameActive())
            {
                // Open cheat screen
                if (input.IsNewKeyPress(Keys.F1) && input.IsAnyCtrlKeyPressed())
                {
                    MyGuiManager.AddScreen(new MyGuiScreenCheats());
                }

                // Open help screen
                if (input.IsNewKeyPress(Keys.F1) && !input.IsAnyCtrlKeyPressed())
                {
                    MyGuiManager.AddScreen(new MyGuiScreenHelp());
                }

                if (IsControlledPlayerShip)
                {
                    m_selectAmmoMenu.HandleInput(input, true, true, receivedFocusInThisUpdate);
                    m_wheelControlMenu.HandleInput(input, true, true, receivedFocusInThisUpdate);
                }

                // DrawMouseCursor = m_wheelControlMenu.Visible;

                /*  //duplicated in if IsGameReady
           if (IsGameActive()) // enable cursor drawing if we have ammo selection opened
           {
               DrawMouseCursor = m_selectAmmoMenu.IsEnabled && m_selectAmmoMenu.Visible;
           } */

                MyDebugConsole.GetInstance().Update(MyDebugSystem.Game, input);
            }

            #endregion

            #region Editor keys

            if (IsEditorActive())
            {
                // Open ship customization screen
                if (input.IsNewGameControlPressed(MyGameControlEnums.INVENTORY) && !input.IsAnyCtrlKeyPressed())
                {
                    if (MyFakes.SHOW_NEW_INVENTORY_SCREEN)
                    {
                        MyGuiScreenInventoryType inventoryType = !IsIngameEditorActive() || Static.IsCheatEnabled(MyGameplayCheatsEnum.UNLIMITED_TRADING)
                                                                        ? MyGuiScreenInventoryType.GodEditor
                                                                        : MyGuiScreenInventoryType.InGameEditor;
                        MyGuiManager.AddScreen(MyGuiScreenInventoryManagerForGame.OpenInventory(inventoryType));
                    }
                }

                MyEditor.Static.HandleInput(input, !AnyControlContainsMouse());
                MyDebugConsole.GetInstance().Update(MyDebugSystem.Editor, input);
            }

            #endregion
        }
コード例 #22
0
            public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
            {
                base.HandleInput(input, receivedFocusInThisUpdate);
                if (input.IsNewKeyPress(Keys.Escape))
                {
                    Canceling();
                }

                //  Do nothing if base.HandleInput closing this screen right now
                if (m_state == MyGuiScreenState.CLOSING || m_state == MyGuiScreenState.HIDING) return;

                if (m_deviceType == MyGuiInputDeviceEnum.Keyboard)
                {
                    List<Toolkit.Input.Keys> pressedKeys = new List<Toolkit.Input.Keys>();
                    input.GetListOfPressedKeys(pressedKeys);

                    //  don't assign keys that were pressed when we arrived in the menu
                    foreach (var key in pressedKeys)
                    {
                        if (!m_oldPressedKeys.Contains(key))
                        {
                            MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                            if (!MyGuiInput.IsKeyValid((Keys)key)) { ShowControlIsNotValidMessageBox(); break; }

                            MyControl ctrl = input.GetControl((Keys)key, m_control.GetGameControlTypeEnum());
                            if (ctrl != null)
                            {
                                if (ctrl.Equals(m_control)) { CloseScreen(); return; }
                                ShowControlIsAlreadyAssigned(ctrl); break;
                            }
                            m_control.SetControl((Keys)key);
                            m_buttonsDictionary[m_control].SetText(new StringBuilder(m_control.GetControlButtonName(MyGuiInputDeviceEnum.Keyboard)));
                            CloseScreen(); return;
                        }
                    }
                    m_oldPressedKeys = pressedKeys;
                }
                else if (m_deviceType == MyGuiInputDeviceEnum.Mouse)
                {
                    var pressedMouseButtons = new List<MyMouseButtonsEnum>();
                    input.GetListOfPressedMouseButtons(pressedMouseButtons);

                    //  don't assign buttons that were pressed when we arrived in the menu
                    foreach (var button in pressedMouseButtons)
                    {
                        if (!m_oldPressedMouseButtons.Contains(button))
                        {
                            MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                            if (!MyGuiInput.IsMouseButtonValid(button)) { ShowControlIsNotValidMessageBox(); break; }

                            MyControl ctrl = input.GetControl(button, m_control.GetGameControlTypeEnum());
                            if (ctrl != null)
                            {
                                if (ctrl.Equals(m_control)) { CloseScreen(); return; }
                                ShowControlIsAlreadyAssigned(ctrl); break;
                            }
                            m_control.SetControl(button);
                            m_buttonsDictionary[m_control].SetText(new StringBuilder(m_control.GetControlButtonName(MyGuiInputDeviceEnum.Mouse)));
                            CloseScreen(); return;
                        }
                    }
                    m_oldPressedMouseButtons = pressedMouseButtons;
                }
                else if (m_deviceType == MyGuiInputDeviceEnum.Joystick)
                {
                    var pressedJoystickButtons = new List<MyJoystickButtonsEnum>();
                    input.GetListOfPressedJoystickButtons(pressedJoystickButtons);

                    //  don't assign buttons that were pressed when we arrived in the menu
                    foreach (var button in pressedJoystickButtons)
                    {
                        if (!m_oldPressedJoystickButtons.Contains(button))
                        {
                            MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                            if (!MyGuiInput.IsJoystickButtonValid(button)) { ShowControlIsNotValidMessageBox(); break; }

                            MyControl ctrl = input.GetControl(button, m_control.GetGameControlTypeEnum());
                            if (ctrl != null)
                            {
                                if (ctrl.Equals(m_control)) { CloseScreen(); return; }
                                ShowControlIsAlreadyAssigned(ctrl); break;
                            }
                            m_control.SetControl(button);
                            m_buttonsDictionary[m_control].SetText(new StringBuilder(m_control.GetControlButtonName(MyGuiInputDeviceEnum.Joystick)));
                            CloseScreen(); return;
                        }
                    }
                    m_oldPressedJoystickButtons = pressedJoystickButtons;
                }
                else if (m_deviceType == MyGuiInputDeviceEnum.JoystickAxis)
                {
                    var pressedJoystickAxes = new List<MyJoystickAxesEnum>();
                    input.GetListOfPressedJoystickAxes(pressedJoystickAxes);

                    //  don't assign axes that were pressed when we arrived in the menu
                    foreach (var axis in pressedJoystickAxes)
                    {
                        if (!m_oldPressedJoystickAxes.Contains(axis))
                        {
                            MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                            if (!MyGuiInput.IsJoystickAxisValid(axis)) { ShowControlIsNotValidMessageBox(); break; }

                            MyControl ctrl = input.GetControl(axis, m_control.GetGameControlTypeEnum());
                            if (ctrl != null)
                            {
                                if (ctrl.Equals(m_control)) { CloseScreen(); return; }
                                ShowControlIsAlreadyAssigned(ctrl); break;
                            }
                            m_control.SetControl(axis);
                            m_buttonsDictionary[m_control].SetText(new StringBuilder(m_control.GetControlButtonName(MyGuiInputDeviceEnum.JoystickAxis)));
                            CloseScreen(); return;
                        }
                    }
                    m_oldPressedJoystickAxes = pressedJoystickAxes;
                }
            }
コード例 #23
0
        private static void HandleRemoteCameraInput(MyGuiInput input)
        {
            if (input.IsGameControlPressed(MyGameControlEnums.CONTROL_SECONDARY_CAMERA))
            {
                var rotationIndicator = new Vector3(input.GetMouseYForGamePlay() - MyMinerGame.ScreenSizeHalf.Y, input.GetMouseXForGamePlay() - MyMinerGame.ScreenSizeHalf.X, 0) * MyGuiConstants.MOUSE_ROTATION_INDICATOR_MULTIPLIER;

                rotationIndicator.X -= input.GetGameControlAnalogState(MyGameControlEnums.ROTATION_UP) * MyRemoteCameraConstants.ROTATION_SENSITIVITY_NON_MOUSE;
                rotationIndicator.X += input.GetGameControlAnalogState(MyGameControlEnums.ROTATION_DOWN) * MyRemoteCameraConstants.ROTATION_SENSITIVITY_NON_MOUSE;
                rotationIndicator.Y -= input.GetGameControlAnalogState(MyGameControlEnums.ROTATION_LEFT) * MyRemoteCameraConstants.ROTATION_SENSITIVITY_NON_MOUSE;
                rotationIndicator.Y += input.GetGameControlAnalogState(MyGameControlEnums.ROTATION_RIGHT) * MyRemoteCameraConstants.ROTATION_SENSITIVITY_NON_MOUSE;

                rotationIndicator *= MyConstants.PHYSICS_STEPS_PER_SECOND * MyGuiConstants.ROTATION_INDICATOR_MULTIPLIER;

                if (rotationIndicator != Vector3.Zero)
                {
                    var remoteCamera = MySession.PlayerShip.GetSelectedRemoteCamera();
                    if (remoteCamera != null)
                        remoteCamera.Rotate(-rotationIndicator);
                }
            }
        }
コード例 #24
0
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
 	         base.HandleInput(input, receivedFocusInThisUpdate);
             if (input.IsNewGameControlPressed(MyGameControlEnums.INVENTORY))
             {
                 Canceling();
             }
        }
コード例 #25
0
        //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();
        }