Skip to content

Commit

Permalink
Check if asset exists, instead of needing to deal with game versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nystrata committed Nov 1, 2024
1 parent a7be495 commit 6dfe945
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 36 deletions.
Binary file not shown.
Binary file not shown.
30 changes: 7 additions & 23 deletions src/open_prime_rando/echoes/widescreen_hud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,10 @@ def apply_widescreen_hud(editor: PatcherEditor):
"""
Replaces certain FRME files to adjust HUD/Visor widgets to better fit a 16:9 screen aspect ratio
"""

# TODO: Properly do version detection
# Currently detecting game version by existence of version-specific assets here, since PAK patching doesn't seem
# to have version detection, unlike DOL patching that does
if editor.does_asset_exists(0xEEF43AA1) and editor.does_asset_exists(0xF7EC0850):
detectedversion = "ntscu"
elif editor.does_asset_exists(0xB5CF0C19) and editor.does_asset_exists(0xD9D58FA5):
detectedversion = "pal"
else:
raise NotImplementedError

for assetversion, assets in WIDESCREEN_HUD_ASSETS.items():
if detectedversion == assetversion:
widescreen_assets = custom_asset_path().joinpath("widescreen_hud", detectedversion)
for asset_id, filename in assets.items():
asset = widescreen_assets.joinpath(filename)
if not asset.exists():
continue
res = RawResource(
type="FRME",
data=asset.read_bytes(),
)
editor.replace_asset(asset_id, res)
for asset_id, filename in WIDESCREEN_HUD_ASSETS.items():
widescreen_assets = custom_asset_path().joinpath("widescreen_hud")
asset = widescreen_assets.joinpath(filename)
if not editor.does_asset_exists(asset_id):
continue
res = RawResource(type="FRME", data=asset.read_bytes())
editor.replace_asset(asset_id, res)
23 changes: 10 additions & 13 deletions src/open_prime_rando/echoes/widescreen_hud/asset_map.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# https://github.com/Nystrata/EchoesWidescreenHUD/wiki#gguisyspak
from retro_data_structures.base_resource import AssetId

WIDESCREEN_HUD_ASSETS: dict[str, dict[AssetId, str]] = {
"ntscu": {
0xE6F37215: "FRME_Helmet.FRME",
0x88738D60: "FRME_SamusHud1Ball.FRME",
0xEEF43AA1: "FRME_SamusHud1Combat.FRME",
0xF7EC0850: "FRME_ScanHudFlat_0.FRME",
},
"pal": {
0xE6F37215: "FRME_Helmet.FRME",
0x88738D60: "FRME_SamusHud1Ball.FRME",
0xB5CF0C19: "FRME_SamusHud1Combat_0.FRME",
0xD9D58FA5: "FRME_ScanHudFlat_1.FRME",
},
WIDESCREEN_HUD_ASSETS: dict[AssetId, str] = {
# Common
0xE6F37215: "FRME_Helmet.FRME",
0x88738D60: "FRME_SamusHud1Ball.FRME",
# NTSC-U
0xEEF43AA1: "FRME_SamusHud1Combat.FRME",
0xF7EC0850: "FRME_ScanHudFlat_0.FRME",
# PAL
0xB5CF0C19: "FRME_SamusHud1Combat_0.FRME",
0xD9D58FA5: "FRME_ScanHudFlat_1.FRME",
}

0 comments on commit 6dfe945

Please sign in to comment.