Skip to content

Commit

Permalink
Fix turrent ammo type grouping (using English names for grouping). Al…
Browse files Browse the repository at this point in the history
…so made missile damage type grouping translation-aware
  • Loading branch information
blitzmann committed Jun 28, 2020
1 parent 1d0c890 commit 546a3b6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
24 changes: 16 additions & 8 deletions gui/builtinContextMenus/moduleAmmoChange.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ def __init__(self):
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
# Format: {type ID: set(loadable, charges)}
self.loadableChargesCache = {}
# Translations for the missile categories, as the text here is auto-generated via damage attributes
self.ddMissileChargeCatTrans = {
'em': _t('EM'),
'thermal': _t('Thermal'),
'explosive': _t('Explosive'),
'kinetic': _t('Kinetic'),
'mixed': _t('Mixed')
}

def display(self, callingWindow, srcContext, mainItem, selection):
if srcContext not in ('fittingModule', 'projectedModule'):
Expand Down Expand Up @@ -48,7 +56,7 @@ def _getAmmo(self, mod):

def _addCharge(self, menu, charge):
id_ = ContextMenuCombined.nextID()
name = charge.name if charge is not None else 'Empty'
name = charge.name if charge is not None else _t('Empty')
self.chargeEventMap[id_] = charge
item = wx.MenuItem(menu, id_, name)
menu.Bind(wx.EVT_MENU, self.handleAmmoSwitch, item)
Expand All @@ -71,7 +79,7 @@ def getSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, p
self.chargeEventMap = {}
modType, chargeDict = Ammo.getInstance().getModuleStructuredAmmo(self.module, ammo=self.mainCharges)
if modType == 'ddTurret':
self._addSeparator(menu, 'Long Range')
self._addSeparator(menu, _t('Long Range'))
menuItems = []
for charges in chargeDict.values():
if len(charges) == 1:
Expand All @@ -83,25 +91,25 @@ def getSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, p
subMenu = wx.Menu()
subMenu.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
menuItem.SetSubMenu(subMenu)
self._addSeparator(subMenu, 'Less Damage')
self._addSeparator(subMenu, _t('Less Damage'))
for charge in charges:
subMenu.Append(self._addCharge(rootMenu if msw else subMenu, charge))
self._addSeparator(subMenu, 'More Damage')
self._addSeparator(subMenu, _t('More Damage'))
for menuItem in menuItems:
menu.Append(menuItem)
self._addSeparator(menu, 'Short Range')
self._addSeparator(menu, _t('Short Range'))
elif modType == 'ddMissile':
menuItems = []
for chargeCatName, charges in chargeDict.items():
menuItem = wx.MenuItem(menu, wx.ID_ANY, chargeCatName.capitalize())
menuItem = wx.MenuItem(menu, wx.ID_ANY, self.ddMissileChargeCatTrans.get(chargeCatName, chargeCatName))
menuItems.append(menuItem)
subMenu = wx.Menu()
subMenu.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
menuItem.SetSubMenu(subMenu)
self._addSeparator(subMenu, 'Less Damage')
self._addSeparator(subMenu, _t('Less Damage'))
for charge in charges:
subMenu.Append(self._addCharge(rootMenu if msw else subMenu, charge))
self._addSeparator(subMenu, 'More Damage')
self._addSeparator(subMenu, _t('More Damage'))
for menuItem in menuItems:
menu.Append(menuItem)
elif modType == 'general':
Expand Down
3 changes: 1 addition & 2 deletions pyfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def _process_args(self, largs, rargs, values):
config.debug = options.debug
config.loggingLevel = config.LOGLEVEL_MAP.get(options.logginglevel.lower(), config.LOGLEVEL_MAP['error'])

from service.settings import LocaleSettings
config.language = options.language or LocaleSettings.getInstance().get('locale')
config.language = options.language

config.defPaths(options.savepath)
config.defLogging()
Expand Down
6 changes: 3 additions & 3 deletions service/ammo.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ def turretSorter(charge):
damage += d
# Take optimal and falloff as range factor
rangeFactor = range_ + falloff
return -rangeFactor, charge.name.rsplit()[-2:], damage, charge.name
return -rangeFactor, charge.typeName.rsplit()[-2:], damage, charge.name

all = OrderedDict()
sub = []
prevNameBase = None
prevRange = None
for charge in sorted(chargesFlat, key=turretSorter):
if 'civilian' in charge.name.lower():
if 'civilian' in charge.typeName.lower():
continue
currNameBase = ' '.join(charge.name.rsplit()[-2:])
currNameBase = ' '.join(charge.typeName.rsplit()[-2:])
currRange = charge.getAttribute('weaponRangeMultiplier')
if sub and (currRange != prevRange or currNameBase != prevNameBase):
all[sub[0].name] = sub
Expand Down

0 comments on commit 546a3b6

Please sign in to comment.