Added UI for new type of copying data about fit to the clipboard

This commit is contained in:
Gochim
2019-10-26 18:36:38 +03:00
parent 76bdefcda6
commit 10dfdc3627
3 changed files with 32 additions and 13 deletions

View File

@@ -64,7 +64,7 @@ class CopySelectDialog(wx.Dialog):
("ESI", (CopySelectDialog.copyFormatEsi, None)), ("ESI", (CopySelectDialog.copyFormatEsi, None)),
("DNA", (CopySelectDialog.copyFormatDna, DNA_OPTIONS)), ("DNA", (CopySelectDialog.copyFormatDna, DNA_OPTIONS)),
("EFS", (CopySelectDialog.copyFormatEfs, None)), ("EFS", (CopySelectDialog.copyFormatEfs, None)),
("Fit Stats", (CopySelectDialog.copyFormatFitStats, None)), ("Fit stats", (CopySelectDialog.copyFormatFitStats, None)),
# ("XML", (CopySelectDialog.copyFormatXml, None)), # ("XML", (CopySelectDialog.copyFormatXml, None)),
)) ))
@@ -120,7 +120,8 @@ class CopySelectDialog(wx.Dialog):
self.Center() self.Center()
def Validate(self): 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() # This always returns False, and when we're ready will EndModal()
selected = self.GetSelected() selected = self.GetSelected()
options = self.GetOptions() options = self.GetOptions()
@@ -192,5 +193,8 @@ class CopySelectDialog(wx.Dialog):
""" """
Puts fit stats in textual format into the clipboard Puts fit stats in textual format into the clipboard
""" """
# noinspection PyUnusedLocal
def exportFitStats(self, options, callback): def exportFitStats(self, options, callback):
pass fit = getFit(self.mainFrame.getActiveFit())
Port.exportFitStats(fit, callback)

View File

@@ -39,6 +39,7 @@ from service.port.eft import (
from service.port.esi import exportESI, importESI from service.port.esi import exportESI, importESI
from service.port.multibuy import exportMultiBuy from service.port.multibuy import exportMultiBuy
from service.port.shared import IPortUser, UserCancelException, processing_notify 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.xml import importXml, exportXml
from service.port.muta import parseMutant from service.port.muta import parseMutant
@@ -317,3 +318,7 @@ class Port:
@staticmethod @staticmethod
def exportMultiBuy(fit, options, callback=None): def exportMultiBuy(fit, options, callback=None):
return exportMultiBuy(fit, options, callback=callback) return exportMultiBuy(fit, options, callback=callback)
@staticmethod
def exportFitStats(fit, callback=None):
return exportFitStats(fit, callback=callback)

View File

@@ -1,10 +1,8 @@
from functools import reduce from functools import reduce
from eos.saveddata.damagePattern import DamagePattern from eos.saveddata.damagePattern import DamagePattern
from gui.utils.numberFormatter import formatAmount from gui.utils.numberFormatter import formatAmount
#todo remove these enums. Not sure they are not needed
tankTypes = ("shield", "armor", "hull") tankTypes = ("shield", "armor", "hull")
damageTypes = ("em", "thermal", "kinetic", "explosive") damageTypes = ("em", "thermal", "kinetic", "explosive")
damagePatterns = [DamagePattern.oneType(damageType) for damageType in damageTypes] damagePatterns = [DamagePattern.oneType(damageType) for damageType in damageTypes]
@@ -16,13 +14,19 @@ resonanceNames = {"shield": ["shield" + s for s in damageTypeResonanceNames],
def firepowerSection(fit): def firepowerSection(fit):
""" Returns the text of the firepower section""" """ 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] 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: if sum(firepower) == 0:
return "" return ""
return "DPS: {} (".format(firepowerStr[0]) + \ 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])) ("Volley: {})\n".format(firepowerStr[3]))
@@ -47,7 +51,8 @@ def repsSection(fit):
""" Returns the text of the repairs section""" """ Returns the text of the repairs section"""
selfRep = [fit.effectiveTank[tankType + "Repair"] for tankType in tankTypes] selfRep = [fit.effectiveTank[tankType + "Repair"] for tankType in tankTypes]
sustainRep = [fit.effectiveSustainableTank[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] shieldRegen = [fit.effectiveSustainableTank["passiveShield"], 0, 0]
shieldRechargeModuleMultipliers = [module.item.attributes["shieldRechargeRateMultiplier"].value for module in shieldRechargeModuleMultipliers = [module.item.attributes["shieldRechargeRateMultiplier"].value for module in
fit.modules if fit.modules if
@@ -158,8 +163,10 @@ def miscSection(fit):
return text return text
def statsExportText(fit): def exportFitStats(fit, callback):
""" Returns the text of the stats export of the given fit""" """
Returns the text of the stats export of the given fit
"""
sections = filter(None, (firepowerSection(fit), # Prune empty sections sections = filter(None, (firepowerSection(fit), # Prune empty sections
tankSection(fit), tankSection(fit),
repsSection(fit), repsSection(fit),
@@ -168,4 +175,7 @@ def statsExportText(fit):
text = "{} ({})\n".format(fit.name, fit.ship.name) + "\n" text = "{} ({})\n".format(fit.name, fit.ship.name) + "\n"
text += "\n".join(sections) text += "\n".join(sections)
return text if callback:
callback(text)
else:
return text