mail[Wesnoth-commits] r34263 - in /trunk: data/campaigns/The_Hammer_of_Thursagan/scenarios/ data/campaigns/The_Rise_Of_Wesnoth/scenarios/ data/cam...


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by esr on March 29, 2009 - 22:55:
Author: esr
Date: Sun Mar 29 22:55:13 2009
New Revision: 34263

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34263&view=rev
Log:
Pango-enable message= attributes within [message].

This patch includes (a) switching on this feature in the C core (and
diabling grotty old Wesnoth markup in this context), (b) an upgrade to
wmllint to do most of these conversions automatically (e.g. in TROW),
(c) hand-fixes for some unual cases (in the Tutorial), and (d) a test
of Pango <i> (in THOT).

Modified:
    
trunk/data/campaigns/The_Hammer_of_Thursagan/scenarios/01_At_The_East_Gate.cfg
    
trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/09_Fallen_Lich_Point.cfg
    trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/12_A_Final_Spring.cfg
    trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg
    trunk/data/campaigns/tutorial/scenarios/2_Speaking.cfg
    trunk/data/tools/wmllint
    trunk/src/gui/dialogs/wml_message.cpp

Modified: 
trunk/data/campaigns/The_Hammer_of_Thursagan/scenarios/01_At_The_East_Gate.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/The_Hammer_of_Thursagan/scenarios/01_At_The_East_Gate.cfg?rev=34263&r1=34262&r2=34263&view=diff
==============================================================================
--- 
trunk/data/campaigns/The_Hammer_of_Thursagan/scenarios/01_At_The_East_Gate.cfg
 (original)
+++ 
trunk/data/campaigns/The_Hammer_of_Thursagan/scenarios/01_At_The_East_Gate.cfg
 Sun Mar 29 22:55:13 2009
@@ -130,7 +130,7 @@
 
         [message]
             speaker="Aiglondur"
-            message=_"Up axes! We will be the Northern Alliance's arm today, 
and kill or scatter these invaders."
+            message=_"<i>Up axes!</i> We will be the Northern Alliance's arm 
today, and kill or scatter these invaders."
         [/message]
         [message]
             speaker="Bashnark"

Modified: 
trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/09_Fallen_Lich_Point.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/09_Fallen_Lich_Point.cfg?rev=34263&r1=34262&r2=34263&view=diff
==============================================================================
--- 
trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/09_Fallen_Lich_Point.cfg 
(original)
+++ 
trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/09_Fallen_Lich_Point.cfg 
Sun Mar 29 22:55:13 2009
@@ -337,8 +337,7 @@
         [/filter]
         [message]
             speaker=narrator
-            # wmllint: local spelling <CHIPPED AWAY>
-            message= _ "INSCRIPTION: This monolith was erected by me, 
<CHIPPED AWAY>, first Mage of the good people of the Green Isle. By its power 
the Lich-Lord is bound in stone. To end the spell a noble of the line of 
Kings should utter the following..."
+            message= _ "INSCRIPTION: This monolith was erected by me, 
&lt;CHIPPED AWAY&gt;, first Mage of the good people of the Green Isle. By its 
power the Lich-Lord is bound in stone. To end the spell a noble of the line 
of Kings should utter the following..."
             image=wesnoth-icon.png
         [/message]
 

Modified: 
trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/12_A_Final_Spring.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/12_A_Final_Spring.cfg?rev=34263&r1=34262&r2=34263&view=diff
==============================================================================
--- trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/12_A_Final_Spring.cfg 
(original)
+++ trunk/data/campaigns/The_Rise_Of_Wesnoth/scenarios/12_A_Final_Spring.cfg 
Sun Mar 29 22:55:13 2009
@@ -586,7 +586,7 @@
 
         [message]
             speaker=narrator
-            message= _ "To the Midlands & Oldwood"
+            message= _ "To the Midlands &amp; Oldwood"
             image=scenery/signpost.png
         [/message]
         [allow_undo]

