Skip to content

Commit

Permalink
Implement location choosing for citra
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Sep 28, 2021
1 parent 9d2d116 commit 02c95a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
19 changes: 8 additions & 11 deletions install_majoras_mask_3d/citra.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,25 @@
from install_majoras_mask_3d.utility import download_file, get_only_subdirectory_path, kill_child_processes
from install_majoras_mask_3d.paths import (
get_citra_config_directory,
get_citra_directory,
get_citra_sysdata_directory,
)


def install_and_configure_citra(url):
_install_citra(url)
def install_and_configure_citra(url, citra_directory):
_install_citra(url, citra_directory)
_install_citra_aes_keys()


def install_cia(cia_path):
citra_program = os.path.join(".", get_citra_directory(), "citra.exe")
def install_cia(cia_path, citra_directory):
citra_program = os.path.join(".", citra_directory, "citra.exe")
print(f"'{citra_program}'")
subprocess.run([citra_program, "-i", cia_path])


def _install_citra(url):
def _install_citra(url, citra_directory):
"""
Downloads and installs Citra and returns the path to the Citra directory.
"""
citra_directory = get_citra_directory()
if os.path.isdir(citra_directory):
return

Expand All @@ -56,8 +54,8 @@ def _install_citra_aes_keys():
if not os.path.isfile(target_file):
copyfile(source_file, target_file)

def set_graphics_options():
thread = Thread(target = _initialize_config)
def set_graphics_options(citra_directory):
thread = Thread(target = _initialize_config, args = (citra_directory, ))
thread.start()
sleep(2)
kill_child_processes()
Expand All @@ -72,8 +70,7 @@ def set_graphics_options():
new_config = _set_options(old_config, options)
_write_config(new_config)

def _initialize_config():
citra_directory = get_citra_directory()
def _initialize_config(citra_directory):
citra_executable = os.path.join(citra_directory, "citra-qt.exe")
subprocess.run([citra_executable])

Expand Down
2 changes: 1 addition & 1 deletion install_majoras_mask_3d/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
GAME_IDS = ["0004000000125500", "0004000000125600", "00040000000D6E00"]


def get_citra_directory():
def get_citra_default_directory():
"""
Returns the path to the Citra directory.
"""
Expand Down
18 changes: 12 additions & 6 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from install_majoras_mask_3d.project_restoration import download_project_restoration, download_hd_hud
from install_majoras_mask_3d.hd_textures import download_hd_textures
from install_majoras_mask_3d.remastered_ost import download_remastered_ost
from install_majoras_mask_3d.paths import get_citra_directory
from install_majoras_mask_3d.paths import get_citra_default_directory

if __name__ == "__main__":
try:
Expand All @@ -34,17 +34,24 @@
print(f"CIA not found at {cia_path}. Please enter a valid path to your CIA.")
cia_path = input("> ").strip()

print("")
default_citra_directoryh = get_citra_default_directory()
print("I will now install Citra, a 3DS emulator.\nIf you've already installed Citra, I will instead patch the version you already have.")
print(F"Please enter the Citra install directory or leave the input blank for the default at {default_citra_directoryh}.")
citra_directory = input("> ").strip()
citra_directory = citra_directory if citra_directory else default_citra_directoryh

print("Installing Citra...", end='')
install_and_configure_citra(citra_url)
install_and_configure_citra(citra_url, citra_directory)
print(" Done!")

print("Loading Majora's Mask into Citra...")
install_cia(cia_path)
install_cia(cia_path, citra_directory)
print("Done!")

print("Setting Graphic options...", end='')
set_graphics_options()
print(" Done! (Don't mind the window that just flashed open for a second, haha)")
set_graphics_options(citra_directory)
print(" Done! (Don't mind if a window just flashed open for a second, that was Citra generating config files)")

print("Downloading Project Restoration...", end='')
download_project_restoration(project_restoration_url)
Expand All @@ -62,7 +69,6 @@
download_remastered_ost(remastered_ost_url)
print(" Done!")

citra_directory = get_citra_directory()
print(f"\nSuccessfully installed Majora's Mask!\nI have just opened the installation folder for you: {citra_directory}")
print("There, you can start the emulator via 'citra-qt.exe'.\nDon't forget to setup any controller you might want to play with at Emulation -> Configure -> Controls.\nHave fun! :)\n")
webbrowser.open(citra_directory)
Expand Down

0 comments on commit 02c95a0

Please sign in to comment.