-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from ThanatosGit/parse-bmsmsd
Add support for BMSMSD
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |