Skip to content

Commit

Permalink
Merge pull request #197 from steven11sjf/bpsi
Browse files Browse the repository at this point in the history
BPSI (pack set?)
  • Loading branch information
Miepee authored Jul 27, 2024
2 parents d41dbd1 + 07ba3ff commit db2c05d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Construct type definitions for Mercury Engine
| BMTRE | ✗ | ✗ | ✓ | ✓ |
| BMTUN | ✓ | ✓ | Missing | Missing |
| BNVIB | Missing | Missing | ✓ | ✓ |
| BPSI | ✗ | ✗ | ✗ | ✗ |
| BPSI | ✓ | ✓ | ✓ | ✓ |
| BPTDAT | Missing | Missing | ✗ | ✗ |
| BPTDEF | Missing | Missing | ✗ | ✗ |
| BREM | Missing | Missing | ✓ | ✓ |
Expand Down
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 @@ -31,6 +31,7 @@
from mercury_engine_data_structures.formats.bmtre import Bmtre
from mercury_engine_data_structures.formats.bmtun import Bmtun
from mercury_engine_data_structures.formats.bnvib import Bnvib
from mercury_engine_data_structures.formats.bpsi import Bpsi
from mercury_engine_data_structures.formats.brem import Brem
from mercury_engine_data_structures.formats.bres import Bres
from mercury_engine_data_structures.formats.brev import Brev
Expand Down Expand Up @@ -80,6 +81,7 @@
"BMSLGROUP": Bmslgroup,
"BMSLINK": Bmslink,
"BMSMD": Bmsmd,
"BPSI": Bpsi,
"BMTRE": Bmtre,
"BNVIB": Bnvib,
"BRSA": Brsa,
Expand Down
25 changes: 25 additions & 0 deletions src/mercury_engine_data_structures/formats/bpsi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from construct.core import Const, Construct, IfThenElse, Int32ul, PrefixedArray, Struct, Terminated

from mercury_engine_data_structures import game_check
from mercury_engine_data_structures.common_types import VersionAdapter
from mercury_engine_data_structures.construct_extensions.strings import PascalStringRobust
from mercury_engine_data_structures.formats.base_resource import BaseResource

BPSI = Struct(
_magic = Const(b"MPSI"),
version = IfThenElse(
game_check.current_game_at_most(game_check.Game.SAMUS_RETURNS),
VersionAdapter("1.2.0"),
VersionAdapter("1.3.0")
),
files = PrefixedArray(Int32ul, Struct(
file = PascalStringRobust(Int32ul, "utf-8"),
in_packages = PrefixedArray(Int32ul, PascalStringRobust(Int32ul, "utf-8"))
)),
_eof=Terminated
)

class Bpsi(BaseResource):
@classmethod
def construct_class(cls, target_game: game_check.Game) -> Construct:
return BPSI
14 changes: 14 additions & 0 deletions tests/formats/test_bpsi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest
from tests.test_lib import parse_build_compare_editor

from mercury_engine_data_structures import dread_data, samus_returns_data
from mercury_engine_data_structures.formats.bpsi import Bpsi


@pytest.mark.parametrize("bpsi_path", dread_data.all_files_ending_with(".bpsi"))
def test_bmtre_dread(dread_file_tree, bpsi_path):
parse_build_compare_editor(Bpsi, dread_file_tree, bpsi_path)

@pytest.mark.parametrize("bpsi_path", samus_returns_data.all_files_ending_with(".bpsi"))
def test_bmtre_sr(dread_file_tree, bpsi_path):
parse_build_compare_editor(Bpsi, dread_file_tree, bpsi_path)

0 comments on commit db2c05d

Please sign in to comment.