added Reward and Expiration to task list

moved text scroller into DeckMenu class since it is specific to DeckMenu and not GameStateDuel
added new util function "wordWrap"
This commit is contained in:
techdragon.nguyen@gmail.com
2010-11-03 00:15:12 +00:00
parent 685626128a
commit 4a3d7faf0a
8 changed files with 133 additions and 71 deletions

View File

@@ -217,3 +217,42 @@ std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
return split(s, delim, elems);
}
std::string wordWrap(std::string sentence, int width)
{
std::string::iterator it = sentence.begin();
//remember how long next word is
int nextWordLength = 0;
int distanceFromWidth = width;
while (it != sentence.end())
{
while (*it != ' ')
{
nextWordLength++;
distanceFromWidth--;
++it;
// check if done
if (it == sentence.end())
{
return sentence;
}
}
if (nextWordLength > distanceFromWidth)
{
*it = '\n';
distanceFromWidth = width;
nextWordLength = 0;
}
//skip the space
++it;
}
return sentence;
}