mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 03:08:29 +02:00
started implementing main.dol and StaticR.rel patching
This commit is contained in:
parent
ea79f49121
commit
7f5e709aec
4 changed files with 39 additions and 6 deletions
0
Pack/MKWFaraphel/essentials/_PATCH/files/rel/StaticR.rel
Normal file
0
Pack/MKWFaraphel/essentials/_PATCH/files/rel/StaticR.rel
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"mode": "edit",
|
||||
"base": "sys/main.dol.json"
|
||||
}
|
|
@ -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
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -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)
|
Loading…
Reference in a new issue