Skip to content

Commit

Permalink
Merge pull request #97 from dyceron/bmsmd
Browse files Browse the repository at this point in the history
MSR - Support .bmsmd
  • Loading branch information
ThanatosGit authored Nov 9, 2023
2 parents c38b11c + b913f01 commit a6d8b6f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
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
9 changes: 9 additions & 0 deletions tests/formats/test_bmsmd.py
Original file line number Diff line number Diff line change
@@ -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"
)

0 comments on commit a6d8b6f

Please sign in to comment.