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).
This commit is contained in:
parent
117c0dfd35
commit
f384fe4058
7 changed files with 89 additions and 17 deletions
|
@ -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"
|
||||
|
|
|
@ -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, <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..."
|
||||
image=wesnoth-icon.png
|
||||
[/message]
|
||||
|
||||
|
|
|
@ -586,7 +586,7 @@
|
|||
|
||||
[message]
|
||||
speaker=narrator
|
||||
message= _ "To the Midlands & Oldwood"
|
||||
message= _ "To the Midlands & Oldwood"
|
||||
image=scenery/signpost.png
|
||||
[/message]
|
||||
[allow_undo]
|
||||
|
|
|
@ -184,7 +184,7 @@ Recruiting"
|
|||
#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 @@ For this tutorial, you are playing Konrad. " +
|
|||
*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 @@ For this tutorial, you are playing Li'sar. " +
|
|||
{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 @@ The places he can move to are highlighted." +
|
|||
[/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 @@ The places she can move to are highlighted." +
|
|||
[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..."
|
||||
|
|
|
@ -36,8 +36,8 @@ You can press 'u' to undo most things; useful for correcting mistakes.")}
|
|||
[message]
|
||||
speaker=narrator
|
||||
image=portraits/elves/captain.png
|
||||
message=_ "*Galdrad" + "
|
||||
" + {MESSAGE_TEXT}
|
||||
message=_ "<big>Galdrad" + "
|
||||
" + {MESSAGE_TEXT} + "</big>"
|
||||
[/message]
|
||||
#enddef
|
||||
|
||||
|
@ -46,8 +46,8 @@ You can press 'u' to undo most things; useful for correcting mistakes.")}
|
|||
[message]
|
||||
speaker=narrator
|
||||
image=portraits/elves/captain.png
|
||||
message=_ "*Galdrad" + "
|
||||
" + {MESSAGE_TEXT}
|
||||
message=_ "<big>Galdrad" + "
|
||||
" + {MESSAGE_TEXT} + "</big>"
|
||||
[/message]
|
||||
#enddef
|
||||
|
||||
|
@ -59,8 +59,8 @@ You can press 'u' to undo most things; useful for correcting mistakes.")}
|
|||
[message]
|
||||
speaker=narrator
|
||||
image=portraits/elves/captain.png
|
||||
message=_ "*Galdrad" + "
|
||||
" + {MESSAGE_TEXT}
|
||||
message=_ "<big>Galdrad" + "
|
||||
" + {MESSAGE_TEXT} + "</big>"
|
||||
[/message]
|
||||
#enddef
|
||||
|
||||
|
|
|
@ -647,6 +647,64 @@ declared_spellings = {"GLOBAL":["I'm", "I've", "I'd", "I'll",
|
|||
"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] != "&":
|
||||
message = message[:amper] + "&" + 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] != "<":
|
||||
message = message[:here] + "<" + message[here+1:]
|
||||
here = message.find('>')
|
||||
if message[here:here+4] != ">":
|
||||
message = message[:here] + ">" + 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 @@ def sanity_check(filename, lines):
|
|||
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 @@ def sanity_check(filename, lines):
|
|||
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 @@ def sanity_check(filename, lines):
|
|||
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 @@ def spellcheck(fn, d):
|
|||
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 @@ def spellcheck(fn, d):
|
|||
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
|
||||
|
|
|
@ -72,7 +72,7 @@ void twml_message_::pre_show(CVideo& video, twindow& window)
|
|||
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*>(
|
||||
|
|
Loading…
Add table
Reference in a new issue