-
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 #7 from duncathan/fixes-for-patcher
couple things for patcher needs
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from construct.core import Struct, Construct, Const | ||
|
||
from mercury_engine_data_structures.common_types import make_dict | ||
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 | ||
|
||
TXT = Struct( | ||
"magic" / Const(b'BTXT'), | ||
"version" / Const(b'\x01\x00\x0a\x00'), | ||
"strings" / make_dict(CStringRobust("utf16")) | ||
) | ||
|
||
|
||
class Txt(BaseResource): | ||
@classmethod | ||
def construct_class(cls, target_game: Game) -> Construct: | ||
return TXT | ||
|
||
@property | ||
def strings(self) -> dict[str, str]: | ||
return self._raw.strings | ||
|
||
@strings.setter | ||
def strings(self, value): | ||
self._raw.strings = value |
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,10 @@ | ||
import pytest | ||
from mercury_engine_data_structures.formats.txt import TXT | ||
from mercury_engine_data_structures.game_check import Game | ||
from test.test_lib import parse_and_build_compare | ||
|
||
def test_compare_dread(dread_path): | ||
file_path = dread_path.joinpath("system/localization/us_english.txt") | ||
parse_and_build_compare( | ||
TXT, Game.DREAD, file_path | ||
) |
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