added support for all other lecode region

This commit is contained in:
raphael60650 2021-06-16 10:52:16 +02:00
parent 3b1294133d
commit 63456239e1
2 changed files with 31 additions and 9 deletions

View file

@ -2,6 +2,7 @@ from tkinter import *
from tkinter import messagebox, filedialog, ttk
from threading import Thread
import subprocess
import glob
import os
from .definition import *
@ -46,7 +47,7 @@ def __init__(self):
Button(self.frame_game_path, text="...", relief=RIDGE, command=select_path).grid(row=1, column=2, sticky="NEWS")
self.frame_game_path_action = Frame(self.frame_game_path) # Action Extraire & Tout faire
self.frame_game_path_action = Frame(self.frame_game_path) # Extract and do everything button
self.frame_game_path_action.grid(row=2, column=1, columnspan=2, sticky="NEWS")
self.frame_game_path_action.columnconfigure(1, weight=1)
@ -65,6 +66,7 @@ def __init__(self):
self.translate("Ce dossier sera écrasé si vous installer le mod !\n" +
"Êtes-vous sûr de vouloir l'utiliser ?")):
self.path_mkwf = os.path.realpath(path + "/../../")
else: return
elif extension.upper() in ["ISO", "WBFS", "WIA", "CSIO"]:
# Fiding a directory name that dosen't already exist
directory_name, i = "MKWiiFaraphel", 1
@ -86,14 +88,33 @@ def __init__(self):
self.Progress(show=False)
return
if os.path.exists(self.path_mkwf + "/files/rel/lecode-PAL.bin"):
if glob.glob(self.path_mkwf + "/files/rel/lecode-???.bin"): # if a LECODE file is already here
messagebox.showwarning(self.translate("Attention"),
self.translate("Cette ROM est déjà moddé, " +
"il est déconseillé de l'utiliser pour installer le mod"))
region_ID = {
"J": "JAP",
"P": "PAL",
"K": "KOR",
"E": "USA"
}
try:
with open(self.path_mkwf + "/setup.txt") as f: setup = f.read()
setup = setup[setup.find("!part-id = ")+len("!part-id = "):]
self.original_game_ID = setup[:setup.find("\n")]
except:
messagebox.showwarning(self.translate("Attention"),
self.transate("Impossible de trouver la région de votre jeu.\n"
"la région PAL sera utilisé par défaut."))
self.original_game_ID = "RMCP01"
try: self.original_region = region_ID[self.original_game_ID[3]]
except: self.original_region = "PAL"
self.frame_action.grid(row=3, column=1, sticky="NEWS")
except: self.log_error()
finally:
self.frame_action.grid(row=3, column=1, sticky="NEWS")
self.Progress(show=False)
t = Thread(target=func)

View file

@ -89,18 +89,19 @@ def install_mod(self):
"--add-lecode"], creationflags=CREATE_NO_WINDOW, cwd=get_dir(self.path_mkwf),
check=True, stdout=subprocess.PIPE)
self.Progress(statut=self.translate("Patch lecode-PAL.bin"), add=1)
self.Progress(statut=self.translate("Patch lecode.bin"), add=1)
shutil.copytree("./file/Track/", self.path_mkwf+"/files/Race/Course/", dirs_exist_ok=True)
if not(os.path.exists(self.path_mkwf+"/tmp/")): os.makedirs(self.path_mkwf+"/tmp/")
filecopy("./file/CTFILE.txt", self.path_mkwf+"/tmp/CTFILE.txt")
filecopy("./file/lpar-default.txt", self.path_mkwf + "/tmp/lpar-default.txt")
filecopy("./file/lecode-PAL.bin", self.path_mkwf + "/tmp/lecode-PAL.bin")
filecopy(f"./file/lecode-{self.original_region}.bin", self.path_mkwf + f"/tmp/lecode-{self.original_region}.bin")
subprocess.run(
["./tools/szs/wlect", "patch", "./tmp/lecode-PAL.bin", "-od", "./files/rel/lecode-PAL.bin",
"--track-dir", "./files/Race/Course/", "--move-tracks", "./files/Race/Course/", "--le-define",
"./tmp/CTFILE.txt", "--lpar", "./tmp/lpar-default.txt", "--overwrite"],
["./tools/szs/wlect", "patch", f"./tmp/lecode-{self.original_region}.bin", "-od",
f"./files/rel/lecode-{self.original_region}.bin", "--track-dir", "./files/Race/Course/",
"--move-tracks", "./files/Race/Course/", "--le-define", "./tmp/CTFILE.txt", "--lpar",
"./tmp/lpar-default.txt", "--overwrite"],
creationflags=CREATE_NO_WINDOW, cwd=self.path_mkwf, check=True, stdout=subprocess.PIPE)
shutil.rmtree(self.path_mkwf + "/tmp/")
@ -117,7 +118,7 @@ def install_mod(self):
shutil.rmtree(self.path_mkwf)
self.Progress(statut=self.translate("Changement de l'ID du jeu"), add=1)
subprocess.run(["./tools/wit/wit", "EDIT", get_dir(self.path_mkwf_format), "--id", "RMCP60"],
subprocess.run(["./tools/wit/wit", "EDIT", get_dir(self.path_mkwf_format), "--id", "RMCP60"], # see to maybe change ID to MKWF
creationflags=CREATE_NO_WINDOW, cwd=get_dir(self.path_mkwf_format),
check=True, stdout=subprocess.PIPE)