Keep name on group, create displayName property to point to translated version

This commit is contained in:
blitzmann
2020-06-28 00:54:51 -04:00
parent 2fd4168ab7
commit 4a6a3fc6ea
7 changed files with 9 additions and 8 deletions

View File

@@ -169,7 +169,8 @@ def update_db():
def processEveGroups():
print('processing evegroups')
data = _readData('fsd_lite', 'evegroups', keyIdName='groupID')
map = {'groupName_en-us': 'groupName'}
map = {'groupName_en-us': 'displayName'}
map.update({'groupName'+v: 'name'+v for (k, v) in eos.config.translation_mapping.items() if k != 'en_US'})
_addRows(data, eos.gamedata.Group, fieldMap=map)
return data

View File

@@ -26,7 +26,7 @@ import eos.config
groups_table = Table("invgroups", gamedata_meta,
Column("groupID", Integer, primary_key=True),
*[Column("groupName{}".format(lang), String) for lang in eos.config.translation_mapping.values()],
*[Column("name{}".format(lang), String) for lang in eos.config.translation_mapping.values()],
# Column("description", String), # deprecated
Column("published", Boolean),
Column("categoryID", Integer, ForeignKey("invcategories.categoryID")),
@@ -36,6 +36,6 @@ mapper(Group, groups_table,
properties={
"category" : relation(Category, backref=backref("groups", cascade="all,delete")),
"ID" : synonym("groupID"),
"name" : synonym("groupName{}".format(eos.config.lang)),
"displayName" : synonym("name{}".format(eos.config.lang)),
# "description": deferred(groups_table.c.description) # deprecated
})

View File

@@ -205,7 +205,7 @@ def getGroup(lookfor, eager=None):
group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.ID == id).first()
else:
# Group names are unique, so we can use first() instead of one()
group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.groupName == lookfor).first()
group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.name == lookfor).first()
if group is not None:
groupNameMap[lookfor] = group.ID
else:

View File

@@ -91,7 +91,7 @@ class Booster(HandledItem, ItemAttrShortcut):
@property
def isInvalid(self):
return self.__item is None or self.__item.group.groupName != "Booster"
return self.__item is None or self.__item.group.name != "Booster"
@property
def slot(self):

View File

@@ -255,7 +255,7 @@ class FighterDisplay(d.Display):
@staticmethod
def fighterKey(fighter):
groupName = Market.getInstance().getGroupByItem(fighter.item).groupName
groupName = Market.getInstance().getGroupByItem(fighter.item).name
orderPos = FIGHTER_ORDER.index(groupName)
# Sort support fighters by name, ignore their abilities
if groupName == 'Support Fighter':

View File

@@ -68,7 +68,7 @@ class Miscellanea(ViewColumn):
item = stuff.item
if item is None:
return "", None
itemGroup = item.group.groupName
itemGroup = item.group.name
itemCategory = item.category.name
if itemGroup == "Ship Modifiers":

View File

@@ -508,7 +508,7 @@ class Market:
# Check custom groups
for cgrp in self.customGroups:
# During first comparison we need exact int, not float for matching
if cgrp.ID == identity or cgrp.groupName == identity:
if cgrp.ID == identity or cgrp.name == identity:
# Return first match
return cgrp
# Return eos group if everything else returned nothing