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; } }
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++; } } } }
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; } }
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(); } }