Пример #1
0
        public void leftClick(int x, int y, EmoteMenuButton emb)
        {
            if (isWithinBounds(x, y))
            {
                int x1 = x - this.xPositionOnScreen;
                int y1 = y - this.yPositionOnScreen;

                if (this.upArrow.containsPoint(x1, y1))
                {
                    this.upArrowPressed(getAmmountToScroll());
                }
                else if (this.downArrow.containsPoint(x1, y1))
                {
                    this.downArrowPressed(getAmmountToScroll());
                }

                foreach (ClickableComponent emoteSelectionButton in this.emoteSelectionButtons)
                {
                    if (emoteSelectionButton.containsPoint(x1, y1))
                    {
                        Game1.player.IsEmoting = false;
                        int emote = this.pageStartIndex + int.Parse(emoteSelectionButton.name);
                        Game1.player.doEmote(emote * 4);
                        Game1.playSound("coin");
                        break;
                    }
                }
            }
        }
Пример #2
0
        // Static arrow test
        //private Texture2D menuTexture;

        public EmoteMenu(IModHelper helper, EmoteMenuButton emoteMenuButton, Texture2D emoteMenuTexture, Texture2D chatBoxTexture, Texture2D emoteTexture, Vector2 position)
        {
            // Static arrow test
            //this.menuTexture = helper.Content.Load<Texture2D>("assets\\emoteBoxPrototype.png", ContentSource.ModFolder);
            this.emoteMenuButton  = emoteMenuButton;
            this.emoteMenuTexture = emoteMenuTexture;
            this.chatBoxTexture   = chatBoxTexture;
            this.emoteTexture     = emoteTexture;

            this.width  = 300;
            this.height = 250;

            this.emoteSelectionButtons = new List <ClickableComponent>();
            int spriteSize = emoteSize * Game1.pixelZoom + 8;

            for (int i = 0; i < maxRowComponents; ++i)
            {
                for (int j = 0; j < maxColComponents; j++)
                {
                    this.emoteSelectionButtons.Add(new ClickableComponent(new Rectangle(j * spriteSize + 36, i * spriteSize + 16, spriteSize, spriteSize), string.Concat(j + (i * maxColComponents) + 1)));
                }
            }

            this.upArrow   = new ClickableComponent(Sprites.ChatBox.UpArrow, nameof(Sprites.ChatBox.UpArrow));
            this.downArrow = new ClickableComponent(Sprites.ChatBox.DownArrow, nameof(Sprites.ChatBox.DownArrow));

            totalEmotes = (emoteTexture.Width / (animationFrames * emoteSize)) * ((emoteTexture.Height - emoteSize) / emoteSize);

            this.exitFunction += this.OnExit;
            IsOpen             = false;
        }