diff --git a/source/mkw/Game.py b/source/mkw/Game.py index f656e4a..3df687f 100644 --- a/source/mkw/Game.py +++ b/source/mkw/Game.py @@ -111,14 +111,18 @@ class Game: # extract the game yield from self.extract(extracted_game.path) + # install mystuff + yield from extracted_game.install_mystuff() + # prepare the cache # TODO: normalize all tracks should get the threads amount changeable yield from extracted_game.extract_autoadd(cache_autoadd_directory) yield from extracted_game.extract_original_tracks(cache_ogtracks_directory) - yield from mod_config.normalize_all_tracks(cache_autoadd_directory, cache_cttracks_directory) + yield from mod_config.normalize_all_tracks(cache_autoadd_directory, cache_cttracks_directory, 8) + + print(mod_config.get_ctfile()) # patch the game - yield from extracted_game.install_mystuff() yield from extracted_game.prepare_dol() yield from extracted_game.install_all_patch(mod_config) yield from extracted_game.recreate_all_szs() diff --git a/source/wt/lec.py b/source/wt/lec.py index b5a4821..49ef187 100644 --- a/source/wt/lec.py +++ b/source/wt/lec.py @@ -4,28 +4,29 @@ tools_path = tools_szs_dir / "wlect" _tools_run = get_tools_run_function(tools_path) -_tools_run_popen = get_tools_run_popen_function(tools_path) -def patch_data(lecode_data: bytes, game_tracks_directory: Path | str, - copy_tracks_directory: Path | str, move_tracks_directory: Path | str, - ct_file: Path | str, lpar: Path | str) -> bytes: +def patch(lecode_file: "Path | str", ct_file: Path | str, lpar: Path | str, + game_tracks_directory: Path | str = None, + copy_tracks_directories: list[Path | str] = None, + move_tracks_directories: list[Path | str] = None, + ) -> Path: """ Patch a LECODE.bin file content :param lpar: parameter that can be applied to the lecode configuration :param ct_file: file defining track and arena slots - :param move_tracks_directory: tracks to move inside the game - :param copy_tracks_directory: tracks to copy inside the game + :param move_tracks_directories: tracks to move inside the game + :param copy_tracks_directories: tracks to copy inside the game :param game_tracks_directory: directory to all the game tracks - :param lecode_data: LECODE.bin file content - :return: patched LECODE.bin file content + :param lecode_file: LECODE.bin file + :return: path to the patched LECODE file """ args = [] - # TODO: implement args + if game_tracks_directory is not None: args.extend(["--track-dir", game_tracks_directory]) + for copy_tracks_directory in copy_tracks_directories if copy_tracks_directories is not None else []: + args.extend(["--copy-tracks", copy_tracks_directory]) + for move_tracks_directory in move_tracks_directories if move_tracks_directories is not None else []: + args.extend(["--move-tracks", move_tracks_directory]) - process = _tools_run_popen("PATCH", "-", "--DEST", "-", *args) - stdout, _ = process.communicate(input=lecode_data) - if process.returncode != 0: - raise WTError(tools_path, process.returncode) - - return stdout + _tools_run("PATCH", lecode_file, "--le-define", ct_file, "--lpar", lpar, "--overwrite", *args) + return Path(lecode_file)