Skip to content

Commit

Permalink
Add support for bmses
Browse files Browse the repository at this point in the history
  • Loading branch information
dyceron committed Nov 5, 2023
1 parent e1889d0 commit a337357
Show file tree
Hide file tree
Showing 3 changed files with 61 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 @@ -8,6 +8,7 @@
from mercury_engine_data_structures.formats.bmmdef import Bmmdef
from mercury_engine_data_structures.formats.bmsad import Bmsad
from mercury_engine_data_structures.formats.bmsas import Bmsas
from mercury_engine_data_structures.formats.bmses import Bmses
from mercury_engine_data_structures.formats.bmsbk import Bmsbk
from mercury_engine_data_structures.formats.bmscc import Bmscc
from mercury_engine_data_structures.formats.bmscu import Bmscu
Expand Down Expand Up @@ -45,6 +46,7 @@
"BMSSS": Bmsss,
"BMSAD": Bmsad,
"BMSAS": Bmsas,
"BMSES": Bmses,
"BMTUN": Bmtun,
"BRFLD": Brfld,
"BMSCC": Bmscc,
Expand Down
46 changes: 46 additions & 0 deletions src/mercury_engine_data_structures/formats/bmses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import functools
import construct
from construct.core import (
Const,
Construct,
Float32l,
Hex,
Int32ul,
Int32sl,
Struct,
)

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


BMSES = Struct(
"magic" / Const(b"MSES"),
"version" / Hex(Int32ul),
"sounds" / make_vector(Struct(
"name" / StrId,
"sound_file" / StrId,
"properties" / Struct(
"fade_in" / Float32l,
"fade_out" / Float32l,
"start_delay" / Float32l,
"volume" / Float32l,
"unk1" / Int32sl,
"sub_sound" / make_vector(Struct(
"name" / StrId,
"properties" / Struct(
"unk2" / Float32l,
"unk3" / CVector3D,
"unk4" / Int32sl,
))),
))),
construct.Terminated,
)


class Bmses(BaseResource):
@classmethod
@functools.lru_cache
def construct_class(cls, target_game: Game) -> Construct:
return BMSES
13 changes: 13 additions & 0 deletions tests/formats/test_bmses.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.bmses import Bmses

all_sr_bmses = [name for name in samus_returns_data.all_name_to_asset_id().keys()
if name.endswith(".bmses")]


@pytest.mark.parametrize("bmses_path", all_sr_bmses)
def test_bmses(samus_returns_tree, bmses_path):
parse_build_compare_editor(Bmses, samus_returns_tree, bmses_path)

0 comments on commit a337357

Please sign in to comment.