summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common.py8
-rw-r--r--src/editorui.py3
-rw-r--r--src/main.py27
-rw-r--r--src/mapdata.py6
-rw-r--r--src/ui.py49
5 files changed, 76 insertions, 17 deletions
diff --git a/src/common.py b/src/common.py
new file mode 100644
index 0000000..b106ab5
--- /dev/null
+++ b/src/common.py
@@ -0,0 +1,8 @@
+import sys
+from PyQt4 import QtCore, QtGui
+from PyQt4.QtCore import Qt
+
+from mapdata import *
+
+from main import KP
+
diff --git a/src/editorui.py b/src/editorui.py
index d53deb7..5055f69 100644
--- a/src/editorui.py
+++ b/src/editorui.py
@@ -1,4 +1,5 @@
-from PyQt4 import QtCore, QtGui
+from common import *
+
class KPEditorWidget(QtGui.QGraphicsView):
pass
diff --git a/src/main.py b/src/main.py
index ba1ff2c..927c970 100644
--- a/src/main.py
+++ b/src/main.py
@@ -1,16 +1,19 @@
-from PyQt4 import QtCore, QtGui
-import sys
-
+from common import *
from ui import KPMainWindow
-def run_koopatlas():
- global Koopatlas
- Koopatlas = KPApplication(sys.argv)
- Koopatlas.run()
+class KP:
+ @staticmethod
+ def newMap():
+ KP.map = KPMap()
+
+ @staticmethod
+ def run():
+ KP.app = QtGui.QApplication(sys.argv)
+
+ KP.newMap()
+
+ KP.mainWindow = KPMainWindow()
+ KP.mainWindow.show()
-class KPApplication(QtGui.QApplication):
- def run(self):
- self.mainWindow = KPMainWindow()
- self.mainWindow.show()
- self.exec_()
+ KP.app.exec_()
diff --git a/src/mapdata.py b/src/mapdata.py
index 8ecb33c..b453172 100644
--- a/src/mapdata.py
+++ b/src/mapdata.py
@@ -25,8 +25,8 @@ class KPPathSegment(object):
class KPPath(object):
def __init__(self):
- self.start_node = None
- self.end_node = None
+ self.startNode = None
+ self.endNode = None
self.segments = []
@@ -44,3 +44,5 @@ class KPMap(object):
self.paths = []
self.doodads = []
+ self.nextLayerNumber = 1
+
diff --git a/src/ui.py b/src/ui.py
index 9b5f705..8fafd3b 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -1,8 +1,43 @@
-from PyQt4 import QtCore, QtGui
-
+from common import *
from editorui import *
+class KPLayerList(QtGui.QWidget):
+ class LayerModel(QtCore.QAbstractListModel):
+ def headerData(self, section, orientation, role = Qt.DisplayRole):
+ return 'Layer'
+
+ def rowCount(self, parent):
+ print globals().keys()
+ return len(KP.map.layers)
+
+ def data(self, index, role = Qt.DisplayRole):
+ try:
+ if role == Qt.DisplayRole and index.isValid():
+ return KP.map.layers[index.row()].name
+ except IndexError:
+ pass
+
+ return QVariant()
+
+
+ def __init__(self):
+ QtGui.QWidget.__init__(self)
+
+ self.layout = QtGui.QVBoxLayout()
+
+ self.model = KPLayerList.LayerModel()
+
+ self.listWidget = QtGui.QListView()
+ self.listWidget.setModel(self.model)
+ self.layout.addWidget(self.listWidget)
+
+ self.toolbar = QtGui.QToolBar()
+ self.layout.addWidget(self.toolbar)
+
+ self.setLayout(self.layout)
+
+
class KPMainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
@@ -11,6 +46,8 @@ class KPMainWindow(QtGui.QMainWindow):
self.setCentralWidget(self.editor)
self.setupMenuBar()
+
+ self.setupDocks()
def setupMenuBar(self):
@@ -18,6 +55,14 @@ class KPMainWindow(QtGui.QMainWindow):
m = mb.addMenu('&File')
# ...
+
+
+ def setupDocks(self):
+ self.layerList = KPLayerList()
+ self.layerListDock = QtGui.QDockWidget('Layers')
+ self.layerListDock.setWidget(self.layerList)
+
+ self.addDockWidget(Qt.RightDockWidgetArea, self.layerListDock)