Skip to content

Commit

Permalink
Start creating GUI for file extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
ExcaliburZero committed Feb 23, 2024
1 parent f3e882a commit fb3b660
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 9 deletions.
70 changes: 62 additions & 8 deletions dqmj1_info/extract_files.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from typing import List
from typing import Any, List

import argparse
import enum
import glob
import logging
import pathlib
import sys

import gooey

from . import d16_to_png
from . import decompile_evt
from . import enmy_kind_tbl
Expand All @@ -22,18 +25,66 @@
SUCCESS = 0
FAILURE = 1

class UiMode(enum.Enum):
CLI = enum.auto()
GUI = enum.auto()

def main(argv: List[str]):
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s> %(message)s")

def cli_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser()

parser.add_argument("--input_directory", required=True)
parser.add_argument("--output_directory", required=True)
parser.add_argument("--language", default="en")
parser.add_argument(
"--input_directory",
required=True,
help="Directory containing the unpacked game files (typically unpacked using a program link DsLazy).",
)
parser.add_argument(
"--output_directory",
required=True,
help="Directory to write extracted files to. It is recommended to create a new empty directory.",
)
parser.add_argument(
"--language", default="en", choices=language_configs.LANGUAGE_CONFIGS.keys()
)

return parser


@gooey.Gooey(program_name="DQMJ1 Unofficial File Extractor")
def gui_parser() -> gooey.GooeyParser:
parser = gooey.GooeyParser(
description="Program that extracts data files from Dragon Quest Monsters: Joker."
)

parser.add_argument(
"--input_directory",
required=True,
widget="DirChooser",
help="Directory containing the unpacked game files (typically unpacked using a program link DsLazy).",
)
parser.add_argument(
"--output_directory",
required=True,
widget="DirChooser",
help="Directory to write extracted files to. It is recommended to create a new empty directory.",
)
parser.add_argument(
"--language", default="en", choices=language_configs.LANGUAGE_CONFIGS.keys()
)

return parser


def main(argv: List[str], mode: UiMode):
if mode == UiMode.GUI:
parser = gui_parser()
else:
parser = cli_parser()

args = parser.parse_args(argv)

logging.basicConfig(level=logging.DEBUG, format="%(levelname)s> %(message)s")

input_directory = pathlib.Path(args.input_directory)
output_directory = pathlib.Path(args.output_directory)

Expand Down Expand Up @@ -228,5 +279,8 @@ def main(argv: List[str]):
return SUCCESS


def main_without_args() -> None:
return main(sys.argv[1:])
def main_cli() -> None:
return main(sys.argv[1:], mode=UiMode.CLI)

def main_gui() -> None:
return main(sys.argv[1:], mode=UiMode.GUI)
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ version = "0.0.1"
dependencies = ["numpy", "pandas", "Pillow"]

[project.scripts]
dqmj1_extract_files = "dqmj1_info:extract_files.main_without_args"
dqmj1_extract_files = "dqmj1_info:extract_files.main_cli"
dqmj1_extract_files_gui = "dqmj1_info:extract_files.main_gui"
dqmj1_compile_evt = "dqmj1_info:compile_evt.main_without_args"
dqmj1_decompile_evt = "dqmj1_info:decompile_evt.main_without_args"
d16_to_png = "dqmj1_info:d16_to_png.main_without_args"
Expand Down

0 comments on commit fb3b660

Please sign in to comment.