Skip to content

Commit

Permalink
Support for SR TXT files
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanatosGit committed Oct 1, 2023
1 parent e11f4e2 commit c8d6ee4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mercury_engine_data_structures/formats/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from mercury_engine_data_structures.common_types import DictAdapter, DictElement
from mercury_engine_data_structures.construct_extensions.strings import CStringRobust
from mercury_engine_data_structures.formats import BaseResource
from mercury_engine_data_structures.game_check import Game
from mercury_engine_data_structures.game_check import Game, is_sr_or_else

_string_range = GreedyRange(DictElement(CStringRobust("utf-16-le")))

Expand Down Expand Up @@ -38,7 +38,10 @@ def _parse_{n}(io, this):

TXT = Struct(
"magic" / Const(b'BTXT'),
"version" / Const(b'\x01\x00\x0a\x00'),
"version" / is_sr_or_else(
Const(b'\x01\x00\x08\x00'),
Const(b'\x01\x00\x0a\x00'),
),
"strings" / DictAdapter(_string_range),
"_end" / construct.Terminated,
)
Expand Down
6 changes: 6 additions & 0 deletions tests/formats/test_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ def test_compare_dread(dread_path):
parse_and_build_compare(
TXT, Game.DREAD, file_path
)

def test_compare_sr(samus_returns_path):
file_path = samus_returns_path.joinpath("system/localization/us_english.txt")
parse_and_build_compare(
TXT, Game.SAMUS_RETURNS, file_path
)

0 comments on commit c8d6ee4

Please sign in to comment.