diff --git a/Pack/MKWFaraphel/essentials/_PATCH/files/rel/StaticR.rel b/Pack/MKWFaraphel/essentials/_PATCH/files/rel/StaticR.rel new file mode 100644 index 0000000..e69de29 diff --git a/Pack/MKWFaraphel/essentials/_PATCH/files/rel/StaticR.rel.json b/Pack/MKWFaraphel/essentials/_PATCH/files/rel/StaticR.rel.json new file mode 100644 index 0000000..c86748c --- /dev/null +++ b/Pack/MKWFaraphel/essentials/_PATCH/files/rel/StaticR.rel.json @@ -0,0 +1,4 @@ +{ + "mode": "edit", + "base": "sys/main.dol.json" +} \ No newline at end of file diff --git a/source/mkw/Patch/PatchOperation.py b/source/mkw/Patch/PatchOperation.py index 99a0583..374812e 100644 --- a/source/mkw/Patch/PatchOperation.py +++ b/source/mkw/Patch/PatchOperation.py @@ -7,7 +7,7 @@ from PIL import Image, ImageDraw, ImageFont from source.mkw.Patch import * from source.wt import img, bmg -from source.wt import str as wstrt +from source.wt import wstrt as wstrt Patch: any Layer: any @@ -405,10 +405,10 @@ class PatchOperation: patch_content = BytesIO( wstrt.patch_data( file_content.read(), - self.region, - self.https, - self.domain, - checked_sections + region=self.region, + https=self.https, + domain=self.domain, + sections=checked_sections ) ) diff --git a/source/wt/str.py b/source/wt/wstrt.py similarity index 53% rename from source/wt/str.py rename to source/wt/wstrt.py index e572921..3323093 100644 --- a/source/wt/str.py +++ b/source/wt/wstrt.py @@ -25,9 +25,38 @@ def patch_data(dol_data: bytes, region: int = None, https: str = None, domain: s for section in sections if sections is not None else []: args.extend(["--add-section", section]) - process = _tools_run_popen("PATCH", "-", "--DEST", "-", "--clean-dol", "--add-lecode", *args) + process = _tools_run_popen("PATCH", "-", "--DEST", "-", *args) stdout, _ = process.communicate(input=dol_data) if process.returncode != 0: raise WTError(tools_path, process.returncode) return stdout + + +class StrPath: + """ + File representing a main.dol file + """ + + __slots__ = ("path",) + + def __init__(self, path: "Path | str"): + self.path: Path = Path(path) + + def patch(self, clean_dol: bool = False, add_lecode: bool = False, + region: int = None, https: str = None, domain: str = None, + sections: list[Path] = None) -> None: + """ + See "patch_data". Also patch StaticR.rel. + :return: + """ + args = [] + if clean_dol: args.append("--clean-dol") + if add_lecode: args.append("--add-lecode") + if region is not None: args.extend(["--region", region]) + if https is not None: args.extend(["--https", https]) + if domain is not None: args.extend(["--domain", domain]) + for section in sections if sections is not None else []: + args.extend(["--add-section", section]) + + _tools_run("PATCH", self.path, (self.path / "../../files/rel/StaticR.rel").resolve(), "--overwrite", *args)