Skip to content

Commit

Permalink
v0.92
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshakami authored Nov 11, 2021
1 parent c2ff8d0 commit ea8648c
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 45 deletions.
12 changes: 6 additions & 6 deletions arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
for j in range(6, 18):
extract_row += [j, j, j, j]
for j in range(6, 18):
extract_row += [j, j, j, j]
extract_col = [0, 1, 2, 3] * 12 + [4, 5, 6, 7] * 12
extract_row += [j, j, j]
extract_col = [0, 1, 2, 3] * 12 + [4, 5, 6] * 12

create_row = []
for j in range(20, 32):
create_row += [j, j, j, j]
for j in range(20, 32):
create_row += [j, j, j, j]
create_col = [0, 1, 2, 3] * 12 + [4, 5, 6, 7] * 12
create_row += [j, j, j]
create_col = [0, 1, 2, 3] * 12 + [4, 5, 6] * 12

extract_list = []
create_list = []
Expand Down Expand Up @@ -116,7 +116,7 @@ def extract(file, index):
if not os.path.isfile(files):
continue
size = os.path.getsize(files)
if size < 5 or i > 96:
if size < 5 or i >= len(extract_col):
continue
with open(files, 'rb') as check_file:
header = check_file.read(4)
Expand All @@ -132,7 +132,7 @@ def extract(file, index):
continue

for folder in os.listdir('./'): # display a button for each folder found
if os.path.isdir(folder) and n < 96:
if os.path.isdir(folder) and n < len(create_col):
launch_func = partial(create, folder, n)
createbu = Button(a, text=folder, command=launch_func, activebackground='#a9ff99', width=30)
createbu.grid(row=create_row[n], column=create_col[n])
Expand Down
8 changes: 4 additions & 4 deletions brsar.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ button_row = []
for j in range(8, 20):
button_row += [j, j, j]
for j in range(8, 20):
button_row += [j, j, j, j, j]
button_row += [j, j, j, j]
for j in range(20, 32):
button_row += [j, j, j, j, j, j, j, j]
button_row += [j, j, j, j, j, j, j]

button_col = [0, 1, 2] * 12 + [3, 4, 5, 6, 7] * 12 + [0, 1, 2, 3, 4, 5, 6, 7] * 12
button_col = [0, 1, 2] * 12 + [3, 4, 5, 6] * 12 + [0, 1, 2, 3, 4, 5, 6] * 12
button_list = []
a = Tk()
a.title(language[start + 13])
Expand Down Expand Up @@ -66,7 +66,7 @@ def scan_directory():
if not os.path.isfile(files):
continue
size = os.path.getsize(files)
if size < 10 or i > 192:
if size < 10 or i >= len(button_col):
continue
with open(files, 'rb') as check_file:
header = check_file.read(4)
Expand Down
8 changes: 4 additions & 4 deletions dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
for j in range(8, 20):
button_row += [j, j, j]
for j in range(8, 20):
button_row += [j, j, j, j, j]
button_row += [j, j, j, j]
for j in range(20, 32):
button_row += [j, j, j, j, j, j, j, j]
button_row += [j, j, j, j, j, j, j]

button_col = [0, 1, 2] * 12 + [3, 4, 5, 6] * 12 + [0, 1, 2, 3, 4, 5, 6] * 12
colourenc = ['I4', 'I8', 'IA4', 'IA8', 'RGB565', 'RGB5A3', 'RGBA8', 0, 'CI4', 'CI8', 'CI14x2', 0, 0, 0, 'CMPR']
button_col = [0, 1, 2] * 12 + [3, 4, 5, 6, 7] * 12 + [0, 1, 2, 3, 4, 5, 6, 7] * 12
button_list = []
a = Tk()
a.title(language[start])
Expand Down Expand Up @@ -152,7 +152,7 @@ def scan_directory():
if not os.path.isfile(files):
continue
size = os.path.getsize(files)
if size < 10 or i > 192:
if size < 10 or i >= len(button_col):
continue
with open(files, 'rb') as check_file:
header = check_file.read(4)
Expand Down
12 changes: 6 additions & 6 deletions isox.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
for j in range(5, 16):
extract_row += [j, j, j, j]
for j in range(5, 16):
extract_row += [j, j, j, j]
extract_col = [0, 1, 2, 3] * 11 + [4, 5, 6, 7] * 11
extract_row += [j, j, j]
extract_col = [0, 1, 2, 3] * 11 + [4, 5, 6] * 11

