From 54c950f951f9dbf78bb0d276715d9bce70c4f42b Mon Sep 17 00:00:00 2001 From: petosorus Date: Wed, 14 Sep 2016 23:38:09 +0200 Subject: [PATCH 1/7] Multibuy format export feature --- gui/copySelectDialog.py | 6 ++++-- gui/mainFrame.py | 7 ++++++- service/fit.py | 4 ++++ service/port.py | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/gui/copySelectDialog.py b/gui/copySelectDialog.py index 14ee68703..ea2e44620 100644 --- a/gui/copySelectDialog.py +++ b/gui/copySelectDialog.py @@ -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(): diff --git a/gui/mainFrame.py b/gui/mainFrame.py index c209a0422..49fb9385a 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -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() diff --git a/service/fit.py b/service/fit.py index 455e76463..2d3b75be5 100644 --- a/service/fit.py +++ b/service/fit.py @@ -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() diff --git a/service/port.py b/service/port.py index f8a9334ac..23acacb7b 100644 --- a/service/port.py +++ b/service/port.py @@ -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 From 8338b6adb3479f5926896ffbe579e516ada6f7d8 Mon Sep 17 00:00:00 2001 From: petosorus Date: Thu, 15 Sep 2016 08:19:21 +0200 Subject: [PATCH 2/7] Implants and boosters in Multibuy export --- service/port.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/service/port.py b/service/port.py index 23acacb7b..fffa53999 100644 --- a/service/port.py +++ b/service/port.py @@ -893,6 +893,14 @@ class Port(object): 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 export[-1] == "\n": export = export[:-1] From ba3c9b87b5a04a10b829d10d90a2188ceb99dee5 Mon Sep 17 00:00:00 2001 From: petosorus Date: Thu, 15 Sep 2016 08:27:38 +0200 Subject: [PATCH 3/7] Fighters handling in Multibuy export --- service/port.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service/port.py b/service/port.py index fffa53999..bbff8be2d 100644 --- a/service/port.py +++ b/service/port.py @@ -901,6 +901,10 @@ class Port(object): 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] From 533c86de16775246302315943dedc37de858743e Mon Sep 17 00:00:00 2001 From: petosorus Date: Thu, 15 Sep 2016 11:20:45 +0200 Subject: [PATCH 4/7] Removal of empty lines when there are empty slots --- service/port.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/service/port.py b/service/port.py index bbff8be2d..577bae897 100644 --- a/service/port.py +++ b/service/port.py @@ -861,7 +861,6 @@ class Port(object): @staticmethod def exportMultiBuy(fit): - offineSuffix = " /OFFLINE" export = "%s\n" % (fit.ship.item.name) stuff = {} sFit = service.Fit.getInstance() @@ -869,13 +868,10 @@ class Port(object): slot = module.slot if not slot in stuff: stuff[slot] = [] - curr = module.item.name if module.item else ( + curr = "%s\n" % 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" + curr += "%s\n" % module.charge.name stuff[slot].append(curr) for slotType in EFT_SLOT_ORDER: From 43ee03112198cc8d7ddc52a685520f5ca97e5cd9 Mon Sep 17 00:00:00 2001 From: petosorus Date: Thu, 15 Sep 2016 16:01:32 +0200 Subject: [PATCH 5/7] Number of charges loaded --- service/port.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/port.py b/service/port.py index 577bae897..2fc9b00ff 100644 --- a/service/port.py +++ b/service/port.py @@ -871,7 +871,7 @@ class Port(object): curr = "%s\n" % module.item.name if module.item else ( "") if module.charge and sFit.serviceFittingOptions["exportCharges"]: - curr += "%s\n" % module.charge.name + curr += "%s x%s\n" % (module.charge.name, module.numShots) stuff[slot].append(curr) for slotType in EFT_SLOT_ORDER: From 840c041f8c512561909230fd711852aff944a32a Mon Sep 17 00:00:00 2001 From: petosorus Date: Fri, 16 Sep 2016 10:58:31 +0200 Subject: [PATCH 6/7] Fighters get exported in EFT export --- service/port.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/service/port.py b/service/port.py index 2fc9b00ff..0c38bfbbf 100644 --- a/service/port.py +++ b/service/port.py @@ -698,6 +698,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] From 467d244bea0f5d2a9d72bcc43dffaf1a5fd17f23 Mon Sep 17 00:00:00 2001 From: petosorus Date: Fri, 16 Sep 2016 10:59:19 +0200 Subject: [PATCH 7/7] Booster export in EFT Implants export --- service/port.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/service/port.py b/service/port.py index 0c38bfbbf..e5f4ec5dc 100644 --- a/service/port.py +++ b/service/port.py @@ -725,10 +725,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]