Skip to content

Commit

Permalink
LADX: Fix local paths (#1634)
Browse files Browse the repository at this point in the history
  • Loading branch information
zig-for authored Mar 31, 2023
1 parent 1dc4e2b commit 30cfd31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
3 changes: 2 additions & 1 deletion worlds/ladx/LADXR/rom.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import binascii
import Utils

b2h = binascii.hexlify
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):
Expand Down
11 changes: 1 addition & 10 deletions worlds/ladx/LADXR/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions worlds/ladx/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
from Options import Choice, Option, Toggle, DefaultOnToggle, Range, FreeText
from collections import defaultdict
import Utils

DefaultOffToggle = Toggle

Expand Down Expand Up @@ -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:
Expand All @@ -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):
"""
Expand Down

0 comments on commit 30cfd31

Please sign in to comment.