Пример #1
0
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            if ((MyGuiScreenGamePlay.Static.IsEditorActive() == true) && (MyGuiManager.IsScreenOfTypeOpen(typeof(MyGuiScreenEditorContextMenu)) == false))
            {
                m_enabled     = true;
                m_contextMenu = null;
            }

            if (!IsEnabled)
            {
                return(false);
            }

            if (input.IsEditorControlNewPressed(MyEditorControlEnums.ENTER_CONTEXT_MENU))
            {
                m_contextMenu = new MyGuiScreenEditorContextMenu();
                MyGuiManager.AddScreen(m_contextMenu);
                m_enabled = false;
            }

            if (m_contextMenu != null)
            {
                m_contextMenu.HandleInput(input, receivedFocusInThisUpdate);
            }

            return(base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate));
        }
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            if ((MyGuiScreenGamePlay.Static.IsEditorActive() == true) && (MyGuiManager.IsScreenOfTypeOpen(typeof(MyGuiScreenEditorContextMenu)) == false))
            {
                m_enabled = true;
                m_contextMenu = null;
            }

            if (!IsEnabled) return false;

            if (input.IsEditorControlNewPressed(MyEditorControlEnums.ENTER_CONTEXT_MENU))
            {
                m_contextMenu = new MyGuiScreenEditorContextMenu();
                MyGuiManager.AddScreen(m_contextMenu);
                m_enabled = false;
            }

            if (m_contextMenu != null)
            {
                m_contextMenu.HandleInput(input, receivedFocusInThisUpdate);
            }

            return base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate);
        }
Пример #3
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);
             * }
             * } */
        }