diff --git a/inno_setup.iss b/inno_setup.iss index eb794650f3a6..33a82b8cb9f1 100644 --- a/inno_setup.iss +++ b/inno_setup.iss @@ -84,6 +84,7 @@ Type: dirifempty; Name: "{app}" [InstallDelete] Type: files; Name: "{app}\lib\worlds\_bizhawk.apworld" +Type: files; Name: "{app}\ArchipelagoLinksAwakeningClient.exe" Type: files; Name: "{app}\ArchipelagoLttPClient.exe" Type: files; Name: "{app}\ArchipelagoPokemonClient.exe" Type: files; Name: "{app}\data\lua\connector_pkmn_rb.lua" @@ -198,8 +199,8 @@ Root: HKCR; Subkey: "{#MyAppName}mm2patch\shell\open\command"; ValueData: """{a Root: HKCR; Subkey: ".apladx"; ValueData: "{#MyAppName}ladxpatch"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""; Root: HKCR; Subkey: "{#MyAppName}ladxpatch"; ValueData: "Archipelago Links Awakening DX Patch"; Flags: uninsdeletekey; ValueType: string; ValueName: ""; -Root: HKCR; Subkey: "{#MyAppName}ladxpatch\DefaultIcon"; ValueData: "{app}\ArchipelagoLinksAwakeningClient.exe,0"; ValueType: string; ValueName: ""; -Root: HKCR; Subkey: "{#MyAppName}ladxpatch\shell\open\command"; ValueData: """{app}\ArchipelagoLinksAwakeningClient.exe"" ""%1"""; ValueType: string; ValueName: ""; +Root: HKCR; Subkey: "{#MyAppName}ladxpatch\DefaultIcon"; ValueData: "{app}\ArchipelagoLauncher.exe,0"; ValueType: string; ValueName: ""; +Root: HKCR; Subkey: "{#MyAppName}ladxpatch\shell\open\command"; ValueData: """{app}\ArchipelagoLauncher.exe"" ""%1"""; ValueType: string; ValueName: ""; Root: HKCR; Subkey: ".aptloz"; ValueData: "{#MyAppName}tlozpatch"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""; Root: HKCR; Subkey: "{#MyAppName}tlozpatch"; ValueData: "Archipelago The Legend of Zelda Patch"; Flags: uninsdeletekey; ValueType: string; ValueName: ""; diff --git a/worlds/LauncherComponents.py b/worlds/LauncherComponents.py index d1b274c19ae7..3464217f77dc 100644 --- a/worlds/LauncherComponents.py +++ b/worlds/LauncherComponents.py @@ -204,8 +204,6 @@ def install_apworld(apworld_path: str = "") -> None: Component('Generate', 'Generate', cli=True), Component("Install APWorld", func=install_apworld, file_identifier=SuffixIdentifier(".apworld")), Component('Text Client', 'CommonClient', 'ArchipelagoTextClient', func=launch_textclient), - Component('Links Awakening DX Client', 'LinksAwakeningClient', - file_identifier=SuffixIdentifier('.apladx')), Component('LttP Adjuster', 'LttPAdjuster'), # Minecraft Component('Minecraft Client', 'MinecraftClient', icon='mcicon', cli=True, diff --git a/LinksAwakeningClient.py b/worlds/ladx/LinksAwakeningClient.py similarity index 91% rename from LinksAwakeningClient.py rename to worlds/ladx/LinksAwakeningClient.py index aede742b82a0..c9e7036e6bbc 100644 --- a/LinksAwakeningClient.py +++ b/worlds/ladx/LinksAwakeningClient.py @@ -3,9 +3,6 @@ import Utils -if __name__ == "__main__": - Utils.init_logging("LinksAwakeningContext", exception_logger="Client") - import asyncio import base64 import binascii @@ -26,12 +23,12 @@ from CommonClient import (CommonContext, get_base_parser, gui_enabled, logger, server_loop) from NetUtils import ClientStatus -from worlds.ladx.Common import BASE_ID as LABaseID -from worlds.ladx.GpsTracker import GpsTracker -from worlds.ladx.ItemTracker import ItemTracker -from worlds.ladx.LADXR.checkMetadata import checkMetadataTable -from worlds.ladx.Locations import get_locations_to_id, meta_to_name -from worlds.ladx.Tracker import LocationTracker, MagpieBridge +from .Common import BASE_ID as LABaseID +from .GpsTracker import GpsTracker +from .ItemTracker import ItemTracker +from .LADXR.checkMetadata import checkMetadataTable +from .Locations import get_locations_to_id, meta_to_name +from .Tracker import LocationTracker, MagpieBridge class GameboyException(Exception): @@ -567,7 +564,7 @@ def on_package(self, cmd: str, args: dict): if cmd == "Connected": self.game = self.slot_info[self.slot].game self.slot_data = args.get("slot_data", {}) - + # TODO - use watcher_event if cmd == "ReceivedItems": for index, item in enumerate(args["items"], start=args["index"]): @@ -665,42 +662,44 @@ def run_game(romfile: str) -> None: except FileNotFoundError: logger.error(f"Couldn't launch ROM, {args[0]} is missing") -async def main(): - parser = get_base_parser(description="Link's Awakening Client.") - parser.add_argument("--url", help="Archipelago connection url") - parser.add_argument("--no-magpie", dest='magpie', default=True, action='store_false', help="Disable magpie bridge") - parser.add_argument('diff_file', default="", type=str, nargs="?", - help='Path to a .apladx Archipelago Binary Patch file') +def launch(*launch_args): + async def main(): + parser = get_base_parser(description="Link's Awakening Client.") + parser.add_argument("--url", help="Archipelago connection url") + parser.add_argument("--no-magpie", dest='magpie', default=True, action='store_false', help="Disable magpie bridge") + parser.add_argument('diff_file', default="", type=str, nargs="?", + help='Path to a .apladx Archipelago Binary Patch file') - args = parser.parse_args() + args = parser.parse_args(launch_args) - if args.diff_file: - import Patch - logger.info("patch file was supplied - creating rom...") - meta, rom_file = Patch.create_rom_file(args.diff_file) - if "server" in meta and not args.connect: - args.connect = meta["server"] - logger.info(f"wrote rom file to {rom_file}") + if args.diff_file: + import Patch + logger.info("patch file was supplied - creating rom...") + meta, rom_file = Patch.create_rom_file(args.diff_file) + if "server" in meta and not args.connect: + args.connect = meta["server"] + logger.info(f"wrote rom file to {rom_file}") - ctx = LinksAwakeningContext(args.connect, args.password, args.magpie) + ctx = LinksAwakeningContext(args.connect, args.password, args.magpie) - ctx.server_task = asyncio.create_task(server_loop(ctx), name="server loop") + ctx.server_task = asyncio.create_task(server_loop(ctx), name="server loop") - # TODO: nothing about the lambda about has to be in a lambda - ctx.la_task = create_task_log_exception(ctx.run_game_loop()) - if gui_enabled: - ctx.run_gui() - ctx.run_cli() + # TODO: nothing about the lambda about has to be in a lambda + ctx.la_task = create_task_log_exception(ctx.run_game_loop()) + if gui_enabled: + ctx.run_gui() + ctx.run_cli() - # Down below run_gui so that we get errors out of the process - if args.diff_file: - run_game(rom_file) + # Down below run_gui so that we get errors out of the process + if args.diff_file: + run_game(rom_file) - await ctx.exit_event.wait() - await ctx.shutdown() + await ctx.exit_event.wait() + await ctx.shutdown() + + Utils.init_logging("LinksAwakeningContext", exception_logger="Client") -if __name__ == '__main__': colorama.init() asyncio.run(main()) colorama.deinit() diff --git a/worlds/ladx/__init__.py b/worlds/ladx/__init__.py index f20b7f8018aa..b673762c6304 100644 --- a/worlds/ladx/__init__.py +++ b/worlds/ladx/__init__.py @@ -12,6 +12,7 @@ from BaseClasses import Entrance, Item, ItemClassification, Location, Tutorial, MultiWorld from Fill import fill_restrictive from worlds.AutoWorld import WebWorld, World +from worlds.LauncherComponents import Component, components, SuffixIdentifier, Type, launch_subprocess from .Common import * from . import ItemIconGuessing from .Items import (DungeonItemData, DungeonItemType, ItemName, LinksAwakeningItem, TradeItemData, @@ -34,6 +35,15 @@ DEVELOPER_MODE = False +def launch_client(*args): + from .LinksAwakeningClient import launch + launch_subprocess(launch, name="Links Awakening DX Client", args=args) + +components.append(Component("Links Awakening DX Client", + func=launch_client, + component_type=Type.CLIENT, + file_identifier=SuffixIdentifier('.apladx'))) + class LinksAwakeningSettings(settings.Group): class RomFile(settings.UserFilePath): """File name of the Link's Awakening DX rom"""