Merge branch 'master' of https://github.com/pyfa-org/Pyfa
This commit is contained in:
@@ -11,6 +11,5 @@ def handler(fit, module, context):
|
||||
bonus = "%s%sDamageResonance" % (attrPrefix, damageType)
|
||||
bonus = "%s%s" % (bonus[0].lower(), bonus[1:])
|
||||
booster = "%s%sDamageResonance" % (layer, damageType)
|
||||
penalize = False if layer == 'hull' else True
|
||||
fit.ship.multiplyItemAttr(bonus, module.getModifiedItemAttr(booster),
|
||||
stackingPenalties=penalize, penaltyGroup="preMul")
|
||||
stackingPenalties=True, penaltyGroup="preMul")
|
||||
|
||||
@@ -8,4 +8,6 @@ runtime = "late"
|
||||
|
||||
def handler(fit, src, context):
|
||||
for dmgType in ('em', 'thermal', 'kinetic', 'explosive'):
|
||||
fit.ship.forceItemAttr('{}DamageResonance'.format(dmgType), src.getModifiedItemAttr("hull{}DamageResonance".format(dmgType.title())))
|
||||
fit.ship.multiplyItemAttr('{}DamageResonance'.format(dmgType),
|
||||
src.getModifiedItemAttr("hull{}DamageResonance".format(dmgType.title())),
|
||||
stackingPenalties=True, penaltyGroup="postMul")
|
||||
|
||||
@@ -4,6 +4,7 @@ import wx
|
||||
from service.fit import Fit
|
||||
import gui.globalEvents as GE
|
||||
import gui.mainFrame
|
||||
from gui.utils.helpers_wxPython import HandleCtrlBackspace
|
||||
|
||||
|
||||
class NotesView(wx.Panel):
|
||||
@@ -17,9 +18,16 @@ class NotesView(wx.Panel):
|
||||
self.SetSizer(mainSizer)
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
|
||||
self.Bind(wx.EVT_TEXT, self.onText)
|
||||
self.editNotes.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
|
||||
self.saveTimer = wx.Timer(self)
|
||||
self.Bind(wx.EVT_TIMER, self.delayedSave, self.saveTimer)
|
||||
|
||||
def OnKeyDown(self, event):
|
||||
if event.RawControlDown() and event.GetKeyCode() == wx.WXK_BACK:
|
||||
HandleCtrlBackspace(self.editNotes)
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
def fitChanged(self, event):
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(event.fitID)
|
||||
|
||||
@@ -46,8 +46,18 @@ class ItemMutator(wx.Panel):
|
||||
|
||||
for m in sorted(stuff.mutators.values(), key=lambda x: x.attribute.displayName):
|
||||
# Format: [raw value, modifier applied to base raw value, display value]
|
||||
minRange = (m.minValue, m.attribute.unit.SimplifyValue(m.minValue))
|
||||
maxRange = (m.maxValue, m.attribute.unit.SimplifyValue(m.maxValue))
|
||||
range1 = (m.minValue, m.attribute.unit.SimplifyValue(m.minValue))
|
||||
range2 = (m.maxValue, m.attribute.unit.SimplifyValue(m.maxValue))
|
||||
|
||||
# minValue/maxValue do not always correspond to min/max, because these are
|
||||
# just base value multiplied by minMod/maxMod, and in case base is negative
|
||||
# minValue is actually bigger than maxValue
|
||||
if range1[0] <= range2[0]:
|
||||
minRange = range1
|
||||
maxRange = range2
|
||||
else:
|
||||
minRange = range2
|
||||
maxRange = range1
|
||||
|
||||
if (m.highIsGood and minRange[0] >= maxRange[0]) or (not m.highIsGood and minRange[0] <= maxRange[0]):
|
||||
betterRange = minRange
|
||||
@@ -66,10 +76,10 @@ class ItemMutator(wx.Panel):
|
||||
# If base value is outside of mutation range, make sure that center of slider
|
||||
# corresponds to the value which is closest available to actual base value. It's
|
||||
# how EVE handles it
|
||||
if m.minValue <= m.baseValue <= m.maxValue:
|
||||
if minRange[0] <= m.baseValue <= maxRange[0]:
|
||||
sliderBaseValue = m.baseValue
|
||||
else:
|
||||
sliderBaseValue = max(m.minValue, min(m.maxValue, m.baseValue))
|
||||
sliderBaseValue = max(minRange[0], min(maxRange[0], m.baseValue))
|
||||
|
||||
headingSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import wx
|
||||
import gui.utils.color as colorUtils
|
||||
import gui.utils.draw as drawUtils
|
||||
from gui.utils.helpers_wxPython import HandleCtrlBackspace
|
||||
|
||||
SearchButton, EVT_SEARCH_BTN = wx.lib.newevent.NewEvent()
|
||||
CancelButton, EVT_CANCEL_BTN = wx.lib.newevent.NewEvent()
|
||||
@@ -55,7 +56,7 @@ class PFSearchBox(wx.Window):
|
||||
|
||||
self.EditBox.Bind(wx.EVT_SET_FOCUS, self.OnEditSetFocus)
|
||||
self.EditBox.Bind(wx.EVT_KILL_FOCUS, self.OnEditKillFocus)
|
||||
|
||||
self.EditBox.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress)
|
||||
self.EditBox.Bind(wx.EVT_TEXT, self.OnText)
|
||||
self.EditBox.Bind(wx.EVT_TEXT_ENTER, self.OnTextEnter)
|
||||
|
||||
@@ -83,6 +84,12 @@ class PFSearchBox(wx.Window):
|
||||
self.Clear()
|
||||
event.Skip()
|
||||
|
||||
def OnKeyPress(self, event):
|
||||
if event.RawControlDown() and event.GetKeyCode() == wx.WXK_BACK:
|
||||
HandleCtrlBackspace(self.EditBox)
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
def Clear(self):
|
||||
self.EditBox.Clear()
|
||||
# self.EditBox.ChangeValue(self.descriptiveText)
|
||||
|
||||
@@ -76,10 +76,6 @@ class PFGeneralPref(PreferenceView):
|
||||
self.cbGaugeAnimation = wx.CheckBox(panel, wx.ID_ANY, "Animate gauges", wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
mainSizer.Add(self.cbGaugeAnimation, 0, wx.ALL | wx.EXPAND, 5)
|
||||
|
||||
self.cbExportCharges = wx.CheckBox(panel, wx.ID_ANY, "Export loaded charges", wx.DefaultPosition,
|
||||
wx.DefaultSize, 0)
|
||||
mainSizer.Add(self.cbExportCharges, 0, wx.ALL | wx.EXPAND, 5)
|
||||
|
||||
self.cbOpenFitInNew = wx.CheckBox(panel, wx.ID_ANY, "Open fittings in a new page by default",
|
||||
wx.DefaultPosition, wx.DefaultSize, 0)
|
||||
mainSizer.Add(self.cbOpenFitInNew, 0, wx.ALL | wx.EXPAND, 5)
|
||||
@@ -133,7 +129,6 @@ class PFGeneralPref(PreferenceView):
|
||||
self.cbShowTooltip.SetValue(self.sFit.serviceFittingOptions["showTooltip"] or False)
|
||||
self.cbMarketShortcuts.SetValue(self.sFit.serviceFittingOptions["showMarketShortcuts"] or False)
|
||||
self.cbGaugeAnimation.SetValue(self.sFit.serviceFittingOptions["enableGaugeAnimation"])
|
||||
self.cbExportCharges.SetValue(self.sFit.serviceFittingOptions["exportCharges"])
|
||||
self.cbOpenFitInNew.SetValue(self.sFit.serviceFittingOptions["openFitInNew"])
|
||||
self.chPriceSource.SetStringSelection(self.sFit.serviceFittingOptions["priceSource"])
|
||||
self.chPriceSystem.SetStringSelection(self.sFit.serviceFittingOptions["priceSystem"])
|
||||
@@ -151,7 +146,6 @@ class PFGeneralPref(PreferenceView):
|
||||
self.cbShowTooltip.Bind(wx.EVT_CHECKBOX, self.onCBShowTooltip)
|
||||
self.cbMarketShortcuts.Bind(wx.EVT_CHECKBOX, self.onCBShowShortcuts)
|
||||
self.cbGaugeAnimation.Bind(wx.EVT_CHECKBOX, self.onCBGaugeAnimation)
|
||||
self.cbExportCharges.Bind(wx.EVT_CHECKBOX, self.onCBExportCharges)
|
||||
self.cbOpenFitInNew.Bind(wx.EVT_CHECKBOX, self.onCBOpenFitInNew)
|
||||
self.chPriceSource.Bind(wx.EVT_CHOICE, self.onPricesSourceSelection)
|
||||
self.chPriceSystem.Bind(wx.EVT_CHOICE, self.onPriceSelection)
|
||||
@@ -220,9 +214,6 @@ class PFGeneralPref(PreferenceView):
|
||||
def onCBGaugeAnimation(self, event):
|
||||
self.sFit.serviceFittingOptions["enableGaugeAnimation"] = self.cbGaugeAnimation.GetValue()
|
||||
|
||||
def onCBExportCharges(self, event):
|
||||
self.sFit.serviceFittingOptions["exportCharges"] = self.cbExportCharges.GetValue()
|
||||
|
||||
def onCBOpenFitInNew(self, event):
|
||||
self.sFit.serviceFittingOptions["openFitInNew"] = self.cbOpenFitInNew.GetValue()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import gui.utils.fonts as fonts
|
||||
from .events import FitSelected, SearchSelected, ImportSelected, Stage1Selected, Stage2Selected, Stage3Selected
|
||||
from gui.bitmap_loader import BitmapLoader
|
||||
from service.fit import Fit
|
||||
from gui.utils.helpers_wxPython import HandleCtrlBackspace
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
@@ -72,7 +73,7 @@ class NavigationPanel(SFItem.SFBrowserItem):
|
||||
|
||||
# self.BrowserSearchBox.Bind(wx.EVT_TEXT_ENTER, self.OnBrowserSearchBoxEnter)
|
||||
# self.BrowserSearchBox.Bind(wx.EVT_KILL_FOCUS, self.OnBrowserSearchBoxLostFocus)
|
||||
self.BrowserSearchBox.Bind(wx.EVT_KEY_DOWN, self.OnBrowserSearchBoxEsc)
|
||||
self.BrowserSearchBox.Bind(wx.EVT_KEY_DOWN, self.OnBrowserSearchBoxKeyPress)
|
||||
self.BrowserSearchBox.Bind(wx.EVT_TEXT, self.OnScheduleSearch)
|
||||
|
||||
self.SetMinSize(size)
|
||||
@@ -103,9 +104,11 @@ class NavigationPanel(SFItem.SFBrowserItem):
|
||||
def OnBrowserSearchBoxLostFocus(self, event):
|
||||
self.BrowserSearchBox.Show(False)
|
||||
|
||||
def OnBrowserSearchBoxEsc(self, event):
|
||||
def OnBrowserSearchBoxKeyPress(self, event):
|
||||
if event.GetKeyCode() == wx.WXK_ESCAPE:
|
||||
self.BrowserSearchBox.Show(False)
|
||||
elif event.RawControlDown() and event.GetKeyCode() == wx.WXK_BACK:
|
||||
HandleCtrlBackspace(self.BrowserSearchBox)
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
|
||||
@@ -18,9 +18,13 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
# noinspection PyPackageRequirements
|
||||
import wx
|
||||
|
||||
from service.port.eft import EFT_OPTIONS
|
||||
from service.port.multibuy import MULTIBUY_OPTIONS
|
||||
from service.settings import SettingsProvider
|
||||
|
||||
|
||||
@@ -37,39 +41,53 @@ class CopySelectDialog(wx.Dialog):
|
||||
style=wx.DEFAULT_DIALOG_STYLE)
|
||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": 0, "options": 0})
|
||||
self.copyFormats = OrderedDict((
|
||||
("EFT", (CopySelectDialog.copyFormatEft, EFT_OPTIONS)),
|
||||
("MultiBuy", (CopySelectDialog.copyFormatMultiBuy, MULTIBUY_OPTIONS)),
|
||||
("ESI", (CopySelectDialog.copyFormatEsi, None)),
|
||||
("EFS", (CopySelectDialog.copyFormatEfs, None)),
|
||||
# ("XML", (CopySelectDialog.copyFormatXml, None)),
|
||||
# ("DNA", (CopySelectDialog.copyFormatDna, None)),
|
||||
))
|
||||
|
||||
self.copyFormats = {
|
||||
"EFT": CopySelectDialog.copyFormatEft,
|
||||
"XML": CopySelectDialog.copyFormatXml,
|
||||
"DNA": CopySelectDialog.copyFormatDna,
|
||||
"ESI": CopySelectDialog.copyFormatEsi,
|
||||
"MultiBuy": CopySelectDialog.copyFormatMultiBuy,
|
||||
"EFS": CopySelectDialog.copyFormatEfs
|
||||
}
|
||||
defaultFormatOptions = {}
|
||||
for formatId, formatOptions in self.copyFormats.values():
|
||||
if formatOptions is None:
|
||||
continue
|
||||
defaultFormatOptions[formatId] = {opt[0]: opt[3] for opt in formatOptions}
|
||||
|
||||
self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": 0, "options": defaultFormatOptions})
|
||||
# Options used to be stored as int (EFT export options only),
|
||||
# overwrite them with new format when needed
|
||||
if isinstance(self.settings["options"], int):
|
||||
self.settings["options"] = defaultFormatOptions
|
||||
|
||||
self.options = {}
|
||||
|
||||
for i, format in enumerate(self.copyFormats.keys()):
|
||||
if i == 0:
|
||||
rdo = wx.RadioButton(self, wx.ID_ANY, format, style=wx.RB_GROUP)
|
||||
initialized = False
|
||||
for formatName, formatData in self.copyFormats.items():
|
||||
formatId, formatOptions = formatData
|
||||
if not initialized:
|
||||
rdo = wx.RadioButton(self, wx.ID_ANY, formatName, style=wx.RB_GROUP)
|
||||
initialized = True
|
||||
else:
|
||||
rdo = wx.RadioButton(self, wx.ID_ANY, format)
|
||||
rdo = wx.RadioButton(self, wx.ID_ANY, formatName)
|
||||
rdo.Bind(wx.EVT_RADIOBUTTON, self.Selected)
|
||||
if self.settings['format'] == self.copyFormats[format]:
|
||||
if self.settings['format'] == formatId:
|
||||
rdo.SetValue(True)
|
||||
self.copyFormat = self.copyFormats[format]
|
||||
self.copyFormat = formatId
|
||||
mainSizer.Add(rdo, 0, wx.EXPAND | wx.ALL, 5)
|
||||
|
||||
if format == "EFT":
|
||||
if formatOptions:
|
||||
bsizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.options[formatId] = {}
|
||||
|
||||
for x, v in EFT_OPTIONS.items():
|
||||
ch = wx.CheckBox(self, -1, v['name'])
|
||||
self.options[x] = ch
|
||||
if self.settings['options'] & x:
|
||||
ch.SetValue(True)
|
||||
bsizer.Add(ch, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
|
||||
for optId, optName, optDesc, _ in formatOptions:
|
||||
checkbox = wx.CheckBox(self, -1, optName)
|
||||
self.options[formatId][optId] = checkbox
|
||||
if self.settings['options'].get(formatId, {}).get(optId, defaultFormatOptions.get(formatId, {}).get(optId)):
|
||||
checkbox.SetValue(True)
|
||||
bsizer.Add(checkbox, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
|
||||
mainSizer.Add(bsizer, 1, wx.EXPAND | wx.LEFT, 20)
|
||||
|
||||
buttonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
|
||||
@@ -83,21 +101,21 @@ class CopySelectDialog(wx.Dialog):
|
||||
|
||||
def Selected(self, event):
|
||||
obj = event.GetEventObject()
|
||||
format = obj.GetLabel()
|
||||
self.copyFormat = self.copyFormats[format]
|
||||
formatName = obj.GetLabel()
|
||||
self.copyFormat = self.copyFormats[formatName][0]
|
||||
self.toggleOptions()
|
||||
self.Fit()
|
||||
|
||||
def toggleOptions(self):
|
||||
for ch in self.options.values():
|
||||
ch.Enable(self.GetSelected() == CopySelectDialog.copyFormatEft)
|
||||
for formatId in self.options:
|
||||
for checkbox in self.options[formatId].values():
|
||||
checkbox.Enable(self.GetSelected() == formatId)
|
||||
|
||||
def GetSelected(self):
|
||||
return self.copyFormat
|
||||
|
||||
def GetOptions(self):
|
||||
i = 0
|
||||
for x, v in self.options.items():
|
||||
if v.IsChecked():
|
||||
i = i ^ x
|
||||
return i
|
||||
options = {}
|
||||
for formatId in self.options:
|
||||
options[formatId] = {optId: ch.IsChecked() for optId, ch in self.options[formatId].items()}
|
||||
return options
|
||||
|
||||
@@ -91,7 +91,7 @@ class ItemStatsDialog(wx.Dialog):
|
||||
|
||||
self.SetMinSize((300, 200))
|
||||
if "wxGTK" in wx.PlatformInfo: # GTK has huge tab widgets, give it a bit more room
|
||||
self.SetSize((630, 550))
|
||||
self.SetSize((640, 620))
|
||||
else:
|
||||
self.SetSize((550, 500))
|
||||
# self.SetMaxSize((500, -1))
|
||||
|
||||
@@ -703,10 +703,6 @@ class MainFrame(wx.Frame):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportEft(fit, options))
|
||||
|
||||
def clipboardEftImps(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportEftImps(fit))
|
||||
|
||||
def clipboardDna(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportDna(fit))
|
||||
@@ -721,7 +717,7 @@ class MainFrame(wx.Frame):
|
||||
|
||||
def clipboardMultiBuy(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
toClipboard(Port.exportMultiBuy(fit))
|
||||
toClipboard(Port.exportMultiBuy(fit, options))
|
||||
|
||||
def clipboardEfs(self, options):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
@@ -744,22 +740,22 @@ class MainFrame(wx.Frame):
|
||||
|
||||
def exportToClipboard(self, event):
|
||||
CopySelectDict = {CopySelectDialog.copyFormatEft: self.clipboardEft,
|
||||
# CopySelectDialog.copyFormatEftImps: self.clipboardEftImps,
|
||||
CopySelectDialog.copyFormatXml: self.clipboardXml,
|
||||
CopySelectDialog.copyFormatDna: self.clipboardDna,
|
||||
CopySelectDialog.copyFormatEsi: self.clipboardEsi,
|
||||
CopySelectDialog.copyFormatMultiBuy: self.clipboardMultiBuy,
|
||||
CopySelectDialog.copyFormatEfs: self.clipboardEfs}
|
||||
dlg = CopySelectDialog(self)
|
||||
dlg.ShowModal()
|
||||
selected = dlg.GetSelected()
|
||||
options = dlg.GetOptions()
|
||||
btnPressed = dlg.ShowModal()
|
||||
|
||||
settings = SettingsProvider.getInstance().getSettings("pyfaExport")
|
||||
settings["format"] = selected
|
||||
settings["options"] = options
|
||||
if btnPressed == wx.ID_OK:
|
||||
selected = dlg.GetSelected()
|
||||
options = dlg.GetOptions()
|
||||
|
||||
CopySelectDict[selected](options)
|
||||
settings = SettingsProvider.getInstance().getSettings("pyfaExport")
|
||||
settings["format"] = selected
|
||||
settings["options"] = options
|
||||
CopySelectDict[selected](options.get(selected))
|
||||
|
||||
try:
|
||||
dlg.Destroy()
|
||||
|
||||
@@ -6,3 +6,23 @@ def YesNoDialog(question='Are you sure you want to do this?', caption='Yes or no
|
||||
result = dlg.ShowModal() == wx.ID_YES
|
||||
dlg.Destroy()
|
||||
return result
|
||||
|
||||
|
||||
def HandleCtrlBackspace(textControl):
|
||||
"""
|
||||
Handles the behavior of Windows ctrl+space
|
||||
deletes everything from the cursor to the left,
|
||||
up to the next whitespace.
|
||||
"""
|
||||
curPos = textControl.GetInsertionPoint()
|
||||
searchText = textControl.GetValue()
|
||||
foundChar = False
|
||||
for startIndex in range(curPos, -1, -1):
|
||||
if startIndex - 1 < 0:
|
||||
break
|
||||
if searchText[startIndex - 1] != " ":
|
||||
foundChar = True
|
||||
elif foundChar:
|
||||
break
|
||||
textControl.Remove(startIndex, curPos)
|
||||
textControl.SetInsertionPoint(startIndex)
|
||||
@@ -89,7 +89,6 @@ class Fit(FitDeprecated):
|
||||
"showTooltip": True,
|
||||
"showMarketShortcuts": False,
|
||||
"enableGaugeAnimation": True,
|
||||
"exportCharges": True,
|
||||
"openFitInNew": False,
|
||||
"priceSystem": "Jita",
|
||||
"priceSource": "eve-marketdata.com",
|
||||
|
||||
@@ -138,7 +138,7 @@ def exportDna(fit):
|
||||
mods[mod.itemID] = 0
|
||||
mods[mod.itemID] += 1
|
||||
|
||||
if mod.charge and sFit.serviceFittingOptions["exportCharges"]:
|
||||
if mod.charge:
|
||||
if mod.chargeID not in charges:
|
||||
charges[mod.chargeID] = 0
|
||||
# `or 1` because some charges (ie scripts) are without qty
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
import re
|
||||
from enum import Enum
|
||||
|
||||
from logbook import Logger
|
||||
|
||||
@@ -36,7 +37,6 @@ from service.fit import Fit as svcFit
|
||||
from service.market import Market
|
||||
from service.port.muta import parseMutant, renderMutant
|
||||
from service.port.shared import IPortUser, fetchItem, processing_notify
|
||||
from enum import Enum
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
@@ -45,23 +45,20 @@ pyfalog = Logger(__name__)
|
||||
class Options(Enum):
|
||||
IMPLANTS = 1
|
||||
MUTATIONS = 2
|
||||
LOADED_CHARGES = 3
|
||||
|
||||
|
||||
EFT_OPTIONS = (
|
||||
(Options.LOADED_CHARGES.value, 'Loaded Charges', 'Export charges loaded into modules', True),
|
||||
(Options.MUTATIONS.value, 'Mutated Attributes', 'Export mutated modules\' stats', True),
|
||||
(Options.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters', True),
|
||||
)
|
||||
|
||||
|
||||
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.value: {
|
||||
"name": "Implants",
|
||||
"description": "Exports implants"
|
||||
},
|
||||
Options.MUTATIONS.value: {
|
||||
"name": "Mutated Attributes",
|
||||
"description": "Exports Abyssal stats"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def exportEft(fit, options):
|
||||
# EFT formatted export is split in several sections, each section is
|
||||
@@ -73,7 +70,6 @@ def exportEft(fit, options):
|
||||
|
||||
# Section 1: modules, rigs, subsystems, services
|
||||
modsBySlotType = {}
|
||||
sFit = svcFit.getInstance()
|
||||
for module in fit.modules:
|
||||
modsBySlotType.setdefault(module.slot, []).append(module)
|
||||
modSection = []
|
||||
@@ -85,20 +81,19 @@ def exportEft(fit, options):
|
||||
modules = modsBySlotType.get(slotType, ())
|
||||
for module in modules:
|
||||
if module.item:
|
||||
mutated = bool(module.mutators)
|
||||
# if module was mutated, use base item name for export
|
||||
if mutated:
|
||||
if module.isMutated:
|
||||
modName = module.baseItem.name
|
||||
else:
|
||||
modName = module.item.name
|
||||
if mutated and options & Options.MUTATIONS.value:
|
||||
if module.isMutated and options[Options.MUTATIONS.value]:
|
||||
mutants[mutantReference] = module
|
||||
mutationSuffix = ' [{}]'.format(mutantReference)
|
||||
mutantReference += 1
|
||||
else:
|
||||
mutationSuffix = ''
|
||||
modOfflineSuffix = ' {}'.format(OFFLINE_SUFFIX) if module.state == State.OFFLINE else ''
|
||||
if module.charge and sFit.serviceFittingOptions['exportCharges']:
|
||||
if module.charge and options[Options.LOADED_CHARGES.value]:
|
||||
rackLines.append('{}, {}{}{}'.format(
|
||||
modName, module.charge.name, modOfflineSuffix, mutationSuffix))
|
||||
else:
|
||||
@@ -127,7 +122,7 @@ def exportEft(fit, options):
|
||||
sections.append('\n\n'.join(minionSection))
|
||||
|
||||
# Section 3: implants, boosters
|
||||
if options & Options.IMPLANTS.value:
|
||||
if options[Options.IMPLANTS.value]:
|
||||
charSection = []
|
||||
implantLines = []
|
||||
for implant in fit.implants:
|
||||
@@ -154,7 +149,7 @@ def exportEft(fit, options):
|
||||
|
||||
# Section 5: mutated modules' details
|
||||
mutationLines = []
|
||||
if mutants and options & Options.MUTATIONS.value:
|
||||
if mutants and options[Options.MUTATIONS.value]:
|
||||
for mutantReference in sorted(mutants):
|
||||
mutant = mutants[mutantReference]
|
||||
mutationLines.append(renderMutant(mutant, firstPrefix='[{}] '.format(mutantReference), prefix=' '))
|
||||
@@ -164,8 +159,8 @@ def exportEft(fit, options):
|
||||
return '{}\n\n{}'.format(header, '\n\n\n'.join(sections))
|
||||
|
||||
|
||||
def importEft(eftString):
|
||||
lines = _importPrepareString(eftString)
|
||||
def importEft(lines):
|
||||
lines = _importPrepare(lines)
|
||||
try:
|
||||
fit = _importCreateFit(lines)
|
||||
except EftImportError:
|
||||
@@ -293,7 +288,7 @@ def importEft(eftString):
|
||||
return fit
|
||||
|
||||
|
||||
def importEftCfg(shipname, contents, iportuser):
|
||||
def importEftCfg(shipname, lines, iportuser):
|
||||
"""Handle import from EFT config store file"""
|
||||
|
||||
# Check if we have such ship in database, bail if we don't
|
||||
@@ -305,7 +300,6 @@ def importEftCfg(shipname, contents, iportuser):
|
||||
|
||||
fits = [] # List for fits
|
||||
fitIndices = [] # List for starting line numbers for each fit
|
||||
lines = re.split('[\n\r]+', contents) # Separate string into lines
|
||||
|
||||
for line in lines:
|
||||
# Detect fit header
|
||||
@@ -486,8 +480,7 @@ def importEftCfg(shipname, contents, iportuser):
|
||||
return fits
|
||||
|
||||
|
||||
def _importPrepareString(eftString):
|
||||
lines = eftString.splitlines()
|
||||
def _importPrepare(lines):
|
||||
for i in range(len(lines)):
|
||||
lines[i] = lines[i].strip()
|
||||
while lines and not lines[0]:
|
||||
|
||||
@@ -97,7 +97,7 @@ def exportESI(ofit):
|
||||
item['type_id'] = module.item.ID
|
||||
fit['items'].append(item)
|
||||
|
||||
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
|
||||
if module.charge:
|
||||
if module.chargeID not in charges:
|
||||
charges[module.chargeID] = 0
|
||||
# `or 1` because some charges (ie scripts) are without qty
|
||||
@@ -137,11 +137,11 @@ def exportESI(ofit):
|
||||
return json.dumps(fit)
|
||||
|
||||
|
||||
def importESI(str_):
|
||||
def importESI(string):
|
||||
|
||||
sMkt = Market.getInstance()
|
||||
fitobj = Fit()
|
||||
refobj = json.loads(str_)
|
||||
refobj = json.loads(string)
|
||||
items = refobj['items']
|
||||
# "<" and ">" is replace to "<", ">" by EVE client
|
||||
fitobj.name = refobj['name']
|
||||
|
||||
@@ -18,10 +18,23 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
from service.fit import Fit as svcFit
|
||||
from enum import Enum
|
||||
|
||||
|
||||
def exportMultiBuy(fit):
|
||||
class Options(Enum):
|
||||
IMPLANTS = 1
|
||||
CARGO = 2
|
||||
LOADED_CHARGES = 3
|
||||
|
||||
|
||||
MULTIBUY_OPTIONS = (
|
||||
(Options.LOADED_CHARGES.value, 'Loaded Charges', 'Export charges loaded into modules', True),
|
||||
(Options.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters', False),
|
||||
(Options.CARGO.value, 'Cargo', 'Export cargo contents', True),
|
||||
)
|
||||
|
||||
|
||||
def exportMultiBuy(fit, options):
|
||||
itemCounts = {}
|
||||
|
||||
def addItem(item, quantity=1):
|
||||
@@ -29,11 +42,13 @@ def exportMultiBuy(fit):
|
||||
itemCounts[item] = 0
|
||||
itemCounts[item] += quantity
|
||||
|
||||
exportCharges = svcFit.getInstance().serviceFittingOptions["exportCharges"]
|
||||
for module in fit.modules:
|
||||
if module.item:
|
||||
# Mutated items are of no use for multibuy
|
||||
if module.isMutated:
|
||||
continue
|
||||
addItem(module.item)
|
||||
if exportCharges and module.charge:
|
||||
if module.charge and options[Options.LOADED_CHARGES.value]:
|
||||
addItem(module.charge, module.numCharges)
|
||||
|
||||
for drone in fit.drones:
|
||||
@@ -42,14 +57,16 @@ def exportMultiBuy(fit):
|
||||
for fighter in fit.fighters:
|
||||
addItem(fighter.item, fighter.amountActive)
|
||||
|
||||
for cargo in fit.cargo:
|
||||
addItem(cargo.item, cargo.amount)
|
||||
if options[Options.CARGO.value]:
|
||||
for cargo in fit.cargo:
|
||||
addItem(cargo.item, cargo.amount)
|
||||
|
||||
for implant in fit.implants:
|
||||
addItem(implant.item)
|
||||
if options[Options.IMPLANTS.value]:
|
||||
for implant in fit.implants:
|
||||
addItem(implant.item)
|
||||
|
||||
for booster in fit.boosters:
|
||||
addItem(booster.item)
|
||||
for booster in fit.boosters:
|
||||
addItem(booster.item)
|
||||
|
||||
exportLines = []
|
||||
exportLines.append(fit.ship.item.name)
|
||||
|
||||
@@ -207,9 +207,14 @@ class Port(object):
|
||||
@classmethod
|
||||
def importAuto(cls, string, path=None, activeFit=None, iportuser=None):
|
||||
# type: (Port, str, str, object, IPortUser) -> object
|
||||
lines = string.splitlines()
|
||||
# Get first line and strip space symbols of it to avoid possible detection errors
|
||||
firstLine = re.split("[\n\r]+", string.strip(), maxsplit=1)[0]
|
||||
firstLine = firstLine.strip()
|
||||
firstLine = ''
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line:
|
||||
firstLine = line
|
||||
break
|
||||
|
||||
# If XML-style start of tag encountered, detect as XML
|
||||
if re.search(RE_XML_START, firstLine):
|
||||
@@ -224,12 +229,12 @@ class Port(object):
|
||||
if re.match("\[.*\]", firstLine) and path is not None:
|
||||
filename = os.path.split(path)[1]
|
||||
shipName = filename.rsplit('.')[0]
|
||||
return "EFT Config", cls.importEftCfg(shipName, string, iportuser)
|
||||
return "EFT Config", cls.importEftCfg(shipName, lines, iportuser)
|
||||
|
||||
# If no file is specified and there's comma between brackets,
|
||||
# consider that we have [ship, setup name] and detect like eft export format
|
||||
if re.match("\[.*,.*\]", firstLine):
|
||||
return "EFT", (cls.importEft(string),)
|
||||
return "EFT", (cls.importEft(lines),)
|
||||
|
||||
# Check if string is in DNA format
|
||||
if re.match("\d+(:\d+(;\d+))*::", firstLine):
|
||||
@@ -237,19 +242,19 @@ class Port(object):
|
||||
|
||||
# Assume that we import stand-alone abyssal module if all else fails
|
||||
try:
|
||||
return "MutatedItem", (parseMutant(string.split("\n")),)
|
||||
return "MutatedItem", (parseMutant(lines),)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# EFT-related methods
|
||||
@staticmethod
|
||||
def importEft(eftString):
|
||||
return importEft(eftString)
|
||||
def importEft(lines):
|
||||
return importEft(lines)
|
||||
|
||||
@staticmethod
|
||||
def importEftCfg(shipname, contents, iportuser=None):
|
||||
return importEftCfg(shipname, contents, iportuser)
|
||||
def importEftCfg(shipname, lines, iportuser=None):
|
||||
return importEftCfg(shipname, lines, iportuser)
|
||||
|
||||
@classmethod
|
||||
def exportEft(cls, fit, options):
|
||||
@@ -284,5 +289,5 @@ class Port(object):
|
||||
|
||||
# Multibuy-related methods
|
||||
@staticmethod
|
||||
def exportMultiBuy(fit):
|
||||
return exportMultiBuy(fit)
|
||||
def exportMultiBuy(fit, options):
|
||||
return exportMultiBuy(fit, options)
|
||||
|
||||
@@ -283,7 +283,7 @@ def exportXml(iportuser, *fits):
|
||||
hardware.setAttribute("slot", "%s slot %d" % (slotName, slotId))
|
||||
fitting.appendChild(hardware)
|
||||
|
||||
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
|
||||
if module.charge:
|
||||
if module.charge.name not in charges:
|
||||
charges[module.charge.name] = 0
|
||||
# `or 1` because some charges (ie scripts) are without qty
|
||||
|
||||
Reference in New Issue
Block a user