示例#1
0
        public override void Draw(SpriteBatch spriteBatch, bool drawShadow = true)
        {
            bool caretVisible2 = true;

            caretVisible2 = ((DateTime.UtcNow.Millisecond % 1000 >= 500) ? true : false);
            if (_textBoxTexture != null)
            {
                spriteBatch.Draw(_textBoxTexture, new Rectangle(base.X, base.Y, 16, base.Height), new Rectangle(0, 0, 16, base.Height), Color.White);
                spriteBatch.Draw(_textBoxTexture, new Rectangle(base.X + 16, base.Y, base.Width - 32, base.Height), new Rectangle(16, 0, 4, base.Height), Color.White);
                spriteBatch.Draw(_textBoxTexture, new Rectangle(base.X + base.Width - 16, base.Y, 16, base.Height), new Rectangle(_textBoxTexture.Bounds.Width - 16, 0, 16, base.Height), Color.White);
            }
            else
            {
                Game1.drawDialogueBox(base.X - 32, base.Y - 112 + 10, base.Width + 80, base.Height, speaker: false, drawOnlyBox: true);
            }
            if (caretVisible2 && base.Selected)
            {
                spriteBatch.Draw(Game1.staminaRect, new Rectangle(base.X + 16 + (int)currentWidth - 2, base.Y + 8, 4, 32), _textColor);
            }
            float xPositionSoFar = 0f;

            for (int i = 0; i < finalText.Count; i++)
            {
                if (finalText[i].emojiIndex != -1)
                {
                    spriteBatch.Draw(ChatBox.emojiTexture, new Vector2((float)base.X + xPositionSoFar + 12f, base.Y + 12), new Rectangle(finalText[i].emojiIndex * 9 % ChatBox.emojiTexture.Width, finalText[i].emojiIndex * 9 / ChatBox.emojiTexture.Width * 9, 9, 9), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.99f);
                }
                else if (finalText[i].message != null)
                {
                    spriteBatch.DrawString(ChatBox.messageFont(LocalizedContentManager.CurrentLanguageCode), finalText[i].message, new Vector2((float)base.X + xPositionSoFar + 12f, base.Y + 12), ChatMessage.getColorFromName(Game1.player.defaultChatColor), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.99f);
                }
                xPositionSoFar += finalText[i].myLength;
            }
        }
示例#2
0
        public void draw(SpriteBatch b, int x, int y)
        {
            float xPositionSoFar = 0f;
            float yPositionSoFar = 0f;

            for (int i = 0; i < message.Count; i++)
            {
                if (message[i].emojiIndex != -1)
                {
                    b.Draw(ChatBox.emojiTexture, new Vector2((float)x + xPositionSoFar + 1f, (float)y + yPositionSoFar - 4f), new Rectangle(message[i].emojiIndex * 9 % ChatBox.emojiTexture.Width, message[i].emojiIndex * 9 / ChatBox.emojiTexture.Width * 9, 9, 9), Color.White * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.99f);
                }
                else if (message[i].message != null)
                {
                    if (message[i].message.Equals(Environment.NewLine))
                    {
                        xPositionSoFar  = 0f;
                        yPositionSoFar += ChatBox.messageFont(language).MeasureString("(").Y;
                    }
                    else
                    {
                        b.DrawString(ChatBox.messageFont(language), message[i].message, new Vector2((float)x + xPositionSoFar, (float)y + yPositionSoFar), color * alpha, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.99f);
                    }
                }
                xPositionSoFar += message[i].myLength;
                if (xPositionSoFar >= 888f)
                {
                    xPositionSoFar  = 0f;
                    yPositionSoFar += ChatBox.messageFont(language).MeasureString("(").Y;
                    if (message.Count > i + 1 && message[i + 1].message != null && message[i + 1].message.Equals(Environment.NewLine))
                    {
                        i++;
                    }
                }
            }
        }
示例#3
0
 public void leftClick(int x, int y, ChatBox cb)
 {
     if (isWithinBounds(x, y))
     {
         int relativeX = x - xPositionOnScreen;
         int relativeY = y - yPositionOnScreen;
         if (upArrow.containsPoint(relativeX, relativeY))
         {
             upArrowPressed();
         }
         else if (downArrow.containsPoint(relativeX, relativeY))
         {
             downArrowPressed();
         }
         else if (sendArrow.containsPoint(relativeX, relativeY) && cb.chatBox.currentWidth > 0f)
         {
             cb.textBoxEnter(cb.chatBox);
             sendArrow.scale = 0.5f;
             Game1.playSound("shwip");
         }
         foreach (ClickableComponent c in emojiSelectionButtons)
         {
             if (c.containsPoint(relativeX, relativeY))
             {
                 int index = pageStartIndex + int.Parse(c.name);
                 cb.chatBox.receiveEmoji(index);
                 Game1.playSound("coin");
                 break;
             }
         }
     }
 }
