From 06ac2e91738f2dfc3043bbe23b807a45ea69596a Mon Sep 17 00:00:00 2001 From: Colin Noga Date: Sun, 4 Dec 2011 14:35:00 -0600 Subject: broken commit --- src/ui.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/src/ui.py b/src/ui.py index bd447ca..9327bd1 100644 --- a/src/ui.py +++ b/src/ui.py @@ -473,9 +473,9 @@ class KPMainWindow(QtGui.QMainWindow): self.aa = a.addAction('Play Animations', self.playAnim, QKeySequence("Ctrl+P")) self.ac = a.addAction('Reset Animations', self.resetAnim, QKeySequence("Ctrl+Shift+P")) a.addSeparator() - self.ad = a.addAction('Load Animation Presets...') - self.ae = a.addAction('Save Animation Presets...') - self.af = a.addAction('Clear Animation Presets') + self.ad = a.addAction('Load Animation Presets...', self.loadAnimPresets) + self.ae = a.addAction('Save Animation Presets...', self.saveAnimPresets) + self.af = a.addAction('Clear Animation Presets', self.clearAnimPresets) w = mb.addMenu('Window') self.wa = w.addAction('Show Grid', self.showGrid, QKeySequence("Ctrl+G")) @@ -689,9 +689,8 @@ class KPMainWindow(QtGui.QMainWindow): @QtCore.pyqtSlot() def moveTilesetToFolder(self): - log = QtGui.QFileDialog() - path = QtGui.QFileDialog.getOpenFileNames(self, + path = QtGui.QFileDialog.getOpenFileName(self, "Choose a tileset. Tileset will be copied to the Koopatlas Tilesets Folder.", "", "Koopuzzle Tilesets (*.arc)") if path: @@ -739,6 +738,75 @@ class KPMainWindow(QtGui.QMainWindow): self.scene.playPause() + @QtCore.pyqtSlot() + def loadAnimPresets(self): + path = QtGui.QFileDialog.getOpenFileName(self, + "Choose a Koopatlas Animation Preset File.", "", + "Koopatlas Animation Preset (*.kpa)") + if path: + import mapfile + + file = open(path, 'rb') + data = file.read() + loaded = mapfile.load(data) + file.close() + + settings = KP.app.settings + + if settings.contains('AnimationPresets'): + presetList = list(settings.value('AnimationPresets').toPyObject()) + presets = list(settings.value('AnimationPresetData').toPyObject()) + + else: + presetList = [] + presets = [] + + settings.setValue('AnimationPresets', presetList.extend(loaded[0])) + settings.setValue('AnimationPresetData', presets.extend(loaded[1])) + + + + @QtCore.pyqtSlot() + def saveAnimPresets(self): + + settings = KP.app.settings + + msg = QtGui.QMessageBox() + msg.setText("No Animation Presets Found.") + + if settings.contains('AnimationPresets'): + presetList = list(settings.value('AnimationPresets').toPyObject()) + presets = list(settings.value('AnimationPresetData').toPyObject()) + else: + msg._exec() + return + + if len(presetList) == 0: + msg._exec() + return + + path = QtGui.QFileDialog.getSaveFileName(self, + "Choose a tileset. Tileset will be copied to the Koopatlas Tilesets Folder.", "KP Preset.kpa", + "Koopatlas Animation Preset (*.kpa)") + + if path: + import mapfile + output = [presetList, presets] + + file = open(path, 'wb') + file.write(mapfile.dump(output)) + file.close() + + + + @QtCore.pyqtSlot() + def clearAnimPresets(self): + settings = KP.app.settings + + settings.setValue('AnimationPresets', []) + settings.setValue('AnimationPresetData', []) + + # Window ######################## -- cgit v1.2.3