From 9302d79e1d445708bab0456483da8bb09c97bcd6 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 9 Nov 2024 09:04:18 +0100 Subject: [PATCH] Sort glorified mutaplasmids right after their base versions, and shorten them to Gl. --- eos/gamedata.py | 9 +++++++-- gui/builtinContextMenus/itemMutations.py | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index afbf03481..0f1936b14 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -569,13 +569,18 @@ class DynamicItem(EqBase): @property def shortName(self): name = self.item.customName - keywords = ('Decayed', 'Gravid', 'Unstable', 'Radical') + keywords = ( + 'Decayed', 'Glorified Decayed', + 'Gravid', 'Glorified Gravid', + 'Unstable', 'Glorified Unstable', + 'Radical', 'Glorified Radical') for kw in keywords: if name.startswith(f'{kw} '): name = kw - m = re.match('(?P\S+) (?P\S+) Drone (?P\S+) Mutaplasmid', name) + m = re.match(r'(?P(Glorified )?\S+) (?P\S+) Drone (?P\S+) Mutaplasmid', name) if m: name = '{} {}'.format(m.group('mutagrade'), m.group('mutatype')) + name = name.replace('Glorified ', 'Gl. ') return name diff --git a/gui/builtinContextMenus/itemMutations.py b/gui/builtinContextMenus/itemMutations.py index c4deec4a2..f0b99a4d6 100644 --- a/gui/builtinContextMenus/itemMutations.py +++ b/gui/builtinContextMenus/itemMutations.py @@ -13,6 +13,16 @@ from service.fit import Fit _t = wx.GetTranslation +GLORIFIED_PREFIX = 'Gl. ' + + +def nameSorter(mutaplasmid): + name = mutaplasmid.shortName + if name.startswith(GLORIFIED_PREFIX): + return name[len(GLORIFIED_PREFIX):], True + return name, False + + class ChangeItemMutation(ContextMenuSingle): def __init__(self): @@ -45,7 +55,7 @@ class ChangeItemMutation(ContextMenuSingle): menu = rootMenu if msw else sub - for mutaplasmid in mainItem.item.mutaplasmids: + for mutaplasmid in sorted(mainItem.item.mutaplasmids, key=nameSorter): id = ContextMenuSingle.nextID() self.eventIDs[id] = (mutaplasmid, mainItem) mItem = wx.MenuItem(menu, id, mutaplasmid.shortName)