mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-02 18:58:27 +02:00
implemented Game conversion to WBFS / ISO / CISO after installing the mod
This commit is contained in:
parent
cd61ce59c4
commit
94dddac6d4
4 changed files with 41 additions and 3 deletions
|
@ -259,7 +259,7 @@ class SourceGame(ttk.LabelFrame):
|
|||
"""
|
||||
path = Path(tkinter.filedialog.askopenfilename(
|
||||
title=_("SELECT_SOURCE_GAME"),
|
||||
filetypes=[(_("WII GAMES"), "*.iso *.wbfs *.dol")],
|
||||
filetypes=[(_("WII GAMES"), "*.iso *.ciso *.wbfs *.dol")],
|
||||
))
|
||||
# if the user didn't select any file, return None
|
||||
if not path.exists():
|
||||
|
|
|
@ -5,7 +5,7 @@ from typing import Generator, IO
|
|||
|
||||
from source.mkw.ModConfig import ModConfig
|
||||
from source.mkw.Patch.Patch import Patch
|
||||
from source.wt import szs, lec
|
||||
from source.wt import szs, lec, wit
|
||||
from source.wt.wstrt import StrPath
|
||||
|
||||
|
||||
|
@ -155,3 +155,27 @@ class ExtractedGame:
|
|||
for patch_directory in part_directory.glob("_PATCH/"):
|
||||
yield from Patch(patch_directory, mod_config, self._special_file).install(self)
|
||||
|
||||
def convert_to(self, output_type: wit.Extension) -> Generator[dict, None, None]:
|
||||
"""
|
||||
Convert the extracted game to another format
|
||||
:param output_type: path to the destination of the game
|
||||
:output_type: format of the destination game
|
||||
"""
|
||||
yield {"description": f"Converting game to {output_type}", "determinate": False}
|
||||
if output_type == wit.Extension.FST: return
|
||||
|
||||
destination_file = self.path.with_suffix(self.path.suffix + output_type.value)
|
||||
dest_name: str = destination_file.name
|
||||
|
||||
i: int = 0
|
||||
while destination_file.exists():
|
||||
i += 1
|
||||
destination_file = destination_file.with_name(dest_name + f" ({i})")
|
||||
|
||||
wit.copy(
|
||||
source_directory=self.path,
|
||||
destination_file=destination_file,
|
||||
)
|
||||
|
||||
yield {"description": "Deleting the extracted game...", "determinate": False}
|
||||
shutil.rmtree(self.path)
|
||||
|
|
|
@ -139,3 +139,5 @@ class Game:
|
|||
cache_ogtracks_directory,
|
||||
)
|
||||
|
||||
# convert the extracted game into a file
|
||||
yield from extracted_game.convert_to(output_type)
|
||||
|
|
|
@ -13,13 +13,25 @@ _tools_run_dict = get_tools_run_dict_function(tools_path)
|
|||
_tools_run_popen = get_tools_run_popen_function(tools_path)
|
||||
|
||||
|
||||
def copy(source_directory: Path | str, destination_file: Path | str):
|
||||
"""
|
||||
Copy a game directory to a game file with a specific format.
|
||||
:param source_directory: path to the extracted game
|
||||
:param destination_file: path to the destination game
|
||||
:return: the destination game path
|
||||
"""
|
||||
_tools_run("COPY", source_directory, "--DEST", destination_file)
|
||||
return Path(destination_file)
|
||||
|
||||
|
||||
class Extension(enum.Enum):
|
||||
"""
|
||||
Enum for game extension
|
||||
"""
|
||||
WBFS = ".wbfs"
|
||||
ISO = ".iso"
|
||||
FST = ".dol"
|
||||
CISO = ".ciso"
|
||||
ISO = ".iso"
|
||||
|
||||
@classmethod
|
||||
def _missing_(cls, value: str) -> "Extension | None":
|
||||
|
|
Loading…
Reference in a new issue