create_row = []
for j in range(17, 32):
create_row += [j, j, j, j]
for j in range(17, 32):
create_row += [j, j, j, j]
create_col = [0, 1, 2, 3] * 15 + [4, 5, 6, 7] * 15
create_row += [j, j, j]
create_col = [0, 1, 2, 3] * 15 + [4, 5, 6] * 15

extract_list = []
create_list = []
Expand Down Expand Up @@ -78,7 +78,7 @@ def scan_directory(): # triggered each time Enter button / Open File Explorer b
if not os.path.isfile(files):
continue
size = os.path.getsize(files)
if size < 10 or i > 88:
if size < 10 or i >= len(extract_col):
continue
with open(files, 'rb') as check_file:
header = check_file.read(4)
Expand All @@ -98,7 +98,7 @@ def scan_directory(): # triggered each time Enter button / Open File Explorer b
continue

for folder in os.listdir('./'): # display a button for each folder found
if os.path.isdir(folder) and n < 120:
if os.path.isdir(folder) and n < len(create_col):
launch_func = partial(create, folder, n)
createbu = Button(a, text=folder, command=launch_func, activebackground='#a9ff99', width=30)
createbu.grid(row=create_row[n], column=create_col[n])
Expand Down
38 changes: 26 additions & 12 deletions lh.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,18 @@
thrice = [b'U\xaa8-', b'bres', b'\x00 \xaf0', b'\x00\x00\x00\x00'] # arc, brres, tpl and rso files
twice = thrice[:2]
extensions = ['.mdl', '.bin', '.cmp'] # extensions of compressed files recognized
burow_extract = [6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10] + [6, 7, 8, 9, 10] * 5 + [11] * 8 + [12] * 8 + [13] * 8 + [14] * 8 + [15] * 8 + [16] * 8 + [17] * 8
bucolumn = [0] + [0, 1, 2] * 5 + [3] * 5 + [4] * 5 + [5] * 5 + [6] * 5 + [7] * 5 + [0, 1, 2, 3, 4, 5, 6, 7] * 7
# burow_extract = [6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10] + [6, 7, 8, 9, 10] * 5 + [11] * 8 + [12] * 8 + [13] * 8 + [14] * 8 + [15] * 8 + [16] * 8 + [17] * 8
# bucolumn = [0] + [0, 1, 2] * 5 + [3] * 5 + [4] * 5 + [5] * 5 + [6] * 5 + [7] * 5 + [0, 1, 2, 3, 4, 5, 6, 7] * 7
burow_extract = []
for j in range(6, 11):
burow_extract += [j, j, j]
for j in range(6, 11):
burow_extract += [j, j, j, j]
for j in range(11, 18):
burow_extract += [j, j, j, j, j, j, j]

bucolumn = [0, 1, 2] * 5 + [3, 4, 5, 6] * 5 + [0, 1, 2, 3, 4, 5, 6] * 7

burow_compress = [burow_extract[i] + 16 for i in range(len(burow_extract))]

extract_list = []
Expand Down Expand Up @@ -89,9 +99,9 @@ def compress(cfile): # compress cfile
shortname = os.path.splitext(cfile)[0] # if there is a . in the file name
else:
shortname = cfile # else compressed file name will be the file name + its right extension
for j in range(3):
if f"{shortname}{extensions[j]}" != cfile: # don't delete the file the script will compress!
os.system(f'del "{shortname}{extensions[j]}"') # delete the mdl, cmp, or bin file with the same name as the
for k in range(3):
if f"{shortname}{extensions[k]}" != cfile: # don't delete the file the script will compress!
os.system(f'del "{shortname}{extensions[k]}"') # delete the mdl, cmp, or bin file with the same name as the
if ismodel: # future compressed file if it exists ( == overwrite )
os.system(f'C:\\Yosh\\n.exe "{cfile}" -lh -o "{shortname}.mdl" -A32') # create a compressed file with mdl extension
elif iscmp:
Expand Down Expand Up @@ -146,22 +156,22 @@ def compress_file(brres, num):
extract_motbu.config(command=extract_mot)
extract_motbu.grid(row=5, column=2)

