This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Monogame/XNA doesn't allow you to alter the style of a string in the middle of drawing it, so instead you have to draw each | |
individual piece of a string if you want to bold or italicize a word. This involves knowing how long each bit of string is | |
and calling DrawString() for each one, all while making sure they line up correctly. Add in the ability to word wrap and | |
scroll the dialogue one letter at a time and it becomes a pretty painful problem to solve. | |
To start, I wrote a function that can take a dialogue box width and a string with special formatting strings embedded in it. | |
The string used for the text above is this: | |
"I can't {red}shake {blue}the {green}feeling {normal}that {italics}something {normal}belongs here... | |
Something extraordinarily {bold}ordinary." |