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

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

[Wesnoth-cvs-commits] wesnoth/src about.cpp help.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src about.cpp help.cpp
Date: Sun, 24 Apr 2005 12:14:24 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    05/04/24 16:14:24

Modified files:
        src            : about.cpp help.cpp 

Log message:
        Fix the About help screen not being correctly rendered. Along the way, 
remove formatting strings and simplify the code.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/about.cpp.diff?tr1=1.124&tr2=1.125&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/help.cpp.diff?tr1=1.92&tr2=1.93&r1=text&r2=text

Patches:
Index: wesnoth/src/about.cpp
diff -u wesnoth/src/about.cpp:1.124 wesnoth/src/about.cpp:1.125
--- wesnoth/src/about.cpp:1.124 Thu Apr 21 18:58:27 2005
+++ wesnoth/src/about.cpp       Sun Apr 24 16:14:24 2005
@@ -1,4 +1,4 @@
-/* $Id: about.cpp,v 1.124 2005/04/21 18:58:27 ettin Exp $ */
+/* $Id: about.cpp,v 1.125 2005/04/24 16:14:24 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -30,26 +30,12 @@
 
 std::vector<std::string> get_text() {
        static const char *credits[] = {
-               " ",
-               "- ",
-               " ",
-               "- ",
-               " ",
-               "- ",
-               " ",
-               "- ",
-               " ",
-               "- ",
-               " ",
-               "- ",
-
                "_" N_("+Core Developers"),
                "_" N_("-   Main Developer"),
                "   David White (Sirp)",
                "- ",
                "_" N_("-   Artwork and graphics designer"),
                "   Francisco Muñoz (fmunoz)",
-               "+ ",
 
                "_" N_("+Developers"),
                "-   Alfredo Beaumont (ziberpunk)",
@@ -66,12 +52,10 @@
                "-   Philippe Plantier (Ayin)",
                "-   Yann Dirson",
                "-   Zas",
-               "+ ",
 
                "_" N_("+General Purpose Administrators"),
                "-   Crossbow/Miyo",
                "-   Isaac Clerencia",
-               "+ ",
 
                "_" N_("+Artwork and graphics designers"),
                "-   Andrew James Patterson (Kamahawk)",
@@ -97,14 +81,12 @@
                "-   Slainte",
                "-   Stephen Stone (Disto)",
                "-   Svetac",
-               "+ ",
 
                "_" N_("+Music"),
                "-   Aleksi",
                "-   Fredrik Lindroth",
                "-   Joseph Toscano (zhaymusic.com)",
                "-   Pau Congost",
-               "+ ",
 
                "_" N_("+Scenario Designers"),
                "-   Benjamin Drieu",
@@ -114,12 +96,10 @@
                "-   James Spencer (Shade)",
                "-   Joseph Simmons (Turin)",
                "-   Justin Zaun (jzaun)",
-               "+ ",
 
                "_" N_("+Multiplayer Maps"),
                "-   Peter Groen (pg)",
                "-   Tom Chance (telex4)",
-               "+ ",
 
                "_" N_("+Packagers"),
                "-   Cyril Bouthors (CyrilB)",
@@ -130,35 +110,29 @@
                "-   Marcin Konicki (ahwayakchih)",
                "-   Marcus Phillips (Sithrandel)",
                "-   Mark Michelsen (skovbaer)",
-               "+ ",
 
                "_" N_("+Miscellaneous"),
                "-   Francesco Gigli (Jaramir)",
                "-   Jordà Polo (ettin)",
                "-   Ruben Philipp Wickenhäuser (The Very Uhu)",
-               "+ ",
 
                "_" N_("+Internationalization Managers"),
                "-   Cédric Duval",
                "-   Mark Michelsen (skovbaer)",
                "-   Nils Kneuper (Ivanovic)",
                "-   Susanna Björverud (sanna)",
-               "+ ",
 
                "_" N_("+Afrikaans Translation"),
                "-   Nico Oliver",
                "-   ott",
-               "+ ",
 
                "_" N_("+Basque Translation"),
                "-   Alfredo Beaumont (ziberpunk)",
                "-   Julen Landa (genars)",
                "-   Mikel Olasagasti (Hey_neken)",
-               "+ ",
 
                "_" N_("+Bulgarian Translation"),
                "-   Anton Tsigularov (Atilla)",
-               "+ ",
 
                "_" N_("+Catalan Translation"),
                "-   Carles Company (brrr)",
@@ -166,11 +140,9 @@
                "-   Jordà Polo (ettin)",
                "-   Mark Recasens",
                "-   Pau Rul·lan Ferragut",
-               "+ ",
 
                "_" N_("+Chinese Translation"),
                "-   林俊杰 - Lim Choon Kiat",
-               "+ ",
 
                "_" N_("+Czech Translation"),
                "-   David Nečas (Yeti)",
@@ -179,12 +151,10 @@
                "-   Petr Kovár (Juans)",
                "-   Sofronius",
                "-   Vít Krčál",
-               "+ ",
 
                "_" N_("+Danish Translation"),
                "-   Mark Michelsen (skovbaer)",
                "-   Mathias Bundgaard Svensson (freaken)",
-               "+ ",
 
                "_" N_("+Dutch Translation"),
                "-   Arne Deprez",
@@ -192,20 +162,16 @@
                "-   Maarten Albrecht",
                "-   Pieter Vermeylen (Onne)",
                "-   Tobe Deprez",
-               "+ ",
 
                "_" N_("+English (GB) Translation"),
                "-   ott",
-               "+ ",
                
                "_" N_("+Estonian Translation"),
                "-   Mart Tõnso",
-               "+ ",
 
                "_" N_("+Finnish Translation"),
                "-   Ankka",
                "-   paxed",
-               "+ ",
 
                "_" N_("+French Translation"),
                "-   Benoit Astruc",
@@ -219,7 +185,6 @@
                "-   Tout",
                "-   Yann Dirson",
                "-   Zas",
-               "+ ",
 
                "_" N_("+German Translation"),
                "-   Andre Schmidt (schmidta)",
@@ -231,12 +196,10 @@
                "-   Nils Kneuper (Ivanovic)",
                "-   Ruben Philipp Wickenhäuser (The Very Uhu)",
                "-   Stephan Grochtmann (Schattenstephan)",
-               "+ ",
 
                "_" N_("+Greek Translation"),
                "-   Katerina Sykioti",
                "-   Konstantinos Karasavvas",
-               "+ ",
 
                "_" N_("+Hungarian Translation"),
                "-   adson",
@@ -248,7 +211,6 @@
                "-   krix",
                "-   ott",
                "-   Széll Tamás (TomJoad)",
-               "+ ",
 
                "_" N_("+Italian Translation"),
                "-   Alessio D'Ascanio (otaku)",
@@ -258,24 +220,20 @@
                "-   Federico Tomassetti",
                "-   isazi",
                "-   RokStar",
-               "+ ",
                
                "_" N_("+Japanese Translation"),
                "-   Naoki Iimura",
                "-   Nobuhito Okada",
                "-   Yuji Matsumoto",
-               "+ ",
 
                "_" N_("+Latin Translation"),
                "-   Mark Polo (mpolo)",
-               "+ ",
 
                "_" N_("+Norwegian Translation"),
                "-   Hallvard Norheim Bø (Lysander)",
                "-   HÃ¥vard Korsvoll",
                "-   Erik J. Mesoy (Circon)",
                "-   Susanne Mesoy (Rarlgland)",
-               "+ ",
 
                "_" N_("+Polish Translation"),
                "-   Artur R. Czechowski",
@@ -286,7 +244,6 @@
                "-   Michał Jedynak (Artanis)",
                "-   Paweł Stradomski",
                "-   Paweł Tomak",
-               "+ ",
 
                "_" N_("+Portuguese (Brazil) Translation"),
                "-   Ambra Viviani Loos",
@@ -295,21 +252,17 @@
                "-   Michel Loos",
                "-   Renato Cunha",
                "-   Sérgio de Miranda Costa",
-               "+ ",
 
                "_" N_("+Russian Translation"),
                "-   Alexandr Menovchicov",
                "-   Azamat Hackimov",
                "-   Roman Tuchin (Sankt)",
-               "+ ",
 
                "_" N_("+Slovak Translation"),
                "-   Viliam Bur",
-               "+ ",
                
                "_" N_("+Slovenian Translation"),
                "-   Jaka Kranjc (lynx)",
-               "+ ",
 
                "_" N_("+Spanish Translation"),
                "-   David Martínez",
@@ -318,27 +271,22 @@
                "-   Gabriel Rodríguez (Chewie)",
                "-   Jose Gordillo (kilder)",
                "-   Jose Manuel Gomez (joseg)",
-               "+ ",
 
                "_" N_("+Swedish Translation"),
                "-   Alexander Kjäll (capitol)",
                "-   Stefan Bergström (tephlon)",
                "-   Susanna Björverud (sanna)",
                "-   wint3r",
-               "+ ",
                
                "_" N_("+Turkish Translation"),
                "-   İhsan Akın",
                "-   Selim Farsakoğlu",
-               "+ ",
                
                "_" N_("+Contributors"),
                "-   Frédéric Wagner",
-               "+ ",
 
                "_" N_("+Bots"),
                "-   wesbot",
-               "+ "
        };
 
        std::vector< std::string > res;
@@ -378,15 +326,21 @@
 
 
        //substitute in the correct control characters for '+' and '-'
-       for(std::vector<std::string>::iterator itor = text.begin(); itor != 
text.end(); ++itor) {
-               if(itor->empty() == false) {
-                       if((*itor)[0] == '-') {
-                               (*itor)[0] = font::SMALL_TEXT;
-                       } else if((*itor)[0] == '+') {
-                               (*itor)[0] = font::LARGE_TEXT;
-                       }
+       std::string before_header(2, ' ');
+       before_header[0] = font::LARGE_TEXT;
+       for(unsigned i = 0; i < text.size(); ++i) {
+               std::string &s = text[i];
+               if (s.empty()) continue;
+               char &first = s[0];
+               if (first == '-')
+                       first = font::SMALL_TEXT;
+               else if (first == '+') {
+                       first = font::LARGE_TEXT;
+                       text.insert(text.begin() + i, before_header);
+                       ++i;
                }
        }
+       text.insert(text.begin(), 10, before_header);
 
        int startline = 0;
 
Index: wesnoth/src/help.cpp
diff -u wesnoth/src/help.cpp:1.92 wesnoth/src/help.cpp:1.93
--- wesnoth/src/help.cpp:1.92   Sun Apr 24 11:58:04 2005
+++ wesnoth/src/help.cpp        Sun Apr 24 16:14:24 2005
@@ -546,42 +546,15 @@
        /// for the help dialog.
        class about_text_formatter {
        public:
-               about_text_formatter() : text_started_(false) {}
                std::string operator()(const std::string &s) {
-                       std::string res = s;
-                       if (res.size() > 0) {
-                               bool header = false;
-                               // Format + as headers, and the rest as normal 
text.
-                               if (res[0] == '+') {
-                                       header = true;
-                                       res.erase(res.begin());
-                               }
-                               else if (res[0] == '-') {
-                                       res.erase(res.begin());
-                               }
-                               // There is a bunch of empty rows in the start 
in about.cpp,
-                               // we do not want to show these here. Thus, if 
we still
-                               // encounter one of those, return an empty 
string that will
-                               // be removed totally at a later stage.
-                               if (!text_started_ && res.find_first_not_of(' 
') != std::string::npos) {
-                                       text_started_ = true;
-                               }
-                               if (text_started_) {
-                                       std::stringstream ss;
-                                       if (header) {
-                                               ss << "<header>text='" << 
help::escape(res) << "'</header>";
-                                               res = ss.str();
-                                       }
-                                       text_started_ = false;
-                               }
-                               else {
-                                       res = " ";
-                               }
-                       }
-                       return res;
+                       if (s.empty()) return s;
+                       // Format + as headers, and the rest as normal text.
+                       if (s[0] == '+')
+                               return " \n<header>text='" + 
help::escape(s.substr(1)) + "'</header>";
+                       if (s[0] == '-')
+                               return s.substr(1);
+                       return s;
                }
-       private:
-               bool text_started_;
        };
 
        // Helpers for making generation of topics easier.
@@ -1426,10 +1399,8 @@
        std::vector<std::string> res_lines;
        std::transform(about_lines.begin(), about_lines.end(), 
std::back_inserter(res_lines),
                                   about_text_formatter());
-       std::vector<std::string>::iterator it =
-               std::remove(res_lines.begin(), res_lines.end(), "");
-       std::vector<std::string> res_lines_rem(res_lines.begin(), it);
-       std::string text = utils::join(res_lines_rem, '\n');
+       res_lines.erase(std::remove(res_lines.begin(), res_lines.end(), ""), 
res_lines.end());
+       std::string text = utils::join(res_lines, '\n');
        return text;
 }
 




reply via email to

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