XNA C# How to draw fonts in different color
- by XNA newbie
I'm doing a simple chat system with XNA C#. It is a chatbox that contains 5 lines of chat typed by the users. Something like a MMORPG chatting system.
[User1name] says: Hi
[User2name] says: Hello
[User1name] says: What are you doing?
[User2name] says: I'm fine
[System] The time is now 1:03AM.
When the user pressed 'ENTER', the text he entered will be added inside an ArrayList
chatList.Add(s);
For displaying the text he entered, I used
for (int i = 0; i < chatList.Count(); i++)
{
spriteBatch.DrawString(font, chatList[i], new Vector2(40, arr1[i]), Color.Yellow);
}
*arr1[i] contains 5 y-axis points to print my 5 line of chats in the chatbox
Question1: What if I have another type of message which will be added into ChatList (something like a system message). I need the System Message to be printed out in red color.
And if the user keeps on chatting, the chat box will be updated according: (MAX 5 LINES) The newest chat will be shown below, and the oldest one will be deleted if they reached the max 5 lines.
[User2name] says: Hello
[User1name] says: What are you doing?
[User2name] says: I'm fine
[System] The time is now 1:03AM.
[User1name] says: Ok, great to hear that!
I'm having trouble to print each line color according to their msg type. For normal msg, it should be yellow. For system msg, it should be red.
Question2: And for the next problem, I need the chat texts to be white color, while the names of the user is yellow (like warcraft3 chat system). How do I do that?
I have a hard time thinking of a solution for these to work. Advise needed.