summaryrefslogtreecommitdiff
path: root/src/dialogs.py
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2011-12-03 02:08:17 -0600
committerColin Noga <Tempus@chronometry.ca>2011-12-03 02:08:17 -0600
commitbd62c887e956b658d3ec1b47099fa07882386d1f (patch)
tree8f839153a85e4a714985f9248de11f1645bcf19e /src/dialogs.py
parent3bdc780bd3eaa204b1df5d5e6727a876d5967401 (diff)
downloadkoopatlas-bd62c887e956b658d3ec1b47099fa07882386d1f.tar.gz
koopatlas-bd62c887e956b658d3ec1b47099fa07882386d1f.zip
Fixed up some UI stuff, added animation presets to make life easier for animations
Diffstat (limited to 'src/dialogs.py')
-rw-r--r--src/dialogs.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/dialogs.py b/src/dialogs.py
index b033294..0419f4f 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -69,3 +69,101 @@ class KPTilesetChooserDialog(QtGui.QDialog):
return None
+
+
+class KPAnimationPresetChooser(QtGui.QDialog):
+ def __init__(self, label='Choose a preset to add:', specials=None):
+ QtGui.QDialog.__init__(self)
+
+ self.label = QtGui.QLabel(label)
+ self.label.setWordWrap(True)
+
+ # can't be assed to create a model
+ self.chooser = QtGui.QListWidget()
+
+ settings = KP.app.settings
+
+ if settings.contains('AnimationPresets'):
+ self.presetList = settings.value('AnimationPresets').toPyObject()
+ self.presets = settings.value('AnimationPresetData').toPyObject()
+
+ else:
+ self.presetList = ["Circle", "Wiggle", "Drifting Cloud"]
+ self.presets = [ [["Loop", "Sinusoidial", 200.0, "X Position", -200.0, 200.0],
+ ["Loop", "Cosinoidial", 200.0, "Y Position", -200.0, 200.0]],
+
+ [["Reversible Loop", "Sinusoidial", 50.0, "Y Scale", 100.0, 120.0],
+ ["Loop", "Cosinoidial", 50.0, "X Scale", 100.0, 90.0],
+ ["Reversible Loop", "Sinusoidial", 20.0, "Angle", 10.0, -10.0]],
+
+ [["Loop", "Sinusoidial", 5000.0, "X Position", -400.0, 400.0],
+ ["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)
+
+
+ self.chooser.addItems(self.presetList)
+
+ self.chooser.currentRowChanged.connect(self.handleCurrentRowChanged)
+ self.chooser.itemActivated.connect(self.handleItemActivated)
+
+ self.buttons = QtGui.QDialogButtonBox(
+ QtGui.QDialogButtonBox.Ok |
+ QtGui.QDialogButtonBox.Cancel)
+
+ self.okButton = self.buttons.button(QtGui.QDialogButtonBox.Ok)
+ self.okButton.setEnabled(False)
+
+ self.buttons.accepted.connect(self.accept)
+ self.buttons.rejected.connect(self.reject)
+
+ self.layout = QtGui.QVBoxLayout()
+ self.layout.addWidget(self.label)
+ self.layout.addWidget(self.chooser)
+ self.layout.addWidget(self.buttons)
+ self.setLayout(self.layout)
+
+ def handleCurrentRowChanged(self, row):
+ self.okButton.setEnabled(row != -1)
+
+ def handleItemActivated(self, item):
+ self.accept()
+
+ def getChoice(self):
+ item = self.chooser.currentItem()
+ number = self.chooser.currentRow()
+
+ if item is None:
+ return None
+ else:
+ return self.presets[number]
+
+
+ @classmethod
+ def run(cls, *args):
+ dialog = cls(*args)
+ result = dialog.exec_()
+
+ if result == QtGui.QDialog.Accepted:
+ return dialog.getChoice()
+ else:
+ return None
+
+
+
+
+
+def getTextDialog():
+
+ text, ok = QtGui.QInputDialog.getText(KP.mainWindow, "Choose Preset Name", "Preset name:")
+
+ print text
+ if ok and text != '':
+ return text
+ else:
+ return None
+
+