static const float SCROLL = 60;
static const float ITEMS_SPACE = 4;
-
-
TextScroller::TextScroller(const std::string& filename)
{
defaultspeed = DEFAULT_SPEED;
background.reset(new Surface("images/background/" + background_file));
scroll = 0;
+ fading = false;
}
TextScroller::~TextScroller()
y += lines[i]->get_height();
}
- if(y < 0) {
+ if(y < 0 && !fading ) {
+ fading = true;
main_loop->exit_screen(new FadeOut(0.5));
}
}
continue;
}
- // if we are dealing with text, wrap long lines
- while ((int)s.length() > line_length) {
- int split_at = line_length;
- while ((split_at > 0) && (s[split_at] != ' ')) split_at--;
- if (split_at == 0) split_at = line_length;
-
- lines.push_back(new InfoBoxLine(format_char, s.substr(0, split_at)));
- if (s[split_at] == ' ') split_at++;
- s = s.substr(split_at);
- }
- lines.push_back(new InfoBoxLine(format_char, s));
+ // append wrapped parts of line into list
+ std::string overflow;
+ do {
+ lines.push_back(new InfoBoxLine(format_char, Font::wrap_to_chars(s, line_length, &overflow)));
+ s = overflow;
+ } while (s.length() > 0);
}