summaryrefslogtreecommitdiff
path: root/src/tileset.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/tileset.py')
-rw-r--r--src/tileset.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/tileset.py b/src/tileset.py
index ab77223..cc36d18 100644
--- a/src/tileset.py
+++ b/src/tileset.py
@@ -341,22 +341,18 @@ class KPTileset(object):
def loadFromArc(cls, handleOrPath):
arc = WiiArchiveU8(handleOrPath)
- img = arc.resolvePath('/BG_tex').children[0].data
- grp = arc.resolvePath('/BG_grp').children[0].data
+ img = arc.resolvePath('/texture.bin').data
+ grp = arc.resolvePath('/groups.bin').data
- untDir = arc.resolvePath('/BG_unt')
- obj, meta = None, None
+ obj = arc.resolvePath('/objects.bin').data
+ meta = arc.resolvePath('/objectsMeta.bin').data
- for child in untDir.children:
- if child.name.endswith('_hd.bin'):
- meta = child.data
- else:
- obj = child.data
+ tmaps = arc.resolvePath('/optimisedTileMappings.txt').data
- return cls(img, obj, meta, grp)
+ return cls(img, obj, meta, grp, tmaps)
- def __init__(self, imageBuffer, objectBuffer, objectMetadata, groupBuffer):
+ def __init__(self, imageBuffer, objectBuffer, objectMetadata, groupBuffer, optMapBuffer):
'''A Koopatlas Tileset class. To initialize, pass it image data,
object data, and group data as read from a Koopatlas tileset file.
@@ -402,6 +398,8 @@ class KPTileset(object):
self.groupItem.calculateIndices(0)
self.groupModel = KPGroupModel(self.groupItem)
+ self.optMappings = map(int, optMapBuffer.split(','))
+
def processImage(self, imageBuffer):
'''Takes an imageBuffer from a Koopatlas Tileset and converts it into 24x24
@@ -412,14 +410,14 @@ class KPTileset(object):
self.tileImage = QtGui.QPixmap.fromImage(dest)
# Makes us some nice Tiles!
- Xoffset = 4
- Yoffset = 4
+ Xoffset = 2
+ Yoffset = 2
for i in range(512):
self.tiles.append(self.tileImage.copy(Xoffset,Yoffset,24,24))
- Xoffset += 32
- if Xoffset >= 1024:
- Xoffset = 4
- Yoffset += 32
+ Xoffset += 28
+ if Xoffset >= 896:
+ Xoffset = 2
+ Yoffset += 28
@@ -428,8 +426,8 @@ class KPTileset(object):
import time
b = time.clock()
- out = bytearray(1024*512*4)
- dest = QtGui.QImage(1024,512,QtGui.QImage.Format_ARGB32)
+ out = bytearray(896*448*4)
+ dest = QtGui.QImage(896,448,QtGui.QImage.Format_ARGB32)
dest.fill(Qt.transparent)
# Some fairly ugly code, in an attempt to make it run faster
@@ -440,8 +438,8 @@ class KPTileset(object):
i = 0
- xtile_range = _xrange(0, 1024, 4)
- ytile_range = _xrange(0, 512, 4)
+ xtile_range = _xrange(0, 896, 4)
+ ytile_range = _xrange(0, 448, 4)
for ytile in ytile_range:
ypixel_range = _xrange(ytile, ytile + 4)