Multibuy format export feature

This commit is contained in:
petosorus
2016-09-14 23:38:09 +02:00
parent d1c18d9642
commit 54c950f951
4 changed files with 53 additions and 3 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

@@ -858,3 +858,42 @@ class Port(object):
wx.CallAfter(callback, i)
return doc.toprettyxml()
@staticmethod
def exportMultiBuy(fit):
offineSuffix = " /OFFLINE"
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 = module.item.name if module.item else (
"")
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
curr += "\n%s" % module.charge.name
if module.state == State.OFFLINE:
curr += offineSuffix
curr += "\n"
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 export[-1] == "\n":
export = export[:-1]
return export