示例#1
0
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            //If this control is not enable, do nothing
            if (!IsEnable)
            {
                return(false);
            }

            if (Visible)
            {
                if (((input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift)) && input.IsNewKeyPress(Keys.Tab)) || input.IsNewKeyPress(Keys.Up) || input.IsNewGamepadKeyUpPressed())
                {
                    SelectPrev();
                }
                if ((!(input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift)) && input.IsNewKeyPress(Keys.Tab)) || input.IsNewKeyPress(Keys.Down) || input.IsNewGamepadKeyDownPressed())
                {
                    SelectNext();
                }
                if (input.IsNewKeyPress(Keys.Escape) || input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J02))
                {
                    HideScreenIfPossible();
                }

                if (m_displayedItems[m_selected] != null)
                {
                    if (input.IsNewKeyPress(Keys.Left) || input.IsNewGamepadKeyLeftPressed())
                    {
                        m_displayedItems[m_selected].ChangeValueDown();
                    }
                    if (input.IsNewKeyPress(Keys.Right) || input.IsNewGamepadKeyRightPressed())
                    {
                        m_displayedItems[m_selected].ChangeValueUp();
                    }
                    if (input.IsNewKeyPress(Keys.Enter) || input.IsNewKeyPress(Keys.Space) || input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J01))
                    {
                        m_displayedItems[m_selected].ChangeValueUp();
                    }
                }

                HandleMouse(input);
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.WHEEL_CONTROL))
            {
                m_first = 0;
                Visible = !Visible;
                if (Visible == false)
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlClose);
                }
                else
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlOpen);
                }
            }

            return(base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate));
        }
        //  Method returns true if input was captured by control, so no other controls, nor screen can use input in this update
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool isThisFirstHandleInput)
        {
            bool ret = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, isThisFirstHandleInput);

            if (ret == false)
            {
                //float valuePrevious = m_value;

                if ((IsMouseOver() == true) && (input.IsNewLeftMousePressed() == true))
                {
                    m_controlCaptured = true;
                }

                if (input.IsLeftMouseReleased())
                {
                    m_controlCaptured = false;
                }

                if ((IsMouseOver() == true) && m_controlCaptured)
                {
                    float lineHorizontalPositionStart = GetStart();
                    float lineHorizontalPositionEnd   = GetEnd();

                    SetValue(((MyGuiManager.MouseCursorPosition.X - lineHorizontalPositionStart) / (lineHorizontalPositionEnd - lineHorizontalPositionStart)) * (m_maxValue - m_minValue) + m_minValue);
                    //KeenSoftwareHouse.Library.Trace.Trace.SendMsgLastCall("t");
                    ret = true;
                }

                if (hasKeyboardActiveControl == true)
                {
                    const float MOVEMENT_DELTA_NORMALIZED = 0.001f;

                    if (input.IsKeyPress(Keys.Left) || input.IsGamepadKeyLeftPressed())
                    {
                        MoveForward(-MOVEMENT_DELTA_NORMALIZED);
                        ret = true;
                    }

                    if (input.IsKeyPress(Keys.Right) || input.IsGamepadKeyRightPressed())
                    {
                        MoveForward(+MOVEMENT_DELTA_NORMALIZED);
                        ret = true;
                    }

                    if (ret == true)
                    {
                        m_blinkerTimer = 0;
                    }
                }
            }

            return(ret);
        }
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if (!input.IsKeyPress(Keys.Tab))
            {
                CloseScreen();
            }
        }
 //  Call this every update, it will check if key as UNPRESSED (thus UP), and if yes, we will remove delay, so multiple
 //  keypresses are possible fast, but not automatic. User must press DOWN/UP.
 void ResetLastKeyPressTimes(MyGuiInput input)
 {
     for (int i = 0; i < m_keyToString.Length; i++)
     {
         MyGuiControlTextboxKeyToString keyEx = m_keyToString[i];
         if (keyEx != null)
         {
             if (input.IsKeyPress(keyEx.Key) == false)
             {
                 keyEx.LastKeyPressTime = MyConstants.FAREST_TIME_IN_PAST;
             }
         }
     }
 }
        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;
            }
        }
