Add option to export implants/boosters via ESI
This commit is contained in:
@@ -193,7 +193,7 @@ class CopySelectDialog(wx.Dialog):
|
|||||||
|
|
||||||
def exportEsi(self, options, callback):
|
def exportEsi(self, options, callback):
|
||||||
fit = getFit(self.mainFrame.getActiveFit())
|
fit = getFit(self.mainFrame.getActiveFit())
|
||||||
Port.exportESI(fit, True, callback)
|
Port.exportESI(fit, False, False, False, callback)
|
||||||
|
|
||||||
def exportXml(self, options, callback):
|
def exportXml(self, options, callback):
|
||||||
fit = getFit(self.mainFrame.getActiveFit())
|
fit = getFit(self.mainFrame.getActiveFit())
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ class ExportToEve(AuxiliaryFrame):
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
parent, id=wx.ID_ANY, title=_t("Export fit to EVE"), pos=wx.DefaultPosition,
|
parent, id=wx.ID_ANY, title=_t("Export fit to EVE"), pos=wx.DefaultPosition,
|
||||||
size=wx.Size(400, 140) if "wxGTK" in wx.PlatformInfo else wx.Size(350, 115), resizeable=True)
|
size=wx.Size(400, 175) if "wxGTK" in wx.PlatformInfo else wx.Size(350, 145), resizeable=True)
|
||||||
|
|
||||||
self.mainFrame = parent
|
self.mainFrame = parent
|
||||||
|
|
||||||
@@ -305,6 +305,16 @@ class ExportToEve(AuxiliaryFrame):
|
|||||||
self.exportChargesCb.Bind(wx.EVT_CHECKBOX, self.OnChargeExportChange)
|
self.exportChargesCb.Bind(wx.EVT_CHECKBOX, self.OnChargeExportChange)
|
||||||
mainSizer.Add(self.exportChargesCb, 0, 0, 5)
|
mainSizer.Add(self.exportChargesCb, 0, 0, 5)
|
||||||
|
|
||||||
|
self.exportImplantsCb = wx.CheckBox(self, wx.ID_ANY, _t('Export Implants'), wx.DefaultPosition, wx.DefaultSize, 0)
|
||||||
|
self.exportImplantsCb.SetValue(EsiSettings.getInstance().get('exportImplants'))
|
||||||
|
self.exportImplantsCb.Bind(wx.EVT_CHECKBOX, self.OnImplantsExportChange)
|
||||||
|
mainSizer.Add(self.exportImplantsCb, 0, 0, 5)
|
||||||
|
|
||||||
|
self.exportBoostersCb = wx.CheckBox(self, wx.ID_ANY, _t('Export Boosters'), wx.DefaultPosition, wx.DefaultSize, 0)
|
||||||
|
self.exportBoostersCb.SetValue(EsiSettings.getInstance().get('exportBoosters'))
|
||||||
|
self.exportBoostersCb.Bind(wx.EVT_CHECKBOX, self.OnBoostersExportChange)
|
||||||
|
mainSizer.Add(self.exportBoostersCb, 0, 0, 5)
|
||||||
|
|
||||||
self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting)
|
self.exportBtn.Bind(wx.EVT_BUTTON, self.exportFitting)
|
||||||
|
|
||||||
self.statusbar = wx.StatusBar(self)
|
self.statusbar = wx.StatusBar(self)
|
||||||
@@ -324,6 +334,14 @@ class ExportToEve(AuxiliaryFrame):
|
|||||||
EsiSettings.getInstance().set('exportCharges', self.exportChargesCb.GetValue())
|
EsiSettings.getInstance().set('exportCharges', self.exportChargesCb.GetValue())
|
||||||
event.Skip()
|
event.Skip()
|
||||||
|
|
||||||
|
def OnImplantsExportChange(self, event):
|
||||||
|
EsiSettings.getInstance().set('exportImplants', self.exportChargesCb.GetValue())
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
|
def OnBoostersExportChange(self, event):
|
||||||
|
EsiSettings.getInstance().set('exportBoosters', self.exportChargesCb.GetValue())
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
def updateCharList(self):
|
def updateCharList(self):
|
||||||
sEsi = Esi.getInstance()
|
sEsi = Esi.getInstance()
|
||||||
chars = sEsi.getSsoCharacters()
|
chars = sEsi.getSsoCharacters()
|
||||||
@@ -360,8 +378,10 @@ class ExportToEve(AuxiliaryFrame):
|
|||||||
|
|
||||||
sFit = Fit.getInstance()
|
sFit = Fit.getInstance()
|
||||||
exportCharges = self.exportChargesCb.GetValue()
|
exportCharges = self.exportChargesCb.GetValue()
|
||||||
|
exportImplants = self.exportImplantsCb.GetValue()
|
||||||
|
exportBoosters = self.exportBoostersCb.GetValue()
|
||||||
try:
|
try:
|
||||||
data = sPort.exportESI(sFit.getFit(fitID), exportCharges)
|
data = sPort.exportESI(sFit.getFit(fitID), exportCharges, exportImplants, exportBoosters)
|
||||||
except ESIExportException as e:
|
except ESIExportException as e:
|
||||||
msg = str(e)
|
msg = str(e)
|
||||||
if not msg:
|
if not msg:
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ INV_FLAG_DRONEBAY = 87
|
|||||||
INV_FLAG_FIGHTER = 158
|
INV_FLAG_FIGHTER = 158
|
||||||
|
|
||||||
|
|
||||||
def exportESI(ofit, exportCharges, callback):
|
def exportESI(ofit, exportCharges, exportImplants, exportBoosters, callback):
|
||||||
# A few notes:
|
# A few notes:
|
||||||
# max fit name length is 50 characters
|
# max fit name length is 50 characters
|
||||||
# Most keys are created simply because they are required, but bogus data is okay
|
# Most keys are created simply because they are required, but bogus data is okay
|
||||||
@@ -133,6 +133,22 @@ def exportESI(ofit, exportCharges, callback):
|
|||||||
item['type_id'] = fighter.item.ID
|
item['type_id'] = fighter.item.ID
|
||||||
fit['items'].append(item)
|
fit['items'].append(item)
|
||||||
|
|
||||||
|
if exportImplants:
|
||||||
|
for implant in ofit.implants:
|
||||||
|
item = nested_dict()
|
||||||
|
item['flag'] = INV_FLAG_CARGOBAY
|
||||||
|
item['quantity'] = 1
|
||||||
|
item['type_id'] = implant.item.ID
|
||||||
|
fit['items'].append(item)
|
||||||
|
|
||||||
|
if exportBoosters:
|
||||||
|
for booster in ofit.boosters:
|
||||||
|
item = nested_dict()
|
||||||
|
item['flag'] = INV_FLAG_CARGOBAY
|
||||||
|
item['quantity'] = 1
|
||||||
|
item['type_id'] = booster.item.ID
|
||||||
|
fit['items'].append(item)
|
||||||
|
|
||||||
if len(fit['items']) == 0:
|
if len(fit['items']) == 0:
|
||||||
raise ESIExportException("Cannot export fitting: module list cannot be empty.")
|
raise ESIExportException("Cannot export fitting: module list cannot be empty.")
|
||||||
|
|
||||||
|
|||||||
@@ -323,8 +323,8 @@ class Port:
|
|||||||
return importESI(string)
|
return importESI(string)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def exportESI(fit, exportCharges, callback=None):
|
def exportESI(fit, exportCharges, exportImplants, exportBoosters, callback=None):
|
||||||
return exportESI(fit, exportCharges, callback=callback)
|
return exportESI(fit, exportCharges, exportImplants, exportBoosters, callback=callback)
|
||||||
|
|
||||||
# XML-related methods
|
# XML-related methods
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -376,6 +376,8 @@ class EsiSettings:
|
|||||||
"timeout": 60,
|
"timeout": 60,
|
||||||
"server": "Tranquility",
|
"server": "Tranquility",
|
||||||
"exportCharges": True,
|
"exportCharges": True,
|
||||||
|
"exportImplants": True,
|
||||||
|
"exportBoosters": True,
|
||||||
"enforceJwtExpiration": True
|
"enforceJwtExpiration": True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user