}   // end of Deactivate()

        public void Update()
        {
            touchedThisFrame = false;
            if (active)
            {
                InGame.SetViewportToScreen();

                camera.Resolution = new Point((int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y);
                camera.Recalc();
                camera.Update();

                Matrix matrix = Matrix.Identity;
                brightnessSlider.Update(ref matrix);
                durationSlider.Update(ref matrix);
                ledGrid.Update(ref matrix);
                bar.Update(ref matrix);

                switch (GamePadInput.ActiveMode)
                {
                case GamePadInput.InputMode.GamePad:
                    HandleGamePad();
                    break;

                case GamePadInput.InputMode.Touch:
                    HandleTouch();
                    break;

                case GamePadInput.InputMode.KeyboardMouse:
                    HandleMouse();
                    break;
                }

                // Adjust alpha value for stick icons if needed.
                float targetAlpha = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? 1.0f : 0.0f;
                if (targetAlpha != _stickAlpha)
                {
                    _stickAlpha = targetAlpha;
                    TwitchManager.Set <float> set = delegate(float value, Object param) { stickAlpha = value; };
                    TwitchManager.CreateTwitch <float>(stickAlpha, _stickAlpha, set, 0.2f, TwitchCurve.Shape.EaseOut);
                }

                // touchedThisFrame = true;
            }
        }   // end of Update()
Пример #2
0
        private void UpdateMouseSliders(Camera uicamera)
        {
            Vector2 hitPos = new Vector2(MouseInput.Position.X, MouseInput.Position.Y);

            Matrix mat = Matrix.Invert(slider.WorldMatrix);

            // Convert mouse hit into UV coords.
            Vector2 hitUV = TouchInput.GetHitUV(hitPos, uicamera, ref mat, slider.Size.X, slider.Size.Y, useRtCoords: false);


            bool outside = true;

            if (hitUV.X >= 0 && hitUV.X < 1 && hitUV.Y >= 0 && hitUV.Y < 1)
            {
                slider.HandleMouseInput(hitUV);
                outside = false;
            }

            Matrix identity = Matrix.Identity;

            slider.Update(ref identity);

            //Get Close position matrix.
            mat             = slider.WorldMatrix;
            mat.Translation = new Vector3(closePosition.X, closePosition.Y, mat.Translation.Z);
            mat             = Matrix.Invert(mat);

            hitUV = TouchInput.GetHitUV(hitPos, uicamera, ref mat, closeSize.X, closeSize.Y, useRtCoords: false);

            if (hitUV.X >= 0 && hitUV.X < 1 && hitUV.Y >= 0 && hitUV.Y < 1)
            {
                if (MouseInput.Left.WasPressed)
                {
                    MouseInput.ClickedOnObject = this;
                }
                if (MouseInput.Left.WasReleased && MouseInput.ClickedOnObject == this)
                {
                    sliderActive = false;
                }

                if (MouseInput.ClickedOnObject == this)
                {
                    closeSquareTexture = closeSquareLitTexture;
                }
            }
            else
            {
                closeSquareTexture = closeSquareUnlitTexture;

                // If user clicked outside of slide and close box, close slider.
                if (MouseInput.Left.WasPressed && outside)
                {
                    MouseInput.Left.ClearAllWasPressedState();
                    sliderActive = false;
                }
            }
            if (Actions.Cancel.WasPressed)
            {
                Actions.Cancel.ClearAllWasPressedState();
                sliderActive = false;
            }
        }
Пример #3
0
        private void HandleSliderInput(Camera uicamera)
        {
            if (sliderActive)
            {
                Vector2      dragPos;
                TouchContact touch = null;
                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    touch = TouchInput.GetOldestTouch();
                    if (touch != null)
                    {
                        dragPos = touch.position;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    dragPos = new Vector2(MouseInput.Position.X, MouseInput.Position.Y);
                }


                // Convert mouse hit into UV coords. (GetHitUV for MouseInput and TouchInput have same implementation...)
                Matrix  worldMat = Matrix.Invert(slider.WorldMatrix);
                Vector2 hitUV    = TouchInput.GetHitUV(dragPos, uicamera, ref worldMat, slider.Size.X, slider.Size.Y, useRtCoords: false);;

                bool outside = true;
                if (hitUV.X >= 0 && hitUV.X < 1 && hitUV.Y >= 0 && hitUV.Y < 1)
                {
                    /// \TODO : add touch input for sliders
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        slider.HandleTouchInput(touch, hitUV);
                    }
                    else
                    {
                        slider.HandleMouseInput(hitUV);
                    }
                    outside = false;
                }

                Matrix identity = Matrix.Identity;
                slider.Update(ref identity);

                //Get Close position matrix.
                worldMat             = slider.WorldMatrix;
                worldMat.Translation = new Vector3(closePosition.X, closePosition.Y, worldMat.Translation.Z);
                worldMat             = Matrix.Invert(worldMat);

                hitUV = TouchInput.GetHitUV(dragPos, uicamera, ref worldMat, closeSize.X, closeSize.Y, useRtCoords: false);

                if (hitUV.X >= 0 && hitUV.X < 1 && hitUV.Y >= 0 && hitUV.Y < 1)
                {
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        if (touch.phase == TouchPhase.Began)
                        {
                            touch.TouchedObject = this;
                        }
                        if (touch.phase == TouchPhase.Ended && touch.TouchedObject == this)
                        {
                            sliderActive = false;
                        }

                        if (touch.TouchedObject == this)
                        {
                            closeSquareTexture = closeSquareLitTexture;
                        }
                    }
                    else
                    {
                        if (MouseInput.Left.WasPressed)
                        {
                            MouseInput.ClickedOnObject = this;
                        }
                        if (MouseInput.Left.WasReleased && MouseInput.ClickedOnObject == this)
                        {
                            sliderActive = false;
                        }

                        if (MouseInput.ClickedOnObject == this)
                        {
                            closeSquareTexture = closeSquareLitTexture;
                        }
                    }
                }
                else
                {
                    closeSquareTexture = closeSquareUnlitTexture;
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        // If user TOUCHED outside of slide and close box, close slider.
                        if (TouchInput.WasTouched && outside)
                        {
                            sliderActive = false;
                        }
                    }
                    else
                    {
                        // If user clicked outside of slide and close box, close slider.
                        if (MouseInput.Left.WasPressed && outside)
                        {
                            MouseInput.Left.ClearAllWasPressedState();
                            sliderActive = false;
                        }
                    }
                }
                if (Actions.Cancel.WasPressed)
                {
                    Actions.Cancel.ClearAllWasPressedState();
                    sliderActive = false;
                }
            }
        }