Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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;
        }