+ /* Cut lines changes into seperate strings, needed to support center/right text
+ allignments with break lines.
+ Feel free to replace this hack with a more elegant solution
+ */
+ char temp[1024];
+ std::string::size_type l, i, y;
+ bool done = false;
+ i = y = 0;
+
+ while(!done)
+ {
+ l = text.find("\n", i);
+ if(l == std::string::npos)
+ {
+ l = text.size();
+ done = true;
+ }
+
+ temp[text.copy(temp, l - i, i)] = '\0';
+
+ // calculate X positions based on the allignment type
+ Vector pos = Vector(pos_);
+ if(allignment == CENTER_ALLIGN)
+ pos.x -= get_text_width(temp) / 2;
+ else if(allignment == RIGHT_ALLIGN)
+ pos.x -= get_text_width(temp);
+
+ draw_text(temp, pos + Vector(0,y), drawing_effect, alpha);
+
+ i = l+1;
+ y += h + 2;
+ }