diff options
author | Treeki <treeki@gmail.com> | 2011-11-14 23:13:09 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-11-14 23:13:09 +0100 |
commit | b336977192da8208e3fe1521e68f130c62ea9e04 (patch) | |
tree | 4be011e4a2b5cccc8d18edbf42ffec32555c71c0 /src | |
parent | ffc9daf57c6a3ad8377c82d811cb3bcad2421bea (diff) | |
download | koopatlas-b336977192da8208e3fe1521e68f130c62ea9e04.tar.gz koopatlas-b336977192da8208e3fe1521e68f130c62ea9e04.zip |
an abysmal extension to the KPTilesetChooserDialog API
Diffstat (limited to '')
-rw-r--r-- | src/dialogs.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/dialogs.py b/src/dialogs.py index 48c3bfe..b033294 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -2,7 +2,7 @@ from common import * class KPTilesetChooserDialog(QtGui.QDialog): - def __init__(self, label='Choose a tileset'): + def __init__(self, label='Choose a tileset', specials=None): QtGui.QDialog.__init__(self) self.label = QtGui.QLabel(label) @@ -10,8 +10,14 @@ class KPTilesetChooserDialog(QtGui.QDialog): # can't be assed to create a model self.chooser = QtGui.QListWidget() + self.nameList = KP.map.tilesets.keys() self.nameList.sort() + + # this piece of the API is kinda shitty but whatever + self.specials = specials + if specials: + self.chooser.addItems(self.specials) self.chooser.addItems(self.nameList) self.chooser.currentRowChanged.connect(self.handleCurrentRowChanged) @@ -34,7 +40,6 @@ class KPTilesetChooserDialog(QtGui.QDialog): self.setLayout(self.layout) def handleCurrentRowChanged(self, row): - print row self.okButton.setEnabled(row != -1) def handleItemActivated(self, item): @@ -42,15 +47,20 @@ class KPTilesetChooserDialog(QtGui.QDialog): def getChoice(self): item = self.chooser.currentItem() + number = self.chooser.currentRow() + if item is None: return None else: - return str(item.text()) + if self.specials is not None and number < len(self.specials): + return number + else: + return str(item.text()) @classmethod - def run(cls, label=None): - dialog = cls(label) + def run(cls, *args): + dialog = cls(*args) result = dialog.exec_() if result == QtGui.QDialog.Accepted: |