Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class SETS():
wikihttp = wikihttp_current
wikiImages = wikihttp+wikiImagesText

loaded_filename = ""

#query for ship cargo table on the wiki
ship_query = 'Special:CargoExport?tables=Ships&fields=_pageName%3DPage,name,image,fc,tier,type,hull,hullmod,shieldmod,turnrate,impulse,inertia,powerall,powerweapons,powershields,powerengines,powerauxiliary,powerboost,boffs,fore,aft,equipcannons,devices,consolestac,consoleseng,consolessci,uniconsole,t5uconsole,experimental,secdeflector,hangars,abilities,displayprefix,displayclass,displaytype,factionlede&limit=2500&format=json'
#query for ship equipment cargo table on the wiki
Expand Down Expand Up @@ -3142,6 +3144,7 @@ def importByFilename(self, inFilename, force=False, autosave=False):
if not result and self.persistent['forceJsonLoad']:
return self.importByFilename(inFilename, True)
else:
if autosave is False : self.loaded_filename = inFilename
return result

def repair_build(self):
Expand Down Expand Up @@ -3216,7 +3219,7 @@ def filenameDefault(self):
def in_splash(self):
return self.visible_window == 'splash'

def exportCallback(self, event=None):
def exportAs(self, save_as, event=None):
"""Callback for export as png button"""
if self.in_splash():
return
Expand All @@ -3237,7 +3240,12 @@ def exportCallback(self, event=None):
defaultExtensionOption = 'json'
#self.logWrite('==={}'.format(self.persistent['exportDefault'].lower()), 2)

outFilename = filedialog.asksaveasfilename(defaultextension='.'+defaultExtensionOption,filetypes=filetypesOptions, initialfile=self.filenameDefault(), initialdir=initialDir)
if save_as is True:
outFilename = filedialog.asksaveasfilename(defaultextension='.'+defaultExtensionOption,filetypes=filetypesOptions, initialfile=self.filenameDefault(), initialdir=initialDir)
self.loaded_filename = outFilename
else:
outFilename = self.loaded_filename

if not outFilename:
return

Expand All @@ -3257,6 +3265,15 @@ def exportCallback(self, event=None):

self.logWriteTransaction('Export build', chosenExtension, str(os.path.getsize(outFilename)), outFilename, 0, [str(image.size) if chosenExtension.lower() == '.png' else None])


def exportAsCallback(self):
self.exportAs(True)


def exportCallback(self):
self.exportAs(False)


def update_build_master(self):
if self.persistent['versioning']:
if self.build != self.buildImport[-1]:
Expand Down Expand Up @@ -3294,6 +3311,7 @@ def skillValidDeselect(self, name, environment, rank):
else:
return True


def skillAllowed(self, skill_id, environment):
(rank, row, col) = skill_id
name = self.skillGetFieldNode(environment, (rank, row, col), type='name')
Expand Down Expand Up @@ -7171,7 +7189,8 @@ def setupMenuFrame(self):
exportImportFrame.grid(row=0, column=col, sticky='nsew')
settingsMenuExport = {
'default': {'sticky': 'n', 'bg': self.theme['button_medium']['bg'], 'fg': self.theme['button_medium']['fg'], 'font_data': self.font_tuple_create('button_medium')},
'Save': {'type': 'button_block', 'var_name': 'exportFullButton', 'callback': self.exportCallback},
'Save As': {'type': 'button_block', 'var_name': 'exportFullButton', 'callback': self.exportAsCallback},
'Save': {'type': 'button_block', 'var_name': 'exportButton', 'callback': self.exportCallback},
'Open': {'type': 'button_block', 'var_name': 'importButton', 'callback': self.importCallback},
'Clear...': {'type': 'menu', 'var_name': 'clearButton', 'setting_options': ['Clear all', 'Clear skills'], 'callback': 'menu_clear_callback'},
}
Expand Down