Modified: trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg?rev=34263&r1=34262&r2=34263&view=diff
==============================================================================
--- trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg (original)
+++ trunk/data/campaigns/tutorial/scenarios/1_Tutorial.cfg Sun Mar 29 
22:55:13 2009
@@ -184,7 +184,7 @@
 #wmlindent: start ignoring
         {GENDER ([message]
                 speaker=narrator
-                message=_ "*Welcome to Wesnoth!" +
+                message=_ "<big>Welcome to Wesnoth!</big>" +
                         _ "
 For this tutorial, you are playing Konrad. " +
                         _ "You are standing in the keep, and your mentor 
Delfador is on the east side of the river." +
@@ -192,7 +192,7 @@
 *Left click or press spacebar to continue..."
         [/message]) ([message]
                 speaker=narrator
-                message=_ "*Welcome to Wesnoth!" +
+                message=_ "<big>Welcome to Wesnoth!</big>" +
                         _ "
 For this tutorial, you are playing Li'sar. " +
                         _ "You are standing in the keep, and your mentor 
Delfador is on the east side of the river." +
@@ -219,7 +219,7 @@
         {GENDER ([message]
                 speaker=narrator
 #wmllint: display on
-                message=_ "*You have selected Konrad.
+                message=_ "<big>You have selected Konrad.</big>
 The places he can move to are highlighted." +
                         _ "
 *Left click or press spacebar to continue..."
@@ -227,7 +227,7 @@
         [/message]) ([message]
                 speaker=narrator
 #wmllint: display on
-                message=_ "*You have selected Li'sar.
+                message=_ "<big>You have selected Li'sar.</big>
 The places she can move to are highlighted." +
                         _ "
 *Left click or press spacebar to continue..."
@@ -277,7 +277,7 @@
                 [message]
                     speaker=narrator
                     #wmllint: display on
-                    message=_ "*Oops!
+                    message=_ "<big>Oops!</big>
 You moved to the wrong place! After this message, you can press 'u' to undo, 
then try again." +
                     _ "
 *Left click or press spacebar to continue..."

Modified: trunk/data/campaigns/tutorial/scenarios/2_Speaking.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/tutorial/scenarios/2_Speaking.cfg?rev=34263&r1=34262&r2=34263&view=diff
==============================================================================
--- trunk/data/campaigns/tutorial/scenarios/2_Speaking.cfg (original)
+++ trunk/data/campaigns/tutorial/scenarios/2_Speaking.cfg Sun Mar 29 
22:55:13 2009
@@ -36,8 +36,8 @@
     [message]
         speaker=narrator
         image=portraits/elves/captain.png
-        message=_ "*Galdrad" + "
-" + {MESSAGE_TEXT}
+        message=_ "<big>Galdrad" + "
+" + {MESSAGE_TEXT} + "</big>"
     [/message]
 #enddef
 
@@ -46,8 +46,8 @@
     [message]
         speaker=narrator
         image=portraits/elves/captain.png
-        message=_ "*Galdrad" + "
-" + {MESSAGE_TEXT}
+        message=_ "<big>Galdrad" + "
+" + {MESSAGE_TEXT} + "</big>"
     [/message]
 #enddef
 
@@ -59,8 +59,8 @@
     [message]
         speaker=narrator
         image=portraits/elves/captain.png
-        message=_ "*Galdrad" + "
-" + {MESSAGE_TEXT}
+        message=_ "<big>Galdrad" + "
+" + {MESSAGE_TEXT} + "</big>"
     [/message]
 #enddef
 

Modified: trunk/data/tools/wmllint
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmllint?rev=34263&r1=34262&r2=34263&view=diff
==============================================================================
--- trunk/data/tools/wmllint (original)
+++ trunk/data/tools/wmllint Sun Mar 29 22:55:13 2009
@@ -647,6 +647,64 @@
                                 "princeling", "wilderlands", "ensorcels"
                                 ]}
 
+pango_conversions = (("~", '<b>', '</b>'),
+                     ("@", '<span color="green">', "</span>"),
+                     ("#", '<span color="red">', "</span>"),
+                     ("*", '<span size="big">', "</span>"),
+                     ("`", '<span size="small">', "</span>"),
+                     )
+
+def pangostrip(message):
+    "Strip Pango margup out of a string."
+    # This is all known Pango convenience tags
+    for tag in ("b", "big", "i", "s", "sub", "sup", "small", "tt", "u"):
+        message = message.replace("<"+tag+">", "").replace("</"+tag+">", "")
+    # Now remove general span tags
+    message = re.sub("</?span[^>]*>", "", message)
+    # And Pango specials;
+    message = re.sub("&[a-z]+;", "", message)
+    return message
+
+def pangoize(message, filename, line):
+    "Pango conversion of old-style Wesnoth markup."
+    if '&' in message:
+        amper = message.find('&')
+        if message[amper:amper+5] != "&amp;":
+            message = message[:amper] + "&amp;" + message[amper+1:]
+    if re.search("<[0-9]+,[0-9]+,[0-9]+>", message):
+        print '"%s", line %d: color spec in line requires manual fix.' % 
(filename, line)
+    # Hack old-style Wesnoth markup
+    for (oldstyle, newstart, newend) in pango_conversions:
+        if oldstyle not in message:
+            continue
+        where = message.find(oldstyle)
+        if message[where-1] != '"':    # Start of string only
+            continue
+        if message.strip()[-1] != '"':
+            print '"%s", line %d: %s highlight at start of multiline string 
requires manual fix.' % (filename, line, oldstyle)
+            continue
+        if '+' in message:
+            print '"%s", line %d: %s highlight in composite string requires 
manual fix.' % (filename, line, oldstyle)
+            continue
+        # This is the common, simple case we can fix automatically
+        message = message[:where] + newstart + message[where+1:]
+        endq = lines[where].rfind('"')
+        message = message[:endq] + newend + message[endq+1:]
+    # Check for unescaped < and >
+    if "<" in message or ">" in message:
+        reduced = pangostrip(message)
+        if "<" in reduced or ">" in reduced:
+            if message == reduced:     # No pango markup
+                here = message.find('<')
+                if message[here:here+4] != "&lt;":
+                    message = message[:here] + "&lt;" + message[here+1:]
+                here = message.find('>')
+                if message[here:here+4] != "&gt;":
+                    message = message[:here] + "&gt;" + message[here+1:]
+            else:
+                print '"%s", line %d: < or > in pango string requires manual 
fix.' % (filename, line, oldstyle)
+    return message
+
 class WmllintIterator(WmlIterator):
     "Fold an Emacs-compatible error reporter into WmlIterator."
     def printError(self, *misc):
@@ -891,6 +949,8 @@
     in_trait = False
     ignore_id = False
     in_object = False
+    in_message = False
+    in_option = False
     ignoreable = False
     preamble_seen = False
     sentence_end = re.compile("(?<=[.!?;:])  +")
@@ -913,6 +973,14 @@
             in_object = True
         elif "[/object]" in lines[i]:
             in_object = False
+        elif "[message]" in lines[i]:
+            in_message = True
+        elif "[/message]" in lines[i]:
+            in_message = False
+        elif "[/option]" in lines[i]:
+            in_option = False
+        elif "[option]" in lines[i]:
+            in_option = True
         elif "[label]" in lines[i] or "[chamber]" in lines[i] or "[time]" in 
lines[i]:
             ignore_id = True
         elif "[/label]" in lines[i] or "[/chamber]" in lines[i] or "[/time]" 
in lines[i]:
@@ -976,6 +1044,8 @@
                 if capitalization_error.search(lines[i]):
                     print '"%s", line %d: probable capitalization or 
punctuation error' \
                           % (filename, i+1)
+                if key == "message" and in_message and not in_option:
+                    lines[i] = pangoize(lines[i], filename, i)
             else:
                 if in_scenario and key == "id":
                     if in_person:
@@ -1585,6 +1655,9 @@
                 value = value[:-1].rstrip()
             # Strip off string quotes
             value = string_strip(value)
+            # Remove pango markup
+            if "<" in value or ">" in value or '&' in value:
+                value = pangostrip(value)
             # Discard extraneous stuff 
             value = value.replace("...", " ")
             value = value.replace("''", "")
@@ -1604,7 +1677,7 @@
                 lowered = token.lower()
                 if d.check(lowered):
                     continue
-                # Strip leading punctuastion and grotty Wesnoth highlighters
+                # Strip leading punctuation and grotty Wesnoth highlighters
                 while lowered and lowered[0] in " \t(`@*'%_":
                     lowered = lowered[1:]
                 # Not interested in interpolations or numeric literals

Modified: trunk/src/gui/dialogs/wml_message.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/wml_message.cpp?rev=34263&r1=34262&r2=34263&view=diff
==============================================================================
--- trunk/src/gui/dialogs/wml_message.cpp (original)
+++ trunk/src/gui/dialogs/wml_message.cpp Sun Mar 29 22:55:13 2009
@@ -72,7 +72,7 @@
        tcontrol* label =
                        dynamic_cast<tcontrol*>(window.find_widget("label", 
false));
        assert(label);
-       label->set_markup_mode(tcontrol::WML_MARKUP);
+       label->set_markup_mode(tcontrol::PANGO_MARKUP);
 
        // Find the input box related fields.
        tlabel* caption = dynamic_cast<tlabel*>(




Related Messages


Powered by MHonArc, Updated Sun Mar 29 23:20:36 2009