Exemplo n.º 1
0
        internal override void HandleClick(int mouse_clicks, EventArgs e)
        {
            base.HandleClick(mouse_clicks, e);

            MouseEventArgs mea = e as MouseEventArgs;

            if (mea != null)
            {
                if (ButtonBounds.Contains(mea.Location))
                {
                    OnButtonClick(EventArgs.Empty);
                }
            }
        }
Exemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            if (!IsEnabled)
            {
                return;
            }

            MouseState mouseState = Mouse.GetState();

            if (ButtonBounds.Contains(mouseState.Position) && mouseState.LeftButton == ButtonState.Pressed)
            {
                _game.Replay();
            }
        }
Exemplo n.º 3
0
        private Rectangle ScrollButtonBounds(ButtonBounds buttonBounds)
        {
            Rectangle leftScrollButtonBounds = new Rectangle();

            GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "System.Drawing.Point", MemberTypes.Constructor, new Parameter(GUI.m_APE, 10), new Parameter(GUI.m_APE, 10));
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store2, "GetLayoutSystemAt", MemberTypes.Method, new Parameter(GUI.m_APE, DataStores.Store1));
            switch (buttonBounds)
            {
            case ButtonBounds.Left:
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store2, DataStores.Store3, "LeftScrollButtonBounds", MemberTypes.Property);
                break;

            case ButtonBounds.Right:
                GUI.m_APE.AddQueryMessageReflect(DataStores.Store2, DataStores.Store3, "RightScrollButtonBounds", MemberTypes.Property);
                break;

            default:
                throw new Exception("Unsupported button bounds: " + buttonBounds.ToString());
            }
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store4, "X", MemberTypes.Property);
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store5, "Y", MemberTypes.Property);
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store6, "Width", MemberTypes.Property);
            GUI.m_APE.AddQueryMessageReflect(DataStores.Store3, DataStores.Store7, "Height", MemberTypes.Property);
            GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store4);
            GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store5);
            GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store6);
            GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store7);
            GUI.m_APE.SendMessages(EventSet.APE);
            GUI.m_APE.WaitForMessages(EventSet.APE);
            //Get the value(s) returned MUST be done straight after the WaitForMessages call
            leftScrollButtonBounds.X      = GUI.m_APE.GetValueFromMessage();
            leftScrollButtonBounds.Y      = GUI.m_APE.GetValueFromMessage();
            leftScrollButtonBounds.Width  = GUI.m_APE.GetValueFromMessage();
            leftScrollButtonBounds.Height = GUI.m_APE.GetValueFromMessage();

            return(leftScrollButtonBounds);
        }
Exemplo n.º 4
0
        public override void Update(GameTime gameTime)
        {
            if ((Name == "Resume" || Name == "End") && !Active)
            {
                Active = true;
            }

            if (Active)
            {
                //				if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) && !ContainsMouse)
                //                    ContainsMouse = true;
                //				else if (!ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) && ContainsMouse)
                //                {
                //                    HasFocus = false;
                //                    ContainsMouse = false;
                //                }
                //				if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) &&
                //					InputHandler.IsScreenBeingTouched())
                //                {
                //                    HasFocus = true;
                //                    base.OnSelected(null);
                //                }
                #region Mouse
                if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) && !ContainsMouse)
                {
                    ContainsMouse = true;
                }
                else if (!ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) && ContainsMouse)
                {
                    HasFocus      = false;
                    ContainsMouse = false;
                }

                if (ContainsMouse && InputHandler.FingerRaised())
                {
                    HasFocus = true;
                    base.OnSelected(null);
                    #endregion

                    #region Touch
                    //if (ButtonBounds.Contains (InputHandler.TouchVectorScaled.ToPoint ()) && !ContainsMouse)
                    //    ContainsMouse = true;
                    //else if (!ButtonBounds.Contains (InputHandler.TouchVectorScaled.ToPoint ()) && ContainsMouse) {
                    //    HasFocus = false;
                    //    ContainsMouse = false;
                    //}

                    //if (ContainsMouse && InputHandler.FingerRaised ()) {
                    //    HasFocus = true;
                    //    base.OnSelected (null);
                }
                #endregion
            }
            else
            {
                var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

                moveTimer += elapsed;

                if (moveTimer >= moveTimerDuration)
                {
                    moveTimer = 0;

                    if (!bounceUp)
                    {
                        Position = new Vector2(Position.X, Position.Y + 10);

                        if (Position.Y >= targetPoint + 22)
                        {
                            bounceUp = true;
                        }
                    }
                    else
                    {
                        Position = new Vector2(Position.X, Position.Y - 3);
                        if (Position.Y <= targetPoint)
                        {
                            Enabled = true;
                            Active  = true;

                            ButtonBounds = new Rectangle((int)Position.X, (int)Position.Y, ButtonBounds.Width, ButtonBounds.Height);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        //-------------------------------------------------------
        //------------------------Methods------------------------
        //-------------------------------------------------------

        protected virtual bool InBounds(MouseState mouseState)
        {
            return(ButtonBounds.Contains(mouseState.Position));
        }
Exemplo n.º 6
0
        public override void Update(GameTime gameTime)
        {
            #region Mouse
            if (!ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()))
            {
                Highlighted = true;
                HasFocus    = false;

                if (HasPlayed)
                {
                    HasPlayed = false;
                }
            }

            if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()))
            {
                Highlighted = true;
                HasFocus    = true;
            }

            if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) &&
                InputHandler.FingerRaised())
            {
                HasFocus = true;
                base.OnSelected(null);
            }
            #endregion

            #region Touch
            //if (!ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()))
            //{
            //    Highlighted = true;
            //    HasFocus = false;

            //    if (HasPlayed)
            //        HasPlayed = false;

            //}


            //if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()))
            //{
            //    Highlighted = true;
            //    HasFocus = true;

            //}

            //if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) &&
            //    InputHandler.FingerRaised())
            //{
            //    HasFocus = true;
            //    base.OnSelected(null);
            //}

            #endregion

            //if (HasFocus && !HasPlayed)
            //{
            //    SoundBoard.ButtonHighlight.Play();
            //    HasPlayed = true;
            //}
        }