From 5adfa5973564bec0638d661339240c1df61f41d5 Mon Sep 17 00:00:00 2001 From: Colin Noga Date: Fri, 30 Dec 2011 04:23:40 -0600 Subject: Tried for a windows build, failed. Added some icons. --- Resources/DelFolder.png | Bin 0 -> 1451 bytes Resources/Folder.png | Bin 0 -> 1370 bytes Resources/NewFolder.png | Bin 0 -> 1622 bytes koopatlas.py | 8 ++++- src/editorui/editormain.py | 3 +- src/editorui/paths.py | 12 +++++++- src/ui.py | 39 ++++++++++++++--------- windows_build.py | 75 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 120 insertions(+), 17 deletions(-) create mode 100644 Resources/DelFolder.png create mode 100644 Resources/Folder.png create mode 100644 Resources/NewFolder.png create mode 100755 windows_build.py diff --git a/Resources/DelFolder.png b/Resources/DelFolder.png new file mode 100644 index 0000000..ca77aad Binary files /dev/null and b/Resources/DelFolder.png differ diff --git a/Resources/Folder.png b/Resources/Folder.png new file mode 100644 index 0000000..bef3d1f Binary files /dev/null and b/Resources/Folder.png differ diff --git a/Resources/NewFolder.png b/Resources/NewFolder.png new file mode 100644 index 0000000..9d0cac4 Binary files /dev/null and b/Resources/NewFolder.png differ diff --git a/koopatlas.py b/koopatlas.py index 423df0a..b08f8b5 100755 --- a/koopatlas.py +++ b/koopatlas.py @@ -5,7 +5,13 @@ # Started 2nd November 2011 import os.path, sys -sys.path.append(os.path.join(os.path.dirname(__file__), 'src')) + +if hasattr(sys, 'frozen'): + sys.path.append(os.path.join(os.path.dirname(sys.executable), 'src')) +else: + sys.path.append(os.path.join(os.path.dirname(__file__), 'src')) + + from common import * diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py index 46660f4..6161e7d 100644 --- a/src/editorui/editormain.py +++ b/src/editorui/editormain.py @@ -64,7 +64,7 @@ class KPMapScene(QtGui.QGraphicsScene): @QtCore.pyqtSlot(int) - def viewportUpdateProxy(self, value): + def viewportUpdateProxy(self, valueA = None, value = None): self.views()[0].viewport().update() @@ -252,6 +252,7 @@ class KPMapScene(QtGui.QGraphicsScene): elif isinstance(layer, KPPathLayer): for pnLayer in reversed(KP.mainWindow.pathNodeList.getLayers()): + if not pnLayer.visible: continue # Render Tiles left, top = pnLayer.cacheBasePos diff --git a/src/editorui/paths.py b/src/editorui/paths.py index 55bfac0..b240b22 100644 --- a/src/editorui/paths.py +++ b/src/editorui/paths.py @@ -142,7 +142,6 @@ class KPEditorNode(KPEditorItem): self.transitionProxy = self.HiddenProxy(self.transition, self, -102, 24) self.transition.currentIndexChanged.connect(self.transitionChange) - self._updatePosition() @@ -183,6 +182,7 @@ class KPEditorNode(KPEditorItem): self.update() + KP.mainWindow.pathNodeList.update() @QtCore.pyqtSlot(int) @@ -191,6 +191,8 @@ class KPEditorNode(KPEditorItem): node = self._nodeRef() node.level[0] = world + KP.mainWindow.pathNodeList.update() + @QtCore.pyqtSlot(int) def stageChange(self, stage): @@ -198,6 +200,8 @@ class KPEditorNode(KPEditorItem): node = self._nodeRef() node.level[1] = stage + KP.mainWindow.pathNodeList.update() + @QtCore.pyqtSlot(int) def foreignIDChange(self, ID): @@ -205,6 +209,8 @@ class KPEditorNode(KPEditorItem): node = self._nodeRef() node.foreignID = ID + KP.mainWindow.pathNodeList.update() + @QtCore.pyqtSlot(int) def transitionChange(self, index): @@ -212,6 +218,8 @@ class KPEditorNode(KPEditorItem): node = self._nodeRef() node.transition = index + KP.mainWindow.pathNodeList.update() + @QtCore.pyqtSlot(str) def mapChangeChange(self, mapname): @@ -219,6 +227,8 @@ class KPEditorNode(KPEditorItem): node = self._nodeRef() node.mapChange = mapname + KP.mainWindow.pathNodeList.update() + def _updatePosition(self): self.ignoreMovement = True diff --git a/src/ui.py b/src/ui.py index 13d0039..d5418bc 100644 --- a/src/ui.py +++ b/src/ui.py @@ -16,7 +16,7 @@ class KPPathNodeList(QtGui.QWidget): self.layer = layer self.associate = associate - self.setFlags(Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled) + self.setFlags(Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable) def data(self, index, role=Qt.DisplayRole): @@ -26,33 +26,35 @@ class KPPathNodeList(QtGui.QWidget): node = self.associate if node.level: - return QtGui.QIcon('LevelNodeIcon') + return KP.icon('BlackLevel') elif node.mapChange != None: - return QtGui.QIcon('ExitNodeIcon') + return KP.icon('Exit') elif len(node.exits) != 2: - return QtGui.QIcon('StopNodeIcon') + return KP.icon('Stop') else: - return QtGui.QIcon('ThroughNodeIcon') + return KP.icon('Through') else: - return QtGui.QIcon('PathIcon') + return KP.icon('LayerPath') elif role == Qt.DisplayRole: if isinstance(self.associate, KPNode): node = self.associate if node.level: - return "Level Node: {0}".format(node.level) + return "Level: {0}".format(node.level) elif node.mapChange != None: - return "Exit to World {0}, entrance {1}".format(mapID, foreignID) + return "Exit: World {0}, entrance {1}".format(node.mapID, node.foreignID) elif len(node.exits) == 3: - return "3-way Junction" + return "Node: 3-way Junction" elif len(node.exits) == 4: - return "4-way Junction" + return "Node: 4-way Junction" + elif (len(node.exits) == 1) or (len(node.exits) == 0): + return "Node: End Point" elif len(node.exits) > 4: return "Illegal Node" else: - return "Pass Through Node" + return "Node: Pass-Through" else: AnimationList = ["Walk", "WalkSand", "WalkSnow", "WalkIce", @@ -67,10 +69,18 @@ class KPPathNodeList(QtGui.QWidget): return 'Path: {0} Exit, {1}'.format(unlock, animation) + elif role == Qt.CheckStateRole: + return (Qt.Checked if self.layer.visible else Qt.Unchecked) + else: return QtGui.QTreeWidgetItem.data(self, index, role) + def setData(self, column, role = Qt.EditRole, value = None): + if role == Qt.CheckStateRole: + self.layer.visible = value.toBool() + + def layer(self): return self.layer @@ -88,6 +98,7 @@ class KPPathNodeList(QtGui.QWidget): self.tree.setColumnCount(1) self.tree.setDragEnabled(True) self.tree.setDragDropMode(self.tree.InternalMove) + self.tree.setHeaderHidden(True) self.tree.itemClicked.connect(self.handleRowChanged) self.layout.addWidget(self.tree) @@ -99,8 +110,8 @@ class KPPathNodeList(QtGui.QWidget): def setupToolbar(self, tb): - self.actAddFolder = tb.addAction(KP.icon('LayerNewTile'), 'Add Folder', self.addFolder) - self.actRemoveFolder = tb.addAction(KP.icon('LayerNewObjects'), 'Remove Folder', self.removeFolder) + self.actAddFolder = tb.addAction(KP.icon('NewFolder'), 'Add Folder', self.addFolder) + self.actRemoveFolder = tb.addAction(KP.icon('DelFolder'), 'Remove Folder', self.removeFolder) self.selectTileset = tb.addAction(KP.icon('LayerNewTile'), 'Select Tileset', self.setTileset) selectedLayerChanged = QtCore.pyqtSignal(KPLayer) @@ -115,7 +126,7 @@ class KPPathNodeList(QtGui.QWidget): def addFolder(self): item = QtGui.QTreeWidgetItem(self.tree) - item.setIcon(0, QtGui.QIcon('Folder')) + item.setIcon(0, KP.icon('Folder')) item.setText(0, 'Untitled Folder') item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled | Qt.ItemIsEditable | Qt.ItemIsEnabled) diff --git a/windows_build.py b/windows_build.py new file mode 100755 index 0000000..5b9d33c --- /dev/null +++ b/windows_build.py @@ -0,0 +1,75 @@ +from distutils.core import setup +from py2exe.build_exe import py2exe +import os, os.path, shutil, sys + +upxFlag = False +if '-upx' in sys.argv: + sys.argv.remove('-upx') + upxFlag = True + +dir = 'distrib/windows' + +print '[[ Running Koopatlas Through py2exe! ]]' +print '>> Destination directory: %s' % dir +sys.argv.append('py2exe') + +if os.path.isdir(dir): shutil.rmtree(dir) +os.makedirs(dir) + +# exclude QtWebKit to save space, plus Python stuff we don't use +excludes = ['encodings', 'doctest', 'pdb', 'unittest', 'difflib', 'inspect', + 'os2emxpath', 'posixpath', 'optpath', 'locale', 'calendar', + 'threading', 'select', 'socket', 'hashlib', 'multiprocessing', 'ssl', + 'PyQt4.QtWebKit', 'PyQt4.QtNetwork'] + +# set it up +setup( + name='Koopatlas', + version='0.2', + description="Koopatlas - Newer's Fantastic World Map Editor", + windows=[ + {'script': 'koopatlas.py', + } + ], + options={'py2exe':{ + 'includes': ['sip', 'encodings', 'encodings.hex_codec', 'encodings.utf_8', 'hashlib'], + 'compressed': 1, + 'optimize': 2, + 'excludes': excludes, + 'bundle_files': 3, + 'dist_dir': dir + }} +) + +print '>> Built frozen executable!' + +# now that it's built, configure everything +os.unlink(dir + '/w9xpopen.exe') # not needed + +if upxFlag: + if os.path.isfile('upx.exe'): + print '>> Found UPX, using it to compress the executables!' + files = os.listdir(dir) + upx = [] + for f in files: + if f.endswith('.exe') or f.endswith('.dll') or f.endswith('.pyd'): + upx.append('"%s/%s"' % (dir,f)) + os.system('upx -9 ' + ' '.join(upx)) + print '>> Compression complete.' + else: + print '>> UPX not found, binaries can\'t be compressed.' + print '>> In order to build Koopuzzle! with UPX, place the upx.exe file into '\ + 'this folder.' + + +print '>> Attempting to copy VC++2008 libraries...' +if os.path.isdir('Microsoft.VC90.CRT'): + shutil.copytree('Microsoft.VC90.CRT', dir + '/Microsoft.VC90.CRT') + print '>> Copied libraries!' +else: + print '>> Libraries not found! The frozen executable will require the '\ + 'Visual C++ 2008 runtimes to be installed in order to work.' + print '>> In order to automatically include the runtimes, place the '\ + 'Microsoft.VC90.CRT folder into this folder.' + +print '>> Koopatlas has been frozen to %s!' % dir -- cgit v1.2.3