diff options
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: |