mirror of
https://github.com/grp/Wii.py.git
synced 2025-06-18 14:55:35 -04:00
new U8 API, needs adding to other shit in archive.py
This commit is contained in:
parent
085c1a96fd
commit
c3a4330a94
15
archive.py
15
archive.py
@ -89,6 +89,7 @@ class U8(WiiArchive):
|
||||
def _dumpDir(self, dir):
|
||||
if(not os.path.isdir(dir)):
|
||||
os.mkdir(dir)
|
||||
old = os.getcwd()
|
||||
os.chdir(dir)
|
||||
for item, data in self.files:
|
||||
if(data == None):
|
||||
@ -96,12 +97,13 @@ class U8(WiiArchive):
|
||||
os.mkdir(item)
|
||||
else:
|
||||
open(item, "wb").write(data)
|
||||
os.chdir("..")
|
||||
os.chdir(old)
|
||||
def _loadDir(self, dir):
|
||||
try:
|
||||
self._tmpPath += ''
|
||||
except:
|
||||
self._tmpPath = ''
|
||||
old = os.getcwd()
|
||||
os.chdir(dir)
|
||||
entries = os.listdir(".")
|
||||
for entry in entries:
|
||||
@ -112,7 +114,7 @@ class U8(WiiArchive):
|
||||
elif(os.path.isfile(entry)):
|
||||
data = open(entry, "rb").read()
|
||||
self.files.append((self._tmpPath + entry, data))
|
||||
os.chdir("..")
|
||||
os.chdir(old)
|
||||
self._tmpPath = self._tmpPath[:self._tmpPath.find('/') + 1]
|
||||
def _load(self, data):
|
||||
offset = 0
|
||||
@ -148,7 +150,7 @@ class U8(WiiArchive):
|
||||
if(node.type == 0x0100): # folder
|
||||
recursion.append(node.size)
|
||||
recursiondir.append(name)
|
||||
assert len(recursion) == node.data_offset + 2 #bad idea?
|
||||
assert len(recursion) == node.data_offset + 2 # haxx
|
||||
self.files.append(('/'.join(recursiondir), None))
|
||||
elif(node.type == 0): # file
|
||||
self.files.append(('/'.join(recursiondir) + '/' + name, data[node.data_offset:node.data_offset + node.size]))
|
||||
@ -179,10 +181,11 @@ class U8(WiiArchive):
|
||||
return val
|
||||
raise KeyError
|
||||
def __setitem__(self, key, val):
|
||||
for i in self.files:
|
||||
for i in range(len(self.files)):
|
||||
if(self.files[i][0] == key):
|
||||
self.files[i][1] = val
|
||||
raise KeyError
|
||||
self.files[i] = (self.files[i][0], val)
|
||||
return
|
||||
self.files.append((key, val))
|
||||
|
||||
|
||||
class WAD:
|
||||
|
4
image.py
4
image.py
@ -541,11 +541,11 @@ class TPL():
|
||||
if k == 0:
|
||||
a = (texel >> 8) & 0xff
|
||||
r = (texel >> 0) & 0xff
|
||||
out[m + (l * x)] = out[m + (l * x)] | ((r<<0) | (a<<24))
|
||||
out[m + (l * x)] |= ((r << 0) | (a << 24))
|
||||
else:
|
||||
g = (texel >> 8) & 0xff
|
||||
b = (texel >> 0) & 0xff
|
||||
out[m + (l * x)] = out[m + (l * x)] | ((g<<8) | (b<<16))
|
||||
out[m + (l * x)] |= ((g << 8) | (b << 16))
|
||||
return ''.join(Struct.uint32(p) for p in out)
|
||||
def RGB5A3(self, (w, h), jar):
|
||||
out = [0 for i in range(w * h)]
|
||||
|
Loading…
Reference in New Issue
Block a user