From a3373573063b9995b72f6b2197076489fcb1a67c Mon Sep 17 00:00:00 2001 From: dyceron <38679103+dyceron@users.noreply.github.com> Date: Sun, 5 Nov 2023 03:33:48 -0500 Subject: [PATCH] Add support for bmses --- .../formats/__init__.py | 2 + .../formats/bmses.py | 46 +++++++++++++++++++ tests/formats/test_bmses.py | 13 ++++++ 3 files changed, 61 insertions(+) create mode 100644 src/mercury_engine_data_structures/formats/bmses.py create mode 100644 tests/formats/test_bmses.py diff --git a/src/mercury_engine_data_structures/formats/__init__.py b/src/mercury_engine_data_structures/formats/__init__.py index 515a7d3f..52a8de5d 100644 --- a/src/mercury_engine_data_structures/formats/__init__.py +++ b/src/mercury_engine_data_structures/formats/__init__.py @@ -8,6 +8,7 @@ from mercury_engine_data_structures.formats.bmmdef import Bmmdef from mercury_engine_data_structures.formats.bmsad import Bmsad from mercury_engine_data_structures.formats.bmsas import Bmsas +from mercury_engine_data_structures.formats.bmses import Bmses from mercury_engine_data_structures.formats.bmsbk import Bmsbk from mercury_engine_data_structures.formats.bmscc import Bmscc from mercury_engine_data_structures.formats.bmscu import Bmscu @@ -45,6 +46,7 @@ "BMSSS": Bmsss, "BMSAD": Bmsad, "BMSAS": Bmsas, + "BMSES": Bmses, "BMTUN": Bmtun, "BRFLD": Brfld, "BMSCC": Bmscc, diff --git a/src/mercury_engine_data_structures/formats/bmses.py b/src/mercury_engine_data_structures/formats/bmses.py new file mode 100644 index 00000000..00338748 --- /dev/null +++ b/src/mercury_engine_data_structures/formats/bmses.py @@ -0,0 +1,46 @@ +import functools +import construct +from construct.core import ( + Const, + Construct, + Float32l, + Hex, + Int32ul, + Int32sl, + Struct, +) + +from mercury_engine_data_structures.common_types import CVector3D, StrId, make_vector +from mercury_engine_data_structures.formats import BaseResource +from mercury_engine_data_structures.game_check import Game + + +BMSES = Struct( + "magic" / Const(b"MSES"), + "version" / Hex(Int32ul), + "sounds" / make_vector(Struct( + "name" / StrId, + "sound_file" / StrId, + "properties" / Struct( + "fade_in" / Float32l, + "fade_out" / Float32l, + "start_delay" / Float32l, + "volume" / Float32l, + "unk1" / Int32sl, + "sub_sound" / make_vector(Struct( + "name" / StrId, + "properties" / Struct( + "unk2" / Float32l, + "unk3" / CVector3D, + "unk4" / Int32sl, + ))), + ))), + construct.Terminated, +) + + +class Bmses(BaseResource): + @classmethod + @functools.lru_cache + def construct_class(cls, target_game: Game) -> Construct: + return BMSES \ No newline at end of file diff --git a/tests/formats/test_bmses.py b/tests/formats/test_bmses.py new file mode 100644 index 00000000..6a99b5e8 --- /dev/null +++ b/tests/formats/test_bmses.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.bmses import Bmses + +all_sr_bmses = [name for name in samus_returns_data.all_name_to_asset_id().keys() + if name.endswith(".bmses")] + + +@pytest.mark.parametrize("bmses_path", all_sr_bmses) +def test_bmses(samus_returns_tree, bmses_path): + parse_build_compare_editor(Bmses, samus_returns_tree, bmses_path) \ No newline at end of file