示例#4
0
 public void updateWidth()
 {
     currentWidth = 0f;
     foreach (ChatSnippet cs in finalText)
     {
         if (cs.message != null)
         {
             cs.myLength = ChatBox.messageFont(LocalizedContentManager.CurrentLanguageCode).MeasureString(cs.message).X;
         }
         currentWidth += cs.myLength;
     }
 }
示例#5
0
        public void draw(SpriteBatch b, int left, int bottom, ClickableComponent current, List <ClickableComponent> parentComponents)
        {
            UpdateFarmers(parentComponents);
            if (_farmers.Count == 0)
            {
                return;
            }
            int sizeY = 100;

            height            = sizeY * _farmers.Count;
            xPositionOnScreen = left;
            yPositionOnScreen = bottom - height;
            IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(301, 288, 15, 15), xPositionOnScreen, yPositionOnScreen, width, height, Color.White, 4f, drawShadow: false);
            b.End();
            b.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, Utility.ScissorEnabled);
            Rectangle origClip = b.GraphicsDevice.ScissorRectangle;
            int       x        = xPositionOnScreen + 16;
            int       y        = yPositionOnScreen;

            for (int i = 0; i < _farmers.Count; i++)
            {
                Farmer    farmer  = _farmers[i];
                Rectangle newClip = origClip;
                newClip.X      = x;
                newClip.Y      = y;
                newClip.Height = sizeY - 8;
                newClip.Width  = 200;
                b.GraphicsDevice.ScissorRectangle = newClip;
                FarmerRenderer.isDrawingForUI     = true;
                farmer.FarmerRenderer.draw(b, new FarmerSprite.AnimationFrame(farmer.bathingClothes ? 108 : 0, 0, secondaryArm: false, flip: false), farmer.bathingClothes ? 108 : 0, new Rectangle(0, farmer.bathingClothes ? 576 : 0, 16, 32), new Vector2(x, y), Vector2.Zero, 0.8f, 2, Color.White, 0f, 1f, farmer);
                FarmerRenderer.isDrawingForUI     = false;
                b.GraphicsDevice.ScissorRectangle = origClip;
                int    textX      = x + 80;
                int    textY      = y + 12;
                string farmerName = ChatBox.formattedUserName(farmer);
                b.DrawString(Game1.dialogueFont, farmerName, new Vector2(textX, textY), Color.White);
                string platformUserName = Game1.multiplayer.getUserName(farmer.UniqueMultiplayerID);
                if (!string.IsNullOrEmpty(platformUserName))
                {
                    textY += Game1.dialogueFont.LineSpacing + 4;
                    string userName = "******" + platformUserName + ")";
                    b.DrawString(Game1.smallFont, userName, new Vector2(textX, textY), Color.White);
                }
                y += sizeY;
            }
            b.GraphicsDevice.ScissorRectangle = origClip;
            b.End();
            b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
        }
示例#6
0
 public override void RecieveTextInput(string text)
 {
     if (finalText.Count == 0)
     {
         finalText.Add(new ChatSnippet("", LocalizedContentManager.CurrentLanguageCode));
     }
     if (!(currentWidth + ChatBox.messageFont(LocalizedContentManager.CurrentLanguageCode).MeasureString(text).X >= (float)(base.Width - 16)))
     {
         if (finalText.Last().message != null)
         {
             finalText.Last().message += text;
         }
         else
         {
             finalText.Add(new ChatSnippet(text, LocalizedContentManager.CurrentLanguageCode));
         }
         updateWidth();
     }
 }
示例#7
0
 public EmojiMenu(ChatBox chatBox, Texture2D emojiTexture, Texture2D chatBoxTexture)
 {
     this.chatBox        = chatBox;
     this.chatBoxTexture = chatBoxTexture;
     this.emojiTexture   = emojiTexture;
     width  = 300;
     height = 248;
     for (int y = 0; y < 5; y++)
     {
         for (int x = 0; x < 6; x++)
         {
             emojiSelectionButtons.Add(new ClickableComponent(new Rectangle(16 + x * 10 * 4, 16 + y * 10 * 4, 36, 36), string.Concat(x + y * 6)));
         }
     }
     upArrow     = new ClickableComponent(new Rectangle(256, 16, 32, 20), "");
     downArrow   = new ClickableComponent(new Rectangle(256, 156, 32, 20), "");
     sendArrow   = new ClickableComponent(new Rectangle(256, 188, 32, 32), "");
     totalEmojis = ChatBox.emojiTexture.Width / 9 * (ChatBox.emojiTexture.Height / 9);
 }