summaryrefslogtreecommitdiff
path: root/Puzzle+
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Koopuzzle/.DS_Store (renamed from Puzzle+/.DS_Store)bin6148 -> 6148 bytes
-rwxr-xr-xKoopuzzle/Koopuzzle.py (renamed from Puzzle+/puzzle+.py)152
-rwxr-xr-xKoopuzzle/archive.py (renamed from Puzzle+/archive.py)0
-rwxr-xr-xKoopuzzle/common.py (renamed from Puzzle+/common.py)0
-rwxr-xr-xKoopuzzle/license.txt (renamed from Puzzle+/license.txt)0
-rwxr-xr-xKoopuzzle/windows_build.py (renamed from Puzzle+/windows_build.py)0
-rw-r--r--Puzzle+/nsmblib-0.5a.zipbin9056 -> 0 bytes
7 files changed, 86 insertions, 66 deletions
diff --git a/Puzzle+/.DS_Store b/Koopuzzle/.DS_Store
index 5008ddf..5008ddf 100644
--- a/Puzzle+/.DS_Store
+++ b/Koopuzzle/.DS_Store
Binary files differ
diff --git a/Puzzle+/puzzle+.py b/Koopuzzle/Koopuzzle.py
index 886a80a..4962e5c 100755
--- a/Puzzle+/puzzle+.py
+++ b/Koopuzzle/Koopuzzle.py
@@ -10,12 +10,6 @@ from ctypes import create_string_buffer
from PyQt4 import QtCore, QtGui
-try:
- import nsmblib
- HaveNSMBLib = True
-except ImportError:
- HaveNSMBLib = False
-
########################################################
# To Do:
@@ -39,11 +33,10 @@ class TilesetClass():
Methods: addTile, removeTile, addObject, removeObject, clear'''
class Tile():
- def __init__(self, image, noalpha):
+ def __init__(self, image):
'''Tile Constructor'''
self.image = image
- self.noalpha = noalpha
class Object():
@@ -69,10 +62,10 @@ class TilesetClass():
self.slot = 0
- def addTile(self, image, noalpha):
+ def addTile(self, image):
'''Adds an tile class to the tile list with the passed image or parameters'''
- self.tiles.append(self.Tile(image, noalpha))
+ self.tiles.append(self.Tile(image))
def addObject(self, height = 1, width = 1, uslope = [0, 0], lslope = [0, 0], tilelist = [[(0, 0xFFFF, 0)]]):
@@ -128,7 +121,7 @@ class objectList(QtGui.QListView):
-def SetupObjectModel(self, objects, tiles):
+def SetupObjectModel(self, objects, tiles, treecko, group):
global Tileset
self.clear()
@@ -143,7 +136,7 @@ def SetupObjectModel(self, objects, tiles):
for i in range(len(object.tiles)):
for tile in object.tiles[i]:
- if (Tileset.slot == 0):
+ if (tile[1] != 0xFFFF):
painter.drawPixmap(Xoffset, Yoffset, tiles[tile[1]].image)
Xoffset += 24
Xoffset = 0
@@ -155,6 +148,41 @@ def SetupObjectModel(self, objects, tiles):
count += 1
+ if group != None:
+ grovyle = cPickle.loads(group)
+ makeTree(grovyle, treecko)
+
+
+def makeTree(grovyle, treecko):
+
+ for razorLeaf in grovyle:
+
+ if (type(razorLeaf) is str) and (razorLeaf[:6] == "Object"):
+
+ pix = QtGui.QPixmap(24, 24)
+ pix.fill(QtCore.Qt.transparent)
+ painter = QtGui.QPainter(pix)
+ painter.drawPixmap(0, 0, pix)
+ painter.end()
+
+ a = QtGui.QTreeWidgetItem(treecko)
+ a.setText(0, razorLeaf)
+ a.setFlags(QtCore.Qt.ItemFlags(0x25))
+ a.setIcon(1, QtGui.QIcon(pix))
+
+ else:
+
+ a = QtGui.QTreeWidgetItem(treecko)
+ a.setText(0, razorLeaf[0])
+ a.setFlags(QtCore.Qt.ItemFlags(0x2F))
+ a.setChildIndicatorPolicy(QtGui.QTreeWidgetItem.ShowIndicator)
+ a.setExpanded(True)
+
+
+ makeTree(razorLeaf[1], a)
+
+
+
@QtCore.pyqtSlot(QtGui.QTreeWidgetItem, int)
def connectToTileWidget(tree, column):
@@ -217,10 +245,6 @@ class displayWidget(QtGui.QListView):
x = option.rect.x()
y = option.rect.y()
-
-
- # Collision Overlays
- curTile = Tileset.tiles[index.row()]
# Highlight stuff.
@@ -1128,8 +1152,9 @@ def RGB4A3Decode(tex):
if(xpixel >= 1024 or ypixel >= 512):
continue
-
- newpixel = (tex[i] << 8) | tex[i+1]
+
+ newpixel = struct.unpack_from('>H', tex, i)[0]
+ # newpixel = (int(tex[i]) << 8) | int(tex[i+1])
if(newpixel >= 0x8000): # Check if it's RGB555
@@ -1237,17 +1262,16 @@ class MainWindow(QtGui.QMainWindow):
global Tileset
Tileset.clear()
- Tileset = TilesetClass()
-
self.treeki.clear()
- # self.objectList.clear()
self.objmodel.clear()
+
+ Tileset = TilesetClass()
EmptyPix = QtGui.QPixmap(24, 24)
EmptyPix.fill(QtCore.Qt.black)
for i in range(512):
- Tileset.addTile(EmptyPix, EmptyPix)
+ Tileset.addTile(EmptyPix)
self.setuptile()
self.setWindowTitle('New Tileset')
@@ -1256,12 +1280,16 @@ class MainWindow(QtGui.QMainWindow):
def openTileset(self):
'''Opens a Koopatlas tileset arc and parses the heck out of it.'''
+ global Tileset
+
path = str(QtGui.QFileDialog.getOpenFileName(self, "Open Koopatlas Tileset", '',
"Image Files (*.arc)"))
if path:
self.setWindowTitle(os.path.basename(path))
Tileset.clear()
+ self.treeki.clear()
+ self.objmodel.clear()
name = path[str(path).rfind('/')+1:-4]
@@ -1283,42 +1311,31 @@ class MainWindow(QtGui.QMainWindow):
if key.startswith('BG_tex/') and key.endswith('_tex.bin'):
Image = arc[key]
if key.startswith('BG_grp/') and key.endswith('_grp.bin'):
- Image = arc[key]
+ group = arc[key]
if key.startswith('BG_unt/'):
if key.endswith('_hd.bin'):
metadata = arc[key]
elif key.endswith('.bin'):
objstrings = arc[key]
-
if (Image == None) or (group == None) or (objstrings == None) or (metadata == None):
QtGui.QMessageBox.warning(None, 'Error', 'Error - the necessary files were not found.\n\nNot a valid Koopatlas tileset, sadly.')
return
- # Stolen from Reggie! Loads the Image Data.
- if HaveNSMBLib:
- argbdata = nsmblib.decodeTileset(Image)
- rgbdata = nsmblib.decodeTilesetNoAlpha(Image)
- dest = QtGui.QImage(argbdata, 1024, 512, 4096, QtGui.QImage.Format_ARGB32_Premultiplied)
- noalphadest = QtGui.QImage(rgbdata, 1024, 512, 4096, QtGui.QImage.Format_ARGB32_Premultiplied)
- else:
- dest = RGB4A3Decode(Image)
+ dest = RGB4A3Decode(Image)
self.tileImage = QtGui.QPixmap.fromImage(dest)
- noalpha = QtGui.QPixmap.fromImage(noalphadest)
-
# Makes us some nice Tile Classes!
Xoffset = 4
Yoffset = 4
for i in range(512):
- Tileset.addTile(self.tileImage.copy(Xoffset,Yoffset,24,24), noalpha.copy(Xoffset,Yoffset,24,24))
+ Tileset.addTile(self.tileImage.copy(Xoffset,Yoffset,24,24))
Xoffset += 32
if Xoffset >= 1024:
Xoffset = 4
Yoffset += 32
-
# Load Objects
meta = []
@@ -1360,7 +1377,10 @@ class MainWindow(QtGui.QMainWindow):
byte = struct.unpack_from('>B', objstrings, offset)[0]
else:
- tilelist[len(tilelist)-1].append(struct.unpack_from('>BH', objstrings, offset).extend([0]))
+ untile = struct.unpack_from('>BH', objstrings, offset)
+ retile = (untile[0], untile[1], 0)
+
+ tilelist[len(tilelist)-1].append(retile)
offset += 3
byte = struct.unpack_from('>B', objstrings, offset)[0]
@@ -1378,11 +1398,10 @@ class MainWindow(QtGui.QMainWindow):
upperslope = [0, 0]
lowerslope = [0, 0]
- Tileset.slot = Tileset.objects[0].tiles[0][0][2] & 3
- self.tileWidget.tilesetType.setText('Pa{0}'.format(Tileset.slot))
-
self.setuptile()
- SetupObjectModel(self.objmodel, Tileset.objects, Tileset.tiles)
+ SetupObjectModel(self.objmodel, Tileset.objects, Tileset.tiles, self.treeki, group)
+
+ self.tileWidget.tiles.updateList()
self.name = path
@@ -1446,22 +1465,22 @@ class MainWindow(QtGui.QMainWindow):
painter.end()
tex.save(fn)
-
-
+
def saveTileset(self):
if self.name == '':
self.saveTilesetAs()
return
- outdata = self.saving(os.path.basename(self.name)[:-4])
+ outdata = self.saving(os.path.basename(unicode(self.name))[:-4])
- fn = self.name
+ fn = unicode(self.name)
f = open(fn, 'wb')
f.write(outdata)
f.close()
-
+ reply = QtGui.QMessageBox.information(self, "Save Complete", "Tileset saved as {0}.".format(os.path.basename(unicode(self.name))[:-4]))
+
def saveTilesetAs(self):
fn = QtGui.QFileDialog.getSaveFileName(self, 'Choose a new filename', '', '.arc (*.arc)')
@@ -1475,6 +1494,8 @@ class MainWindow(QtGui.QMainWindow):
f.write(outdata)
f.close()
+ reply = QtGui.QMessageBox.information(self, "Save Complete", "Tileset saved as {0}.".format(os.path.basename(unicode(self.name))[:-4]))
+
def saving(self, name):
@@ -1676,22 +1697,31 @@ class MainWindow(QtGui.QMainWindow):
def PackGroups(self):
groupList = []
+
+ # Walk through all top level items
for kiddy in xrange(self.treeki.topLevelItemCount()):
- self.walkTree(groupList, self.treeki.topLevelItem(kiddy));
+ groupList.append(self.walkTree(self.treeki.topLevelItem(kiddy)))
return cPickle.dumps(groupList)
- def walkTree(self, stringsList, treeItem):
+ def walkTree(self, treeItem):
- for kiddy in xrange(treeItem.childCount()):
- newList = []
- self.walkTree(newList, treeItem.child(kiddy))
+ # If item has kids, walk through each kid. If not, just add the string.
+
+ name = str(treeItem.text(0))
+
+ alist = []
if treeItem.childCount() > 0:
- stringsList.append(str(treeItem.text(0)), newList)
+
+ for kiddy in xrange(treeItem.childCount()):
+ alist.append(self.walkTree(treeItem.child(kiddy)))
+
+ return (name, alist)
+
else:
- stringsList.append(str(treeItem.text(0)))
+ return name
def setupMenus(self):
@@ -1711,19 +1741,7 @@ class MainWindow(QtGui.QMainWindow):
taskMenu = self.menuBar().addMenu("&Tasks")
- taskMenu.addAction("Toggle Alpha", self.toggleAlpha, QtGui.QKeySequence('Ctrl+Shift+A'))
taskMenu.addAction("Clear Object Data", Tileset.clearObjects, QtGui.QKeySequence('Ctrl+Alt+Backspace'))
-
-
-
- def toggleAlpha(self):
- # Replace Alpha Image with non-Alpha images in model
- if self.alpha == True:
- self.alpha = False
- else:
- self.alpha = True
-
- self.setuptile()
def TriggerNewGroup(self):
@@ -1769,7 +1787,6 @@ class MainWindow(QtGui.QMainWindow):
# Object List
self.objectList = objectList()
self.objmodel = QtGui.QStandardItemModel()
- SetupObjectModel(self.objmodel, Tileset.objects, Tileset.tiles)
self.objectList.setModel(self.objmodel)
self.tileWidget = tileOverlord()
@@ -1834,6 +1851,9 @@ class MainWindow(QtGui.QMainWindow):
self.treeki.itemClicked.connect(connectToTileWidget)
+ SetupObjectModel(self.objmodel, Tileset.objects, Tileset.tiles, self.treeki, None)
+
+
frameLayout.addWidget(self.container)
frameLayout.addWidget(self.tabWidget)
diff --git a/Puzzle+/archive.py b/Koopuzzle/archive.py
index b0495f5..b0495f5 100755
--- a/Puzzle+/archive.py
+++ b/Koopuzzle/archive.py
diff --git a/Puzzle+/common.py b/Koopuzzle/common.py
index 792acec..792acec 100755
--- a/Puzzle+/common.py
+++ b/Koopuzzle/common.py
diff --git a/Puzzle+/license.txt b/Koopuzzle/license.txt
index 63e41a4..63e41a4 100755
--- a/Puzzle+/license.txt
+++ b/Koopuzzle/license.txt
diff --git a/Puzzle+/windows_build.py b/Koopuzzle/windows_build.py
index 10d710c..10d710c 100755
--- a/Puzzle+/windows_build.py
+++ b/Koopuzzle/windows_build.py
diff --git a/Puzzle+/nsmblib-0.5a.zip b/Puzzle+/nsmblib-0.5a.zip
deleted file mode 100644
index bca75e2..0000000
--- a/Puzzle+/nsmblib-0.5a.zip
+++ /dev/null
Binary files differ