[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src intro.cpp
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src intro.cpp |
Date: |
Sat, 23 Jul 2005 14:07:10 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 05/07/23 18:07:10
Modified files:
src : intro.cpp
Log message:
* Factored intro code with word_wrap_text
* Fixed bug #13352
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/intro.cpp.diff?tr1=1.80&tr2=1.81&r1=text&r2=text
Patches:
Index: wesnoth/src/intro.cpp
diff -u wesnoth/src/intro.cpp:1.80 wesnoth/src/intro.cpp:1.81
--- wesnoth/src/intro.cpp:1.80 Sat Jul 2 21:37:19 2005
+++ wesnoth/src/intro.cpp Sat Jul 23 18:07:09 2005
@@ -1,4 +1,4 @@
-/* $Id: intro.cpp,v 1.80 2005/07/02 21:37:19 ott Exp $ */
+/* $Id: intro.cpp,v 1.81 2005/07/23 18:07:09 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -216,7 +216,8 @@
}
}
- const std::string& story = part["story"];
+ const int max_width = next_button.location().x - 10 - textx;
+ const std::string story = font::word_wrap_text(part["story"],
font::SIZE_PLUS, max_width);
utils::utf8_iterator itor(story);
bool skip = false, last_key = true;
@@ -224,38 +225,14 @@
int xpos = textx, ypos = texty;
//the maximum position that text can reach before wrapping
- const int max_xpos = next_button.location().x - 10;
size_t height = 0;
for(;;) {
if(itor != utils::utf8_iterator::end(story)) {
- if(*itor == ' ') {
- //we're at a space, so find the next space or
end-of-text,
- //to find out if the next word will fit, or if
it has to be wrapped
- utils::utf8_iterator start_word = itor;
- ++start_word;
- utils::utf8_iterator end_word = start_word;
- const utils::utf8_iterator end_story =
utils::utf8_iterator::end(story);
- for(; end_word != end_story; ++end_word) {
- if(*end_word == ' ') {
- break;
- }
- }
-
- std::string word;
- for(; start_word != end_word; ++start_word) {
- word.append(start_word.substr().first,
start_word.substr().second);
- }
- const SDL_Rect rect =
font::draw_text(NULL,screen_area(),
-
font::SIZE_PLUS,font::NORMAL_COLOUR,
- word, xpos, ypos, false);
-
- if(xpos + rect.w >= max_xpos) {
- xpos = textx;
- ypos += height;
- ++itor;
- continue;
- }
+ if(*itor == '\n') {
+ xpos = textx;
+ ypos += height;
+ ++itor;
}
// output the character
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src intro.cpp,
Philippe Plantier <=