diff --git a/worlds/ladx/LADXR/rom.py b/worlds/ladx/LADXR/rom.py index e7ff2f244d0d..ea4f14089feb 100644 --- a/worlds/ladx/LADXR/rom.py +++ b/worlds/ladx/LADXR/rom.py @@ -1,4 +1,5 @@ import binascii +import Utils b2h = binascii.hexlify h2b = binascii.unhexlify @@ -6,7 +7,7 @@ class ROM: def __init__(self, filename): - data = open(filename, "rb").read() + data = open(Utils.local_path(filename), "rb").read() #assert len(data) == 1024 * 1024 self.banks = [] for n in range(0x40): diff --git a/worlds/ladx/LADXR/settings.py b/worlds/ladx/LADXR/settings.py index d52e8fe45d49..848d64390de3 100644 --- a/worlds/ladx/LADXR/settings.py +++ b/worlds/ladx/LADXR/settings.py @@ -69,15 +69,6 @@ def toJson(self): class Settings: def __init__(self, ap_options): - gfx_options = [('', '', 'Default')] - gfx_path = os.path.join("data", "sprites", "ladx") - for filename in sorted(os.listdir(gfx_path)): - if filename.endswith(".bin") or filename.endswith(".png") or filename.endswith(".bmp"): - gfx_options.append((filename, filename + ">", filename[:-4])) - if filename.endswith(".bdiff"): - gfx_options.append((filename, filename + ">", filename[:-6])) - - self.__all = [ Setting('seed', 'Main', '<', 'Seed', placeholder='Leave empty for random seed', default="", multiworld=False, description="""For multiple people to generate the same randomization result, enter the generated seed number here. @@ -201,7 +192,7 @@ def __init__(self, ap_options): Setting('nagmessages', 'User options', 'S', 'Show nag messages', default=False, description='Enables the nag messages normally shown when touching stones and crystals', aesthetic=True), - Setting('gfxmod', 'User options', 'c', 'Graphics', options=gfx_options, default='', + Setting('gfxmod', 'User options', 'c', 'Graphics', default='', description='Generally affects at least Link\'s sprite, but can alter any graphics in the game', aesthetic=True), Setting('linkspalette', 'User options', 'C', "Link's color", diff --git a/worlds/ladx/Options.py b/worlds/ladx/Options.py index b14d7b2af077..8d30186670fe 100644 --- a/worlds/ladx/Options.py +++ b/worlds/ladx/Options.py @@ -3,6 +3,7 @@ import logging from Options import Choice, Option, Toggle, DefaultOnToggle, Range, FreeText from collections import defaultdict +import Utils DefaultOffToggle = Toggle @@ -318,12 +319,13 @@ class GfxMod(FreeText, LADXROption): default = 'Link' __spriteFiles: typing.DefaultDict[str, typing.List[str]] = defaultdict(list) - __spriteDir = os.path.join('data', 'sprites','ladx') + __spriteDir: str = None extensions = [".bin", ".bdiff", ".png", ".bmp"] def __init__(self, value: str): super().__init__(value) - if not GfxMod.__spriteFiles: + if not GfxMod.__spriteDir: + GfxMod.__spriteDir = Utils.local_path(os.path.join('data', 'sprites','ladx')) for file in os.listdir(GfxMod.__spriteDir): name, extension = os.path.splitext(file) if extension in self.extensions: @@ -344,7 +346,7 @@ def to_ladxr_option(self, all_options): if len(GfxMod.__spriteFiles[self.value]) > 1: logger.warning(f"{self.value} does not uniquely identify a file. Possible matches: {GfxMod.__spriteFiles[self.value]}. Using {GfxMod.__spriteFiles[self.value][0]}") - return self.ladxr_name, GfxMod.__spriteFiles[self.value][0] + return self.ladxr_name, self.__spriteDir + "/" + GfxMod.__spriteFiles[self.value][0] class Palette(Choice): """