added LECODE patching (the installer can now output a working game)

This commit is contained in:
Faraphel 2022-07-19 13:42:49 +02:00
parent ea35b09f44
commit db87f6cdd7
2 changed files with 25 additions and 3 deletions

View file

@ -5,7 +5,7 @@ from typing import Generator, IO
from source.mkw.ModConfig import ModConfig from source.mkw.ModConfig import ModConfig
from source.mkw.Patch.Patch import Patch from source.mkw.Patch.Patch import Patch
from source.wt import szs from source.wt import szs, lec
from source.wt.wstrt import StrPath from source.wt.wstrt import StrPath
@ -79,6 +79,29 @@ class ExtractedGame:
szs.create(extracted_szs, extracted_szs.with_suffix(".szs"), overwrite=True) szs.create(extracted_szs, extracted_szs.with_suffix(".szs"), overwrite=True)
shutil.rmtree(str(extracted_szs.resolve())) shutil.rmtree(str(extracted_szs.resolve()))
def patch_lecode(self, mod_config: ModConfig, cache_directory: Path | str) -> Generator[dict, None, None]:
"""
install lecode on the mod
:param cache_directory: Path to the cache
:param mod_config: mod configuration
"""
yield {"description": "Patching LECODE.bin"}
cache_directory = Path(cache_directory)
# write ctfile data to a file in the cache
ct_file = (cache_directory / "ctfile.lpar")
ct_file.write_text(mod_config.get_ctfile())
# TODO: the lpar file should be customizable
for lecode_file in (self.path / "files/rel/").glob("lecode-*.bin"):
lec.patch(
lecode_file=lecode_file,
ct_file=ct_file,
lpar=mod_config.path.parent / "_LPAR/normal.lpar",
game_tracks_directory=self.path / "files/Race/Course/",
copy_tracks_directories=[cache_directory / "original-tracks/", cache_directory / "custom-tracks/"]
)
def install_all_patch(self, mod_config: ModConfig) -> Generator[dict, None, None]: def install_all_patch(self, mod_config: ModConfig) -> Generator[dict, None, None]:
""" """
Install all patchs of the mod_config into the game Install all patchs of the mod_config into the game

View file

@ -120,10 +120,9 @@ class Game:
yield from extracted_game.extract_original_tracks(cache_ogtracks_directory) yield from extracted_game.extract_original_tracks(cache_ogtracks_directory)
yield from mod_config.normalize_all_tracks(cache_autoadd_directory, cache_cttracks_directory, 8) yield from mod_config.normalize_all_tracks(cache_autoadd_directory, cache_cttracks_directory, 8)
print(mod_config.get_ctfile())
# patch the game # patch the game
yield from extracted_game.prepare_dol() yield from extracted_game.prepare_dol()
yield from extracted_game.install_all_patch(mod_config) yield from extracted_game.install_all_patch(mod_config)
yield from extracted_game.recreate_all_szs() yield from extracted_game.recreate_all_szs()
yield from extracted_game.patch_lecode(mod_config, cache_directory)