Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSR - Add .blsnd support #123

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mercury_engine_data_structures/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from mercury_engine_data_structures.formats.base_resource import AssetType, BaseResource
from mercury_engine_data_structures.formats.bcmdl import Bcmdl
from mercury_engine_data_structures.formats.bldef import Bldef
from mercury_engine_data_structures.formats.blsnd import Blsnd
from mercury_engine_data_structures.formats.bmbls import Bmbls
from mercury_engine_data_structures.formats.bmmap import Bmmap
from mercury_engine_data_structures.formats.bmmdef import Bmmdef
Expand Down Expand Up @@ -38,6 +39,7 @@
"PKG": Pkg,
"BCMDL": Bcmdl,
"BLDEF": Bldef,
"BLSND": Blsnd,
"BMBLS": Bmbls,
"BMMAP": Bmmap,
"BMMDEF": Bmmdef,
Expand Down
32 changes: 32 additions & 0 deletions src/mercury_engine_data_structures/formats/blsnd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import functools

import construct
from construct.core import (
Const,
Construct,
Hex,
Int32ul,
Struct,
)

from mercury_engine_data_structures.common_types import StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.game_check import Game

BLSND = Struct(
"_magic" / Const(b"LSND"),
"version" / Const(0x000B0001, Hex(Int32ul)),
"unk" / Int32ul,
"sound_limits" / make_vector(Struct(
"name" / StrId,
"value" / Int32ul,
)),
construct.Terminated,
)


class Blsnd(BaseResource):
@classmethod
@functools.lru_cache
def construct_class(cls, target_game: Game) -> Construct:
return BLSND
13 changes: 13 additions & 0 deletions tests/formats/test_blsnd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest
from tests.test_lib import parse_build_compare_editor

from mercury_engine_data_structures import samus_returns_data
from mercury_engine_data_structures.formats.blsnd import Blsnd

all_sr_blsnd = [name for name in samus_returns_data.all_name_to_asset_id().keys()
if name.endswith(".blsnd")]


@pytest.mark.parametrize("blsnd_path", all_sr_blsnd)
def test_blsnd(samus_returns_tree, blsnd_path):
parse_build_compare_editor(Blsnd, samus_returns_tree, blsnd_path)