i = 0
n = 0
for file_to_extract in os.listdir('./'):
try:
if os.path.isfile(file_to_extract):
size = os.path.getsize(file_to_extract)
if size < 5 or i > 96:
if size < 5 or n >= len(bucolumn):
continue
with open(file_to_extract, 'rb') as check_xfile:
header = check_xfile.read(4)
if header[:1] in [b'@', b'\x10', b'\x11', b'\x81', b'\x82', b'$', b'(', b'0', b'P'] and header != b'PK\x03\x04': # lh @, old lz \x10, lz77 \x11, diff8 \x81, diff16 \x82, huff4 $, huff8 (, runlength 0, lrc P
run_extract_file = partial(extract_file, file_to_extract, i)
run_extract_file = partial(extract_file, file_to_extract, n)
temp = Button(a, text=file_to_extract, command=run_extract_file, activebackground='#a9ff99', width=30)
temp.grid(row=burow_extract[i], column=bucolumn[i])
temp.grid(row=burow_extract[n], column=bucolumn[n])
extract_list.append(temp)
print(file_to_extract, i)
i += 1
print(file_to_extract, n)
n += 1

except PermissionError as error:
print(error)
Expand Down Expand Up @@ -192,7 +202,7 @@ def compress_file(brres, num):
try:
if os.path.isfile(file_to_compress):
size = os.path.getsize(file_to_compress)
if size < 5 or i > 96:
if size < 5 or i >= len(bucolumn):
continue
with open(file_to_compress, 'rb') as check_cfile:
header4 = check_cfile.read(4)
Expand All @@ -206,6 +216,10 @@ def compress_file(brres, num):
except PermissionError as error:
print(error)
continue
if i > 50 or n > 50: # creates a big exit button and make the window fullscreen as it was too tiny to display all buttons
exitbu2 = Button(a, text=language[msm + 40], command=a.quit, activebackground='#d9ff8c', bg='#d9ff8c', fg='#ff2222', width=58, height=3, font=100)
exitbu2.grid(row=0, column=4, rowspan=2, columnspan=3)
a.attributes('-fullscreen', True)


def change_directory(): # enter button to change directory (take the entry content)
Expand Down
2 changes: 1 addition & 1 deletion msm.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ with open('C:\\Yosh\\#language.txt', 'r', encoding="utf-8") as txt:

start = int(language[1].split(":")[1])
a = Tk()
a.title(language[start + 2] + " v0.91")
a.title(language[start + 2] + " v0.92")
a.minsize(680, 495)
a.maxsize(680, 495)
a.config(bg="#aecfee")
Expand Down
2 changes: 1 addition & 1 deletion pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def scan_directory():
if not os.path.isfile(files):
continue
size = os.path.getsize(files)
if size < 10 or i > 192:
if size < 10 or i >= len(button_col):
continue
with open(files, 'rb') as check_file:
header = check_file.read(4)
Expand Down
12 changes: 6 additions & 6 deletions tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
for j in range(8, 20):
button_row += [j, j, j]
for j in range(8, 20):
button_row += [j, j, j, j, j]
button_row += [j, j, j, j]
for j in range(20, 32):
button_row += [j, j, j, j, j, j, j, j]
button_row += [j, j, j, j, j, j, j]

print(f"{language[start + 2]}\n")
button_col = [0, 1, 2] * 12 + [3, 4, 5, 6] * 12 + [0, 1, 2, 3, 4, 5, 6] * 12