示例#6
0
        public virtual void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            //  Here we can make some one-time initialization hidden in update
            bool isThisFirstHandleInput = !m_firstUpdateServed;

            if (m_firstUpdateServed == false && m_keyboardControlIndex == -1) //m_keyboardControlIndex could be set from constructor
            {
                //  Move to first control that can accept it
                //Controls.HandleKeyboardActiveIndex(true);
                HandleKeyboardActiveIndex(true);

                //  Never again call this update-initialization
                m_firstUpdateServed = true;
            }

            // if we are dragging some control, then we don't pass this focus to controls
            if (MyFakes.CONTROLS_MOVE_ENABLED && input.IsKeyPress(Keys.M))
            {
                if (HandleControlMoving(input))
                {
                    return;
                }
            }

            if (MyModelsStatisticsConstants.GET_MODEL_STATISTICS_AUTOMATICALLY)
            {
                if (MyMinerGame.IsGameReady)
                {
                    Models.MyModels.LogUsageInformation();
                }
            }

            if (!HandleControlsInput(input, receivedFocusInThisUpdate))
            {
                bool handled = false;
                //  If input wasn't completely handled or captured by some control, only then we can handle screen's input
                if ((input.IsKeyPress(Keys.LeftShift) && (input.IsNewKeyPress(Keys.Tab))) || (input.IsNewKeyPress(Keys.Up)) || (input.IsNewGamepadKeyUpPressed()))
                {
                    handled = HandleKeyboardActiveIndex(false);
                }
                else if ((input.IsNewKeyPress(Keys.Tab)) || (input.IsNewKeyPress(Keys.Down)) || (input.IsNewGamepadKeyDownPressed()))
                {
                    handled = HandleKeyboardActiveIndex(true);
                }
                else if ((m_closeOnEsc == true) && ((input.IsNewKeyPress(Keys.Escape) || input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J02))))
                {
                    Canceling();
                }
                else if ((OnEnterCallback != null) && (input.IsNewKeyPress(Keys.Enter)))
                {
                    OnEnterCallback();
                }

                // Scrolling down/up between controls using mouse scroll wheel
                //if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue())
                //{
                //    handled = HandleKeyboardActiveIndex(true);
                //}
                //else if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue())
                //{
                //    handled = HandleKeyboardActiveIndex(false);
                //}

                if (!handled)
                {
                    HandleUnhandledInput(input, receivedFocusInThisUpdate);
                }
            }
        }
