diff --git a/src/mercury_engine_data_structures/cli.py b/src/mercury_engine_data_structures/cli.py index 211870bb..044b93b9 100644 --- a/src/mercury_engine_data_structures/cli.py +++ b/src/mercury_engine_data_structures/cli.py @@ -8,11 +8,15 @@ from pathlib import Path from typing import Optional +import construct + from mercury_engine_data_structures import formats from mercury_engine_data_structures.construct_extensions.json import convert_to_raw_python from mercury_engine_data_structures.file_tree_editor import FileTreeEditor from mercury_engine_data_structures.game_check import Game +construct.setGlobalPrintFullStrings(True) + def game_argument_type(s: str) -> Game: try: diff --git a/src/mercury_engine_data_structures/formats/__init__.py b/src/mercury_engine_data_structures/formats/__init__.py index bcf3488b..acf4c8c9 100644 --- a/src/mercury_engine_data_structures/formats/__init__.py +++ b/src/mercury_engine_data_structures/formats/__init__.py @@ -13,6 +13,7 @@ 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 +from mercury_engine_data_structures.formats.bmsem import Bmsem from mercury_engine_data_structures.formats.bmses import Bmses from mercury_engine_data_structures.formats.bmsld import Bmsld from mercury_engine_data_structures.formats.bmslgroup import Bmslgroup @@ -58,6 +59,7 @@ "BMSCC": Bmscc, "BMSCD": Bmscc, "BMSCU": Bmscu, + "BMSEM": Bmsem, "BMSLD": Bmsld, "BMSMSD": Bmsmsd, "BMSNAV": Bmsnav, diff --git a/src/mercury_engine_data_structures/formats/bmsem.py b/src/mercury_engine_data_structures/formats/bmsem.py new file mode 100644 index 00000000..fa685eab --- /dev/null +++ b/src/mercury_engine_data_structures/formats/bmsem.py @@ -0,0 +1,43 @@ +import construct +from construct import ( + Array, + Const, + Construct, + Float32l, + Int16ul, + 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 + +VectorArray = Array(3, Float32l) + +BMSEM = Struct( + _magic=Const(b"MSEM"), + unk1=Int16ul, + unk2=Int16ul, + things= make_vector(Struct( + "layer_name" / StrId, + "objects" / make_vector(Struct( + "whatever_name" / StrId, + # "unk1" / Int32ul + "inner_things" / make_vector(Struct( + "first_part" / StrId, + "second_part" / StrId, + "unk3" / Int32ul, + "unk4" / Int32ul, + "unk6" / Int32ul, + "unk7" / Int32ul + )) + )) + )), + rest=construct.GreedyBytes, +) + +class Bmsem(BaseResource): + @classmethod + def construct_class(cls, target_game: Game) -> Construct: + return BMSEM diff --git a/tests/formats/test_bmsem.py b/tests/formats/test_bmsem.py new file mode 100644 index 00000000..9e91de71 --- /dev/null +++ b/tests/formats/test_bmsem.py @@ -0,0 +1,12 @@ +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.bmsem import Bmsem + +all_sr_bmsmsd = [name for name in samus_returns_data.all_name_to_asset_id().keys() + if name.endswith(".bmsem")] + +@pytest.mark.parametrize("bmsmsd_path", all_sr_bmsmsd) +def test_bmsem(samus_returns_tree, bmsmsd_path): + parse_build_compare_editor(Bmsem, samus_returns_tree, bmsmsd_path, print_data=True)