Add CLI flags for inserting text

This commit is contained in:
Mc-muffin
2023-09-04 20:08:15 -05:00
parent 98198e99ae
commit 5ec5a4dd6d
2 changed files with 35 additions and 3 deletions

View File

@@ -158,6 +158,33 @@ def get_arguments(argv=None):
help="(Optional) - Only for extract Iso command",
)
sp_insert.add_argument(
"--with-proofreading",
required=False,
action="store_const",
const="Proofreading",
default="",
help="(Optional) - Insert lines in 'Proofreading' status",
)
sp_insert.add_argument(
"--with-editing",
required=False,
action="store_const",
const="Editing",
default="",
help="(Optional) - Insert lines in 'Editing' status",
)
sp_insert.add_argument(
"--with-problematic",
required=False,
action="store_const",
const="Problematic",
default="",
help="(Optional) - Insert lines in 'Problematic' status",
)
# Debug commands
sp_debug = sp.add_parser(
"debug",
@@ -228,7 +255,11 @@ def hex2bytes(tales_instance, hex_value):
def getTalesInstance(args, game_name):
if game_name == "TOR":
talesInstance = ToolsTOR.ToolsTOR(args.project.resolve())
if args.action == "insert":
insert_mask = [args.with_proofreading, args.with_editing, args.with_problematic]
else:
insert_mask = [""]
talesInstance = ToolsTOR.ToolsTOR(args.project.resolve(), insert_mask)
elif game_name == "NDX":
talesInstance = ToolsNDX.ToolsNDX("TBL_All.json")
else:

View File

@@ -46,7 +46,7 @@ class ToolsTOR(ToolsTales):
LOW_BITS = 0x3F
def __init__(self, project_file: Path) -> None:
def __init__(self, project_file: Path, insert_mask: list[str]) -> None:
base_path = project_file.parent
self.jsonTblTags = {}
self.ijsonTblTags = {}
@@ -71,7 +71,8 @@ class ToolsTOR(ToolsTales):
# byteCode
self.story_byte_code = b"\xF8"
self.string_opcode = InstructionType.STRING
self.list_status_insertion: list[str] = ['Done', 'Proofreading', 'Editing']
self.list_status_insertion: list[str] = ['Done']
self.list_status_insertion.append(*insert_mask)
# Extract the story files