wmlunits: Added unit_description as alternate name for description,
...and always add all advancements of all filtered units to the units tree.
This commit is contained in:
parent
4b1ed95db6
commit
04cf9aa4f6
2 changed files with 23 additions and 5 deletions
|
@ -277,6 +277,13 @@ class WesnothList:
|
|||
movetype = self.get_unit_value(unit, "movement_type")
|
||||
try: unit.movetype = self.movetype_lookup[movetype]
|
||||
except KeyError: unit.movetype = None
|
||||
|
||||
unit.advance = []
|
||||
advanceto = unit.get_text_val("advanceto")
|
||||
if advanceto and advanceto != "null":
|
||||
for advance in advanceto.split(","):
|
||||
auid = advance.strip()
|
||||
if auid: unit.advance.append(auid)
|
||||
|
||||
return len(newunits)
|
||||
|
||||
|
@ -375,11 +382,7 @@ class UnitNode:
|
|||
self.id = unit.get_text_val("id")
|
||||
self.child_ids = []
|
||||
self.parent_ids = []
|
||||
advanceto = unit.get_text_val("advanceto")
|
||||
if advanceto and advanceto != "null":
|
||||
for advance in advanceto.split(","):
|
||||
advance = advance.strip()
|
||||
self.child_ids.append(advance)
|
||||
self.child_ids.extend(unit.advance)
|
||||
|
||||
def try_add(self, un):
|
||||
# A child of yours truly?
|
||||
|
|
|
@ -94,9 +94,23 @@ class HTMLOutput:
|
|||
|
||||
# Build an advancement tree forest of all units.
|
||||
forest = self.forest = helpers.UnitForest()
|
||||
units_added = {}
|
||||
for uid, u in self.wesnoth.unit_lookup.items():
|
||||
if grouper.unitfilter(u):
|
||||
forest.add_node(helpers.UnitNode(u))
|
||||
units_added[uid] = u
|
||||
|
||||
# Always add any child units, even if they have been filtered out..
|
||||
for uid, u in units_added.items():
|
||||
for auid in u.advance:
|
||||
if not auid in units_added:
|
||||
try:
|
||||
au = self.wesnoth.unit_lookup[auid]
|
||||
except KeyError:
|
||||
# FIXME: write error message
|
||||
continue
|
||||
forest.add_node(helpers.UnitNode(au))
|
||||
units_added[auid] = au
|
||||
forest.update_breadth()
|
||||
|
||||
# Partition trees by race/faction of first unit.
|
||||
|
@ -422,6 +436,7 @@ class HTMLOutput:
|
|||
write('</div>\n')
|
||||
|
||||
description = unit.get_text_val("description")
|
||||
if not description: description = unit.get_text_val("unit_description")
|
||||
if not description: description = "-"
|
||||
write("<p>%s</p>\n" % description)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue