Add support for default export option values
This commit is contained in:
@@ -41,11 +41,6 @@ class CopySelectDialog(wx.Dialog):
|
||||
style=wx.DEFAULT_DIALOG_STYLE)
|
||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": 0, "options": {}})
|
||||
# Overwrite older options format which was plain int storing EFT options
|
||||
if not isinstance(self.settings["options"], dict):
|
||||
self.settings["options"] = {CopySelectDialog.copyFormatEft: self.settings["options"]}
|
||||
|
||||
self.copyFormats = OrderedDict((
|
||||
("EFT", (CopySelectDialog.copyFormatEft, EFT_OPTIONS)),
|
||||
("XML", (CopySelectDialog.copyFormatXml, None)),
|
||||
@@ -55,6 +50,18 @@ class CopySelectDialog(wx.Dialog):
|
||||
("EFS", (CopySelectDialog.copyFormatEfs, None)),
|
||||
))
|
||||
|
||||
defaultFormatOptions = {}
|
||||
for formatId, formatOptions in self.copyFormats.values():
|
||||
if formatOptions is None:
|
||||
continue
|
||||
defaultFormatOptions[formatId] = self._GetFormatOptions(
|
||||
{option[0]: option[3] for option in formatOptions})
|
||||
|
||||
self.settings = SettingsProvider.getInstance().getSettings("pyfaExport", {"format": 0, "options": defaultFormatOptions})
|
||||
# Overwrite older options format which was plain int storing EFT options
|
||||
if not isinstance(self.settings["options"], dict):
|
||||
self.settings["options"] = {CopySelectDialog.copyFormatEft: self.settings["options"]}
|
||||
|
||||
self.options = {}
|
||||
|
||||
initialized = False
|
||||
@@ -75,7 +82,7 @@ class CopySelectDialog(wx.Dialog):
|
||||
bsizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.options[formatId] = {}
|
||||
|
||||
for optId, optName, optDesc in formatOptions:
|
||||
for optId, optName, optDesc, optDefault in formatOptions:
|
||||
checkbox = wx.CheckBox(self, -1, optName)
|
||||
self.options[formatId][optId] = checkbox
|
||||
if self.settings['options'].get(formatId, 0) & optId:
|
||||
@@ -110,9 +117,13 @@ class CopySelectDialog(wx.Dialog):
|
||||
def GetOptions(self):
|
||||
options = {}
|
||||
for formatId in self.options:
|
||||
optVal = 0
|
||||
for optId, checkbox in self.options[formatId].items():
|
||||
if checkbox.IsChecked():
|
||||
optVal = optVal ^ optId
|
||||
options[formatId] = optVal
|
||||
options[formatId] = self._GetFormatOptions(
|
||||
{optId: ch.IsChecked() for optId, ch in self.options[formatId].items()})
|
||||
return options
|
||||
|
||||
def _GetFormatOptions(self, optMap):
|
||||
optVal = 0
|
||||
for optId, optState in optMap.items():
|
||||
if optState:
|
||||
optVal = optVal ^ optId
|
||||
return optVal
|
||||
|
||||
@@ -48,8 +48,8 @@ class Options(Enum):
|
||||
|
||||
|
||||
EFT_OPTIONS = (
|
||||
(Options.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters'),
|
||||
(Options.MUTATIONS.value, 'Mutated Attributes', 'Export mutated modules\' stats'),
|
||||
(Options.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters', True),
|
||||
(Options.MUTATIONS.value, 'Mutated Attributes', 'Export mutated modules\' stats', True),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ class Options(Enum):
|
||||
|
||||
|
||||
MULTIBUY_OPTIONS = (
|
||||
(Options.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters'),
|
||||
(Options.CARGO.value, 'Cargo', 'Export cargo contents'),
|
||||
(Options.IMPLANTS.value, 'Implants && Boosters', 'Export implants and boosters', False),
|
||||
(Options.CARGO.value, 'Cargo', 'Export cargo contents', True),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user