User short mutaplasmid name in mutation panel

This commit is contained in:
DarkPhoenix
2021-10-26 01:31:09 +03:00
parent 148093f6ad
commit b0d3469f01
3 changed files with 16 additions and 13 deletions

View File

@@ -567,7 +567,18 @@ class Group(EqBase):
class DynamicItem(EqBase):
pass
@property
def shortName(self):
name = self.item.name
keywords = ('Decayed', 'Gravid', 'Unstable', 'Radical')
for kw in keywords:
if name.startswith(f'{kw} '):
name = kw
m = re.match('(?P<mutagrade>\S+) (?P<dronetype>\S+) Drone (?P<mutatype>\S+) Mutaplasmid', name)
if m:
name = '{} {}'.format(m.group('mutagrade'), m.group('mutatype'))
return name
class DynamicItemAttribute(EqBase):

View File

@@ -45,18 +45,10 @@ class ChangeItemMutation(ContextMenuSingle):
menu = rootMenu if msw else sub
for item in mainItem.item.mutaplasmids:
label = item.item.name
keywords = ('Decayed', 'Gravid', 'Unstable', 'Radical')
for kw in keywords:
if item.item.name.startswith(f'{kw} '):
label = kw
m = re.match('(?P<mutagrade>\S+) (?P<dronetype>\S+) Drone (?P<mutatype>\S+) Mutaplasmid', label)
if m:
label = '{} {}'.format(m.group('mutagrade'), m.group('mutatype'))
for mutaplasmid in mainItem.item.mutaplasmids:
id = ContextMenuSingle.nextID()
self.eventIDs[id] = (item, mainItem)
mItem = wx.MenuItem(menu, id, label)
self.eventIDs[id] = (mutaplasmid, mainItem)
mItem = wx.MenuItem(menu, id, mutaplasmid.shortName)
menu.Bind(wx.EVT_MENU, self.handleMenu, mItem)
sub.Append(mItem)

View File

@@ -33,7 +33,7 @@ class ItemMutatorPanel(wx.Panel):
mutaIcon = BitmapLoader.getStaticBitmap(stuff.mutaplasmid.item.iconID, self, "icons")
if mutaIcon is not None:
headerSizer.Add(mutaIcon, 0, wx.LEFT, 0)
sourceItemShort = "{} {}".format(stuff.mutaplasmid.item.name.split(" ")[0], stuff.baseItem.name)
sourceItemShort = "{} {}".format(stuff.mutaplasmid.shortName, stuff.baseItem.name)
sourceItemText = wx.StaticText(self, wx.ID_ANY, sourceItemShort)
font = parent.GetFont()
font.SetWeight(wx.BOLD)