summaryrefslogtreecommitdiff
path: root/src/ui.py
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2011-12-04 14:35:00 -0600
committerColin Noga <Tempus@chronometry.ca>2011-12-04 14:35:00 -0600
commit06ac2e91738f2dfc3043bbe23b807a45ea69596a (patch)
treee6e4393a54c633e319a7ccad5ea5e2886a13b692 /src/ui.py
parent5e44650b39381787e4b0ae769e7e194bca83f717 (diff)
downloadkoopatlas-06ac2e91738f2dfc3043bbe23b807a45ea69596a.tar.gz
koopatlas-06ac2e91738f2dfc3043bbe23b807a45ea69596a.zip
broken commit
Diffstat (limited to 'src/ui.py')
-rw-r--r--src/ui.py78
1 files 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
########################