renamed some parameter, all wszst call now have keyword argument only

This commit is contained in:
raphael60650 2021-07-28 19:19:23 +02:00
parent 2baf246599
commit f2807e6f58
6 changed files with 29 additions and 34 deletions

View file

@ -104,12 +104,12 @@ class Game:
"""
if format in ["ISO", "WBFS", "CISO"]:
path_game_format: str = os.path.realpath(self.path + "/../MKWFaraphel." + format.lower())
wit.copy(self.path, path_game_format, format)
wit.copy(src_path=self.path, dst_path=path_game_format, format=format)
shutil.rmtree(self.path)
self.path = path_game_format
self.gui.progress(statut=self.gui.translate("Changing game's ID"), add=1)
wit.edit(self.path, region_ID=self.region_ID, name=f"Mario Kart Wii Faraphel {self.ctconfig.version}")
wit.edit(file=self.path, region_ID=self.region_ID, name=f"Mario Kart Wii Faraphel {self.ctconfig.version}")
def extract(self) -> None:
"""
@ -126,7 +126,7 @@ class Game:
if not (os.path.exists(path_dir)): break
directory_name, i = f"MKWiiFaraphel ({i})", i + 1
wit.extract(self.path, path_dir)
wit.extract(file=self.path, dst_dir=path_dir)
self.path = path_dir
if os.path.exists(self.path + "/DATA"): self.path += "/DATA"
@ -195,7 +195,7 @@ class Game:
if extension == "szs":
if not (os.path.realpath(path) in extracted_file):
szs.extract(path, get_nodir(path))
szs.extract(file=path)
extracted_file.append(os.path.realpath(path))
szs_extract_path = path + ".d"
@ -223,29 +223,26 @@ class Game:
for file in extracted_file:
self.gui.progress(statut=self.gui.translate("Recompilating", "\n", get_nodir(file)), add=1)
szs.create(file)
szs.create(file=file)
if os.path.exists(file + ".d"):
shutil.rmtree(file + ".d")
self.gui.progress(statut=self.gui.translate("Patch main.dol"), add=1)
wstrt.patch(self.path)
wstrt.patch(path=self.path)
self.gui.progress(statut=self.gui.translate("Patch lecode.bin"), add=1)
shutil.copytree("./file/Track/", self.path + "/files/Race/Course/", dirs_exist_ok=True)
if not (os.path.exists(self.path + "/tmp/")): os.makedirs(self.path + "/tmp/")
shutil.copyfile("./file/CTFILE.txt", self.path + "/tmp/CTFILE.txt")
shutil.copyfile("./file/lpar-default.txt", self.path + "/tmp/lpar-default.txt")
shutil.copyfile(f"./file/lecode-{self.region}.bin", self.path + f"/tmp/lecode-{self.region}.bin")
lec.patch(
self.path,
lecode_file=f"./tmp/lecode-{self.region}.bin",
dest_lecode_file=f"./files/rel/lecode-{self.region}.bin",
lecode_file=f"./file/lecode-{self.region}.bin",
dest_lecode_file=f"{self.path}/files/rel/lecode-{self.region}.bin",
game_track_path=f"{self.path}/files/Race/Course/",
move_track_path=f"{self.path}/files/Race/Course/",
ctfile_path="./file/CTFILE.txt",
lpar_path="./file/lpar-default.txt",
)
shutil.rmtree(self.path + "/tmp/")
output_format = self.gui.stringvar_game_format.get()
self.gui.progress(statut=self.gui.translate("Converting to", " ", output_format), add=1)
self.convert_to(output_format)
@ -263,7 +260,7 @@ class Game:
:param auto_add_dir: autoadd directory
"""
if os.path.exists(auto_add_dir): shutil.rmtree(auto_add_dir)
szs.autoadd(self.path, auto_add_dir)
szs.autoadd(path=self.path, dest_dir=auto_add_dir)
def patch_bmg(self, gamefile: str) -> None:
"""
@ -293,8 +290,8 @@ class Game:
szs.extract(file=gamefile)
bmgmenu = bmg.cat(gamefile, ".d/message/Menu.bmg") # Menu.bmg
bmgtracks = bmg.cat(gamefile, ".d/message/Common.bmg") # Common.bmg
bmgmenu = bmg.cat(path=gamefile, subfile=".d/message/Menu.bmg") # Menu.bmg
bmgtracks = bmg.cat(path=gamefile, subfile=".d/message/Common.bmg") # Common.bmg
trackheader = "#--- standard track names"
trackend = "2328"
@ -394,7 +391,7 @@ class Game:
for i, file in enumerate(fc["img"]):
self.gui.progress(statut=self.gui.translate("Converting images") + f"\n({i + 1}/{len(fc['img'])}) {file}",
add=1)
img.encode("./file/" + file, fc["img"][file])
img.encode(file="./file/" + file, format=fc["img"][file])
def patch_img_desc(self, img_desc_path: str = "./file/img_desc", dest_dir: str = "./file") -> None:
"""

View file

@ -60,7 +60,7 @@ class Track:
check if track wu8's sha1 is correct
:return: 0 if yes, -1 if no
"""
if szs.sha1(self.file_wu8) == self.sha1: return 0
if szs.sha1(file=self.file_wu8) == self.sha1: return 0
else: return -1
def convert_wu8_to_szs(self) -> None:

View file

@ -1,11 +1,11 @@
import subprocess
def encode(src_file: str, format: str) -> None:
def encode(file: str, format: str) -> None:
"""
Encode an .png image into a new format
:param src_file: .png image
:param format: new image format
"""
subprocess.run(["./tools/szs/wimgt", "ENCODE", src_file, "-x", format, "--overwrite"],
subprocess.run(["./tools/szs/wimgt", "ENCODE", file, "-x", format, "--overwrite"],
creationflags=subprocess.CREATE_NO_WINDOW, check=True, stdout=subprocess.PIPE)

View file

@ -1,8 +1,7 @@
import subprocess
def patch(path: str,
lecode_file: str = f"./tmp/lecode-PAL.bin",
def patch(lecode_file: str = f"./file/lecode-PAL.bin",
dest_lecode_file: str = f"./files/rel/lecode-PAL.bin",
game_track_path: str = "./files/Race/Course/",
move_track_path: str = "./files/Race/Course/",
@ -10,7 +9,6 @@ def patch(path: str,
lpar_path: str = "./file/lpar-default.txt") -> None:
"""
Patch the file with a lecode file (this is the adding track part)
:param path: path to the game file
:param lecode_file: path to the lecode file
:param dest_lecode_file: destination of the lecode file
:param game_track_path: subpath to the track directory

View file

@ -47,11 +47,11 @@ def create(file: str) -> None:
creationflags=subprocess.CREATE_NO_WINDOW, check=True, stdout=subprocess.PIPE)
def autoadd(file: str, dest_dir: str) -> None:
def autoadd(path: str, dest_dir: str) -> None:
"""
Create an auto_add directory from a game file
:param file: the game's path
:param path: the game's path
:param dest_dir: directory where to store autoadd file
"""
subprocess.run(["./tools/szs/wszst", "AUTOADD", file + "/files/Race/Course/", "--DEST", dest_dir],
subprocess.run(["./tools/szs/wszst", "AUTOADD", path + "/files/Race/Course/", "--DEST", dest_dir],
creationflags=subprocess.CREATE_NO_WINDOW, check=True, stdout=subprocess.PIPE)

View file

@ -1,13 +1,13 @@
import subprocess
def extract(file: str, dest_dir: str) -> None:
def extract(file: str, dst_dir: str) -> None:
"""
extract the game into a directory
:param file: game's file to extract (can be WBFS, ISO, CISO)
:param dest_dir: where to extract the game
:param dst_dir: where to extract the game
"""
subprocess.run(["./tools/wit/wit", "EXTRACT", file, "--DEST", dest_dir],
subprocess.run(["./tools/wit/wit", "EXTRACT", file, "--DEST", dst_dir],
creationflags=subprocess.CREATE_NO_WINDOW)