Skip to content

Commit 9ea1ea3

Browse files
committed
Options: added auto saver options
Added auto saver options tab, which contains two Pmw counters for interval and max auto save files to save.
1 parent acf0d98 commit 9ea1ea3

3 files changed

Lines changed: 39 additions & 12 deletions

File tree

toontown/leveleditor/AutoSaver.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def manageAutoSaveFiles():
4848

4949
# Sets max number of auto save files
5050
if autoSaveCount >= AutoSaver.maxAutoSaveCount:
51-
autoSaveCount = AutoSaver.maxAutoSaveCount
51+
autoSaveCount = int(AutoSaver.maxAutoSaveCount)
5252

5353
# Defining outputFile name properties
5454
base = os.path.basename(DNASerializer.outputFile)
@@ -57,6 +57,12 @@ def manageAutoSaveFiles():
5757

5858
# Renames output file to auto save file naming convention
5959
if autoSaveCount == 0:
60+
# Only save & manage 'latest' file
61+
if AutoSaver.maxAutoSaveCount == 0:
62+
# Only save auto save latest file
63+
if basename[-16:] == '_autosave-latest':
64+
DNASerializer.outputDNADefaultFile() # Saves working DNA file
65+
return
6066
DNASerializer.outputFile = os.path.join(dir, basename + '_autosave-latest' + extension).replace('\\', '/')
6167

6268
# Deletes 'latest' from filename

toontown/leveleditor/DNASerializer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
class DNASerializer:
1111
notify = DirectNotifyGlobal.directNotify.newCategory('LevelEditor')
1212
outputFile = None
13+
# Local AutoSaver variables
1314
autoSaverMgrRunning = False
1415
autoSaveCount = 0
1516

toontown/leveleditor/LevelEditorPanel.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ def __init__(self, levelEditor, parent = None, **kw):
131131
menuBar.addmenuitem('Advanced', 'separator')
132132
menuBar.addmenuitem('Advanced', 'checkbutton',
133133
'Toggle Auto-saver On/Off',
134-
label = 'Toggle Auto-Saver',
134+
label = 'Toggle Auto Saver',
135135
command = self.toggleAutoSaver)
136136
menuBar.addmenuitem('Advanced', 'command',
137-
'User Set Auto Saver Interval',
138-
label = 'Set Auto-Saver Interval',
137+
'User Set Auto Saver Options',
138+
label = 'Auto Saver Options',
139139
command = self.showAutoSaverDialog)
140140

141141
# Corporate Clash Old Toontown-esque Filter
@@ -187,13 +187,32 @@ def __init__(self, levelEditor, parent = None, **kw):
187187
message_text = CONTROLS)
188188
self.controlsDialog.withdraw()
189189

190-
self.autoSaverDialog = Pmw.Dialog(parent,
191-
title = 'Set Auto-Saver Interval (in minutes)',
192-
buttons = ('Enter',),
193-
command = self.setAutoSaverInterval)
190+
self.autoSaverDialog = Pmw.Dialog(parent, title='Autosaver Options',
191+
buttons=('Save Options',),
192+
command=self.setAutoSaverInterval
193+
)
194194
self.autoSaverDialog.withdraw()
195-
self.autoSaverDialogTextBox = Text(self.autoSaverDialog.interior(), height = 10)
196-
self.autoSaverDialogTextBox.pack(expand = 1, fill = BOTH)
195+
196+
self.autoSaverDialogInterval = Pmw.Counter(self.autoSaverDialog.interior(),
197+
labelpos='w',
198+
label_text = 'Auto save interval in minutes:',
199+
entry_width=10,
200+
entryfield_value = int(AutoSaver.autoSaverInterval),
201+
entryfield_validate={'validator': 'real',
202+
'min': 1, 'max': 60})
203+
204+
self.autoSaverDialogMax = Pmw.Counter(self.autoSaverDialog.interior(),
205+
labelpos='w',
206+
label_text = 'Max auto save files:',
207+
entry_width=10,
208+
entryfield_value = int(AutoSaver.maxAutoSaveCount),
209+
entryfield_validate={'validator': 'numeric',
210+
'min': 0, 'max': 99})
211+
212+
counters = (self.autoSaverDialogInterval, self.autoSaverDialogMax)
213+
Pmw.alignlabels(counters)
214+
for counter in counters:
215+
counter.pack(fill='both', expand=1, padx=10, pady=10)
197216

198217
self.editMenu = Pmw.ComboBox(
199218
menuFrame, labelpos = W,
@@ -1489,9 +1508,10 @@ def setBattleCellType(self, name):
14891508
self.levelEditor.currentBattleCellType = name
14901509

14911510
def setAutoSaverInterval(self, i):
1492-
if i == 'Enter':
1511+
if i == 'Save Options':
14931512
try:
1494-
AutoSaver.autoSaverInterval = float(self.autoSaverDialogTextBox.get("1.0", 'end-1c'))
1513+
AutoSaver.autoSaverInterval = float(self.autoSaverDialogInterval.get())
1514+
AutoSaver.maxAutoSaveCount = float(self.autoSaverDialogMax.get())
14951515
except ValueError as e:
14961516
# Non-float was passed
14971517
raise e

0 commit comments

Comments
 (0)