First bit of work for GUI support for abyssal export.
This commit is contained in:
@@ -20,41 +20,59 @@
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
from service.eftPort import EFT_OPTIONS
|
||||
|
||||
|
||||
class CopySelectDialog(wx.Dialog):
|
||||
copyFormatEft = 0
|
||||
copyFormatEftImps = 1
|
||||
copyFormatXml = 2
|
||||
copyFormatDna = 3
|
||||
copyFormatEsi = 4
|
||||
copyFormatMultiBuy = 5
|
||||
copyFormatEfs = 6
|
||||
copyFormatXml = 1
|
||||
copyFormatDna = 2
|
||||
copyFormatEsi = 3
|
||||
copyFormatMultiBuy = 4
|
||||
copyFormatEfs = 5
|
||||
|
||||
def __init__(self, parent):
|
||||
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="Select a format", size=(-1, -1),
|
||||
style=wx.DEFAULT_DIALOG_STYLE)
|
||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
copyFormats = ["EFT", "EFT (Implants)", "XML", "DNA", "ESI", "MultiBuy", "EFS"]
|
||||
copyFormatTooltips = {CopySelectDialog.copyFormatEft: "EFT text format",
|
||||
CopySelectDialog.copyFormatEftImps: "EFT text format",
|
||||
CopySelectDialog.copyFormatXml: "EVE native XML format",
|
||||
CopySelectDialog.copyFormatDna: "A one-line text format",
|
||||
CopySelectDialog.copyFormatEsi: "A JSON format used for ESI",
|
||||
CopySelectDialog.copyFormatMultiBuy: "MultiBuy text format",
|
||||
CopySelectDialog.copyFormatEfs: "JSON data format used by EFS"}
|
||||
selector = wx.RadioBox(self, wx.ID_ANY, label="Copy to the clipboard using:", choices=copyFormats,
|
||||
style=wx.RA_SPECIFY_ROWS)
|
||||
selector.Bind(wx.EVT_RADIOBOX, self.Selected)
|
||||
for format, tooltip in copyFormatTooltips.items():
|
||||
selector.SetItemToolTip(format, tooltip)
|
||||
self.copyFormats = {
|
||||
"EFT": CopySelectDialog.copyFormatEft,
|
||||
"XML": CopySelectDialog.copyFormatXml,
|
||||
"DNA": CopySelectDialog.copyFormatDna,
|
||||
"ESI": CopySelectDialog.copyFormatEsi,
|
||||
"MultiBuy": CopySelectDialog.copyFormatMultiBuy,
|
||||
"EFS": CopySelectDialog.copyFormatEfs
|
||||
}
|
||||
|
||||
for i, format in enumerate(self.copyFormats.keys()):
|
||||
if i == 0:
|
||||
rdo = wx.RadioButton(self, wx.ID_ANY, format, style=wx.RB_GROUP)
|
||||
else:
|
||||
rdo = wx.RadioButton(self, wx.ID_ANY, format)
|
||||
rdo.Bind(wx.EVT_RADIOBUTTON, self.Selected)
|
||||
mainSizer.Add(rdo, 0, wx.EXPAND | wx.ALL, 5)
|
||||
|
||||
self.copyFormat = CopySelectDialog.copyFormatEft
|
||||
selector.SetSelection(self.copyFormat)
|
||||
|
||||
mainSizer.Add(selector, 0, wx.EXPAND | wx.ALL, 5)
|
||||
# some sizer magic to deal with https://github.com/wxWidgets/Phoenix/issues/974
|
||||
self.box1 = wx.StaticBox(self, -1, "EFT Options")
|
||||
self.bsizer1 = wx.BoxSizer(wx.VERTICAL)
|
||||
self.bsizer2 = wx.BoxSizer(wx.VERTICAL)
|
||||
self.bsizer1.AddSpacer(10)
|
||||
|
||||
self.bsizer1.Add(self.bsizer2, 1, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)
|
||||
|
||||
self.options = {}
|
||||
|
||||
for x, v in EFT_OPTIONS.items():
|
||||
ch = wx.CheckBox(self.box1, -1, v['name'])
|
||||
self.options[x] = ch
|
||||
self.bsizer2.Add(ch, 1, wx.EXPAND)
|
||||
|
||||
self.box1.SetSizer(self.bsizer1)
|
||||
|
||||
mainSizer.Add(self.box1, 0, wx.EXPAND | wx.ALL, 5)
|
||||
buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
|
||||
if buttonSizer:
|
||||
mainSizer.Add(buttonSizer, 0, wx.EXPAND | wx.ALL, 5)
|
||||
@@ -64,7 +82,19 @@ class CopySelectDialog(wx.Dialog):
|
||||
self.Center()
|
||||
|
||||
def Selected(self, event):
|
||||
self.copyFormat = event.GetSelection()
|
||||
obj = event.GetEventObject()
|
||||
format = obj.GetLabel()
|
||||
self.box1.Show(format == "EFT")
|
||||
self.Fit()
|
||||
self.copyFormat = self.copyFormats[format]
|
||||
|
||||
def GetSelected(self):
|
||||
return self.copyFormat
|
||||
|
||||
def GetOptions(self):
|
||||
i = 0
|
||||
for x, v in self.options.items():
|
||||
if v.IsChecked():
|
||||
i = i ^ x.value
|
||||
return i
|
||||
|
||||
|
||||
@@ -703,31 +703,31 @@ class MainFrame(wx.Frame):
|
||||
else:
|
||||
self.marketBrowser.search.Focus()
|
||||
|
||||
def clipboardEft(self):
|
||||
def clipboardEft(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportEft(fit))
|
||||
toClipboard(Port.exportEft(fit, options))
|
||||
|
||||
def clipboardEftImps(self):
|
||||
def clipboardEftImps(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportEftImps(fit))
|
||||
|
||||
def clipboardDna(self):
|
||||
def clipboardDna(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportDna(fit))
|
||||
|
||||
def clipboardEsi(self):
|
||||
def clipboardEsi(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportESI(fit))
|
||||
|
||||
def clipboardXml(self):
|
||||
def clipboardXml(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportXml(None, fit))
|
||||
|
||||
def clipboardMultiBuy(self):
|
||||
def clipboardMultiBuy(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportMultiBuy(fit))
|
||||
|
||||
def clipboardEfs(self):
|
||||
def clipboardEfs(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(EfsPort.exportEfs(fit, 0))
|
||||
|
||||
@@ -742,7 +742,7 @@ class MainFrame(wx.Frame):
|
||||
|
||||
def exportToClipboard(self, event):
|
||||
CopySelectDict = {CopySelectDialog.copyFormatEft: self.clipboardEft,
|
||||
CopySelectDialog.copyFormatEftImps: self.clipboardEftImps,
|
||||
#CopySelectDialog.copyFormatEftImps: self.clipboardEftImps,
|
||||
CopySelectDialog.copyFormatXml: self.clipboardXml,
|
||||
CopySelectDialog.copyFormatDna: self.clipboardDna,
|
||||
CopySelectDialog.copyFormatEsi: self.clipboardEsi,
|
||||
@@ -751,8 +751,8 @@ class MainFrame(wx.Frame):
|
||||
dlg = CopySelectDialog(self)
|
||||
dlg.ShowModal()
|
||||
selected = dlg.GetSelected()
|
||||
|
||||
CopySelectDict[selected]()
|
||||
options = dlg.GetOptions()
|
||||
CopySelectDict[selected](options)
|
||||
|
||||
try:
|
||||
dlg.Destroy()
|
||||
|
||||
@@ -35,14 +35,33 @@ from eos.saveddata.fit import Fit
|
||||
from gui.utils.numberFormatter import roundToPrec
|
||||
from service.fit import Fit as svcFit
|
||||
from service.market import Market
|
||||
from enum import Enum
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
|
||||
class Options(Enum):
|
||||
IMPLANTS = 1
|
||||
MUTATIONS = 2
|
||||
|
||||
|
||||
MODULE_CATS = ('Module', 'Subsystem', 'Structure Module')
|
||||
SLOT_ORDER = (Slot.LOW, Slot.MED, Slot.HIGH, Slot.RIG, Slot.SUBSYSTEM, Slot.SERVICE)
|
||||
OFFLINE_SUFFIX = ' /OFFLINE'
|
||||
|
||||
EFT_OPTIONS = {
|
||||
Options.IMPLANTS: {
|
||||
"name": "Implants",
|
||||
"description": "Exports implants"
|
||||
},
|
||||
Options.MUTATIONS: {
|
||||
"name": "Abyssal",
|
||||
"description": "Exports Abyssal stats"
|
||||
}
|
||||
# 4: []
|
||||
}
|
||||
|
||||
|
||||
def fetchItem(typeName, eagerCat=False):
|
||||
sMkt = Market.getInstance()
|
||||
@@ -326,7 +345,7 @@ class AbstractFit:
|
||||
class EftPort:
|
||||
|
||||
@classmethod
|
||||
def exportEft(cls, fit, mutations, implants):
|
||||
def exportEft(cls, fit, options):
|
||||
# EFT formatted export is split in several sections, each section is
|
||||
# separated from another using 2 blank lines. Sections might have several
|
||||
# sub-sections, which are separated by 1 blank line
|
||||
@@ -354,7 +373,7 @@ class EftPort:
|
||||
modName = module.baseItem.name
|
||||
else:
|
||||
modName = module.item.name
|
||||
if mutated and mutations:
|
||||
if mutated and options & Options.MUTATIONS.value:
|
||||
mutants[mutantReference] = module
|
||||
mutationSuffix = ' [{}]'.format(mutantReference)
|
||||
mutantReference += 1
|
||||
@@ -390,7 +409,7 @@ class EftPort:
|
||||
sections.append('\n\n'.join(minionSection))
|
||||
|
||||
# Section 3: implants, boosters
|
||||
if implants:
|
||||
if options & Options.IMPLANTS.value:
|
||||
charSection = []
|
||||
implantLines = []
|
||||
for implant in fit.implants:
|
||||
@@ -417,7 +436,7 @@ class EftPort:
|
||||
|
||||
# Section 5: mutated modules' details
|
||||
mutationLines = []
|
||||
if mutants and mutations:
|
||||
if mutants and options & Options.MUTATIONS.value:
|
||||
for mutantReference in sorted(mutants):
|
||||
mutant = mutants[mutantReference]
|
||||
mutatedAttrs = {}
|
||||
|
||||
@@ -909,8 +909,8 @@ class Port(object):
|
||||
return fit_list
|
||||
|
||||
@classmethod
|
||||
def exportEft(cls, fit):
|
||||
return EftPort.exportEft(fit, mutations=False, implants=False)
|
||||
def exportEft(cls, fit, options):
|
||||
return EftPort.exportEft(fit, options)
|
||||
|
||||
@classmethod
|
||||
def exportEftImps(cls, fit):
|
||||
|
||||
Reference in New Issue
Block a user