Example #1
0
        }   // end of HandleTouchInput()

        private void HandleMouseInput(Vector2 hit)
        {
            if (hitBoxA.LeftPressed(hit))
            {
                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }
            else if (hitBoxB.LeftPressed(hit))
            {
                // Disable this hint until reset by user.
                XmlOptionsData.SetHintAsDisabled(curHint.ID);

                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }
            else if (upBox.LeftPressed(hit))
            {
                ScrollDown();
            }
            else if (downBox.LeftPressed(hit))
            {
                ScrollUp();
            }

            // Check for hover and adjust text color to match.
            Color newColor;

            newColor = hitBoxA.Contains(hit) ? hoverTextColor : lightTextColor;
            if (newColor != labelATargetColor)
            {
                labelATargetColor = newColor;
                Vector3 curColor  = new Vector3(labelAColor.R / 255.0f, labelAColor.G / 255.0f, labelAColor.B / 255.0f);
                Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f);

                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                {
                    labelAColor.R = (byte)(value.X * 255.0f + 0.5f);
                    labelAColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    labelAColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }

            newColor = hitBoxB.Contains(hit) ? hoverTextColor : lightTextColor;
            if (newColor != labelBTargetColor)
            {
                labelBTargetColor = newColor;
                Vector3 curColor  = new Vector3(labelBColor.R / 255.0f, labelBColor.G / 255.0f, labelBColor.B / 255.0f);
                Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f);

                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                {
                    labelBColor.R = (byte)(value.X * 255.0f + 0.5f);
                    labelBColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    labelBColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }
        }   // end of HandleMouseInput()
Example #2
0
        }   // end of c'tor

        public void Update(Camera camera)
        {
            if (Active)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                if (Actions.Select.WasPressed)
                {
                    Actions.Select.ClearAllWasPressedState();

                    // Disable this hint for this session.
                    if (curHint.ShowOnce)
                    {
                        curHint.Disabled = true;
                    }

                    Deactivate();
                }
                if (Actions.X.WasPressed)
                {
                    Actions.X.ClearAllWasPressedState();

                    // Disable this hint until reset by user.
                    XmlOptionsData.SetHintAsDisabled(curHint.ID);

                    // Disable this hint for this session.
                    if (curHint.ShowOnce)
                    {
                        curHint.Disabled = true;
                    }

                    Deactivate();
                }

                // We need to be able to slip out to the mini-hub here since
                // continuous, repeated calls to ScrollableModalHint can lock the
                // user out of control.
                if (Actions.MiniHub.WasPressed)
                {
                    Actions.MiniHub.ClearAllWasPressedState();

                    Deactivate();
                    InGame.inGame.SwitchToMiniHub();
                }

                // We need to be able to slip out to the tool menu here since
                // continuous, repeated calls to ScrollableModalHint can lock the
                // user out of control.
                if (Actions.ToolMenu.WasPressed)
                {
                    Actions.ToolMenu.ClearAllWasPressedState();

                    Deactivate();
                    if (InGame.inGame.State == InGame.States.Active)
                    {
                        InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.ToolMenu;
                    }
                }

                // Scroll text???
                if (blob.NumLines != 0)
                {
                    int scroll = MouseInput.ScrollWheel - MouseInput.PrevScrollWheel;

                    if (Actions.Up.WasPressedOrRepeat || scroll > 0)
                    {
                        ScrollDown();
                    }

                    if (Actions.Down.WasPressedOrRepeat || scroll < 0)
                    {
                        ScrollUp();
                    }

                    // If we're not shutting down...
                    if (Active)
                    {
                    }   // end if not shutting down.
                }

                // We should be on top and owning all input
                // focus so don't let anthing trickle down.
                GamePadInput.ClearAllWasPressedState();

                // Disable the help overlay's tool icon because in some situations
                // it can overlap the text making it unreadable.
                HelpOverlay.ToolIcon = null;

                // If active we need to pre-render the text to the 1k rendertarget since
                // changing render targets on the Xbox forces a resolve.
                PreRender();

                // If we're rendering this into a 1280x720 rt we need a matching camera to calc mouse hits.
                if (useBackgroundThumbnail)
                {
                    camera            = new PerspectiveUICamera();
                    camera.Resolution = new Point(1280, 720);
                }

                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    for (int i = 0; i < TouchInput.TouchCount; i++)
                    {
                        TouchContact touch = TouchInput.GetTouchContactByIndex(i);

                        Vector2 touchHit = touch.position;

                        // Adjust for position and scaling of final rendering.
                        touchHit -= renderPosition;
                        touchHit /= renderScale;

                        if (useRtCoords)
                        {
                            touchHit = ScreenWarp.ScreenToRT(touch.position);
                        }
                        HandleTouchInput(touch, touchHit);
                    }
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    Vector2 hit = MouseInput.PositionVec;

                    // Adjust for position and scaling of final rendering.
                    hit -= renderPosition;
                    hit /= renderScale;

                    if (useRtCoords)
                    {
                        hit = MouseInput.GetMouseInRtCoords();
                    }
                    HandleMouseInput(hit);
                }
            } // end if active.
        }     // end of Update()
