diff --git a/src/mercury_engine_data_structures/formats/__init__.py b/src/mercury_engine_data_structures/formats/__init__.py index 8bba034f..515a7d3f 100644 --- a/src/mercury_engine_data_structures/formats/__init__.py +++ b/src/mercury_engine_data_structures/formats/__init__.py @@ -14,6 +14,7 @@ from mercury_engine_data_structures.formats.bmsld import Bmsld from mercury_engine_data_structures.formats.bmslgroup import Bmslgroup from mercury_engine_data_structures.formats.bmslink import Bmslink +from mercury_engine_data_structures.formats.bmsmsd import Bmsmsd from mercury_engine_data_structures.formats.bmsnav import Bmsnav from mercury_engine_data_structures.formats.bmssd import Bmssd from mercury_engine_data_structures.formats.bmtre import Bmtre @@ -50,6 +51,7 @@ "BMSCD": Bmscc, "BMSCU": Bmscu, "BMSLD": Bmsld, + "BMSMSD": Bmsmsd, "BMSNAV": Bmsnav, "BMSLGROUP": Bmslgroup, "BMSLINK": Bmslink, diff --git a/src/mercury_engine_data_structures/formats/bmsmsd.py b/src/mercury_engine_data_structures/formats/bmsmsd.py new file mode 100644 index 00000000..1e19bdb5 --- /dev/null +++ b/src/mercury_engine_data_structures/formats/bmsmsd.py @@ -0,0 +1,50 @@ +import functools + +import construct +from construct.core import Const, Construct, Float32l, Hex, Int32sl, Int32ul, Struct + +from mercury_engine_data_structures.common_types import CVector2D, CVector3D, StrId, make_vector +from mercury_engine_data_structures.formats import BaseResource +from mercury_engine_data_structures.game_check import Game + +# BMSMSD +BMSMSD = Struct( + "_magic" / Const(b"MMSD"), + "version" / Const(0x00070001, Hex(Int32ul)), + "scenario" / StrId, + "tile_size" / construct.Array(2, Float32l), + "x_tiles" / Int32sl, + "y_tiles" / Int32sl, + "map_dimensions" / Struct( + "bottom_left" / CVector2D, + "top_right" / CVector2D, + ), + "tiles" / make_vector( + Struct( + "tile_coordinates" / construct.Array(2, Int32sl), + "dimension" / Struct( + "bottom_left" / CVector2D, + "top_right" / CVector2D, + ), + "border_type" / Int32sl, + "tile_type" / Int32sl, + "icons" / make_vector( + Struct( + "actor_name" / StrId, + "clear_condition" / StrId, + "icon" / StrId, + "icon_priority" / Int32sl, + "coordinates" / CVector3D, + ) + ), + ) + ), + construct.Terminated, +) + + +class Bmsmsd(BaseResource): + @classmethod + @functools.lru_cache + def construct_class(cls, target_game: Game) -> Construct: + return BMSMSD diff --git a/tests/formats/test_bmsmsd.py b/tests/formats/test_bmsmsd.py new file mode 100644 index 00000000..6e11cf29 --- /dev/null +++ b/tests/formats/test_bmsmsd.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.bmsmsd import Bmsmsd + +all_sr_bmsmsd = [name for name in samus_returns_data.all_name_to_asset_id().keys() + if name.endswith(".bmsmsd")] + + +@pytest.mark.parametrize("bmsmsd_path", all_sr_bmsmsd) +def test_bmtun(samus_returns_tree, bmsmsd_path): + parse_build_compare_editor(Bmsmsd, samus_returns_tree, bmsmsd_path)