summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDragorn421 <Dragorn421@users.noreply.github.com>2024-02-06 02:40:31 +0100
committerGitHub <noreply@github.com>2024-02-05 20:40:31 -0500
commit9da4e17c8f5105d71249c260f86bb5469980f23a (patch)
tree09459b8959b44dbab4cf58fd7fff95cd8326a881
parentc240184229ddbfac87d7cde68bbe3e4aebdb002b (diff)
Split msgdis from extract_assets (#1723)
* split msgdis from extract_assets * move import
-rw-r--r--Makefile1
-rwxr-xr-xextract_assets.py17
-rwxr-xr-x[-rw-r--r--]tools/msgdis.py21
3 files changed, 23 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index e241f8364..5245a09b6 100644
--- a/Makefile
+++ b/Makefile
@@ -370,6 +370,7 @@ setup: venv
# TODO: for now, we only extract assets from the Debug ROM
ifeq ($(VERSION),gc-eu-mq-dbg)
$(PYTHON) extract_assets.py -j$(N_THREADS)
+ $(PYTHON) tools/msgdis.py --text-out assets/text/message_data.h --staff-text-out assets/text/message_data_staff.h
endif
disasm: $(DISASM_O_FILES)
diff --git a/extract_assets.py b/extract_assets.py
index defac57dc..ced7da4a1 100755
--- a/extract_assets.py
+++ b/extract_assets.py
@@ -96,7 +96,7 @@ def processZAPDArgs(argsZ):
def main():
parser = argparse.ArgumentParser(description="baserom asset extractor")
parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep")
- parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones, and text (overwriting current files).", action="store_true")
+ parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones (overwriting current files).", action="store_true")
parser.add_argument("-j", "--jobs", help="Number of cpu cores to extract with.")
parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true")
parser.add_argument("-Z", help="Pass the argument on to ZAPD, e.g. `-ZWunaccounted` to warn about unaccounted blocks in XMLs. Each argument should be passed separately, *without* the leading dash.", metavar="ZAPD_ARG", action="append")
@@ -128,21 +128,6 @@ def main():
del extractedAssetsTracker[fullPath]
ExtractFunc(fullPath)
else:
- extract_text_path = "assets/text/message_data.h"
- extract_staff_text_path = "assets/text/message_data_staff.h"
-
- # Only extract text if the header does not already exist, or if --force was passed
- if not args.force:
- if os.path.isfile(extract_text_path):
- extract_text_path = None
- if os.path.isfile(extract_staff_text_path):
- extract_staff_text_path = None
-
- if extract_text_path is not None or extract_staff_text_path is not None:
- print("Extracting text")
- from tools import msgdis
- msgdis.extract_all_text(extract_text_path, extract_staff_text_path)
-
xmlFiles = []
for currentPath, _, files in os.walk(os.path.join("assets", "xml")):
for file in files:
diff --git a/tools/msgdis.py b/tools/msgdis.py
index a946779fa..1da85713e 100644..100755
--- a/tools/msgdis.py
+++ b/tools/msgdis.py
@@ -5,6 +5,7 @@
import re, struct
from os import path
+import argparse
# ===================================================
# Util
@@ -404,3 +405,23 @@ def extract_all_text(text_out, staff_text_out):
with open(staff_text_out, "w", encoding="utf8") as outfile:
outfile.write(out.strip() + "\n")
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description="Extract text from the baserom into .h files"
+ )
+ parser.add_argument("--text-out", help="Path to output .h file for text")
+ parser.add_argument(
+ "--staff-text-out", help="Path to output .h file for staff text"
+ )
+
+ args = parser.parse_args()
+ if not (args.text_out or args.staff_text_out):
+ parser.error("No output file requested")
+
+ extract_all_text(args.text_out, args.staff_text_out)
+
+
+if __name__ == "__main__":
+ main()