LADX: Fix local paths (#1634)

This commit is contained in:
zig-for 2023-03-31 05:05:51 -07:00 committed by GitHub
parent 1dc4e2b44b
commit 30cfd3186c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 14 deletions

View File

@ -1,4 +1,5 @@
import binascii
import Utils
b2h = binascii.hexlify
h2b = binascii.unhexlify
@ -6,7 +7,7 @@ h2b = binascii.unhexlify
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):

View File

@ -69,15 +69,6 @@ class Setting:
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 @@ Note, some entrances can lead into water, use the warp-to-home from the save&qui
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",

View File

@ -3,6 +3,7 @@ import typing
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 @@ class GfxMod(FreeText, LADXROption):
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):
"""