示例#7
0
        public virtual void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            //  Here we can make some one-time initialization hidden in update
            bool isThisFirstHandleInput = !m_firstUpdateServed;

            if (m_firstUpdateServed == false && m_keyboardControlIndex == -1) //m_keyboardControlIndex could be set from constructor
            {
                //  Move to first control that can accept it
                //Controls.HandleKeyboardActiveIndex(true);
                HandleKeyboardActiveIndex(true);

                //  Never again call this update-initialization
                m_firstUpdateServed = true;
            }

            // if we are dragging some control, then we don't pass this focus to controls
            if(MyFakes.CONTROLS_MOVE_ENABLED && input.IsKeyPress(Keys.M))
            {
                if(HandleControlMoving(input))
                {
                    return;
                }
            }

            if (MyModelsStatisticsConstants.GET_MODEL_STATISTICS_AUTOMATICALLY)
            {
                if(MyMinerGame.IsGameReady)
                    Models.MyModels.LogUsageInformation();
            }

            if (!HandleControlsInput(input, receivedFocusInThisUpdate))
            {
                bool handled = false;
                //  If input wasn't completely handled or captured by some control, only then we can handle screen's input
                if ((input.IsKeyPress(Keys.LeftShift) && (input.IsNewKeyPress(Keys.Tab))) || (input.IsNewKeyPress(Keys.Up)) || (input.IsNewGamepadKeyUpPressed()))
                {
                    handled = HandleKeyboardActiveIndex(false);
                }
                else if ((input.IsNewKeyPress(Keys.Tab)) || (input.IsNewKeyPress(Keys.Down)) || (input.IsNewGamepadKeyDownPressed()))
                {
                    handled = HandleKeyboardActiveIndex(true);
                }
                else if ((m_closeOnEsc == true) && ((input.IsNewKeyPress(Keys.Escape) || input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J02))))
                {
                    Canceling();
                }
                else if ((OnEnterCallback != null) && (input.IsNewKeyPress(Keys.Enter)))
                {
                    OnEnterCallback();
                }

                // Scrolling down/up between controls using mouse scroll wheel
                //if (input.PreviousMouseScrollWheelValue() > input.MouseScrollWheelValue())
                //{
                //    handled = HandleKeyboardActiveIndex(true);
                //}
                //else if (input.PreviousMouseScrollWheelValue() < input.MouseScrollWheelValue())
                //{
                //    handled = HandleKeyboardActiveIndex(false);
                //}

                if (!handled)
                {
                    HandleUnhandledInput(input, receivedFocusInThisUpdate);
                }
            }
        }
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            //If this control is not enable, do nothing
            if (!IsEnable) return false;

            if (Visible)
            {
                if (((input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift)) && input.IsNewKeyPress(Keys.Tab)) || input.IsNewKeyPress(Keys.Up) || input.IsNewGamepadKeyUpPressed())
                    SelectPrev();
                if ((!(input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift)) && input.IsNewKeyPress(Keys.Tab)) || input.IsNewKeyPress(Keys.Down) || input.IsNewGamepadKeyDownPressed())
                    SelectNext();
                if (input.IsNewKeyPress(Keys.Escape) || input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J02))
                    HideScreenIfPossible();

                if (m_displayedItems[m_selected] != null)
                {
                    if (input.IsNewKeyPress(Keys.Left) || input.IsNewGamepadKeyLeftPressed())
                        m_displayedItems[m_selected].ChangeValueDown();
                    if (input.IsNewKeyPress(Keys.Right) || input.IsNewGamepadKeyRightPressed())
                        m_displayedItems[m_selected].ChangeValueUp();
                    if (input.IsNewKeyPress(Keys.Enter) || input.IsNewKeyPress(Keys.Space) || input.IsJoystickButtonNewPressed(MyJoystickButtonsEnum.J01))
                        m_displayedItems[m_selected].ChangeValueUp();
                }
                
                HandleMouse(input);
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.WHEEL_CONTROL))
            {
                m_first = 0;
                Visible = !Visible;
                if (Visible == false)
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlClose);
                }
                else
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlOpen);
                }
            }

            return base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate);
        }
        //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);
             * }
             * } */
        }
示例#10
0
        //  Method returns true if input was captured by control, so no other controls, nor screen can use input in this update
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool isThisFirstHandleInput)
        {
            bool ret = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, isThisFirstHandleInput);

            if (ret == false)
            {
                //float valuePrevious = m_value;

                if ((IsMouseOver() == true) && (input.IsNewLeftMousePressed() == true))
                {
                    m_controlCaptured = true;
                }

                if (input.IsLeftMouseReleased())
                {
                    m_controlCaptured = false;
                }

                if ((IsMouseOver() == true) && m_controlCaptured)
                {
                    float lineHorizontalPositionStart = GetStart();
                    float lineHorizontalPositionEnd = GetEnd();

                    SetValue(((MyGuiManager.MouseCursorPosition.X - lineHorizontalPositionStart) / (lineHorizontalPositionEnd - lineHorizontalPositionStart)) * (m_maxValue - m_minValue) + m_minValue);
                    //KeenSoftwareHouse.Library.Trace.Trace.SendMsgLastCall("t");
                    ret = true;
                }

                if (hasKeyboardActiveControl == true)
                {
                    const float MOVEMENT_DELTA_NORMALIZED = 0.001f;

                    if (input.IsKeyPress(Keys.Left) || input.IsGamepadKeyLeftPressed())
                    {
                        MoveForward(-MOVEMENT_DELTA_NORMALIZED);
                        ret = true;
                    }

                    if (input.IsKeyPress(Keys.Right) || input.IsGamepadKeyRightPressed())
                    {
                        MoveForward(+MOVEMENT_DELTA_NORMALIZED);
                        ret = true;
                    }

                    if (ret == true) m_blinkerTimer = 0;
                }
            }

            return ret;
        }
