Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions worlds/tunic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
LaurelsLocation, LaurelsZips, IceGrappling, LadderStorage, EntranceLayout,
check_options, LocalFill, get_hexagons_in_pool, HexagonQuestAbilityUnlockType)
from . import ut_stuff
from . import launcher


class TunicSettings(Group):
Expand All @@ -37,9 +38,15 @@ class UTPoptrackerPath(FilePath):
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):
Expand Down
68 changes: 68 additions & 0 deletions worlds/tunic/launcher.py
Original file line number Diff line number Diff line change
@@ -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,
),
)
)
Loading