Skip to content

Commit

Permalink
Merge pull request #91 from ThanatosGit/parse-bmsmsd
Browse files Browse the repository at this point in the history
Add support for BMSMSD
  • Loading branch information
dyceron authored Oct 25, 2023
2 parents 87ab147 + b91e0ce commit 47630bb
Show file tree
Hide file tree
Showing 3 changed files with 65 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 @@ -14,6 +14,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.bmsmsd import Bmsmsd
from mercury_engine_data_structures.formats.bmsnav import Bmsnav
from mercury_engine_data_structures.formats.bmssd import Bmssd
from mercury_engine_data_structures.formats.bmtre import Bmtre
Expand Down Expand Up @@ -50,6 +51,7 @@
"BMSCD": Bmscc,
"BMSCU": Bmscu,
"BMSLD": Bmsld,
"BMSMSD": Bmsmsd,
"BMSNAV": Bmsnav,
"BMSLGROUP": Bmslgroup,
"BMSLINK": Bmslink,
Expand Down
50 changes: 50 additions & 0 deletions src/mercury_engine_data_structures/formats/bmsmsd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import functools

import construct
from construct.core import Const, Construct, Float32l, Hex, Int32sl, Int32ul, Struct

from mercury_engine_data_structures.common_types import CVector2D, CVector3D, StrId, make_vector
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.game_check import Game

# BMSMSD
BMSMSD = Struct(
"_magic" / Const(b"MMSD"),
"version" / Const(0x00070001, Hex(Int32ul)),
"scenario" / StrId,
"tile_size" / construct.Array(2, Float32l),
"x_tiles" / Int32sl,
"y_tiles" / Int32sl,
"map_dimensions" / Struct(
"bottom_left" / CVector2D,
"top_right" / CVector2D,
),
"tiles" / make_vector(
Struct(
"tile_coordinates" / construct.Array(2, Int32sl),
"dimension" / Struct(
"bottom_left" / CVector2D,
"top_right" / CVector2D,
),
"border_type" / Int32sl,
"tile_type" / Int32sl,
"icons" / make_vector(
Struct(
"actor_name" / StrId,
"clear_condition" / StrId,
"icon" / StrId,
"icon_priority" / Int32sl,
"coordinates" / CVector3D,
)
),
)
),
construct.Terminated,
)


class Bmsmsd(BaseResource):
@classmethod
@functools.lru_cache
def construct_class(cls, target_game: Game) -> Construct:
return BMSMSD
13 changes: 13 additions & 0 deletions tests/formats/test_bmsmsd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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.bmsmsd import Bmsmsd

all_sr_bmsmsd = [name for name in samus_returns_data.all_name_to_asset_id().keys()
if name.endswith(".bmsmsd")]


@pytest.mark.parametrize("bmsmsd_path", all_sr_bmsmsd)
def test_bmtun(samus_returns_tree, bmsmsd_path):
parse_build_compare_editor(Bmsmsd, samus_returns_tree, bmsmsd_path)

0 comments on commit 47630bb

Please sign in to comment.