示例#11
0
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool receivedFocusInThisUpdate)
        {
            //If this control is not enable, do nothing
            if (!IsEnabled)
            {
                return(false);
            }

            bool isKeyPress = false;
            bool backwardSelectDirection = input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift);
            int  deltaWheelPos           = input.PreviousMouseScrollWheelValue() - input.MouseScrollWheelValue();

            if (deltaWheelPos != 0) // determine just direction
            {
                deltaWheelPos /= Math.Abs(deltaWheelPos);
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_BULLET))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.Bullet;
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_MISSILE))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.Missile;
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_CANNON))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.Cannon;
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_UNIVERSAL_LAUNCHER_FRONT))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront;
            }

            if (input.IsNewGameControlPressed(MyGameControlEnums.SELECT_AMMO_UNIVERSAL_LAUNCHER_BACK))
            {
                isKeyPress      = true;
                m_selectedGroup = MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack;
            }

            // in case of wheel direction modify flags to run correct code
            if (deltaWheelPos > 0 && Visible && IsEnabled)
            {
                isKeyPress = true;
                backwardSelectDirection = false;
            }
            // in case of wheel direction modify flags to run correct code
            if (deltaWheelPos < 0 && Visible && IsEnabled)
            {
                isKeyPress = true;
                backwardSelectDirection = true;
            }

            if (isKeyPress)
            {
                if (Visible == false)
                {
                    //I am here when the menu opens
                    LoadAmmoFromShip();
                    //If player change fire commands during game play, we need to show actual buttons names.
                    //ReloadControlText();
                    MyGuiSmallShipHelperAmmo.ResetDescription();
                }
                else
                {
                    if (m_selectedGroup == m_selectedGroupLast)
                    {
                        // if (!MyFakes.MW25D)
                        {
                            if (!backwardSelectDirection)
                            {
                                m_selectedIndex++;
                            }
                            else
                            {
                                m_selectedIndex--;
                            }
                        }
                        // else
                        //   m_selectedIndex = 0;
                    }
                    else
                    {
                        //I am here when category is changed
                        LoadAmmoFromShip();
                        MyGuiSmallShipHelperAmmo.ResetDescription();
                    }

                    if (m_selectedIndex >= m_ammoTypesAmounts.Count)
                    {
                        m_selectedIndex = 0;
                    }
                    if (m_selectedIndex < 0)
                    {
                        m_selectedIndex = m_ammoTypesAmounts.Count - 1;
                    }
                }

                Visible             = true;
                m_selectedGroupLast = m_selectedGroup;
                if (m_selectedIndex < m_ammoTypesAmounts.Count && m_selectedIndex >= 0)
                {
                    m_selectedAmmo = m_ammoTypesAmounts[m_selectedIndex].Type;
                }

                MyAudio.AddCue2D(MySoundCuesEnum.SfxHudWeaponScroll);
            }


            //Because I do not want the gun fired before I made the choice, the menu disappears after the release of key (not press)
            if (Visible)
            {
                if (!MySession.Is25DSector)
                {
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_PRIMARY) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SECONDARY) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_THIRD) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FOURTH) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FIFTH) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }

                    if (input.IsNewKeyPress(Keys.Escape))
                    {
                        Visible = false;
                    }
                }
                else
                {  //MyFakes.MW25D
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_PRIMARY) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_SECONDARY) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_THIRD) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FOURTH) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }
                    if (input.IsGameControlPressed(MyGameControlEnums.FIRE_FIFTH) && m_selectedAmmo != 0)
                    {
                        MySession.PlayerShip.Weapons.AmmoAssignments.AssignAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, m_selectedGroup, m_selectedAmmo);
                        m_isPressLast = true;
                    }

                    if (input.IsNewKeyPress(Keys.Escape))
                    {
                        Visible = false;
                    }
                }

                for (int i = m_ammoTypesAmounts.Count - 1; i >= 0; i--)
                {
                    int itemsPerColumn = 7;

                    int orderX = (int)m_selectedGroup + i / itemsPerColumn;
                    int orderY = i % itemsPerColumn;

                    /*
                     * Vector2 mousePos = MyGuiManager.MouseCursorPosition;
                     * if (MyVideoModeManager.IsTripleHead() == true)
                     *  mousePos += new Vector2(-1, 0);
                     *
                     * if (MyGuiSmallShipHelpers.GetMyGuiSmallShipHelperAmmo(m_ammoTypesAmounts[i].Type).IsPointInMyArea(mousePos))
                     * {
                     * }
                     */
                    //if (MyGuiSmallShipHelpers.GetMyGuiSmallShipHelperAmmo(m_ammoTypesAmounts[i].Type).IsPointInMyArea(MyGuiManager.MouseCursorPosition))
                    MyGuiSmallShipHelperAmmo ammoHelper =
                        MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)m_ammoTypesAmounts[i].Type) as MyGuiSmallShipHelperAmmo;
                    if (ammoHelper.IsPointInMyArea(MyGuiManager.MouseCursorPosition))
                    {
                        if (m_selectedIndex != i || m_selectedAmmo != m_ammoTypesAmounts[m_selectedIndex].Type)
                        {
                            MyAudio.AddCue2D(MySoundCuesEnum.SfxHudWeaponScroll);
                        }
                        m_selectedIndex = i;
                        m_selectedAmmo  = m_ammoTypesAmounts[m_selectedIndex].Type;
                    }
                }

                //if (!MyFakes.MW25D)
                {
                    if (m_isPressLast &&
                        !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))
                    {
                        //I am here when the menu closes
                        m_isPressLast = false;
                        Visible       = false;
                        MyAudio.AddCue2D(MySoundCuesEnum.SfxHudWeaponSelect);
                    }
                }

                /*  else
                 * {
                 *    if (isKeyPress)
                 *        MyAudio.AddCue2D(MySoundCuesEnum.SfxHudWeaponSelect);
                 * } */
            }

            /*
             * if (MyFakes.MW25D)
             * {
             * return false;
             * }   */

            return(base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, receivedFocusInThisUpdate));
        }
