Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSR - Support .bmsmd #97

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mercury_engine_data_structures/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,6 +58,7 @@
"BMSNAV": Bmsnav,
"BMSLGROUP": Bmslgroup,
"BMSLINK": Bmslink,
"BMSMD": Bmsmd,
"BMTRE": Bmtre,
"BRSA": Brsa,
"BREM": Brem,
Expand Down
49 changes: 49 additions & 0 deletions src/mercury_engine_data_structures/formats/bmsmd.py
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 49 in src/mercury_engine_data_structures/formats/bmsmd.py

View check run for this annotation

Codecov / codecov/patch

src/mercury_engine_data_structures/formats/bmsmd.py#L49

Added line #L49 was not covered by tests
11 changes: 11 additions & 0 deletions tests/formats/test_bmsmd.py
Original file line number Diff line number Diff line change
@@ -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(r"gui\minimaps\c10_samus.bmsmd")
parse_and_build_compare(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the parse_build_compare_editor here instead? Then the uncovered construct_class method would be in the tests, too.

Bmsmd, Game.SAMUS_RETURNS, file_path
)