diff --git a/src/mercury_engine_data_structures/formats/__init__.py b/src/mercury_engine_data_structures/formats/__init__.py index 40b95070..39b9ca83 100644 --- a/src/mercury_engine_data_structures/formats/__init__.py +++ b/src/mercury_engine_data_structures/formats/__init__.py @@ -15,6 +15,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.bmsmd import Bmsmd 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 @@ -57,6 +58,7 @@ "BMSNAV": Bmsnav, "BMSLGROUP": Bmslgroup, "BMSLINK": Bmslink, + "BMSMD": Bmsmd, "BMTRE": Bmtre, "BRSA": Brsa, "BREM": Brem, diff --git a/src/mercury_engine_data_structures/formats/bmsmd.py b/src/mercury_engine_data_structures/formats/bmsmd.py new file mode 100644 index 00000000..488725cc --- /dev/null +++ b/src/mercury_engine_data_structures/formats/bmsmd.py @@ -0,0 +1,49 @@ +import functools + +from construct.core import ( + Array, + 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 + +BMSMD = Struct( + "_magic" / Const(b"MSMD"), + "version" / Const(0x000D0001, Hex(Int32ul)), + "map_data" / make_vector(Struct( + "icon" / StrId, + "scenarios" / make_vector(Struct( + "name" / StrId, + "unk1" / Hex(Int32ul), + "unk2" / Hex(Int32ul), + "unk3" / Hex(Int32ul), + "unk4" / Hex(Int32ul), + "unk5" / Hex(Int32ul), + "unk6" / Hex(Int32ul), + "number_of_tiles" / Int32ul, + "unk7" / Hex(Int32ul), + "unk8" / Hex(Int32ul), + "coordinates" / Array(2, Int32ul), + "sub_scenarios" / make_vector(Struct( + "name" / StrId, + "unk1" / Float32l, + "unk2" / Float32l, + "coordinates" / Array(2, Int32sl), + )), + )), + )), +) + +class Bmsmd(BaseResource): + @classmethod + @functools.lru_cache + def construct_class(cls, target_game: Game) -> Construct: + return BMSMD diff --git a/tests/formats/test_bmsmd.py b/tests/formats/test_bmsmd.py new file mode 100644 index 00000000..09b9c52d --- /dev/null +++ b/tests/formats/test_bmsmd.py @@ -0,0 +1,9 @@ +from tests.test_lib import parse_build_compare_editor + +from mercury_engine_data_structures.formats.bmsmd import Bmsmd + + +def test_bmsmd(samus_returns_tree): + parse_build_compare_editor( + Bmsmd, samus_returns_tree, r"gui/minimaps/c10_samus.bmsmd" + )