summaryrefslogtreecommitdiff
path: root/src/ui.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ui.py67
1 files changed, 61 insertions, 6 deletions
diff --git a/src/ui.py b/src/ui.py
index 568a0a8..dc95f85 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -3,7 +3,7 @@
from common import *
from editorui.editorcommon import *
from editorui.editormain import *
-import os
+import os, copy
import os.path
@@ -963,6 +963,7 @@ class KPMainWindow(QtGui.QMainWindow):
self.setIconSize(QtCore.QSize(16, 16))
self.scene = KPMapScene()
+ self.clipboard = None
self.editor = KPEditorWidget(self.scene)
self.setCentralWidget(self.editor)
@@ -1003,13 +1004,14 @@ class KPMainWindow(QtGui.QMainWindow):
self.ff = f.addAction('Export...', self.exportMap, QKeySequence("Ctrl+Shift+E"))
f.addSeparator()
self.fg = f.addAction('Take Screenshot...', self.screenshot, QKeySequence("Ctrl+Alt+S"))
+ self.fh = f.addAction('Export Doodads...', self.exportDoodads, QKeySequence("Ctrl+Alt+Shift+D"))
f.addSeparator()
# self.fi = f.addAction('Quit')
e = mb.addMenu('Edit')
- self.ea = e.addAction('Copy') # C
+ self.ea = e.addAction('Copy', self.copy, QKeySequence.Copy)
self.eb = e.addAction('Cut') # X
- self.ec = e.addAction('Paste') # V
+ self.ec = e.addAction('Paste', self.paste, QKeySequence.Paste)
e.addSeparator()
self.ed = e.addAction('Select All', self.selectAll, QKeySequence.SelectAll)
self.ee = e.addAction('Deselect', self.deSelect, QKeySequence("Ctrl+D"))
@@ -1038,11 +1040,13 @@ class KPMainWindow(QtGui.QMainWindow):
w = mb.addMenu('Window')
self.wa = w.addAction('Show Grid', self.showGrid, QKeySequence("Ctrl+G"))
+ self.wa.setCheckable(True)
w.addSeparator()
self.wb = w.addAction('Zoom In', self.ZoomIn, QKeySequence.ZoomIn)
self.wc = w.addAction('Zoom Out', self.ZoomOut, QKeySequence.ZoomOut)
self.wd = w.addAction('Actual Size', self.ZoomActual, QKeySequence("Ctrl+="))
- self.wh = w.addAction('Show Wii Zoom', self.showWiiZoom)
+ self.wh = w.addAction('Show Wii Zoom', self.showWiiZoom, QKeySequence("Ctrl+F"))
+ self.wh.setCheckable(True)
w.addSeparator()
layerAction = self.layerListDock.toggleViewAction()
@@ -1305,6 +1309,17 @@ class KPMainWindow(QtGui.QMainWindow):
ScreenshotImage.save(fn, 'PNG', 50)
+ @QtCore.pyqtSlot()
+ def exportDoodads(self):
+ fn = QtGui.QFileDialog.getExistingDirectory(self, 'Choose a folder')
+ if fn == '': return
+ fn = unicode(fn)
+
+ for d in KP.map.doodadDefinitions:
+ d[1].save(fn + d[0] + '.png', 'PNG')
+
+
+
# Edit
########################
@QtCore.pyqtSlot()
@@ -1319,6 +1334,39 @@ class KPMainWindow(QtGui.QMainWindow):
self.scene.clearSelection()
+ @QtCore.pyqtSlot()
+ def copy(self):
+ self.clipboard = self.scene.selectedItems()
+
+
+ @QtCore.pyqtSlot()
+ def paste(self):
+ self.scene.clearSelection()
+ for paper in self.clipboard:
+ layer = paper._layerRef()
+
+ if isinstance(paper, KPEditorObject):
+ co = copy.deepcopy(paper._objRef())
+
+ co.updateCache()
+ layer.objects.append(co)
+ layer.updateCache()
+
+ q = KPEditorObject(co, layer)
+ self.scene.addItem(q)
+ q.setSelected(True)
+
+ if isinstance(paper, KPEditorDoodad):
+ cd = copy.copy(paper._doodadRef())
+
+ layer.objects.append(cd)
+
+ cd.setupAnimations()
+ q = KPEditorDoodad(cd, layer)
+ self.scene.addItem(q)
+ q.setSelected(True)
+
+
# Layers
########################
@QtCore.pyqtSlot()
@@ -1510,15 +1558,22 @@ class KPMainWindow(QtGui.QMainWindow):
if self.scene.grid == True:
self.scene.grid = False
+ self.wa.setChecked(False)
else:
self.scene.grid = True
+ self.wa.setChecked(True)
- print self.scene.grid
self.scene.update()
@QtCore.pyqtSlot(bool)
def showWiiZoom(self):
- pass
+ if self.editor.grid == True:
+ self.editor.grid = False
+
+ else:
+ self.editor.grid = True
+
+ self.editor.update()
# Help