示例#12
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);
                }
            }
        }
        //  Method returns true if input was captured by control, so no other controls, nor screen can use input in this update
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool isThisFirstHandleInput)
        {
            if (!Visible)
            {
                return(false);
            }

            bool ret = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, isThisFirstHandleInput);

            if (ret == false)
            {
                if ((IsMouseOver() == true) && (input.IsNewLeftMousePressed() == true))
                {
                    m_carriagePositionIndex = GetCarriagePositionFromMouseCursor();
                    ret = true;
                }

                if ((m_hasKeyboardActiveControl == true) && (hasKeyboardActiveControlPrevious == false))
                {
                    UpdateLastKeyPressTimes(null);
                }

                if (hasKeyboardActiveControl == true)
                {
                    bool isShiftPressed = input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift);
                    bool isCapsLockOn   = (ushort)MyGuiInput.GetKeyState(0x14) == 1;

                    //(deltaFromLastKeypress > MyGuiConstants.TEXTBOX_KEYPRESS_DELAY)
                    //int deltaFromLastKeypress = MyMinerGame.TotalGameTime_Miliseconds - m_lastKeyPressTime;

                    input.GetPressedKeys(m_pressedKeys);

                    for (int i = 0; i < m_pressedKeys.Count; i++)
                    {
                        System.Diagnostics.Debug.Assert(input.IsKeyPress((Keys)m_pressedKeys[i]));
                    }

                    //  Transform pressed letters, characters, numbers, etc to real character/string
                    for (int i = 0; i < m_pressedKeys.Count; i++)
                    {
                        bool tempShift     = isShiftPressed;
                        bool transformText = true;
                        MyGuiControlTextboxKeyToString pressedKey = m_keyToString[(int)m_pressedKeys[i]];

                        //Allow to enter only digits in case such textbox type is set
                        if (m_type == MyGuiControlTextboxType.DIGITS_ONLY)
                        {
                            if ((pressedKey != null) && !input.IsKeyDigit(pressedKey.Key) && pressedKey.Key != Keys.OemPeriod && pressedKey.Key != Keys.Decimal)
                            {
                                transformText = false;
                            }
                        }

                        if (transformText)
                        {
                            //  If we have mapping from this key to string (that means it's allowed character)
                            if (pressedKey != null && m_text.Length < m_maxLength && pressedKey.Character != null && pressedKey.CharacterWhenShift != null)
                            {
                                ret = true;
                                if (IsEnoughDelay((Keys)m_pressedKeys[i], MyGuiConstants.TEXTBOX_CHANGE_DELAY))
                                {
                                    if (Char.IsLetter(pressedKey.Character, 0))
                                    {
                                        if (isCapsLockOn)
                                        {
                                            tempShift = !tempShift;//carefull here variable is not used anymore so we can invert it
                                        }
                                    }
                                    m_text = m_text.Insert(m_carriagePositionIndex, (tempShift == true) ? pressedKey.CharacterWhenShift : pressedKey.Character);

                                    m_carriagePositionIndex++;
                                    UpdateLastKeyPressTimes((Keys)m_pressedKeys[i]);

                                    OnTextChanged();
                                }
                            }
                        }
                    }

                    //  Move left
                    if ((input.IsKeyPress(Keys.Left)) && (IsEnoughDelay(Keys.Left, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        m_carriagePositionIndex--;
                        if (m_carriagePositionIndex < 0)
                        {
                            m_carriagePositionIndex = 0;
                        }
                        UpdateLastKeyPressTimes(Keys.Left);
                    }

                    //  Move right
                    if ((input.IsKeyPress(Keys.Right)) && (IsEnoughDelay(Keys.Right, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        m_carriagePositionIndex++;
                        if (m_carriagePositionIndex > m_text.Length)
                        {
                            m_carriagePositionIndex = m_text.Length;
                        }
                        UpdateLastKeyPressTimes(Keys.Right);
                    }

                    //  Move home
                    if ((input.IsNewKeyPress(Keys.Home)) && (IsEnoughDelay(Keys.Home, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        m_carriagePositionIndex = 0;
                        UpdateLastKeyPressTimes(Keys.Home);
                    }

                    //  Move end
                    if ((input.IsNewKeyPress(Keys.End)) && (IsEnoughDelay(Keys.End, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        m_carriagePositionIndex = m_text.Length;
                        UpdateLastKeyPressTimes(Keys.End);
                    }

                    //  Delete
                    if ((input.IsKeyPress(Keys.Delete)) && (IsEnoughDelay(Keys.Delete, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        if (m_carriagePositionIndex < m_text.Length)
                        {
                            m_text = m_text.Remove(m_carriagePositionIndex, 1);
                            UpdateLastKeyPressTimes(Keys.Delete);

                            OnTextChanged();
                        }
                    }

                    //  Backspace
                    if ((input.IsKeyPress(Keys.Back)) && (IsEnoughDelay(Keys.Back, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        if (m_carriagePositionIndex > 0)
                        {
                            // Handle text scrolling, basicaly try hold carriage on same position in textBox window (avoid textBox with hidden characters)
                            var carriagePositionChange = GetCarriagePosition(m_carriagePositionIndex) - GetCarriagePosition(m_carriagePositionIndex - 1);;
                            var textAreaPosition       = GetTextAreaPosition();
                            if (m_slidingWindowPosition.X - carriagePositionChange.X >= textAreaPosition.X)
                            {
                                m_slidingWindowPosition.X -= carriagePositionChange.X;
                            }
                            else
                            {
                                m_slidingWindowPosition.X = textAreaPosition.X;
                            }

                            m_text = m_text.Remove(m_carriagePositionIndex - 1, 1);
                            m_carriagePositionIndex--;
                            UpdateLastKeyPressTimes(Keys.Back);

                            OnTextChanged();
                        }
                    }

                    ResetLastKeyPressTimes(input);
                    m_formattedAlready = false;
                }
                else
                {
                    if (m_type == MyGuiControlTextboxType.DIGITS_ONLY && m_formattedAlready == false && !string.IsNullOrEmpty(m_text))
                    {
                        var number        = MyValueFormatter.GetDecimalFromString(m_text, 1);
                        int decimalDigits = (number - (int)number > 0) ? 1 : 0;
                        m_text = MyValueFormatter.GetFormatedFloat((float)number, decimalDigits, "");
                        m_carriagePositionIndex = m_text.Length;
                        m_formattedAlready      = true;
                    }
                }
            }

            return(ret);
        }
        //  Method returns true if input was captured by control, so no other controls, nor screen can use input in this update
        public override bool HandleInput(MyGuiInput input, bool hasKeyboardActiveControl, bool hasKeyboardActiveControlPrevious, bool isThisFirstHandleInput)
        {
            if (!Visible)
            {
                return false;
            }

            bool ret = base.HandleInput(input, hasKeyboardActiveControl, hasKeyboardActiveControlPrevious, isThisFirstHandleInput);
            
            if (ret == false)
            {
                if ((IsMouseOver() == true) && (input.IsNewLeftMousePressed() == true))                    
                {
                    m_carriagePositionIndex = GetCarriagePositionFromMouseCursor();
                    ret = true;
                }

                if ((m_hasKeyboardActiveControl == true) && (hasKeyboardActiveControlPrevious == false))
                {
                    UpdateLastKeyPressTimes(null);
                }

                if (hasKeyboardActiveControl == true)
                {
                    bool isShiftPressed = input.IsKeyPress(Keys.LeftShift) || input.IsKeyPress(Keys.RightShift);
                    bool isCapsLockOn = (ushort)MyGuiInput.GetKeyState(0x14) == 1;

                    //(deltaFromLastKeypress > MyGuiConstants.TEXTBOX_KEYPRESS_DELAY)
                    //int deltaFromLastKeypress = MyMinerGame.TotalGameTime_Miliseconds - m_lastKeyPressTime;

                    input.GetPressedKeys(m_pressedKeys);

                    for (int i = 0; i < m_pressedKeys.Count; i++)
                    {
                        System.Diagnostics.Debug.Assert(input.IsKeyPress((Keys)m_pressedKeys[i]));
                    }

                    //  Transform pressed letters, characters, numbers, etc to real character/string
                    for (int i = 0; i < m_pressedKeys.Count; i++)
                    {
                        bool tempShift = isShiftPressed;
                        bool transformText = true;
                        MyGuiControlTextboxKeyToString pressedKey = m_keyToString[(int)m_pressedKeys[i]];

                        //Allow to enter only digits in case such textbox type is set
                        if (m_type == MyGuiControlTextboxType.DIGITS_ONLY)
                        {
                            if ((pressedKey != null) && !input.IsKeyDigit(pressedKey.Key) && pressedKey.Key != Keys.OemPeriod && pressedKey.Key != Keys.Decimal)
                            {
                                transformText = false;
                            }
                        }

                        if (transformText)  
                        {
                            //  If we have mapping from this key to string (that means it's allowed character)
                            if (pressedKey != null && m_text.Length < m_maxLength && pressedKey.Character != null && pressedKey.CharacterWhenShift != null)
                            {
                                ret = true;
                                if (IsEnoughDelay((Keys)m_pressedKeys[i], MyGuiConstants.TEXTBOX_CHANGE_DELAY))
                                {
                                    if (Char.IsLetter(pressedKey.Character, 0))
                                    {
                                        if (isCapsLockOn)
                                            tempShift = !tempShift;//carefull here variable is not used anymore so we can invert it
                                        
                                    }
                                    m_text = m_text.Insert(m_carriagePositionIndex, (tempShift == true) ? pressedKey.CharacterWhenShift : pressedKey.Character);
                                
                                    m_carriagePositionIndex++;
                                    UpdateLastKeyPressTimes((Keys)m_pressedKeys[i]);

                                    OnTextChanged();
                                }
                            }
                        }
                    }

                    //  Move left
                    if ((input.IsKeyPress(Keys.Left)) && (IsEnoughDelay(Keys.Left, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        m_carriagePositionIndex--;
                        if (m_carriagePositionIndex < 0) m_carriagePositionIndex = 0;
                        UpdateLastKeyPressTimes(Keys.Left);
                    }

                    //  Move right
                    if ((input.IsKeyPress(Keys.Right)) && (IsEnoughDelay(Keys.Right, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        m_carriagePositionIndex++;
                        if (m_carriagePositionIndex > m_text.Length) m_carriagePositionIndex = m_text.Length;
                        UpdateLastKeyPressTimes(Keys.Right);
                    }

                    //  Move home
                    if ((input.IsNewKeyPress(Keys.Home)) && (IsEnoughDelay(Keys.Home, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        m_carriagePositionIndex = 0;
                        UpdateLastKeyPressTimes(Keys.Home);
                    }

                    //  Move end
                    if ((input.IsNewKeyPress(Keys.End)) && (IsEnoughDelay(Keys.End, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        m_carriagePositionIndex = m_text.Length;
                        UpdateLastKeyPressTimes(Keys.End);
                    }

                    //  Delete
                    if ((input.IsKeyPress(Keys.Delete)) && (IsEnoughDelay(Keys.Delete, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        if (m_carriagePositionIndex < m_text.Length)
                        {
                            m_text = m_text.Remove(m_carriagePositionIndex, 1);
                            UpdateLastKeyPressTimes(Keys.Delete);

                            OnTextChanged();
                        }
                    }

                    //  Backspace
                    if ((input.IsKeyPress(Keys.Back)) && (IsEnoughDelay(Keys.Back, MyGuiConstants.TEXTBOX_MOVEMENT_DELAY)))
                    {
                        if (m_carriagePositionIndex > 0)
                        {
                            // Handle text scrolling, basicaly try hold carriage on same position in textBox window (avoid textBox with hidden characters)
                            var carriagePositionChange = GetCarriagePosition(m_carriagePositionIndex) - GetCarriagePosition(m_carriagePositionIndex-1); ;
                            var textAreaPosition = GetTextAreaPosition();
                            if (m_slidingWindowPosition.X - carriagePositionChange.X >= textAreaPosition.X)
                            {
                                m_slidingWindowPosition.X -= carriagePositionChange.X;
                            }
                            else
                            {
                                m_slidingWindowPosition.X = textAreaPosition.X;
                            }

                            m_text = m_text.Remove(m_carriagePositionIndex - 1, 1);
                            m_carriagePositionIndex--;
                            UpdateLastKeyPressTimes(Keys.Back);

                            OnTextChanged();
                        }
                    }

                    ResetLastKeyPressTimes(input);
                    m_formattedAlready = false;
                }
                else
                {
                    if (m_type == MyGuiControlTextboxType.DIGITS_ONLY && m_formattedAlready == false && !string.IsNullOrEmpty(m_text))
                    {
                        var number = MyValueFormatter.GetDecimalFromString(m_text, 1);
                        int decimalDigits = (number - (int)number > 0) ? 1 : 0;
                        m_text = MyValueFormatter.GetFormatedFloat((float)number, decimalDigits, "");
                        m_carriagePositionIndex = m_text.Length;
                        m_formattedAlready = true;
                    }
                }
            }

            return ret;
        }
 //  Call this every update, it will check if key as UNPRESSED (thus UP), and if yes, we will remove delay, so multiple 
 //  keypresses are possible fast, but not automatic. User must press DOWN/UP.
 void ResetLastKeyPressTimes(MyGuiInput input)
 {
     for (int i = 0; i < m_keyToString.Length; i++)
     {
         MyGuiControlTextboxKeyToString keyEx = m_keyToString[i];
         if (keyEx != null)
         {
             if (input.IsKeyPress(keyEx.Key) == false)
             {
                 keyEx.LastKeyPressTime = MyConstants.FAREST_TIME_IN_PAST;
             }
         }
     }            
 }