wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src display.cpp font.cpp font.hpp show_...


From: Yann Dirson
Subject: [Wesnoth-cvs-commits] wesnoth/src display.cpp font.cpp font.hpp show_...
Date: Wed, 23 Mar 2005 15:46:59 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Yann Dirson <address@hidden>    05/03/23 20:46:58

Modified files:
        src            : display.cpp font.cpp font.hpp show_dialog.cpp 
                         show_dialog.hpp tooltips.cpp 

Log message:
        text_to_lines() does not belong to show_dialog - being more closely 
related to text, moved it to font

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.cpp.diff?tr1=1.306&tr2=1.307&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.cpp.diff?tr1=1.123&tr2=1.124&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.hpp.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/show_dialog.cpp.diff?tr1=1.116&tr2=1.117&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/show_dialog.hpp.diff?tr1=1.45&tr2=1.46&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/tooltips.cpp.diff?tr1=1.22&tr2=1.23&r1=text&r2=text

Patches:
Index: wesnoth/src/display.cpp
diff -u wesnoth/src/display.cpp:1.306 wesnoth/src/display.cpp:1.307
--- wesnoth/src/display.cpp:1.306       Tue Mar 22 23:42:36 2005
+++ wesnoth/src/display.cpp     Wed Mar 23 20:46:58 2005
@@ -1,4 +1,4 @@
-/* $Id: display.cpp,v 1.306 2005/03/22 23:42:36 ydirson Exp $ */
+/* $Id: display.cpp,v 1.307 2005/03/23 20:46:58 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -2196,7 +2196,7 @@
                msg = message;
                action = false;
        }
-       gui::text_to_lines(msg,80);
+       font::text_to_lines(msg,80);
 
        int ypos = chat_message_x;
        for(std::vector<chat_message>::const_iterator m = 
chat_messages_.begin(); m != chat_messages_.end(); ++m) {
Index: wesnoth/src/font.cpp
diff -u wesnoth/src/font.cpp:1.123 wesnoth/src/font.cpp:1.124
--- wesnoth/src/font.cpp:1.123  Sat Mar 19 10:26:43 2005
+++ wesnoth/src/font.cpp        Wed Mar 23 20:46:58 2005
@@ -1,4 +1,4 @@
-/* $Id: font.cpp,v 1.123 2005/03/19 10:26:43 gruikya Exp $ */
+/* $Id: font.cpp,v 1.124 2005/03/23 20:46:58 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1355,4 +1355,52 @@
        font::set_font_list(fontlist);
        return true;
 }
+
+
+size_t text_to_lines(std::string& message, size_t max_length)
+{
+       std::string starting_markup;
+       bool at_start = true;
+
+       size_t cur_line = 0, longest_line = 0;
+       for(std::string::iterator i = message.begin(); i != message.end(); ++i) 
{
+               if(at_start) {
+                       if(font::is_format_char(*i)) {
+                               push_back(starting_markup,*i);
+                       } else {
+                               at_start = false;
+                       }
+               }
+
+               if(*i == '\n') {
+                       at_start = true;
+                       starting_markup = "";
+               }
+
+               if(*i == ' ' && cur_line > max_length) {
+                       *i = '\n';
+                       const size_t index = i - message.begin();
+                       message.insert(index+1,starting_markup);
+                       i = message.begin() + index + starting_markup.size();
+
+                       if(cur_line > longest_line)
+                               longest_line = cur_line;
+
+                       cur_line = 0;
+               }
+
+               if(*i == '\n' || i+1 == message.end()) {
+                       if(cur_line > longest_line)
+                               longest_line = cur_line;
+
+                       cur_line = 0;
+
+               } else {
+                       ++cur_line;
+               }
+       }
+
+       return longest_line;
+}
+
 }
Index: wesnoth/src/font.hpp
diff -u wesnoth/src/font.hpp:1.52 wesnoth/src/font.hpp:1.53
--- wesnoth/src/font.hpp:1.52   Tue Mar 15 20:01:31 2005
+++ wesnoth/src/font.hpp        Wed Mar 23 20:46:58 2005
@@ -1,4 +1,4 @@
-/* $Id: font.hpp,v 1.52 2005/03/15 20:01:31 ydirson Exp $ */
+/* $Id: font.hpp,v 1.53 2005/03/23 20:46:58 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -188,6 +188,9 @@
 
 bool load_font_config();
 
+//function to chop up one long string of text into lines
+size_t text_to_lines(std::string& text, size_t max_length);
+
 }
 
 #endif
Index: wesnoth/src/show_dialog.cpp
diff -u wesnoth/src/show_dialog.cpp:1.116 wesnoth/src/show_dialog.cpp:1.117
--- wesnoth/src/show_dialog.cpp:1.116   Fri Mar 18 21:21:48 2005
+++ wesnoth/src/show_dialog.cpp Wed Mar 23 20:46:58 2005
@@ -1,4 +1,4 @@
-/* $Id: show_dialog.cpp,v 1.116 2005/03/18 21:21:48 ydirson Exp $ */
+/* $Id: show_dialog.cpp,v 1.117 2005/03/23 20:46:58 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -310,55 +310,6 @@
 
 } //end namespace gui
 
-namespace gui
-{
-
-size_t text_to_lines(std::string& message, size_t max_length)
-{
-       std::string starting_markup;
-       bool at_start = true;
-
-       size_t cur_line = 0, longest_line = 0;
-       for(std::string::iterator i = message.begin(); i != message.end(); ++i) 
{
-               if(at_start) {
-                       if(font::is_format_char(*i)) {
-                               push_back(starting_markup,*i);
-                       } else {
-                               at_start = false;
-                       }
-               }
-
-               if(*i == '\n') {
-                       at_start = true;
-                       starting_markup = "";
-               }
-
-               if(*i == ' ' && cur_line > max_length) {
-                       *i = '\n';
-                       const size_t index = i - message.begin();
-                       message.insert(index+1,starting_markup);
-                       i = message.begin() + index + starting_markup.size();
-
-                       if(cur_line > longest_line)
-                               longest_line = cur_line;
-
-                       cur_line = 0;
-               }
-
-               if(*i == '\n' || i+1 == message.end()) {
-                       if(cur_line > longest_line)
-                               longest_line = cur_line;
-
-                       cur_line = 0;
-
-               } else {
-                       ++cur_line;
-               }
-       }
-
-       return longest_line;
-}
-
 namespace {
 
 struct help_handler : public hotkey::command_executor
@@ -385,6 +336,9 @@
 
 }
 
+namespace gui
+{
+
 void show_error_message(display &disp, std::string const &message)
 {
        ERR_G << message << std::endl;
@@ -462,7 +416,7 @@
 #endif
 
        std::string message = msg;
-       text_to_lines(message,max_line_length);
+       font::text_to_lines(message,max_line_length);
 
        SDL_Rect text_size = { 0, 0, 0, 0 };
        if(!message.empty()) {
Index: wesnoth/src/show_dialog.hpp
diff -u wesnoth/src/show_dialog.hpp:1.45 wesnoth/src/show_dialog.hpp:1.46
--- wesnoth/src/show_dialog.hpp:1.45    Fri Mar 18 21:21:48 2005
+++ wesnoth/src/show_dialog.hpp Wed Mar 23 20:46:58 2005
@@ -1,4 +1,4 @@
-/* $Id: show_dialog.hpp,v 1.45 2005/03/18 21:21:48 ydirson Exp $ */
+/* $Id: show_dialog.hpp,v 1.46 2005/03/23 20:46:58 ydirson Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -124,9 +124,6 @@
        virtual void set_selection(int index) = 0;
 };
 
-//function to chop up one long string of text into lines
-size_t text_to_lines(std::string& text, size_t max_length);
-
 //if a menu is given, then returns -1 if the dialog was cancelled, and the
 //index of the selection otherwise. If no menu is given, returns the index
 //of the button that was pressed
Index: wesnoth/src/tooltips.cpp
diff -u wesnoth/src/tooltips.cpp:1.22 wesnoth/src/tooltips.cpp:1.23
--- wesnoth/src/tooltips.cpp:1.22       Tue Mar 15 20:01:31 2005
+++ wesnoth/src/tooltips.cpp    Wed Mar 23 20:46:58 2005
@@ -2,7 +2,6 @@
 
 #include "font.hpp"
 #include "sdl_utils.hpp"
-#include "show_dialog.hpp"
 #include "tooltips.hpp"
 #include "video.hpp"
 
@@ -27,7 +26,7 @@
 {
        tooltip(const SDL_Rect& r, const std::string& msg) : rect(r), 
message(msg)
        {
-               gui::text_to_lines(message,60);
+               font::text_to_lines(message,60);
        }
        SDL_Rect rect;
        std::string message;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]