Example #3
0
        private void HandleTouchInput(TouchContact touch, Vector2 hit)
        {
            if (hitBoxA.Touched(touch, hit))
            {
                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }
            else if (hitBoxB.Touched(touch, hit))
            {
                // Disable this hint until reset by user.
                XmlOptionsData.SetHintAsDisabled(curHint.ID);

                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }
            else if (upBox.Touched(touch, hit))
            {
                ScrollDown();
            }
            else if (downBox.Touched(touch, hit))
            {
                ScrollUp();
            }
            else
            {
                // Touch is active, but none of the buttons were hit so assume user is trying to scroll text.
                if (touch.phase == TouchPhase.Began)
                {
                    prevTouchY = touch.position.Y;
                }
                if (touch.phase == TouchPhase.Moved)
                {
                    // Note we calc the delta ourselves since the TouchInput code
                    // may return the TouchContact for multiple frames.
                    float delta = touch.position.Y - prevTouchY;

                    // Adjust for screen / rt ratio.
                    Vector2 ratio = TouchInput.GetWinRTRatio(camera);
                    delta /= ratio.Y;

                    accumulatedTouchInput += delta;
                    prevTouchY             = touch.position.Y;
                    if (accumulatedTouchInput > blob.TotalSpacing / 2)
                    {
                        accumulatedTouchInput -= blob.TotalSpacing;
                        ScrollDown();
                    }
                    else if (accumulatedTouchInput < -blob.TotalSpacing / 2)
                    {
                        accumulatedTouchInput += blob.TotalSpacing;
                        ScrollUp();
                    }
                }
            }

            // Check for hover and adjust text color to match.
            Color newColor;

            newColor = hitBoxA.Contains(hit) ? hoverTextColor : lightTextColor;
            if (newColor != labelATargetColor)
            {
                labelATargetColor = newColor;
                Vector3 curColor  = new Vector3(labelAColor.R / 255.0f, labelAColor.G / 255.0f, labelAColor.B / 255.0f);
                Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f);

                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                {
                    labelAColor.R = (byte)(value.X * 255.0f + 0.5f);
                    labelAColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    labelAColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }

            newColor = hitBoxB.Contains(hit) ? hoverTextColor : lightTextColor;
            if (newColor != labelBTargetColor)
            {
                labelBTargetColor = newColor;
                Vector3 curColor  = new Vector3(labelBColor.R / 255.0f, labelBColor.G / 255.0f, labelBColor.B / 255.0f);
                Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f);

                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                {
                    labelBColor.R = (byte)(value.X * 255.0f + 0.5f);
                    labelBColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    labelBColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }
        }   // end of HandleTouchInput()
Example #4
0
        }   // end of c'tor

        public void Update(Camera camera)
        {
            if (Active)
            {
                GamePadInput pad = GamePadInput.GetGamePad0();

                if (InGame.inGame.State == InGame.States.Active && InGame.inGame.CurrentUpdateMode == InGame.UpdateMode.RunSim)
                {
                    // We need to be able to slip out to the mini-hub here since
                    // continuous, repeated calls to ModalHint can lock the
                    // user out of control.
                    if (Actions.MiniHub.WasPressed)
                    {
                        Actions.MiniHub.ClearAllWasPressedState();

                        Deactivate();
                        InGame.inGame.SwitchToMiniHub();
                    }

                    // We need to be able to slip out to the tool menu here since
                    // continuous, repeated calls to ModalHint can lock the
                    // user out of control.
                    if (Actions.ToolMenu.WasPressed)
                    {
                        Actions.ToolMenu.ClearAllWasPressedState();

                        Deactivate();
                        InGame.inGame.CurrentUpdateMode = InGame.UpdateMode.ToolMenu;
                    }
                }

                if (Actions.Select.WasPressed)
                {
                    Actions.Select.ClearAllWasPressedState();

                    // Disable this hint for this session.
                    if (curHint.ShowOnce)
                    {
                        curHint.Disabled = true;
                    }

                    Deactivate();
                }
                if (Actions.X.WasPressed)
                {
                    Actions.X.ClearAllWasPressedState();

                    // Disable this hint until reset by user.
                    XmlOptionsData.SetHintAsDisabled(curHint.ID);

                    // Disable this hint for this session.
                    if (curHint.ShowOnce)
                    {
                        curHint.Disabled = true;
                    }

                    Deactivate();
                }

                if (useBackgroundThumbnail)
                {
                    camera            = new PerspectiveUICamera();
                    camera.Resolution = new Point(1280, 720);
                }

                if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                {
                    for (int i = 0; i < TouchInput.TouchCount; i++)
                    {
                        TouchContact touch = TouchInput.GetTouchContactByIndex(i);

                        Vector2 touchHit = touch.position;
                        if (useRtCoords)
                        {
                            touchHit = ScreenWarp.ScreenToRT(touch.position);
                        }
                        HandleTouchInput(touch, touchHit);
                    }
                }
                else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                {
                    Vector2 hit = MouseInput.PositionVec;
                    if (useRtCoords)
                    {
                        hit = MouseInput.GetMouseInRtCoords();
                    }
                    HandleMouseInput(hit);
                }
            } // end if active.
        }     // end of Update()