mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-10-04 18:14:47 -07:00
TUNIC: Add launcher options (#6199)
This commit is contained in:
1 parent
bce01b9325
commit
25a08b47cc
2 files changed
+75
No files matched your search
@@ -23,6 +23,7 @@ from .options import (TunicOptions, EntranceRando, tunic_option_groups, tunic_op
|
||||
LaurelsLocation, LaurelsZips, IceGrappling, LadderStorage, EntranceLayout,
|
||||
check_options, LocalFill, get_hexagons_in_pool, HexagonQuestAbilityUnlockType)
|
||||
from . import ut_stuff
|
||||
from . import launcher
|
||||
|
||||
|
||||
class TunicSettings(Group):
|
||||
@@ -37,9 +38,15 @@ class TunicSettings(Group):
|
||||
description = "TUNIC Poptracker Pack zip file"
|
||||
required = False
|
||||
|
||||
class GamePath(FilePath):
|
||||
"""Name of the TUNIC executable file."""
|
||||
description = "TUNIC Game Executable"
|
||||
is_exe = True
|
||||
|
||||
disable_local_spoiler: DisableLocalSpoiler | bool = False
|
||||
limit_grass_rando: LimitGrassRando | bool = True
|
||||
ut_poptracker_path: UTPoptrackerPath | str = UTPoptrackerPath()
|
||||
game_path: GamePath = GamePath(["Tunic.exe", "Secret Legend.exe"])
|
||||
|
||||
|
||||
class TunicWeb(WebWorld):
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from Utils import messagebox
|
||||
from worlds.LauncherComponents import Component, Type, components
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def launch_game(*args: str) -> None:
|
||||
from . import TunicWorld
|
||||
|
||||
try:
|
||||
game_folder = os.path.dirname(TunicWorld.settings.game_path)
|
||||
except ValueError as e:
|
||||
logger.error(e)
|
||||
messagebox(
|
||||
"Invalid File",
|
||||
"Please try again and ensure you select Tunic.exe or Secret Legend.exe.",
|
||||
)
|
||||
return
|
||||
|
||||
working_directory = os.getcwd()
|
||||
parser = argparse.ArgumentParser(description="TUNIC Launcher")
|
||||
parser.add_argument("url", type=str, nargs="?", help="Archipelago Webhost URI to auto connect to.")
|
||||
parsed_args = parser.parse_args(args)
|
||||
os.chdir(game_folder)
|
||||
if parsed_args.url:
|
||||
subprocess.Popen([TunicWorld.settings.game_path, str(parsed_args.url)])
|
||||
else:
|
||||
subprocess.Popen(TunicWorld.settings.game_path)
|
||||
os.chdir(working_directory)
|
||||
|
||||
|
||||
def attempt_launch_ut(*args: str) -> None:
|
||||
try:
|
||||
from worlds.tracker import launch_client
|
||||
|
||||
launch_client(*args)
|
||||
except ImportError as e:
|
||||
logger.error(e)
|
||||
messagebox(
|
||||
"Cannot Load UT",
|
||||
"There was an error loading Universal Tracker. Please ensure it is installed and up to date.",
|
||||
)
|
||||
|
||||
|
||||
components.extend(
|
||||
(
|
||||
Component(
|
||||
"TUNIC",
|
||||
func=launch_game,
|
||||
game_name="TUNIC",
|
||||
component_type=Type.HIDDEN,
|
||||
supports_uri=True,
|
||||
),
|
||||
Component(
|
||||
"Universal Tracker for TUNIC",
|
||||
func=attempt_launch_ut,
|
||||
game_name="TUNIC",
|
||||
component_type=Type.HIDDEN,
|
||||
supports_uri=True,
|
||||
),
|
||||
)
|
||||
)
|
||||
Reference in new issue
Block a user