예제 #1
0
 /// <summary>
 /// Handles the button press event to track which focused menu item will get the activation
 /// </summary>
 /// <param name="backButton"></param>
 /// <param name="startButton"></param>
 /// <param name="systemButton"></param>
 /// <param name="aButton"></param>
 /// <param name="bButton"></param>
 /// <param name="xButton"></param>
 /// <param name="yButton"></param>
 /// <param name="leftShoulder"></param>
 /// <param name="rightShoulder"></param>
 /// <param name="player"></param>
 protected override void OnGamePadButtonUpdate(CCGamePadButtonStatus backButton, CCGamePadButtonStatus startButton, CCGamePadButtonStatus systemButton, CCGamePadButtonStatus aButton, CCGamePadButtonStatus bButton, CCGamePadButtonStatus xButton, CCGamePadButtonStatus yButton, CCGamePadButtonStatus leftShoulder, CCGamePadButtonStatus rightShoulder, Microsoft.Xna.Framework.PlayerIndex player)
 {
     base.OnGamePadButtonUpdate(backButton, startButton, systemButton, aButton, bButton, xButton, yButton, leftShoulder, rightShoulder, player);
     if (!HasFocus)
     {
         return;
     }
     if (backButton == CCGamePadButtonStatus.Pressed || aButton == CCGamePadButtonStatus.Pressed || bButton == CCGamePadButtonStatus.Pressed ||
         xButton == CCGamePadButtonStatus.Pressed || yButton == CCGamePadButtonStatus.Pressed || leftShoulder == CCGamePadButtonStatus.Pressed ||
         rightShoulder == CCGamePadButtonStatus.Pressed)
     {
         CCMenuItem item = FocusedItem;
         item.Selected();
         m_pSelectedItem = item;
         m_eState        = CCMenuState.TrackingTouch;
     }
     else if (backButton == CCGamePadButtonStatus.Released || aButton == CCGamePadButtonStatus.Released || bButton == CCGamePadButtonStatus.Released ||
              xButton == CCGamePadButtonStatus.Released || yButton == CCGamePadButtonStatus.Released || leftShoulder == CCGamePadButtonStatus.Released ||
              rightShoulder == CCGamePadButtonStatus.Released)
     {
         if (m_eState == CCMenuState.TrackingTouch)
         {
             // Now we are selecting the menu item
             CCMenuItem item = FocusedItem;
             if (item != null && m_pSelectedItem == item)
             {
                 // Activate this item
                 item.Unselected();
                 item.Activate();
                 m_eState        = CCMenuState.Waiting;
                 m_pSelectedItem = null;
             }
         }
     }
 }
예제 #2
0
        public override void TouchMoved(CCTouch touch)
        {
            Debug.Assert(m_eState == CCMenuState.TrackingTouch, "[Menu TouchMoved] -- invalid state");
            CCMenuItem currentItem = ItemForTouch(touch);

            if (currentItem != m_pSelectedItem)
            {
                if (m_pSelectedItem != null)
                {
                    m_pSelectedItem.Unselected();
                }

                m_pSelectedItem = currentItem;

                if (m_pSelectedItem != null)
                {
                    m_pSelectedItem.Selected();
                }
            }
        }
예제 #3
0
        public override bool TouchBegan(CCTouch touch)
        {
            if (m_eState != CCMenuState.Waiting || !m_bVisible || !m_bEnabled)
            {
                return(false);
            }

            for (CCNode c = m_pParent; c != null; c = c.Parent)
            {
                if (c.Visible == false)
                {
                    return(false);
                }
            }

            m_pSelectedItem = ItemForTouch(touch);
            if (m_pSelectedItem != null)
            {
                m_eState = CCMenuState.TrackingTouch;
                m_pSelectedItem.Selected();
                return(true);
            }
            return(false);
        }
예제 #4
0
        public override void TouchMoved(CCTouch touch)
        {
            Debug.Assert(m_eState == CCMenuState.TrackingTouch, "[Menu TouchMoved] -- invalid state");
            CCMenuItem currentItem = ItemForTouch(touch);
            if (currentItem != m_pSelectedItem)
            {
                if (m_pSelectedItem != null)
                {
                    m_pSelectedItem.Unselected();
                }

                m_pSelectedItem = currentItem;

                if (m_pSelectedItem != null)
                {
                    m_pSelectedItem.Selected();
                }
            }
        }
예제 #5
0
        public override bool TouchBegan(CCTouch touch)
        {
            if (m_eState != CCMenuState.Waiting || !m_bVisible || !m_bEnabled)
            {
                return false;
            }

            for (CCNode c = m_pParent; c != null; c = c.Parent)
            {
                if (c.Visible == false)
                {
                    return false;
                }
            }

            m_pSelectedItem = ItemForTouch(touch);
            if (m_pSelectedItem != null)
            {
                m_eState = CCMenuState.TrackingTouch;
                m_pSelectedItem.Selected();
                return true;
            }
            return false;
        }