button_col = [0, 1, 2] * 12 + [3, 4, 5, 6, 7] * 12 + [0, 1, 2, 3, 4, 5, 6, 7] * 12
print(f"{language[start + 2]}\n")
button_list = []
a = Tk()
a.title(language[start])
Expand Down Expand Up @@ -61,7 +61,7 @@ def scan_directory():
if not os.path.isfile(files):
continue
size = os.path.getsize(files)
if size < 10 or i > 192:
if size < 10 or i >= len(button_col):
continue
with open(files, 'rb') as check_file:
header = check_file.read(4)
Expand All @@ -76,7 +76,7 @@ def scan_directory():
print(error)
continue

if i > 36: # if many png are found, then it puts the window on fullscreen and create a big exit button
if i > 50: # if many png are found, then it puts the window on fullscreen and create a big exit button
exitbu2 = Button(a, text=language[msm + 39], command=a.quit, activebackground='#d9ff8c', bg='#d9ff8c', fg='#ff2222', width=58, height=3, font=100)
exitbu2.grid(row=0, column=4, rowspan=2, columnspan=3)
a.attributes('-fullscreen', True)
Expand Down
8 changes: 4 additions & 4 deletions thp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@
button_row = []
for j in range(11, 20):
button_row += [j, j, j]
for _ in range(5):
for _ in range(4):
for j in range(11, 20):
button_row += [j]
for j in range(20, 32):
button_row += [j, j, j, j, j, j, j, j]
button_row += [j, j, j, j, j, j, j]

print(f"{language[start + 2]}\n")
button_col = [0, 1, 2] * 9 + [3] * 9 + [4] * 9 + [5] * 9 + [6] * 9 + [7] * 9 + [0, 1, 2, 3, 4, 5, 6, 7] * 11
button_col = [0, 1, 2] * 9 + [3] * 9 + [4] * 9 + [5] * 9 + [6] * 9 + [0, 1, 2, 3, 4, 5, 6] * 12
print(button_col)
button_list = []
a = Tk()
Expand Down Expand Up @@ -549,7 +549,7 @@ def scan_directory():
if not os.path.isfile(files):
continue
size = os.path.getsize(files)
if size < 10 or k > 192:
if size < 10 or k >= len(button_col):
continue
with open(files, 'rb') as check_file:
header = check_file.read(4)
Expand Down
10 changes: 9 additions & 1 deletion trib.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def change_scale(file, offset):

mdl = mdln = 0
for files in os.listdir('./'):
if mdl > 800:
if mdl >= len(button_col):
break
try:
if not os.path.isfile(files):
Expand All @@ -94,6 +94,8 @@ def change_scale(file, offset):
header = bfile.read(4)
if header == b'MDL0':
edit = partial(change_scale, files, mdl)
if mdl >= len(button_col):
break
filebu = Button(a, text='MDL0 ' + files, command=edit, activebackground='#a9ff99', width=30, fg='#0050ff')
filebu.grid(row=button_row[mdl], column=button_col[mdl])
button_list.append(filebu)
Expand All @@ -113,6 +115,8 @@ def change_scale(file, offset):
continue
out = subprocess.check_output(['wszst', 'list', files, '-R']) # returns all file names
first = True
if mdl >= len(button_col):
break
filabel = Label(a, text=files, bg='#bfaaff', font=2, fg='#ff2222', width=19)
filabel.grid(row=button_row[mdl], column=button_col[mdl])
mdl += 1
Expand All @@ -124,6 +128,8 @@ def change_scale(file, offset):
count = 1
while b'\n' not in out[k - count:k]:
count += 1
if mdl >= len(button_col):
break
flabel = Label(a, text=str(out[k - count + 1:k + 5])[2:-1] + " ->", bg='#bfaaff',
fg='#2222ff', width=30)
flabel.grid(row=button_row[mdl], column=button_col[mdl])
Expand All @@ -133,6 +139,8 @@ def change_scale(file, offset):
while b'\n' not in out[k + 15:k + z]:
z += 1
edit = partial(change_scale, files, mdln)
if mdl >= len(button_col):
break
filebu = Button(a, text=str(out[k + 15:k + z])[2:-3], command=edit, activebackground='#a9ff99', width=30)
filebu.grid(row=button_row[mdl], column=button_col[mdl])
button_list.append(filebu)
Expand Down

0 comments on commit ea8648c

Please sign in to comment.