Skip to content

Commit

Permalink
update it so that the iso is automatically launched with the apmp1 fi…
Browse files Browse the repository at this point in the history
…le, fix issues with running client
  • Loading branch information
hesto2 committed May 23, 2024
1 parent 2e006b5 commit 065564f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
50 changes: 33 additions & 17 deletions MetroidPrimeClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ def on_package(self, cmd: str, args: dict):
Utils.async_start(self.update_death_link(
bool(args["slot_data"]["death_link"])))

def run_gui(self):
from kvui import GameManager

class MetroidPrimeManager(GameManager):
logging_pairs = [
("Client", "Archipelago")
]
base_title = "Archipelago Metroid Prime Client"

self.ui = MetroidPrimeManager(self)
self.ui_task = asyncio.create_task(self.ui.async_run(), name="UI")


def update_connection_status(ctx: MetroidPrimeContext, status):
if ctx.connection_state == status:
Expand Down Expand Up @@ -280,23 +292,27 @@ async def patch_and_run_game(apmp1_file: str):
base_name = os.path.splitext(apmp1_file)[0]
output_path = base_name + '.iso'

config_json_file = None
if zipfile.is_zipfile(apmp1_file):
for name in zipfile.ZipFile(apmp1_file).namelist():
if name == 'config.json':
config_json_file = name
break

config_json = None
with zipfile.ZipFile(apmp1_file) as zip_file:
with zip_file.open(config_json_file) as file:
config_json = file.read().decode("utf-8")
config_json = json.loads(config_json)

config_json["gameConfig"]["updateHintStateReplacement"] = construct_hud_message_patch()
notifier = py_randomprime.ProgressNotifier(
lambda progress, message: print("Generating ISO: ", progress, message))
py_randomprime.patch_iso(input_iso_path, output_path, config_json, notifier)
if not os.path.exists(output_path):

config_json_file = None
if zipfile.is_zipfile(apmp1_file):
for name in zipfile.ZipFile(apmp1_file).namelist():
if name == 'config.json':
config_json_file = name
break

config_json = None
with zipfile.ZipFile(apmp1_file) as zip_file:
with zip_file.open(config_json_file) as file:
config_json = file.read().decode("utf-8")
config_json = json.loads(config_json)

config_json["gameConfig"]["updateHintStateReplacement"] = construct_hud_message_patch()
notifier = py_randomprime.ProgressNotifier(
lambda progress, message: print("Generating ISO: ", progress, message))
py_randomprime.patch_iso(input_iso_path, output_path, config_json, notifier)

Utils.async_start(run_game(output_path))


def launch():
Expand Down
5 changes: 2 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict
from typing import Any, Dict, Optional
import typing
from BaseClasses import Item, Tutorial, ItemClassification
from worlds.metroidprime.Container import MetroidPrimeContainer
Expand All @@ -14,8 +14,7 @@
from worlds.LauncherComponents import Component, SuffixIdentifier, Type, components, launch_subprocess


def run_client(_):
print("Running Metroid Prime Client")
def run_client(url: Optional[str] = None):
from .MetroidPrimeClient import launch
launch_subprocess(launch, name="MetroidPrimeClient")

Expand Down
3 changes: 2 additions & 1 deletion docs/setup_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ name and port number from the room's host.

Once you do, follow these steps to connect to the room:

0. (Optional): If you want the `apmp1` file to automatically open your game for you, then right click any existing `iso` file you have and select "Open With" then browse to and select `Dolphin.exe`
1. Double click the `apmp1` file. If you have not done so before, it will ask you what program you want to open it with. Click "Choose another program" and browser to your Archipelago directory. Select `ArchipelagoLauncher.exe`.
2. Be patient, after clicking the `apmp1` file, it can take a minute to have the client and patched iso showup
3. If this is your first time, it will prompt you for an input iso. Select your Metroid Prime USA V1.0 (0-00) iso
4. Once the output iso file appears in the same directory as your `apmp1` file (it should have a name `AP_XXXX.iso`), open it with Dolphin
4. Once the output iso file appears in the same directory as your `apmp1` file (it should have a name `AP_XXXX.iso`), open it with Dolphin (or if you associated the file type with Dolphin, sit back and enjoy watching the computer do this menial task for you)
5. After the game is running, connect the Metroid Prime Client to the room by entering the server name and port number at the top and pressing `Connect`. For rooms hosted
on the website, this will be `archipelago.gg:<port>`, where `<port>` is the port number. If a game is hosted from the
`ArchipelagoServer.exe` (without `.exe` on Linux), this will default to `38281` but may be changed in the `host.yaml`.
Expand Down

0 comments on commit 065564f

Please sign in to comment.