From e447bca32e377d0e1b048e47f1fd99d9478720de Mon Sep 17 00:00:00 2001 From: cncfanatics Date: Thu, 21 Oct 2010 10:20:49 +0200 Subject: [PATCH] Sort ammo by their range + falloff on the turret they're getting fit on --- gui/builtinContextMenus/moduleAmmoPicker.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/gui/builtinContextMenus/moduleAmmoPicker.py b/gui/builtinContextMenus/moduleAmmoPicker.py index 6265abf52..0ae3b7aa7 100644 --- a/gui/builtinContextMenus/moduleAmmoPicker.py +++ b/gui/builtinContextMenus/moduleAmmoPicker.py @@ -24,7 +24,7 @@ class ModuleAmmoPicker(ContextMenu): validCharges = currCharges self.charges = list(validCharges) - self.hardpoint = mod.hardpoint + self.module = mod return len(self.charges) > 0 def getText(self, context, selection): @@ -34,23 +34,15 @@ class ModuleAmmoPicker(ContextMenu): pass def turretSorter(self, charge): - s = [] damage = 0 - range = charge.getAttribute("weaponRangeMultiplier") - falloff = charge.getAttribute("fallofMultiplier") or 1 - types = [] + range = self.module.getModifiedItemAttr("maxRange") * charge.getAttribute("weaponRangeMultiplier") + falloff = self.module.getModifiedItemAttr("falloff") * (charge.getAttribute("fallofMultiplier") or 1) for type in ("em", "explosive", "kinetic", "thermal"): d = charge.getAttribute("%sDamage" % type) if d > 0: - types.append(type) damage += d - s.append(-range) - s.append(-falloff) - s.append(charge.name.rsplit()[-2:]) - s.append(damage) - s.append(charge.name) - return s + return (-range - falloff, charge.name.rsplit()[-2:], damage, charge.name) MISSILE_ORDER = ["em", "thermal", "kinetic", "explosive"] def missileSorter(self, charge): @@ -86,7 +78,8 @@ class ModuleAmmoPicker(ContextMenu): m = wx.Menu() m.Bind(wx.EVT_MENU, self.handleAmmoSwitch) self.chargeIds = {} - if self.hardpoint == Hardpoint.TURRET: + hardpoint = self.module.hardpoint + if hardpoint == Hardpoint.TURRET: self.addSeperator(m, "Long Range") items = [] range = None @@ -122,7 +115,7 @@ class ModuleAmmoPicker(ContextMenu): m.AppendItem(item) self.addSeperator(m, "High Damage") - elif self.hardpoint == Hardpoint.MISSILE: + elif hardpoint == Hardpoint.MISSILE: self.charges.sort(key=self.missileSorter) type = None sub = None