[wmlunits] Add units from an era but without any faction...

...to a special "factionless" faction.
This commit is contained in:
Elias Pschernig 2012-03-03 18:01:06 +00:00
parent 8724c59678
commit 3ebb10809c
3 changed files with 20 additions and 6 deletions

View file

@ -352,6 +352,15 @@ class WesnothList:
if not eid in unit.eras:
unit.eras.append(eid)
unit.factions.append((eid, fid))
# as a special case, add units from this addon but with no faction
for unit in self.unit_lookup.values():
if unit.campaigns[0] == self.cid:
if not unit.factions:
if not eid in unit.eras:
unit.eras.append(eid)
unit.factions.append((eid, None))
def get_base_unit(self, unit):
b = unit.get_all(tag = "base_unit")

View file

@ -134,10 +134,12 @@ class GroupByFaction:
def group_name(self, group):
era = self.wesnoth.era_lookup[group[0]]
faction = era.faction_lookup[group[1]]
name = T(faction, "name")
name = name[name.rfind("=") + 1:]
#name = T(era, "name") + " / " + name
if group[1]:
faction = era.faction_lookup[group[1]]
name = T(faction, "name")
name = name[name.rfind("=") + 1:]
else:
name = "factionless"
return name
global_htmlout = None
@ -174,6 +176,7 @@ class HTMLOutput:
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
@ -548,7 +551,8 @@ class HTMLOutput:
try:
eid, fid = un.data
era = self.wesnoth.era_lookup[eid]
ms = era.faction_lookup[fid]
if fid:
ms = era.faction_lookup[fid]
except TypeError:
pass
racename = un.name

View file

@ -201,7 +201,7 @@ def list_contents():
def process_campaign_or_era(addon, cid, define, batchlist):
n = 0
print(addon + ": " + cid)
print(addon + ": " + cid + " " + define)
wesnoth = helpers.WesnothList(
options.wesnoth,
@ -209,6 +209,7 @@ def process_campaign_or_era(addon, cid, define, batchlist):
options.data_dir,
options.transdir)
wesnoth.batchlist = batchlist
wesnoth.cid = cid
wesnoth.parser.parse_text("{core/units.cfg}", "NORMAL")
wesnoth.add_units("mainline")