Author: alink
Date: Thu Oct 22 02:41:59 2009
New Revision: 39407

URL: http://svn.gna.org/viewcvs/wesnoth?rev=39407&view=rev
Log:
Fix old bug with attackers's info of attack dialog when long words were used.
(ex: very long unit type name break all following infos)
Also now show head instead of tail for these long words when not enough space.

Modified:
    trunk/src/dialogs.cpp

Modified: trunk/src/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/dialogs.cpp?rev=39407&r1=39406&r2=39407&view=diff
==============================================================================
--- trunk/src/dialogs.cpp (original)
+++ trunk/src/dialogs.cpp Thu Oct 22 02:41:59 2009
@@ -817,21 +817,24 @@
        const std::vector<std::string> lines = utils::split(text.str(), '\n',
                utils::STRIP_SPACES & !utils::REMOVE_EMPTY);
 
-       SDL_Rect cur_area = area;
+
+       int ypos = area.y;
 
        if(weapons_) {
-               cur_area.y += image_rect.h + description_rect.h + 
details_button_.location().h;
+               ypos += image_rect.h + description_rect.h + 
details_button_.location().h;
        }
 
        for(std::vector<std::string>::const_iterator line = lines.begin(); line 
!= lines.end(); ++line) {
-               int xpos = cur_area.x;
+               int xpos = area.x;
                if(right_align && !weapons_) {
                        const SDL_Rect& line_area = 
font::text_area(*line,font::SIZE_SMALL);
-                       xpos = cur_area.x + cur_area.w - line_area.w;
-               }
-
-               cur_area = 
font::draw_text(&video(),location(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,xpos,cur_area.y);
-               cur_area.y += cur_area.h;
+                       // right align, but if too long, don't hide line's 
beginning
+                       if (line_area.w < area.w)
+                               xpos = area.x + area.w - line_area.w;
+               }
+
+               SDL_Rect cur_area = 
font::draw_text(&video(),location(),font::SIZE_SMALL,font::NORMAL_COLOUR,*line,xpos,ypos);
+               ypos += cur_area.h;
        }
 }
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to