preparing bmg patch

This commit is contained in:
Faraphel 2022-07-09 22:09:07 +02:00
parent 093319eece
commit dde5a134a5
9 changed files with 227 additions and 179 deletions

View file

@ -2,7 +2,8 @@
"mode": "edit",
"operation": {
"bmg-edit": {
"bmg-edit": [
{
"mode": "regex",
"data": {
"CWF de Nintendo": "{{ONLINE_SERVICE}}",
@ -20,5 +21,6 @@
"Mario Kart Wii": "{{MOD_NICKNAME}} {{MOD_VERSION}} {{MOD_CUSTOMIZED}}"
}
}
]
}
}

View file

@ -1,7 +1,8 @@
{
"mode": "edit",
"operation": {
"bmg-edit": {
"bmg-edit": [
{
"mode": "id",
"data": {
"0x703e": "\\c{white}Random: All tracks",
@ -42,5 +43,6 @@
"M67": "\\c{YOR4}Game : 64 races"
}
}
]
}
}

View file

@ -1,7 +1,8 @@
{
"mode": "edit",
"operation": {
"bmg-edit": {
"bmg-edit": [
{
"mode": "id",
"data": {
"0x703e": "\\c{white}Aleatorio: Todas las pistas",
@ -42,5 +43,6 @@
"M67": "\\c{YOR4}Partido : 64 pistas"
}
}
]
}
}

View file

@ -1,7 +1,8 @@
{
"mode": "edit",
"operation": {
"bmg-edit": {
"bmg-edit": [
{
"mode": "id",
"data": {
"0x703e": "\\c{white}Aléatoire: Toutes les pistes",
@ -42,5 +43,6 @@
"M67": "\\c{YOR4}Partie : 64 courses"
}
}
]
}
}

View file

@ -1,7 +1,8 @@
{
"mode": "edit",
"operation": {
"bmg-edit": {
"bmg-edit": [
{
"mode": "id",
"data": {
"0x703e": "\\c{white}Zufällig: Alle Tracks",
@ -42,5 +43,6 @@
"M67": "\\c{YOR4}Spiel : 64 Tracks"
}
}
]
}
}

View file

@ -1,7 +1,8 @@
{
"mode": "edit",
"operation": {
"bmg-edit": {
"bmg-edit": [
{
"mode": "id",
"data": {
"0x703e": "\\c{white}Casuale: Tutte le tracce",
@ -42,5 +43,6 @@
"M67": "\\c{YOR4}Gioco : 64 pistas"
}
}
]
}
}

View file

@ -249,8 +249,13 @@ class PatchOperation:
type = "bmg-edit"
def __init__(self, *args, **kwargs):
print(args, kwargs)
def __init__(self, layers: list[dict]):
"""
:param layers: all the bmg patch to apply
"""
self.layers = layers
def patch(self, patch: "Patch", file_name: str, file_content: IO) -> (str, IO):
print(file_content)
return file_name, file_content

View file

@ -0,0 +1,31 @@
from source.wt import *
from source.wt import _run
tools_path = tools_szs_dir / ("wimgt.exe" if system == "win64" else "wimgt")
@better_wt_error(tools_path)
class BMGPath:
"""
Represent a path to a bmg file (game file containing text data)
"""
__slots__ = ("path",)
def __init__(self, path: Path | str):
self.path: Path = Path(path)
@better_wt_error(tools_path)
def _run(self, *args) -> bytes:
"""
Return a command with wbmgt and return the output
:param args: command arguments
:return: the output of the command
"""
return _run(tools_path, *args)
def get_decoded_data(self):
"""
Return the decoded content of the bmg file
:return:
"""
return self._run("DECODE", self.path, "--DEST", "-")

View file

@ -7,7 +7,7 @@ tools_path = tools_szs_dir / ("wimgt.exe" if system == "win64" else "wimgt")
@better_wt_error(tools_path)
class IMGPath:
"""
Represent a path to an image
Represent a path to a normal image, that can be converted into game image data
"""
__slots__ = ("path", )
@ -17,7 +17,7 @@ class IMGPath:
@better_wt_error(tools_path)
def _run(self, *args) -> bytes:
"""
Return a command with wszst and return the output
Return a command with wimgt and return the output
:param args: command arguments
:return: the output of the command
"""