From 629fdc1561927acf1336622dcc6a7294e4348089 Mon Sep 17 00:00:00 2001 From: dyceron <38679103+dyceron@users.noreply.github.com> Date: Mon, 6 Nov 2023 17:53:25 -0500 Subject: [PATCH 1/3] Support bmsmd --- .../formats/__init__.py | 2 + .../formats/bmsmd.py | 48 +++++++++++++++++++ tests/formats/test_bmsmd.py | 11 +++++ 3 files changed, 61 insertions(+) create mode 100644 src/mercury_engine_data_structures/formats/bmsmd.py create mode 100644 tests/formats/test_bmsmd.py 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..1ea59c42 --- /dev/null +++ b/src/mercury_engine_data_structures/formats/bmsmd.py @@ -0,0 +1,48 @@ +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 \ No newline at end of file diff --git a/tests/formats/test_bmsmd.py b/tests/formats/test_bmsmd.py new file mode 100644 index 00000000..6d93d02e --- /dev/null +++ b/tests/formats/test_bmsmd.py @@ -0,0 +1,11 @@ +from tests.test_lib import parse_and_build_compare + +from mercury_engine_data_structures.formats.bmsmd import Bmsmd +from mercury_engine_data_structures.game_check import Game + + +def test_bmsmd(samus_returns_path): + file_path = samus_returns_path.joinpath("gui\minimaps\c10_samus.bmsmd") + parse_and_build_compare( + Bmsmd, Game.SAMUS_RETURNS, file_path + ) From ed582b7eed74f12fb8bba7249f3b6e977cf520ee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:55:16 +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/bmsmd.py | 3 ++- tests/formats/test_bmsmd.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mercury_engine_data_structures/formats/bmsmd.py b/src/mercury_engine_data_structures/formats/bmsmd.py index 1ea59c42..488725cc 100644 --- a/src/mercury_engine_data_structures/formats/bmsmd.py +++ b/src/mercury_engine_data_structures/formats/bmsmd.py @@ -1,4 +1,5 @@ import functools + from construct.core import ( Array, Const, @@ -45,4 +46,4 @@ class Bmsmd(BaseResource): @classmethod @functools.lru_cache def construct_class(cls, target_game: Game) -> Construct: - return BMSMD \ No newline at end of file + return BMSMD diff --git a/tests/formats/test_bmsmd.py b/tests/formats/test_bmsmd.py index 6d93d02e..f200f3d5 100644 --- a/tests/formats/test_bmsmd.py +++ b/tests/formats/test_bmsmd.py @@ -5,7 +5,7 @@ def test_bmsmd(samus_returns_path): - file_path = samus_returns_path.joinpath("gui\minimaps\c10_samus.bmsmd") + file_path = samus_returns_path.joinpath(r"gui\minimaps\c10_samus.bmsmd") parse_and_build_compare( Bmsmd, Game.SAMUS_RETURNS, file_path ) From b913f011c0c961e72594c1497949ae0e6dde8f88 Mon Sep 17 00:00:00 2001 From: dyceron <38679103+dyceron@users.noreply.github.com> Date: Wed, 8 Nov 2023 08:51:20 -0500 Subject: [PATCH 3/3] Update test_bmsmd.py --- tests/formats/test_bmsmd.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/formats/test_bmsmd.py b/tests/formats/test_bmsmd.py index f200f3d5..09b9c52d 100644 --- a/tests/formats/test_bmsmd.py +++ b/tests/formats/test_bmsmd.py @@ -1,11 +1,9 @@ -from tests.test_lib import parse_and_build_compare +from tests.test_lib import parse_build_compare_editor from mercury_engine_data_structures.formats.bmsmd import Bmsmd -from mercury_engine_data_structures.game_check import Game -def test_bmsmd(samus_returns_path): - file_path = samus_returns_path.joinpath(r"gui\minimaps\c10_samus.bmsmd") - parse_and_build_compare( - Bmsmd, Game.SAMUS_RETURNS, file_path +def test_bmsmd(samus_returns_tree): + parse_build_compare_editor( + Bmsmd, samus_returns_tree, r"gui/minimaps/c10_samus.bmsmd" )