Example #1
0
        protected override void Update(GameTime gameTime)
        {
            float frameTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            m_Mouse.Update(frameTime);
            m_Pad.Update(frameTime);

#if WINDOWS_PHONE
            m_PadActive = false;
#elif WINDOWS
            m_PadActive = m_Pad.IsActive();
#elif XBOX
            m_PadActive = true;
#endif

            if (m_PadActive)
            {
                if (m_Pad.CheckButton(InputPadButtons.LBumper) == InputState.Pressed)
                {
                    Prev();
                }

                if (m_Pad.CheckButton(InputPadButtons.RBumper) == InputState.Pressed)
                {
                    Next();
                }


                if (m_Pad.CheckButton(InputPadButtons.A) == InputState.Pressed)
                {
                    Play();
                }

                if (m_Pad.CheckButton(InputPadButtons.B) == InputState.Pressed)
                {
                    Stop();
                }
            }

            // Allows the game to exit, WP7 can pick this up as well.
            if (m_Pad.CheckButton(InputPadButtons.Back) == InputState.Pressed)
            {
                this.Exit();
            }


            if (m_Mouse.CheckButton(InputMouseButtons.Left) == InputState.Pressed)
            {
                int selectedButton = -1;
                for (int i = 0; i < 4; i++)
                {
                    if (m_Mouse.GetX() > m_ButtonLocations[i].X && m_Mouse.GetX() < m_ButtonLocations[i].X + m_Buttons[i].Width &&
                        m_Mouse.GetY() > m_ButtonLocations[i].Y && m_Mouse.GetY() < m_ButtonLocations[i].Y + m_Buttons[i].Height)
                    {
                        selectedButton = i;
                        break;
                    }
                }

                if (selectedButton != -1)
                {
                    switch (selectedButton)
                    {
                    case 0:
                    {
                        Prev();
                        break;
                    }

                    case 1:
                    {
                        Play();
                        break;
                    }

                    case 2:
                    {
                        Stop();
                        break;
                    }

                    case 3:
                    {
                        Next();
                        break;
                    }
                    }
                }
            }

            m_ProgressPercentage = m_Player.GetProgress();

            base.Update(gameTime);
        }