From 21cf889b5e45a5619a09e46db246abd4abbec3a4 Mon Sep 17 00:00:00 2001 From: Colin Noga Date: Sun, 4 Dec 2011 19:28:54 -0600 Subject: Added animation preset saving/loading, and icons --- Resources/AddPreset.png | Bin 0 -> 1427 bytes Resources/ClearPreset.png | Bin 0 -> 1987 bytes Resources/LoadPreset.png | Bin 0 -> 1752 bytes Resources/Minus.png | Bin 0 -> 1114 bytes Resources/NewPreset.png | Bin 0 -> 1679 bytes Resources/Plus.png | Bin 0 -> 1427 bytes Resources/SavePreset.png | Bin 0 -> 1713 bytes src/dialogs.py | 10 +++++----- src/editorui/doodads.py | 29 +++++++++++++++++++---------- src/ui.py | 33 ++++++++++++++++++++++++--------- 10 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 Resources/AddPreset.png create mode 100644 Resources/ClearPreset.png create mode 100644 Resources/LoadPreset.png create mode 100644 Resources/Minus.png create mode 100644 Resources/NewPreset.png create mode 100644 Resources/Plus.png create mode 100644 Resources/SavePreset.png diff --git a/Resources/AddPreset.png b/Resources/AddPreset.png new file mode 100644 index 0000000..4ddfa6b Binary files /dev/null and b/Resources/AddPreset.png differ diff --git a/Resources/ClearPreset.png b/Resources/ClearPreset.png new file mode 100644 index 0000000..b196cb4 Binary files /dev/null and b/Resources/ClearPreset.png differ diff --git a/Resources/LoadPreset.png b/Resources/LoadPreset.png new file mode 100644 index 0000000..1b1e9f0 Binary files /dev/null and b/Resources/LoadPreset.png differ diff --git a/Resources/Minus.png b/Resources/Minus.png new file mode 100644 index 0000000..439f371 Binary files /dev/null and b/Resources/Minus.png differ diff --git a/Resources/NewPreset.png b/Resources/NewPreset.png new file mode 100644 index 0000000..e229063 Binary files /dev/null and b/Resources/NewPreset.png differ diff --git a/Resources/Plus.png b/Resources/Plus.png new file mode 100644 index 0000000..b6fb157 Binary files /dev/null and b/Resources/Plus.png differ diff --git a/Resources/SavePreset.png b/Resources/SavePreset.png new file mode 100644 index 0000000..7412d49 Binary files /dev/null and b/Resources/SavePreset.png differ diff --git a/src/dialogs.py b/src/dialogs.py index 0419f4f..54f5de8 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -82,10 +82,11 @@ class KPAnimationPresetChooser(QtGui.QDialog): self.chooser = QtGui.QListWidget() settings = KP.app.settings + import mapfile if settings.contains('AnimationPresets'): - self.presetList = settings.value('AnimationPresets').toPyObject() - self.presets = settings.value('AnimationPresetData').toPyObject() + self.presetList = mapfile.load(str(settings.value('AnimationPresets').toPyObject())) + self.presets = mapfile.load(str(settings.value('AnimationPresetData').toPyObject())) else: self.presetList = ["Circle", "Wiggle", "Drifting Cloud"] @@ -100,9 +101,8 @@ class KPAnimationPresetChooser(QtGui.QDialog): ["Loop", "Sinusoidial", 200.0, "Y Position", 10.0, -10.0], ["Reversible Loop", "Linear", 500.0, "Opacity", 80.0, 40.0]] ] - - settings.setValue('AnimationPresets', self.presetList) - settings.setValue('AnimationPresetData', self.presets) + settings.setValue('AnimationPresets', mapfile.dump(self.presetList)) + settings.setValue('AnimationPresetData', mapfile.dump(self.presets)) self.chooser.addItems(self.presetList) diff --git a/src/editorui/doodads.py b/src/editorui/doodads.py index d7f767f..7b9e222 100644 --- a/src/editorui/doodads.py +++ b/src/editorui/doodads.py @@ -129,15 +129,21 @@ class KPEditorDoodad(KPEditorItem): # Add/Remove Animation Buttons - addbutton = QtGui.QPushButton("Add Animation") - rembutton = QtGui.QPushButton("Remove Animation") - presetbutton = QtGui.QPushButton("Add Preset") - newpbutton = QtGui.QPushButton("New Preset") + addbutton = QtGui.QPushButton(QtGui.QIcon("Resources/Plus.png"), "") + rembutton = QtGui.QPushButton(QtGui.QIcon("Resources/Minus.png"), "") + presetbutton = QtGui.QPushButton(QtGui.QIcon("Resources/AddPreset.png"), "Add Preset") + newpbutton = QtGui.QPushButton(QtGui.QIcon("Resources/NewPreset.png"), "New Preset") + # savebutton = QtGui.QPushButton(QtGui.QIcon("Resources/SavePreset.png"), "Save") + # loadbutton = QtGui.QPushButton(QtGui.QIcon("Resources/LoadPreset.png"), "Load") + # clearbutton = QtGui.QPushButton(QtGui.QIcon("Resources/ClearPreset.png"), "Clear") BottomLayout.addWidget(addbutton, 1, 0, 1, 1) BottomLayout.addWidget(rembutton, 1, 1, 1, 1) BottomLayout.addWidget(QtGui.QLabel(""), 1, 2, 1, 2) BottomLayout.addWidget(presetbutton, 1, 4, 1, 1) BottomLayout.addWidget(newpbutton, 1, 5, 1, 1) + # BottomLayout.addWidget(savebutton, 1, 6, 1, 1) + # BottomLayout.addWidget(loadbutton, 1, 7, 1, 1) + # BottomLayout.addWidget(clearbutton, 1, 8, 1, 1) # Annnnndddd we're spent. @@ -148,13 +154,15 @@ class KPEditorDoodad(KPEditorItem): presetbutton.released.connect(self.selectPreset) newpbutton.released.connect(self.addToPreset) + # savebutton.released.connect(KP.mainWindow.saveAnimPresets) + # loadbutton.released.connect(KP.mainWindow.loadAnimPresets) + # clearbutton.released.connect(KP.mainWindow.clearAnimPresets) def sizeHint(self): return QtCore.QSize(591,300) - def addAnmItem(self): itemA = QtGui.QStandardItem() @@ -229,11 +237,12 @@ class KPEditorDoodad(KPEditorItem): preset.append(listrow) settings = KP.app.settings - + import mapfile + if settings.contains('AnimationPresets'): - presetList = settings.value('AnimationPresets').toPyObject() - presets = settings.value('AnimationPresetData').toPyObject() + presetList = mapfile.load(str(settings.value('AnimationPresets').toPyObject())) + presets = mapfile.load(str(settings.value('AnimationPresetData').toPyObject())) else: @@ -243,8 +252,8 @@ class KPEditorDoodad(KPEditorItem): presetList.append(name) presets.append(preset) - settings.setValue('AnimationPresets', presetList) - settings.setValue('AnimationPresetData', presets) + settings.setValue('AnimationPresets', mapfile.dump(presetList)) + settings.setValue('AnimationPresetData', mapfile.dump(presets)) def __init__(self, doodadRef): diff --git a/src/ui.py b/src/ui.py index 9327bd1..6106e2a 100644 --- a/src/ui.py +++ b/src/ui.py @@ -751,18 +751,31 @@ class KPMainWindow(QtGui.QMainWindow): loaded = mapfile.load(data) file.close() + print loaded settings = KP.app.settings + presetList = [] + presets = [] + if settings.contains('AnimationPresets'): - presetList = list(settings.value('AnimationPresets').toPyObject()) - presets = list(settings.value('AnimationPresetData').toPyObject()) + presetList = mapfile.load(str(settings.value('AnimationPresets').toPyObject())) + presets = mapfile.load(str(settings.value('AnimationPresetData').toPyObject())) - else: + if presetList == None: presetList = [] presets = [] + + print presetList, presets + print dir(presetList) + + presetList.extend(loaded[0]) + presets.extend(loaded[1]) - settings.setValue('AnimationPresets', presetList.extend(loaded[0])) - settings.setValue('AnimationPresetData', presets.extend(loaded[1])) + print presetList + print presets + + settings.setValue('AnimationPresets', mapfile.dump(presetList)) + settings.setValue('AnimationPresetData', mapfile.dump(presets)) @@ -770,13 +783,14 @@ class KPMainWindow(QtGui.QMainWindow): def saveAnimPresets(self): settings = KP.app.settings + import mapfile 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()) + presetList = mapfile.load(str(settings.value('AnimationPresets').toPyObject())) + presets = mapfile.load(str(settings.value('AnimationPresetData').toPyObject())) else: msg._exec() return @@ -802,9 +816,10 @@ class KPMainWindow(QtGui.QMainWindow): @QtCore.pyqtSlot() def clearAnimPresets(self): settings = KP.app.settings + import mapfile - settings.setValue('AnimationPresets', []) - settings.setValue('AnimationPresetData', []) + settings.setValue('AnimationPresets', mapfile.dump([])) + settings.setValue('AnimationPresetData', mapfile.dump([])) # Window -- cgit v1.2.3