From cfc95c272a4039354f8437d58578db9d70f702bf Mon Sep 17 00:00:00 2001 From: Gochim <54093496+Gochim@users.noreply.github.com> Date: Thu, 14 Nov 2019 10:35:16 +0200 Subject: [PATCH 1/4] Possible fix for #2084 --- gui/copySelectDialog.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py index 9beb9698b..4d2b47595 100644 --- a/gui/copySelectDialog.py +++ b/gui/copySelectDialog.py @@ -83,6 +83,7 @@ class CopySelectDialog(wx.Dialog): self.options = {} initialized = False + self.copyFormat = 0 for formatName, formatData in self.copyFormats.items(): formatId, formatOptions = formatData if not initialized: From 41e4c2107d3460f1f74f66b1e033b006cee92af7 Mon Sep 17 00:00:00 2001 From: Gochim <54093496+Gochim@users.noreply.github.com> Date: Thu, 14 Nov 2019 11:36:59 +0200 Subject: [PATCH 2/4] Fix for #2084 --- gui/copySelectDialog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py index 4d2b47595..fc84331f1 100644 --- a/gui/copySelectDialog.py +++ b/gui/copySelectDialog.py @@ -74,7 +74,7 @@ class CopySelectDialog(wx.Dialog): continue defaultFormatOptions[formatId] = {opt[0]: opt[3] for opt in formatOptions} - self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": 0, "options": defaultFormatOptions}) + self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": self.copyFormatEft, "options": defaultFormatOptions}) # Options used to be stored as int (EFT export options only), # overwrite them with new format when needed if isinstance(self.settings["options"], int): @@ -83,7 +83,7 @@ class CopySelectDialog(wx.Dialog): self.options = {} initialized = False - self.copyFormat = 0 + self.copyFormat = self.copyFormatEft for formatName, formatData in self.copyFormats.items(): formatId, formatOptions = formatData if not initialized: From f80b7d972f2a035ac23c11dd6aa1c20efc259b4b Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 15 Nov 2019 12:59:57 +0300 Subject: [PATCH 3/4] Implement hidden flight time bonus --- eos/saveddata/module.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 817ca6736..6d9a804de 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -361,7 +361,11 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): return maxRange maxVelocity = self.getModifiedChargeAttr("maxVelocity") - flightTime = floatUnerr(self.getModifiedChargeAttr("explosionDelay") / 1000.0) + if not maxVelocity: + return 0, 0, 0 + shipRadius = self.owner.ship.getModifiedItemAttr("radius") + # Flight time has bonus based on ship radius, see https://github.com/pyfa-org/Pyfa/issues/2083 + flightTime = floatUnerr(self.getModifiedChargeAttr("explosionDelay") / 1000 + shipRadius / maxVelocity) mass = self.getModifiedChargeAttr("mass") agility = self.getModifiedChargeAttr("agility") lowerTime = math.floor(flightTime) @@ -375,7 +379,6 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): lowerRange = min(lowerRange, rangeLimit) higherRange = min(higherRange, rangeLimit) # Make range center-to-surface, as missiles spawn in the center of the ship - shipRadius = self.owner.ship.getModifiedItemAttr("radius") lowerRange = max(0, lowerRange - shipRadius) higherRange = max(0, higherRange - shipRadius) higherChance = flightTime - lowerTime From 7f86782f547fd1d9ed48b3aa021fe2f705bb3682 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 15 Nov 2019 13:23:27 +0300 Subject: [PATCH 4/4] Change range column tooltip for missiles --- eos/saveddata/module.py | 22 +++++++--------------- gui/builtinViewColumns/maxRange.py | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 6d9a804de..03f056e21 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -322,20 +322,12 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): maxRange = self.getModifiedItemAttr(attr, None) if maxRange is not None: return maxRange - if self.charge is not None: - try: - chargeName = self.charge.group.name - except AttributeError: - pass - else: - if chargeName in ("Scanner Probe", "Survey Probe"): - return None - missileMaxRangeData = self.missileMaxRangeData - if missileMaxRangeData is None: - return None - lowerRange, higherRange, higherChance = missileMaxRangeData - maxRange = lowerRange * (1 - higherChance) + higherRange * higherChance - return maxRange + missileMaxRangeData = self.missileMaxRangeData + if missileMaxRangeData is None: + return None + lowerRange, higherRange, higherChance = missileMaxRangeData + maxRange = lowerRange * (1 - higherChance) + higherRange * higherChance + return maxRange @property def missileMaxRangeData(self): @@ -362,7 +354,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): maxVelocity = self.getModifiedChargeAttr("maxVelocity") if not maxVelocity: - return 0, 0, 0 + return None shipRadius = self.owner.ship.getModifiedItemAttr("radius") # Flight time has bonus based on ship radius, see https://github.com/pyfa-org/Pyfa/issues/2083 flightTime = floatUnerr(self.getModifiedChargeAttr("explosionDelay") / 1000 + shipRadius / maxVelocity) diff --git a/gui/builtinViewColumns/maxRange.py b/gui/builtinViewColumns/maxRange.py index 24f72b3a1..b91465efc 100644 --- a/gui/builtinViewColumns/maxRange.py +++ b/gui/builtinViewColumns/maxRange.py @@ -24,7 +24,7 @@ from eos.saveddata.mode import Mode from service.attribute import Attribute from gui.viewColumn import ViewColumn from gui.bitmap_loader import BitmapLoader -from gui.utils.numberFormatter import formatAmount +from gui.utils.numberFormatter import formatAmount, roundToPrec class MaxRange(ViewColumn): @@ -77,7 +77,21 @@ class MaxRange(ViewColumn): return ("displayName", bool, False), ("showIcon", bool, True) def getToolTip(self, mod): - return "Optimal + Falloff" + lines = [] + missileRangeData = mod.missileMaxRangeData if hasattr(mod, "missileMaxRangeData") else None + if missileRangeData is not None: + lines.append('Missile flight range') + lowerRange, higherRange, higherChance = missileRangeData + if roundToPrec(higherChance, 3) not in (0, 1): + lines.append('{}% chance to fly {}'.format( + formatAmount((1 - higherChance) * 100, prec=3, lowest=0, highest=0), + formatAmount(lowerRange, prec=3, lowest=0, highest=3, unitName='m'))) + lines.append('{}% chance to fly {}'.format( + formatAmount(higherChance * 100, prec=3, lowest=0, highest=0), + formatAmount(higherRange, prec=3, lowest=0, highest=3, unitName='m'))) + else: + lines.append("Optimal + Falloff") + return '\n'.join(lines) MaxRange.register()