Merge pull request #733 from petosorus/multibuy-export

Multibuy format export feature, adresses #726
This commit is contained in:
Ryan Holmes
2016-09-27 01:49:12 -04:00
committed by GitHub
4 changed files with 70 additions and 4 deletions

View File

@@ -26,17 +26,19 @@ class CopySelectDialog(wx.Dialog):
copyFormatXml = 2
copyFormatDna = 3
copyFormatCrest = 4
copyFormatMultiBuy = 5
def __init__(self, parent):
wx.Dialog.__init__(self, parent, id = wx.ID_ANY, title = u"Select a format", size = (-1,-1), style = wx.DEFAULT_DIALOG_STYLE)
mainSizer = wx.BoxSizer(wx.VERTICAL)
copyFormats = [u"EFT", u"EFT (Implants)", u"XML", u"DNA", u"CREST"]
copyFormats = [u"EFT", u"EFT (Implants)", u"XML", u"DNA", u"CREST", u"MultiBuy"]
copyFormatTooltips = {CopySelectDialog.copyFormatEft: u"EFT text format",
CopySelectDialog.copyFormatEftImps: u"EFT text format",
CopySelectDialog.copyFormatXml: u"EVE native XML format",
CopySelectDialog.copyFormatDna: u"A one-line text format",
CopySelectDialog.copyFormatCrest: u"A JSON format used for EVE CREST"}
CopySelectDialog.copyFormatCrest: u"A JSON format used for EVE CREST",
CopySelectDialog.copyFormatMultiBuy: u"MultiBuy text format"}
selector = wx.RadioBox(self, wx.ID_ANY, label = u"Copy to the clipboard using:", choices = copyFormats, style = wx.RA_SPECIFY_ROWS)
selector.Bind(wx.EVT_RADIOBOX, self.Selected)
for format, tooltip in copyFormatTooltips.iteritems():

View File

@@ -678,6 +678,10 @@ class MainFrame(wx.Frame):
sFit = service.Fit.getInstance()
toClipboard(sFit.exportXml(None, self.getActiveFit()))
def clipboardMultiBuy(self):
sFit = service.Fit.getInstance()
toClipboard(sFit.exportMultiBuy(self.getActiveFit()))
def importFromClipboard(self, event):
sFit = service.Fit.getInstance()
try:
@@ -692,7 +696,8 @@ class MainFrame(wx.Frame):
CopySelectDialog.copyFormatEftImps: self.clipboardEftImps,
CopySelectDialog.copyFormatXml: self.clipboardXml,
CopySelectDialog.copyFormatDna: self.clipboardDna,
CopySelectDialog.copyFormatCrest: self.clipboardCrest}
CopySelectDialog.copyFormatCrest: self.clipboardCrest,
CopySelectDialog.copyFormatMultiBuy: self.clipboardMultiBuy}
dlg = CopySelectDialog(self)
dlg.ShowModal()
selected = dlg.GetSelected()

View File

@@ -925,6 +925,10 @@ class Fit(object):
fits = map(lambda fitID: eos.db.getFit(fitID), fitIDs)
return Port.exportXml(callback, *fits)
def exportMultiBuy(self, fitID):
fit = eos.db.getFit(fitID)
return Port.exportMultiBuy(fit)
def backupFits(self, path, callback):
thread = FitBackupThread(path, callback)
thread.start()

View File

@@ -719,6 +719,11 @@ class Port(object):
for drone in fit.drones:
export += "%s x%s\n" % (drone.item.name, drone.amount)
if len(fit.fighters) > 0:
export += "\n\n"
for fighter in fit.fighters:
export += "%s x%s\n" % (fighter.item.name, fighter.amountActive)
if export[-1] == "\n":
export = export[:-1]
@@ -741,10 +746,13 @@ class Port(object):
def exportEftImps(cls, fit):
export = cls._exportEftBase(fit)
if len(fit.implants) > 0:
if len(fit.implants) > 0 or len(fit.boosters) > 0:
export += "\n\n\n"
for implant in fit.implants:
export += "%s\n" % implant.item.name
for booster in fit.boosters:
export += "%s\n" % booster.item.name
if export[-1] == "\n":
export = export[:-1]
@@ -879,3 +887,50 @@ class Port(object):
wx.CallAfter(callback, i)
return doc.toprettyxml()
@staticmethod
def exportMultiBuy(fit):
export = "%s\n" % (fit.ship.item.name)
stuff = {}
sFit = service.Fit.getInstance()
for module in fit.modules:
slot = module.slot
if not slot in stuff:
stuff[slot] = []
curr = "%s\n" % module.item.name if module.item else (
"")
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
curr += "%s x%s\n" % (module.charge.name, module.numShots)
stuff[slot].append(curr)
for slotType in EFT_SLOT_ORDER:
data = stuff.get(slotType)
if data is not None:
# export += "\n"
for curr in data:
export += curr
if len(fit.drones) > 0:
for drone in fit.drones:
export += "%s x%s\n" % (drone.item.name, drone.amount)
if len(fit.cargo) > 0:
for cargo in fit.cargo:
export += "%s x%s\n" % (cargo.item.name, cargo.amount)
if len(fit.implants) > 0:
for implant in fit.implants:
export += "%s\n" % implant.item.name
if len(fit.boosters) > 0:
for booster in fit.boosters:
export += "%s\n" % booster.item.name
if len(fit.fighters) > 0:
for fighter in fit.fighters:
export += "%s x%s\n" % (fighter.item.name, fighter.amountActive)
if export[-1] == "\n":
export = export[:-1]
return export