LADX: Give better feedback during patching (#5401)

This commit is contained in:
threeandthreee
2025-11-25 14:42:55 -05:00
committed by GitHub
parent aa2774a5d5
commit f3000a89d4
5 changed files with 69 additions and 9 deletions

View File

@@ -4,8 +4,10 @@ import os
import typing
import logging
import re
import struct
import settings
import Utils
from BaseClasses import CollectionState, Entrance, Item, ItemClassification, Location, Tutorial
from Fill import fill_restrictive
from worlds.AutoWorld import WebWorld, World
@@ -50,6 +52,17 @@ class LinksAwakeningSettings(settings.Group):
description = "LADX ROM File"
md5s = [LADXProcedurePatch.hash]
@classmethod
def validate(cls, path: str) -> None:
try:
super().validate(path)
except ValueError:
Utils.messagebox(
"Error",
"Provided rom does not match hash for English 1.0/revision-0 of Link's Awakening DX",
True)
raise
class RomStart(str):
"""
Set this to false to never autostart a rom (such as after patching)
@@ -71,6 +84,24 @@ class LinksAwakeningSettings(settings.Group):
Only .bin or .bdiff files
The same directory will be checked for a matching text modification file
"""
def browse(self, filetypes=None, **kwargs):
filetypes = [("Binary / Patch files", [".bin", ".bdiff"])]
return super().browse(filetypes=filetypes, **kwargs)
@classmethod
def validate(cls, path: str) -> None:
with open(path, "rb", buffering=0) as f:
header, size = struct.unpack("<II", f.read()[:8])
if path.endswith('.bin') and header == 0xDEADBEEF and size < 1024:
# detect extended spritesheets from upstream ladxr
Utils.messagebox(
"Error",
"Extended sprite sheets are not supported. Try again with a different gfxmod file, "
"or provide no file to continue without modifying graphics.",
True)
raise ValueError("Provided gfxmod file is an extended sheet, which is not supported")
rom_file: RomFile = RomFile(RomFile.copy_to)
rom_start: typing.Union[RomStart, bool] = True