mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-04 03:38:26 +02:00
added extract game code
This commit is contained in:
parent
42a96db471
commit
6c5f8b1fe8
2 changed files with 37 additions and 3 deletions
|
@ -1,14 +1,44 @@
|
||||||
from .definition import region_ID
|
from . import wszst
|
||||||
|
from .definition import *
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
def __init__(self, path: str, region: str = "PAL"):
|
def __init__(self, path: str, region: str = "PAL", game_ID: str = "RMCP01"):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.region_ID = region_ID[region]
|
self.region_ID = region_ID[region]
|
||||||
self.region = region
|
self.region = region
|
||||||
|
self.game_ID = game_ID
|
||||||
|
|
||||||
def extract_game(self):
|
def extract_game(self):
|
||||||
pass
|
extension = get_extension(self.path)
|
||||||
|
if extension.upper() == "DOL":
|
||||||
|
self.path = os.path.realpath(self.path + "/../../") # main.dol is in PATH/sys/, so go back 2 dir upper
|
||||||
|
|
||||||
|
elif extension.upper() in ["ISO", "WBFS", "CSIO"]:
|
||||||
|
# Fiding a directory name that doesn't already exist
|
||||||
|
directory_name, i = "MKWiiFaraphel", 1
|
||||||
|
while True:
|
||||||
|
self.path = os.path.realpath(self.path + f"/../{directory_name}")
|
||||||
|
if not (os.path.exists(self.path)): break
|
||||||
|
directory_name, i = f"MKWiiFaraphel ({i})", i + 1
|
||||||
|
|
||||||
|
wszst.extract(self.path, self.path)
|
||||||
|
if os.path.exists(self.path + "/DATA"): self.path += "/DATA"
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise Exception("This format is not supported !")
|
||||||
|
|
||||||
|
if glob.glob(self.path + "/files/rel/lecode-???.bin"): # if a LECODE file is already here
|
||||||
|
raise Warning("ROM Already patched") # warning already patched
|
||||||
|
|
||||||
|
with open(self.path + "/setup.txt") as f: setup = f.read()
|
||||||
|
setup = setup[setup.find("!part-id = ") + len("!part-id = "):]
|
||||||
|
self.game_ID = setup[:setup.find("\n")]
|
||||||
|
|
||||||
|
self.region_ID = self.game_ID[3]
|
||||||
|
self.region = region_ID[self.region_ID] if self.region_ID in region_ID else self.region
|
||||||
|
|
||||||
def install_mod(self):
|
def install_mod(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -28,3 +28,7 @@ def normalize(src_file: str, dest_dir: str = "./file/Track/", dest_name: str = "
|
||||||
autoadd_path], creationflags=CREATE_NO_WINDOW, stderr=subprocess.PIPE)
|
autoadd_path], creationflags=CREATE_NO_WINDOW, stderr=subprocess.PIPE)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def extract(file: str, dest_dir: str):
|
||||||
|
subprocess.call(["./tools/wit/wit", "EXTRACT", get_nodir(file), "--DEST", dest_dir],
|
||||||
|
creationflags=CREATE_NO_WINDOW, cwd=get_dir(file))
|
Loading…
Reference in a new issue