mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 11:18:26 +02:00
added try except in most function to help debugging error
This commit is contained in:
parent
1b7bb6ec1f
commit
e4fa9ba95c
9 changed files with 315 additions and 280 deletions
2
main.pyw
2
main.pyw
|
@ -3,6 +3,7 @@ from PIL import Image, ImageFont, ImageDraw
|
|||
from tkinter import messagebox, filedialog, ttk
|
||||
from threading import Thread
|
||||
import subprocess
|
||||
import traceback
|
||||
import requests
|
||||
import zipfile
|
||||
import shutil
|
||||
|
@ -26,6 +27,7 @@ class ClassApp():
|
|||
from source.restart import restart
|
||||
from source.patch_img_desc import patch_img_desc
|
||||
from source.patch_ct_icon import patch_ct_icon
|
||||
from source.log_error import log_error
|
||||
|
||||
|
||||
App = ClassApp()
|
||||
|
|
|
@ -6,13 +6,17 @@ import sys
|
|||
import os
|
||||
|
||||
VERSION_FILE_URL = "https://raw.githubusercontent.com/Faraphel/MKWF-Install/master/version"
|
||||
|
||||
|
||||
def check_update(self):
|
||||
try:
|
||||
gitversion = requests.get(VERSION_FILE_URL, allow_redirects=True).json()
|
||||
with open("version", "rb") as f:
|
||||
with open("./version", "rb") as f:
|
||||
locversion = json.load(f)
|
||||
|
||||
if float(gitversion["version"]) > float(locversion["version"]):
|
||||
if ((float(gitversion["version"]) > float(locversion["version"])) or
|
||||
(float(gitversion["version"]) == float(locversion["version"])) and
|
||||
float(gitversion["subversion"]) > float(locversion["subversion"])):
|
||||
if messagebox.askyesno(self.translate("Mise à jour disponible !"), self.translate("Une mise à jour est disponible, souhaitez-vous l'installer ?") +
|
||||
f"\n\nVersion : {locversion['version']}.{locversion['subversion']} -> {gitversion['version']}.{gitversion['subversion']}\n"+\
|
||||
f"Changelog :\n{gitversion['changelog']}"):
|
||||
|
@ -34,5 +38,5 @@ def check_update(self):
|
|||
os.startfile(os.path.realpath("./Updater/Updater.exe"))
|
||||
sys.exit()
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
except:
|
||||
self.log_error()
|
||||
|
|
|
@ -2,73 +2,77 @@ import json
|
|||
|
||||
|
||||
def create_lecode_config(self):
|
||||
def get_star_text(track):
|
||||
if "warning" in track: warning = "!" * track["warning"]
|
||||
else: warning = ""
|
||||
try:
|
||||
def get_star_text(track):
|
||||
if "warning" in track: warning = "!" * track["warning"]
|
||||
else: warning = ""
|
||||
|
||||
if "score" in track:
|
||||
if track["score"] > 0:
|
||||
return "★" * track["score"] + "☆" * (3 - track["score"]) + warning + " "
|
||||
return ""
|
||||
if "score" in track:
|
||||
if track["score"] > 0:
|
||||
return "★" * track["score"] + "☆" * (3 - track["score"]) + warning + " "
|
||||
return ""
|
||||
|
||||
def get_ctfile_text(track, race=False):
|
||||
track_name = track["name"].replace("_", "")
|
||||
def get_ctfile_text(track, race=False):
|
||||
track_name = track["name"].replace("_", "")
|
||||
|
||||
if "prefix" in track: prefix = f"{track['prefix']} "
|
||||
else: prefix = ""
|
||||
if "suffix" in track: suffix = f" ({track['suffix']})"
|
||||
else: suffix = ""
|
||||
if "prefix" in track: prefix = f"{track['prefix']} "
|
||||
else: prefix = ""
|
||||
if "suffix" in track: suffix = f" ({track['suffix']})"
|
||||
else: suffix = ""
|
||||
|
||||
if race:
|
||||
return f' T {track["music"]}; ' + \
|
||||
f'{track["special"]}; ' + \
|
||||
f'{"0x01" if track["new"] else "0x00"}; ' + \
|
||||
f'"-"; ' + \
|
||||
f'"{get_star_text(track)}{prefix}{track_name}{suffix}\\n{track["author"]}"; ' + \
|
||||
f'"-"\n'
|
||||
else:
|
||||
return f' T {track["music"]}; ' + \
|
||||
f'{track["special"]}; ' + \
|
||||
f'{"0x01" if track["new"] else "0x00"}; ' + \
|
||||
f'"{prefix}{track["name"]}{suffix}"; ' + \
|
||||
f'"{get_star_text(track)}{prefix}{track_name}{suffix}"; ' + \
|
||||
f'"-"\n'
|
||||
if race:
|
||||
return f' T {track["music"]}; ' + \
|
||||
f'{track["special"]}; ' + \
|
||||
f'{"0x01" if track["new"] else "0x00"}; ' + \
|
||||
f'"-"; ' + \
|
||||
f'"{get_star_text(track)}{prefix}{track_name}{suffix}\\n{track["author"]}"; ' + \
|
||||
f'"-"\n'
|
||||
else:
|
||||
return f' T {track["music"]}; ' + \
|
||||
f'{track["special"]}; ' + \
|
||||
f'{"0x01" if track["new"] else "0x00"}; ' + \
|
||||
f'"{prefix}{track["name"]}{suffix}"; ' + \
|
||||
f'"{get_star_text(track)}{prefix}{track_name}{suffix}"; ' + \
|
||||
f'"-"\n'
|
||||
|
||||
with open("./ct_config.json", encoding="utf-8") as f:
|
||||
ctconfig = json.load(f)
|
||||
with open("./ct_config.json", encoding="utf-8") as f:
|
||||
ctconfig = json.load(f)
|
||||
|
||||
with open("./file/CTFILE.txt", "w", encoding="utf-8") as ctfile, \
|
||||
open("./file/RCTFILE.txt", "w", encoding="utf-8") as rctfile:
|
||||
with open("./file/CTFILE.txt", "w", encoding="utf-8") as ctfile, \
|
||||
open("./file/RCTFILE.txt", "w", encoding="utf-8") as rctfile:
|
||||
|
||||
header = "#CT-CODE\n" +\
|
||||
"[RACING-TRACK-LIST]\n" +\
|
||||
"%LE-FLAGS=1\n" +\
|
||||
"%WIIMM-CUP=1\n" +\
|
||||
"N N$SWAP | N$F_WII\n\n"
|
||||
ctfile.write(header)
|
||||
rctfile.write(header)
|
||||
header = "#CT-CODE\n" +\
|
||||
"[RACING-TRACK-LIST]\n" +\
|
||||
"%LE-FLAGS=1\n" +\
|
||||
"%WIIMM-CUP=1\n" +\
|
||||
"N N$SWAP | N$F_WII\n\n"
|
||||
ctfile.write(header)
|
||||
rctfile.write(header)
|
||||
|
||||
for cup in ctconfig["cup"]: # defined cup section
|
||||
_cup_config = ctconfig["cup"][cup]
|
||||
if int(cup) >= 9: # Course qui ne sont ni les originales, ni les courses aléatoires.
|
||||
cup = f'\nC "{_cup_config["name"]}"\n'
|
||||
ctfile.write(cup)
|
||||
rctfile.write(cup)
|
||||
for cup in ctconfig["cup"]: # defined cup section
|
||||
_cup_config = ctconfig["cup"][cup]
|
||||
if int(cup) >= 9: # Course qui ne sont ni les originales, ni les courses aléatoires.
|
||||
cup = f'\nC "{_cup_config["name"]}"\n'
|
||||
ctfile.write(cup)
|
||||
rctfile.write(cup)
|
||||
|
||||
for course in _cup_config["courses"]:
|
||||
_course_config = _cup_config["courses"][course]
|
||||
ctfile.write(get_ctfile_text(_course_config, race=False))
|
||||
rctfile.write(get_ctfile_text(_course_config, race=True))
|
||||
for course in _cup_config["courses"]:
|
||||
_course_config = _cup_config["courses"][course]
|
||||
ctfile.write(get_ctfile_text(_course_config, race=False))
|
||||
rctfile.write(get_ctfile_text(_course_config, race=True))
|
||||
|
||||
for i, _course_config in enumerate(ctconfig["tracks_list"]): # undefined cup section
|
||||
if i % 4 == 0:
|
||||
cup = f'\nC "TL{i//4}"\n'
|
||||
ctfile.write(cup)
|
||||
rctfile.write(cup)
|
||||
for i, _course_config in enumerate(ctconfig["tracks_list"]): # undefined cup section
|
||||
if i % 4 == 0:
|
||||
cup = f'\nC "TL{i//4}"\n'
|
||||
ctfile.write(cup)
|
||||
rctfile.write(cup)
|
||||
|
||||
ctfile.write(get_ctfile_text(_course_config, race=False))
|
||||
rctfile.write(get_ctfile_text(_course_config, race=True))
|
||||
ctfile.write(get_ctfile_text(_course_config, race=False))
|
||||
rctfile.write(get_ctfile_text(_course_config, race=True))
|
||||
|
||||
for _ in range(1, 4-(i%4)): # Complete cup if track are missing
|
||||
ctfile.write(f' T T44; T44; 0x00; "_"; ""; "-"\n')
|
||||
rctfile.write(f' T T44; T44; 0x00; "_"; ""; "-"\n')
|
||||
for _ in range(1, 4-(i%4)): # Complete cup if track are missing
|
||||
ctfile.write(f' T T44; T44; 0x00; "_"; ""; "-"\n')
|
||||
rctfile.write(f' T T44; T44; 0x00; "_"; ""; "-"\n')
|
||||
|
||||
except:
|
||||
self.log_error()
|
||||
|
|
|
@ -11,104 +11,109 @@ from .definition import *
|
|||
|
||||
def install_mod(self):
|
||||
def func():
|
||||
with open("./fs.json") as f:
|
||||
fs = json.load(f)
|
||||
try:
|
||||
with open("./fs.json") as f:
|
||||
fs = json.load(f)
|
||||
|
||||
# This part is used to estimate the max_step
|
||||
extracted_file = []
|
||||
max_step, step = 1, 0
|
||||
# This part is used to estimate the max_step
|
||||
extracted_file = []
|
||||
max_step, step = 1, 0
|
||||
|
||||
def count_rf(path):
|
||||
nonlocal max_step
|
||||
max_step += 1
|
||||
extension = get_extension(path)
|
||||
if extension == "szs":
|
||||
if not (os.path.realpath(path) in extracted_file):
|
||||
extracted_file.append(os.path.realpath(path))
|
||||
max_step += 1
|
||||
def count_rf(path):
|
||||
nonlocal max_step
|
||||
max_step += 1
|
||||
extension = get_extension(path)
|
||||
if extension == "szs":
|
||||
if not (os.path.realpath(path) in extracted_file):
|
||||
extracted_file.append(os.path.realpath(path))
|
||||
max_step += 1
|
||||
|
||||
for fp in fs:
|
||||
for f in glob.glob(self.path_mkwf + "/files/" + fp, recursive=True):
|
||||
if type(fs[fp]) == str:
|
||||
count_rf(path=f)
|
||||
elif type(fs[fp]) == dict:
|
||||
for nf in fs[fp]:
|
||||
if type(fs[fp][nf]) == str:
|
||||
count_rf(path=f)
|
||||
elif type(fs[fp][nf]) == list:
|
||||
for ffp in fs[fp][nf]: count_rf(path=f)
|
||||
###
|
||||
extracted_file = []
|
||||
max_step += 4 # PATCH main.dol et PATCH lecode.bin, conversion, changement d'ID
|
||||
self.Progress(show=True, indeter=False, statut=self.translate("Installation du mod"), max=max_step, step=0)
|
||||
for fp in fs:
|
||||
for f in glob.glob(self.path_mkwf + "/files/" + fp, recursive=True):
|
||||
if type(fs[fp]) == str:
|
||||
count_rf(path=f)
|
||||
elif type(fs[fp]) == dict:
|
||||
for nf in fs[fp]:
|
||||
if type(fs[fp][nf]) == str:
|
||||
count_rf(path=f)
|
||||
elif type(fs[fp][nf]) == list:
|
||||
for ffp in fs[fp][nf]: count_rf(path=f)
|
||||
###
|
||||
extracted_file = []
|
||||
max_step += 4 # PATCH main.dol et PATCH lecode.bin, conversion, changement d'ID
|
||||
self.Progress(show=True, indeter=False, statut=self.translate("Installation du mod"), max=max_step, step=0)
|
||||
|
||||
def replace_file(path, file, subpath="/"):
|
||||
self.Progress(statut=self.translate("Modification de")+f"\n{get_nodir(path)}", add=1)
|
||||
extension = get_extension(path)
|
||||
def replace_file(path, file, subpath="/"):
|
||||
self.Progress(statut=self.translate("Modification de")+f"\n{get_nodir(path)}", add=1)
|
||||
extension = get_extension(path)
|
||||
|
||||
if extension == "szs":
|
||||
if not (os.path.realpath(path) in extracted_file):
|
||||
subprocess.call(["./tools/szs/wszst", "EXTRACT", path, "-d", path + ".d", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
extracted_file.append(os.path.realpath(path))
|
||||
if extension == "szs":
|
||||
if not (os.path.realpath(path) in extracted_file):
|
||||
subprocess.call(["./tools/szs/wszst", "EXTRACT", path, "-d", path + ".d", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
extracted_file.append(os.path.realpath(path))
|
||||
|
||||
szs_extract_path = path + ".d"
|
||||
if os.path.exists(szs_extract_path + subpath):
|
||||
if subpath[-1] == "/":
|
||||
filecopy(f"./file/{file}", szs_extract_path + subpath + file)
|
||||
else:
|
||||
filecopy(f"./file/{file}", szs_extract_path + subpath)
|
||||
szs_extract_path = path + ".d"
|
||||
if os.path.exists(szs_extract_path + subpath):
|
||||
if subpath[-1] == "/":
|
||||
filecopy(f"./file/{file}", szs_extract_path + subpath + file)
|
||||
else:
|
||||
filecopy(f"./file/{file}", szs_extract_path + subpath)
|
||||
|
||||
elif path[-1] == "/":
|
||||
filecopy(f"./file/{file}", path + file)
|
||||
else:
|
||||
filecopy(f"./file/{file}", path)
|
||||
elif path[-1] == "/":
|
||||
filecopy(f"./file/{file}", path + file)
|
||||
else:
|
||||
filecopy(f"./file/{file}", path)
|
||||
|
||||
for fp in fs:
|
||||
for f in glob.glob(self.path_mkwf + "/files/" + fp, recursive=True):
|
||||
if type(fs[fp]) == str:
|
||||
replace_file(path=f, file=fs[fp])
|
||||
elif type(fs[fp]) == dict:
|
||||
for nf in fs[fp]:
|
||||
if type(fs[fp][nf]) == str:
|
||||
replace_file(path=f, subpath=nf, file=fs[fp][nf])
|
||||
elif type(fs[fp][nf]) == list:
|
||||
for ffp in fs[fp][nf]: replace_file(path=f, subpath=nf, file=ffp)
|
||||
for fp in fs:
|
||||
for f in glob.glob(self.path_mkwf + "/files/" + fp, recursive=True):
|
||||
if type(fs[fp]) == str:
|
||||
replace_file(path=f, file=fs[fp])
|
||||
elif type(fs[fp]) == dict:
|
||||
for nf in fs[fp]:
|
||||
if type(fs[fp][nf]) == str:
|
||||
replace_file(path=f, subpath=nf, file=fs[fp][nf])
|
||||
elif type(fs[fp][nf]) == list:
|
||||
for ffp in fs[fp][nf]: replace_file(path=f, subpath=nf, file=ffp)
|
||||
|
||||
for file in extracted_file:
|
||||
self.Progress(statut=self.translate("Recompilation de")+f"\n{get_nodir(file)}", add=1)
|
||||
subprocess.call(["./tools/szs/wszst", "CREATE", file + ".d", "-d", file,
|
||||
"--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
if os.path.exists(file + ".d"): shutil.rmtree(file + ".d")
|
||||
for file in extracted_file:
|
||||
self.Progress(statut=self.translate("Recompilation de")+f"\n{get_nodir(file)}", add=1)
|
||||
subprocess.call(["./tools/szs/wszst", "CREATE", file + ".d", "-d", file,
|
||||
"--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
if os.path.exists(file + ".d"): shutil.rmtree(file + ".d")
|
||||
|
||||
self.Progress(statut=self.translate("Patch main.dol"), add=1)
|
||||
subprocess.call(["./tools/szs/wstrt", "patch", self.path_mkwf + "/sys/main.dol", "--clean-dol",
|
||||
"--add-lecode"], creationflags=CREATE_NO_WINDOW)
|
||||
self.Progress(statut=self.translate("Patch main.dol"), add=1)
|
||||
subprocess.call(["./tools/szs/wstrt", "patch", self.path_mkwf + "/sys/main.dol", "--clean-dol",
|
||||
"--add-lecode"], creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
self.Progress(statut=self.translate("Patch lecode-PAL.bin"), add=1)
|
||||
self.Progress(statut=self.translate("Patch lecode-PAL.bin"), add=1)
|
||||
|
||||
subprocess.call(
|
||||
["./tools/szs/wlect", "patch", "./file/lecode-PAL.bin", "-od", self.path_mkwf + "/files/rel/lecode-PAL.bin",
|
||||
"--track-dir", self.path_mkwf + "/files/Race/Course/", "--copy-tracks", "./file/Track/",
|
||||
"--move-tracks", self.path_mkwf + "/files/Race/Course/", "--le-define",
|
||||
"./file/CTFILE.txt", "--lpar", "./file/lpar-default.txt", "--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
subprocess.call(
|
||||
["./tools/szs/wlect", "patch", "./file/lecode-PAL.bin", "-od", self.path_mkwf +
|
||||
"/files/rel/lecode-PAL.bin", "--track-dir", self.path_mkwf + "/files/Race/Course/", "--copy-tracks",
|
||||
"./file/Track/", "--move-tracks", self.path_mkwf + "/files/Race/Course/", "--le-define",
|
||||
"./file/CTFILE.txt", "--lpar", "./file/lpar-default.txt", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
outputformat = self.listbox_outputformat.get()
|
||||
self.Progress(statut=self.translate("Conversion en")+f" {outputformat}", add=1)
|
||||
outputformat = self.listbox_outputformat.get()
|
||||
self.Progress(statut=self.translate("Conversion en")+f" {outputformat}", add=1)
|
||||
|
||||
if outputformat in ["ISO", "WBFS", "CISO"]:
|
||||
self.path_mkwf_format = os.path.realpath(self.path_mkwf + "/../MKWFaraphel." + outputformat.lower())
|
||||
subprocess.call(["./tools/wit/wit", "COPY", self.path_mkwf, "--DEST",
|
||||
self.path_mkwf_format, f"--{outputformat.lower()}", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
shutil.rmtree(self.path_mkwf)
|
||||
if outputformat in ["ISO", "WBFS", "CISO"]:
|
||||
self.path_mkwf_format = os.path.realpath(self.path_mkwf + "/../MKWFaraphel." + outputformat.lower())
|
||||
subprocess.call(["./tools/wit/wit", "COPY", self.path_mkwf, "--DEST",
|
||||
self.path_mkwf_format, f"--{outputformat.lower()}", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
shutil.rmtree(self.path_mkwf)
|
||||
|
||||
self.Progress(statut=self.translate("Changement de l'ID du jeu"), add=1)
|
||||
subprocess.call(["./tools/wit/wit", "EDIT", self.path_mkwf_format, "--id", "RMCP60"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
self.Progress(statut=self.translate("Changement de l'ID du jeu"), add=1)
|
||||
subprocess.call(["./tools/wit/wit", "EDIT", self.path_mkwf_format, "--id", "RMCP60"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
self.Progress(show=False)
|
||||
messagebox.showinfo(self.translate("Fin"), self.translate("L'installation est terminé !"))
|
||||
self.Progress(show=False)
|
||||
messagebox.showinfo(self.translate("Fin"), self.translate("L'installation est terminé !"))
|
||||
|
||||
except:
|
||||
self.log_error()
|
||||
|
||||
t = Thread(target=func)
|
||||
t.setDaemon(True)
|
||||
|
|
4
source/log_error.py
Normal file
4
source/log_error.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
import traceback
|
||||
|
||||
def log_error(self, exception):
|
||||
with open("error.log", "a") as f: f.write(f"---\n{traceback.format_exc()}\n")
|
|
@ -85,62 +85,66 @@ trackname_color = {
|
|||
}
|
||||
|
||||
def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /files/Scene/UI/ du jeu
|
||||
bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier
|
||||
self.Progress(statut=self.translate("Patch des textes " + bmglang), add=1)
|
||||
try:
|
||||
bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier
|
||||
self.Progress(statut=self.translate("Patch des textes " + bmglang), add=1)
|
||||
|
||||
subprocess.call(["./tools/szs/wszst", "EXTRACT", gamefile, "-d", gamefile + ".d", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
subprocess.call(["./tools/szs/wszst", "EXTRACT", gamefile, "-d", gamefile + ".d", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
# Common.bmg
|
||||
bmgtracks = subprocess.check_output(["./tools/szs/wbmgt", "CAT", gamefile + ".d/message/Common.bmg"],
|
||||
creationflags=CREATE_NO_WINDOW)
|
||||
bmgtracks = bmgtracks.decode()
|
||||
trackheader = "#--- standard track names"
|
||||
trackend = "2328"
|
||||
bmgtracks = bmgtracks[bmgtracks.find(trackheader) + len(trackheader):bmgtracks.find(trackend)]
|
||||
# Common.bmg
|
||||
bmgtracks = subprocess.check_output(["./tools/szs/wbmgt", "CAT", gamefile + ".d/message/Common.bmg"],
|
||||
creationflags=CREATE_NO_WINDOW)
|
||||
bmgtracks = bmgtracks.decode()
|
||||
trackheader = "#--- standard track names"
|
||||
trackend = "2328"
|
||||
bmgtracks = bmgtracks[bmgtracks.find(trackheader) + len(trackheader):bmgtracks.find(trackend)]
|
||||
|
||||
with open("./file/ExtraCommon.txt", "w") as f:
|
||||
f.write("#BMG\n\n"
|
||||
f" 703e\t= {self.translate('Aléatoire: Toutes les pistes', lang=bmglang)}\n"
|
||||
f" 703f\t= {self.translate('Aléatoire: Pistes Originales', lang=bmglang)}\n"
|
||||
f" 7040\t= {self.translate('Aléatoire: Custom Tracks', lang=bmglang)}\n"
|
||||
f" 7041\t= {self.translate('Aléatoire: Pistes Nouvelles', lang=bmglang)}\n")
|
||||
with open("./file/ExtraCommon.txt", "w") as f:
|
||||
f.write("#BMG\n\n"
|
||||
f" 703e\t= {self.translate('Aléatoire: Toutes les pistes', lang=bmglang)}\n"
|
||||
f" 703f\t= {self.translate('Aléatoire: Pistes Originales', lang=bmglang)}\n"
|
||||
f" 7040\t= {self.translate('Aléatoire: Custom Tracks', lang=bmglang)}\n"
|
||||
f" 7041\t= {self.translate('Aléatoire: Pistes Nouvelles', lang=bmglang)}\n")
|
||||
|
||||
for bmgtrack in bmgtracks.split("\n"):
|
||||
if "=" in bmgtrack:
|
||||
for bmgtrack in bmgtracks.split("\n"):
|
||||
if "=" in bmgtrack:
|
||||
|
||||
prefix = ""
|
||||
if "T" in bmgtrack[:bmgtrack.find("=")]:
|
||||
sTid = bmgtrack.find("T")
|
||||
Tid = bmgtrack[sTid:sTid + 3]
|
||||
if Tid[1] in "1234": prefix = "Wii " # Si la course est original à la wii
|
||||
Tid = hex(bmgID_track_move[Tid])[2:]
|
||||
prefix = ""
|
||||
if "T" in bmgtrack[:bmgtrack.find("=")]:
|
||||
sTid = bmgtrack.find("T")
|
||||
Tid = bmgtrack[sTid:sTid + 3]
|
||||
if Tid[1] in "1234": prefix = "Wii " # Si la course est original à la wii
|
||||
Tid = hex(bmgID_track_move[Tid])[2:]
|
||||
|
||||
else: # Arena
|
||||
sTid = bmgtrack.find("U") + 1
|
||||
Tid = bmgtrack[sTid:sTid + 2]
|
||||
Tid = hex((int(Tid[0]) - 1) * 5 + (int(Tid[1]) - 1) + 0x7020)[2:]
|
||||
else: # Arena
|
||||
sTid = bmgtrack.find("U") + 1
|
||||
Tid = bmgtrack[sTid:sTid + 2]
|
||||
Tid = hex((int(Tid[0]) - 1) * 5 + (int(Tid[1]) - 1) + 0x7020)[2:]
|
||||
|
||||
Tname = bmgtrack[bmgtrack.find("= ") + 2:]
|
||||
f.write(f" {Tid}\t= {prefix}{Tname}\n")
|
||||
Tname = bmgtrack[bmgtrack.find("= ") + 2:]
|
||||
f.write(f" {Tid}\t= {prefix}{Tname}\n")
|
||||
|
||||
bmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/CTFILE.txt",
|
||||
"--patch-bmg", "OVERWRITE=" + gamefile + ".d/message/Common.bmg",
|
||||
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
||||
creationflags=CREATE_NO_WINDOW).decode()
|
||||
rbmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/RCTFILE.txt",
|
||||
"--patch-bmg", "OVERWRITE=" + gamefile + ".d/message/Common.bmg",
|
||||
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
||||
creationflags=CREATE_NO_WINDOW).decode()
|
||||
bmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/CTFILE.txt",
|
||||
"--patch-bmg", "OVERWRITE=" + gamefile + ".d/message/Common.bmg",
|
||||
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
||||
creationflags=CREATE_NO_WINDOW).decode()
|
||||
rbmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/RCTFILE.txt",
|
||||
"--patch-bmg", "OVERWRITE=" + gamefile + ".d/message/Common.bmg",
|
||||
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
||||
creationflags=CREATE_NO_WINDOW).decode()
|
||||
|
||||
shutil.rmtree(gamefile + ".d")
|
||||
os.remove("./file/ExtraCommon.txt")
|
||||
shutil.rmtree(gamefile + ".d")
|
||||
os.remove("./file/ExtraCommon.txt")
|
||||
|
||||
def finalise(common_file, bmgtext):
|
||||
for console in trackname_color: bmgtext = bmgtext.replace(console, trackname_color[console])
|
||||
with open(common_file, "w", encoding="utf-8") as f: f.write(bmgtext)
|
||||
subprocess.call(["./tools/szs/wbmgt", "ENCODE", common_file, "--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
os.remove(common_file)
|
||||
def finalise(common_file, bmgtext):
|
||||
for console in trackname_color: bmgtext = bmgtext.replace(console, trackname_color[console])
|
||||
with open(common_file, "w", encoding="utf-8") as f: f.write(bmgtext)
|
||||
subprocess.call(["./tools/szs/wbmgt", "ENCODE", common_file, "--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
os.remove(common_file)
|
||||
|
||||
finalise(f"./file/Common_{bmglang}.txt", bmgtext)
|
||||
finalise(f"./file/Common_R{bmglang}.txt", rbmgtext)
|
||||
finalise(f"./file/Common_{bmglang}.txt", bmgtext)
|
||||
finalise(f"./file/Common_R{bmglang}.txt", rbmgtext)
|
||||
|
||||
except:
|
||||
self.log_error()
|
||||
|
|
|
@ -5,37 +5,41 @@ import os
|
|||
|
||||
|
||||
def patch_ct_icon(self):
|
||||
with open("./ct_config.json", encoding="utf8") as f: config = json.load(f)
|
||||
try:
|
||||
with open("./ct_config.json", encoding="utf8") as f: config = json.load(f)
|
||||
|
||||
cup_number = len(config["cup"]) + math.ceil(len(config["tracks_list"]) / 4)
|
||||
ct_icon = Image.new("RGBA", (128, 128 * (cup_number + 2)))
|
||||
cup_number = len(config["cup"]) + math.ceil(len(config["tracks_list"]) / 4)
|
||||
ct_icon = Image.new("RGBA", (128, 128 * (cup_number + 2)))
|
||||
|
||||
files = ["left", "right"]
|
||||
files.extend(config["cup"].keys())
|
||||
files.extend(["_"] * ((len(config["tracks_list"]) // 4) + 1))
|
||||
files = ["left", "right"]
|
||||
files.extend(config["cup"].keys())
|
||||
files.extend(["_"] * ((len(config["tracks_list"]) // 4) + 1))
|
||||
|
||||
for i, id in enumerate(files):
|
||||
if os.path.exists(f"./file/cup_icon/{id}.png"):
|
||||
cup_icon = Image.open(f"./file/cup_icon/{id}.png").resize((128, 128))
|
||||
for i, id in enumerate(files):
|
||||
if os.path.exists(f"./file/cup_icon/{id}.png"):
|
||||
cup_icon = Image.open(f"./file/cup_icon/{id}.png").resize((128, 128))
|
||||
|
||||
else:
|
||||
cup_icon = Image.new("RGBA", (128, 128))
|
||||
draw = ImageDraw.Draw(cup_icon)
|
||||
font = ImageFont.truetype("./file/SuperMario256.ttf", 90)
|
||||
draw.text((4 - 2, 4 - 2), "CT", (0, 0, 0), font=font)
|
||||
draw.text((4 + 2, 4 - 2), "CT", (0, 0, 0), font=font)
|
||||
draw.text((4 - 2, 4 + 2), "CT", (0, 0, 0), font=font)
|
||||
draw.text((4 + 2, 4 + 2), "CT", (0, 0, 0), font=font)
|
||||
draw.text((4, 4), "CT", (255, 165, 0), font=font)
|
||||
else:
|
||||
cup_icon = Image.new("RGBA", (128, 128))
|
||||
draw = ImageDraw.Draw(cup_icon)
|
||||
font = ImageFont.truetype("./file/SuperMario256.ttf", 90)
|
||||
draw.text((4 - 2, 4 - 2), "CT", (0, 0, 0), font=font)
|
||||
draw.text((4 + 2, 4 - 2), "CT", (0, 0, 0), font=font)
|
||||
draw.text((4 - 2, 4 + 2), "CT", (0, 0, 0), font=font)
|
||||
draw.text((4 + 2, 4 + 2), "CT", (0, 0, 0), font=font)
|
||||
draw.text((4, 4), "CT", (255, 165, 0), font=font)
|
||||
|
||||
font = ImageFont.truetype("./file/SuperMario256.ttf", 60)
|
||||
draw.text((5 - 2, 80 - 2), "%03i" % (i-10), (0, 0, 0), font=font) # i-10 car on ne compte pas les 8 coupes
|
||||
draw.text((5 + 2, 80 - 2), "%03i" % (i-10), (0, 0, 0), font=font) # de base (0-7), la coupe aléatoire, et
|
||||
draw.text((5 - 2, 80 + 2), "%03i" % (i-10), (0, 0, 0), font=font) # les icones droite et gauche.
|
||||
draw.text((5 + 2, 80 + 2), "%03i" % (i-10), (0, 0, 0), font=font)
|
||||
font = ImageFont.truetype("./file/SuperMario256.ttf", 60)
|
||||
draw.text((5 - 2, 80 - 2), "%03i" % (i-10), (0, 0, 0), font=font) # i-10 car on ne compte pas les 8 coupes
|
||||
draw.text((5 + 2, 80 - 2), "%03i" % (i-10), (0, 0, 0), font=font) # de base (0-7), la coupe aléatoire, et
|
||||
draw.text((5 - 2, 80 + 2), "%03i" % (i-10), (0, 0, 0), font=font) # les icones droite et gauche.
|
||||
draw.text((5 + 2, 80 + 2), "%03i" % (i-10), (0, 0, 0), font=font)
|
||||
|
||||
draw.text((5, 80), "%03i" % (i-10), (255, 165, 0), font=font)
|
||||
draw.text((5, 80), "%03i" % (i-10), (255, 165, 0), font=font)
|
||||
|
||||
ct_icon.paste(cup_icon, (0, i * 128))
|
||||
ct_icon.paste(cup_icon, (0, i * 128))
|
||||
|
||||
ct_icon.save("./file/ct_icons.tpl.png")
|
||||
ct_icon.save("./file/ct_icons.tpl.png")
|
||||
|
||||
except:
|
||||
self.log_error()
|
||||
|
|
|
@ -9,65 +9,69 @@ from .definition import *
|
|||
|
||||
def patch_file(self):
|
||||
def func():
|
||||
if os.path.exists("./file/Track-WU8/"):
|
||||
total_track = len(os.listdir("./file/Track-WU8/"))
|
||||
else:
|
||||
total_track = 0
|
||||
with open("./convert_file.json") as f:
|
||||
fc = json.load(f)
|
||||
max_step = len(fc["img"]) + total_track + 3 + len("EGFIS")
|
||||
self.Progress(show=True, indeter=False, statut=self.translate("Conversion des fichiers"), max=max_step, step=0)
|
||||
try:
|
||||
if os.path.exists("./file/Track-WU8/"):
|
||||
total_track = len(os.listdir("./file/Track-WU8/"))
|
||||
else:
|
||||
total_track = 0
|
||||
with open("./convert_file.json") as f:
|
||||
fc = json.load(f)
|
||||
max_step = len(fc["img"]) + total_track + 3 + len("EGFIS")
|
||||
self.Progress(show=True, indeter=False, statut=self.translate("Conversion des fichiers"), max=max_step, step=0)
|
||||
|
||||
self.Progress(statut=self.translate("Configuration de LE-CODE"), add=1)
|
||||
self.create_lecode_config()
|
||||
self.Progress(statut=self.translate("Configuration de LE-CODE"), add=1)
|
||||
self.create_lecode_config()
|
||||
|
||||
self.Progress(statut=self.translate("Création de ct_icon.png"), add=1)
|
||||
self.patch_ct_icon()
|
||||
self.Progress(statut=self.translate("Création de ct_icon.png"), add=1)
|
||||
self.patch_ct_icon()
|
||||
|
||||
self.Progress(statut=self.translate("Création des images descriptives"), add=1)
|
||||
self.patch_img_desc()
|
||||
self.Progress(statut=self.translate("Création des images descriptives"), add=1)
|
||||
self.patch_img_desc()
|
||||
|
||||
for i, file in enumerate(fc["img"]):
|
||||
self.Progress(statut=self.translate("Conversion des images")+f"\n({i + 1}/{len(fc['img'])}) {file}", add=1)
|
||||
subprocess.call(["./tools/szs/wimgt", "ENCODE", "./file/" + file, "-x", fc["img"][file], "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
for i, file in enumerate(fc["img"]):
|
||||
self.Progress(statut=self.translate("Conversion des images")+f"\n({i + 1}/{len(fc['img'])}) {file}", add=1)
|
||||
subprocess.call(["./tools/szs/wimgt", "ENCODE", "./file/" + file, "-x", fc["img"][file], "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
for file in glob.glob(self.path_mkwf+"/files/Scene/UI/MenuSingle_?.szs"):
|
||||
self.patch_bmg(file)
|
||||
for file in glob.glob(self.path_mkwf+"/files/Scene/UI/MenuSingle_?.szs"):
|
||||
self.patch_bmg(file)
|
||||
|
||||
if not (os.path.exists("./file/auto-add/")):
|
||||
subprocess.call(["./tools/szs/wszst", "AUTOADD", self.path_mkwf + "/files/Race/Course/", "--DEST",
|
||||
"./file/auto-add/"], creationflags=CREATE_NO_WINDOW)
|
||||
if not (os.path.exists("./file/auto-add/")):
|
||||
subprocess.call(["./tools/szs/wszst", "AUTOADD", self.path_mkwf + "/files/Race/Course/", "--DEST",
|
||||
"./file/auto-add/"], creationflags=CREATE_NO_WINDOW)
|
||||
|
||||
max_process = 8
|
||||
process_list = {}
|
||||
max_process = 8
|
||||
process_list = {}
|
||||
|
||||
for i, file in enumerate(os.listdir("./file/Track-WU8/")):
|
||||
while True:
|
||||
if len(process_list) < max_process:
|
||||
process_list[file] = None
|
||||
self.Progress(statut=self.translate("Conversion des courses")+f"\n({i + 1}/{total_track})\n" +
|
||||
"\n".join(process_list.keys()), add=1)
|
||||
for i, file in enumerate(os.listdir("./file/Track-WU8/")):
|
||||
while True:
|
||||
if len(process_list) < max_process:
|
||||
process_list[file] = None
|
||||
self.Progress(statut=self.translate("Conversion des courses")+f"\n({i + 1}/{total_track})\n" +
|
||||
"\n".join(process_list.keys()), add=1)
|
||||
|
||||
if not (os.path.exists("./file/Track/" + get_filename(file) + ".szs")):
|
||||
process_list[file] = subprocess.Popen([
|
||||
"./tools/szs/wszst", "NORMALIZE", "./file/Track-WU8/" + file, "--DEST",
|
||||
"./file/Track/%N.szs", "--szs", "--overwrite", "--autoadd-path",
|
||||
"./file/auto-add/"], creationflags=CREATE_NO_WINDOW)
|
||||
break
|
||||
else:
|
||||
for process in process_list:
|
||||
if process_list[process] is not None:
|
||||
if not (process_list[process].poll() is None):
|
||||
if not (os.path.exists("./file/Track/" + get_filename(file) + ".szs")):
|
||||
process_list[file] = subprocess.Popen([
|
||||
"./tools/szs/wszst", "NORMALIZE", "./file/Track-WU8/" + file, "--DEST",
|
||||
"./file/Track/%N.szs", "--szs", "--overwrite", "--autoadd-path",
|
||||
"./file/auto-add/"], creationflags=CREATE_NO_WINDOW)
|
||||
break
|
||||
else:
|
||||
for process in process_list:
|
||||
if process_list[process] is not None:
|
||||
if not (process_list[process].poll() is None):
|
||||
process_list.pop(process)
|
||||
break
|
||||
else:
|
||||
process_list.pop(process)
|
||||
break
|
||||
else:
|
||||
process_list.pop(process)
|
||||
break
|
||||
|
||||
self.Progress(show=False)
|
||||
self.button_install_mod.grid(row=2, column=1, sticky="NEWS")
|
||||
self.listbox_outputformat.grid(row=2, column=2, sticky="NEWS")
|
||||
self.Progress(show=False)
|
||||
self.button_install_mod.grid(row=2, column=1, sticky="NEWS")
|
||||
self.listbox_outputformat.grid(row=2, column=2, sticky="NEWS")
|
||||
|
||||
except:
|
||||
self.log_error()
|
||||
|
||||
t = Thread(target=func)
|
||||
t.setDaemon(True)
|
||||
|
|
|
@ -5,21 +5,25 @@ from .definition import *
|
|||
|
||||
|
||||
def patch_img_desc(self):
|
||||
il = Image.open("./file/img_desc/illustration.png")
|
||||
il_16_9 = il.resize((832, 456))
|
||||
il_4_3 = il.resize((608, 456))
|
||||
try:
|
||||
il = Image.open("./file/img_desc/illustration.png")
|
||||
il_16_9 = il.resize((832, 456))
|
||||
il_4_3 = il.resize((608, 456))
|
||||
|
||||
for file_lang in glob.glob("./file/img_desc/??.png"):
|
||||
img_lang = Image.open(file_lang)
|
||||
img_lang_16_9 = img_lang.resize((832, 456))
|
||||
img_lang_4_3 = img_lang.resize((608, 456))
|
||||
for file_lang in glob.glob("./file/img_desc/??.png"):
|
||||
img_lang = Image.open(file_lang)
|
||||
img_lang_16_9 = img_lang.resize((832, 456))
|
||||
img_lang_4_3 = img_lang.resize((608, 456))
|
||||
|
||||
new_16_9 = Image.new("RGBA", (832, 456), (0, 0, 0, 255))
|
||||
new_16_9.paste(il_16_9, (0, 0), il_16_9)
|
||||
new_16_9.paste(img_lang_16_9, (0, 0), img_lang_16_9)
|
||||
new_16_9.save(f"./file/strapA_16_9_832x456{get_filename(get_nodir(file_lang))}.png")
|
||||
new_16_9 = Image.new("RGBA", (832, 456), (0, 0, 0, 255))
|
||||
new_16_9.paste(il_16_9, (0, 0), il_16_9)
|
||||
new_16_9.paste(img_lang_16_9, (0, 0), img_lang_16_9)
|
||||
new_16_9.save(f"./file/strapA_16_9_832x456{get_filename(get_nodir(file_lang))}.png")
|
||||
|
||||
new_4_3 = Image.new("RGBA", (608, 456), (0, 0, 0, 255))
|
||||
new_4_3.paste(il_4_3, (0, 0), il_4_3)
|
||||
new_4_3.paste(img_lang_4_3, (0, 0), img_lang_4_3)
|
||||
new_4_3.save(f"./file/strapA_608x456{get_filename(get_nodir(file_lang))}.png")
|
||||
new_4_3 = Image.new("RGBA", (608, 456), (0, 0, 0, 255))
|
||||
new_4_3.paste(il_4_3, (0, 0), il_4_3)
|
||||
new_4_3.paste(img_lang_4_3, (0, 0), img_lang_4_3)
|
||||
new_4_3.save(f"./file/strapA_608x456{get_filename(get_nodir(file_lang))}.png")
|
||||
|
||||
except:
|
||||
self.log_error()
|
||||
|
|
Loading…
Reference in a new issue