コード例 #1
0
        public override void Draw(SpriteBatch sb)
        {
            if (MenuButton == null)
            {
                return;
            }

            int buttonLock = ButtonLock;             // we only want to get this once

            bool foundHighlight = false;

            Vector2 mouse = new Vector2(Main.mouseX, Main.mouseY);

            Update();

            int count = 0;

            MenuButton.whoAmi = count++;
            MenuButton.Update();

            if (foundHighlight)
            {
                MenuButton.Draw(sb, false);
            }
            else
            {
                if (MenuButton.canMouseOver && !MenuButton.disabled && (buttonLock == -1 || buttonLock == MenuButton.whoAmi))
                {
                    foundHighlight = MenuButton.MouseOver(mouse);
                }

                if (MenuButton.whoAmi == buttonLock)
                {
                    foundHighlight = true;
                }

                MenuButton.Draw(sb, foundHighlight);

                if (foundHighlight && Main.mouseLeft)
                {
                    if (MenuButton.buttonLock)
                    {
                        ButtonLock = MenuButton.whoAmi;
                    }

                    if (Main.mouseLeftRelease)
                    {
                        MenuButton.framesHeld = 0;
                        MenuButton.Click();
                    }
                    else
                    {
                        MenuButton.framesHeld++;
                        MenuButton.ClickHold();
                    }
                }
            }

            base.Draw(sb);
        }