Implement multi-level selection menu for mining crystals

This commit is contained in:
DarkPhoenix
2021-11-27 00:05:18 +03:00
parent 48818c9709
commit 9d8e338136
2 changed files with 83 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
# noinspection PyPackageRequirements
from collections import OrderedDict
# noinspection PyPackageRequirements
import wx
import gui.fitCommands as cmd
@@ -25,8 +26,20 @@ class ChangeModuleAmmo(ContextMenuCombined):
'thermal': _t('Thermal'),
'explosive': _t('Explosive'),
'kinetic': _t('Kinetic'),
'mixed': _t('Mixed')
}
'mixed': _t('Mixed')}
self.oreChargeCatTrans = OrderedDict([
('a1', _t('Asteroid Common')),
('a2', _t('Asteroid Uncommon')),
('a3', _t('Asteroid Rare')),
('a4', _t('Asteroid Premium')),
('a5', _t('Asteroid Abyssal')),
('a6', _t('Asteroid Mercoxit')),
('r4', _t('Moon Ubiquitous')),
('r8', _t('Moon Common')),
('r16', _t('Moon Uncommon')),
('r32', _t('Moon Rare')),
('r64', _t('Moon Exceptional')),
('misc', _t('Misc'))])
def display(self, callingWindow, srcContext, mainItem, selection):
if srcContext not in ('fittingModule', 'projectedModule'):
@@ -115,6 +128,24 @@ class ChangeModuleAmmo(ContextMenuCombined):
self._addSeparator(subMenu, _t('More Damage'))
for menuItem in menuItems:
menu.Append(menuItem)
elif modType == 'miner':
menuItems = []
for catHandle, catLabel in self.oreChargeCatTrans.items():
charges = chargeDict.get(catHandle)
if not charges:
continue
if len(charges) == 1:
menuItems.append(self._addCharge(rootMenu if msw else menu, charges[0]))
else:
menuItem = wx.MenuItem(menu, wx.ID_ANY, catLabel)
menuItems.append(menuItem)
subMenu = wx.Menu()
subMenu.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
menuItem.SetSubMenu(subMenu)
for charge in charges:
subMenu.Append(self._addCharge(rootMenu if msw else subMenu, charge))
for menuItem in menuItems:
menu.Append(menuItem)
elif modType == 'general':
for charge in chargeDict['general']:
menu.Append(self._addCharge(rootMenu if msw else menu, charge))