From 07a0feee15df26ad7c853f901cd45093ef2470f8 Mon Sep 17 00:00:00 2001 From: dyceron Date: Tue, 6 Feb 2024 19:07:59 -0500 Subject: [PATCH 1/3] Add .blsnd support --- .../formats/__init__.py | 2 ++ .../formats/blsnd.py | 34 +++++++++++++++++++ tests/formats/test_blsnd.py | 13 +++++++ 3 files changed, 49 insertions(+) create mode 100644 src/mercury_engine_data_structures/formats/blsnd.py create mode 100644 tests/formats/test_blsnd.py diff --git a/src/mercury_engine_data_structures/formats/__init__.py b/src/mercury_engine_data_structures/formats/__init__.py index af35457e..274f2c29 100644 --- a/src/mercury_engine_data_structures/formats/__init__.py +++ b/src/mercury_engine_data_structures/formats/__init__.py @@ -4,6 +4,7 @@ from mercury_engine_data_structures.formats.bcmdl import Bcmdl from mercury_engine_data_structures.formats.bldef import Bldef from mercury_engine_data_structures.formats.bmbls import Bmbls +from mercury_engine_data_structures.formats.blsnd import Blsnd from mercury_engine_data_structures.formats.bmmap import Bmmap from mercury_engine_data_structures.formats.bmmdef import Bmmdef from mercury_engine_data_structures.formats.bmsad import Bmsad @@ -38,6 +39,7 @@ "PKG": Pkg, "BCMDL": Bcmdl, "BLDEF": Bldef, + "BLSND": Blsnd, "BMBLS": Bmbls, "BMMAP": Bmmap, "BMMDEF": Bmmdef, diff --git a/src/mercury_engine_data_structures/formats/blsnd.py b/src/mercury_engine_data_structures/formats/blsnd.py new file mode 100644 index 00000000..05f4dfde --- /dev/null +++ b/src/mercury_engine_data_structures/formats/blsnd.py @@ -0,0 +1,34 @@ +import functools + +import construct +from construct.core import ( + Const, + Construct, + Float32l, + Hex, + Int32sl, + 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 diff --git a/tests/formats/test_blsnd.py b/tests/formats/test_blsnd.py new file mode 100644 index 00000000..9ac84a1e --- /dev/null +++ b/tests/formats/test_blsnd.py @@ -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) From d7bc560d33a2dc018fb02e113ae54cb51778a560 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 7 Feb 2024 00:09:34 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/mercury_engine_data_structures/formats/__init__.py | 2 +- src/mercury_engine_data_structures/formats/blsnd.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/__init__.py b/src/mercury_engine_data_structures/formats/__init__.py index 274f2c29..c20889a7 100644 --- a/src/mercury_engine_data_structures/formats/__init__.py +++ b/src/mercury_engine_data_structures/formats/__init__.py @@ -3,8 +3,8 @@ 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.bmbls import Bmbls 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 from mercury_engine_data_structures.formats.bmsad import Bmsad diff --git a/src/mercury_engine_data_structures/formats/blsnd.py b/src/mercury_engine_data_structures/formats/blsnd.py index 05f4dfde..0c08f3f7 100644 --- a/src/mercury_engine_data_structures/formats/blsnd.py +++ b/src/mercury_engine_data_structures/formats/blsnd.py @@ -4,9 +4,7 @@ from construct.core import ( Const, Construct, - Float32l, Hex, - Int32sl, Int32ul, Struct, ) From 8268dd3e5372d29b92856aaaaabad4cb68ba6dfd Mon Sep 17 00:00:00 2001 From: dyceron Date: Tue, 6 Feb 2024 19:09:49 -0500 Subject: [PATCH 3/3] Remove unused imports --- src/mercury_engine_data_structures/formats/blsnd.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/blsnd.py b/src/mercury_engine_data_structures/formats/blsnd.py index 05f4dfde..0c08f3f7 100644 --- a/src/mercury_engine_data_structures/formats/blsnd.py +++ b/src/mercury_engine_data_structures/formats/blsnd.py @@ -4,9 +4,7 @@ from construct.core import ( Const, Construct, - Float32l, Hex, - Int32sl, Int32ul, Struct, )