diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py index fc64aa91a..18fbf4d9a 100644 --- a/gui/copySelectDialog.py +++ b/gui/copySelectDialog.py @@ -64,7 +64,7 @@ class CopySelectDialog(wx.Dialog): ("ESI", (CopySelectDialog.copyFormatEsi, None)), ("DNA", (CopySelectDialog.copyFormatDna, DNA_OPTIONS)), ("EFS", (CopySelectDialog.copyFormatEfs, None)), - ("Fit Stats", (CopySelectDialog.copyFormatFitStats, None)), + ("Fit stats", (CopySelectDialog.copyFormatFitStats, None)), # ("XML", (CopySelectDialog.copyFormatXml, None)), )) @@ -120,7 +120,8 @@ class CopySelectDialog(wx.Dialog): self.Center() def Validate(self): - # Since this dialog is shown through as ShowModal(), we hook into the Validate function to veto the closing of the dialog until we're ready. + # Since this dialog is shown through as ShowModal(), + # we hook into the Validate function to veto the closing of the dialog until we're ready. # This always returns False, and when we're ready will EndModal() selected = self.GetSelected() options = self.GetOptions() @@ -192,5 +193,8 @@ class CopySelectDialog(wx.Dialog): """ Puts fit stats in textual format into the clipboard """ + # noinspection PyUnusedLocal def exportFitStats(self, options, callback): - pass + fit = getFit(self.mainFrame.getActiveFit()) + Port.exportFitStats(fit, callback) + diff --git a/service/port/port.py b/service/port/port.py index 2db627bbc..2fc4d879a 100644 --- a/service/port/port.py +++ b/service/port/port.py @@ -39,6 +39,7 @@ from service.port.eft import ( from service.port.esi import exportESI, importESI from service.port.multibuy import exportMultiBuy from service.port.shared import IPortUser, UserCancelException, processing_notify +from service.port.shipstats import exportFitStats from service.port.xml import importXml, exportXml from service.port.muta import parseMutant @@ -317,3 +318,7 @@ class Port: @staticmethod def exportMultiBuy(fit, options, callback=None): return exportMultiBuy(fit, options, callback=callback) + + @staticmethod + def exportFitStats(fit, callback=None): + return exportFitStats(fit, callback=callback) \ No newline at end of file diff --git a/gui/utils/exportStats.py b/service/port/shipstats.py similarity index 92% rename from gui/utils/exportStats.py rename to service/port/shipstats.py index d0b312792..190c964ec 100644 --- a/gui/utils/exportStats.py +++ b/service/port/shipstats.py @@ -1,10 +1,8 @@ from functools import reduce - from eos.saveddata.damagePattern import DamagePattern - from gui.utils.numberFormatter import formatAmount - +#todo remove these enums. Not sure they are not needed tankTypes = ("shield", "armor", "hull") damageTypes = ("em", "thermal", "kinetic", "explosive") damagePatterns = [DamagePattern.oneType(damageType) for damageType in damageTypes] @@ -16,13 +14,19 @@ resonanceNames = {"shield": ["shield" + s for s in damageTypeResonanceNames], def firepowerSection(fit): """ Returns the text of the firepower section""" - firepower = [fit.totalDPS, fit.weaponDPS, fit.droneDPS, fit.totalVolley] + totalDps = fit.getTotalDps().total + weaponDps = fit.getWeaponDps().total + droneDps = fit.getDroneDps().total + totalVolley = fit.getTotalVolley().total + firepower = [totalDps, weaponDps, droneDps, totalVolley] + firepowerStr = [formatAmount(dps, 3, 0, 0) for dps in firepower] - showWeaponAndDroneDps = (fit.weaponDPS > 0) and (fit.droneDPS > 0) + # showWeaponAndDroneDps = (weaponDps > 0) and (droneDps > 0) if sum(firepower) == 0: return "" + return "DPS: {} (".format(firepowerStr[0]) + \ - ("Weapon: {}, Drone: {}, ".format(*firepowerStr[1:3]) if showWeaponAndDroneDps else "") + \ + ("Weapon: {}, Drone: {}, ".format(*firepowerStr[1:3])) + \ ("Volley: {})\n".format(firepowerStr[3])) @@ -47,7 +51,8 @@ def repsSection(fit): """ Returns the text of the repairs section""" selfRep = [fit.effectiveTank[tankType + "Repair"] for tankType in tankTypes] sustainRep = [fit.effectiveSustainableTank[tankType + "Repair"] for tankType in tankTypes] - remoteRep = [fit.remoteReps[tankType.capitalize()] for tankType in tankTypes] + remoteRepObj = fit.getRemoteReps() + remoteRep = [remoteRepObj.shield, remoteRepObj.armor, remoteRepObj.hull] shieldRegen = [fit.effectiveSustainableTank["passiveShield"], 0, 0] shieldRechargeModuleMultipliers = [module.item.attributes["shieldRechargeRateMultiplier"].value for module in fit.modules if @@ -158,8 +163,10 @@ def miscSection(fit): return text -def statsExportText(fit): - """ Returns the text of the stats export of the given fit""" +def exportFitStats(fit, callback): + """ + Returns the text of the stats export of the given fit + """ sections = filter(None, (firepowerSection(fit), # Prune empty sections tankSection(fit), repsSection(fit), @@ -168,4 +175,7 @@ def statsExportText(fit): text = "{} ({})\n".format(fit.name, fit.ship.name) + "\n" text += "\n".join(sections) - return text + if callback: + callback(text) + else: + return text