From 6438387cbdc3850e8ff1cd5f0c8aa02c0f743e4d Mon Sep 17 00:00:00 2001 From: dazedanon Date: Tue, 28 Oct 2025 12:30:43 -0500 Subject: [PATCH] Speaker Parsing in Ace too --- gui/translation_tab.py | 22 ++++++++++++++-------- modules/main.py | 22 +++++++++++++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/gui/translation_tab.py b/gui/translation_tab.py index f6cbba7..62a5395 100644 --- a/gui/translation_tab.py +++ b/gui/translation_tab.py @@ -303,21 +303,27 @@ class TranslationWorker(QThread): threads = int(os.getenv("fileThreads", "1")) total_cost = "Fail" - # If we're doing Parse Speakers for RPGMaker MV/MZ, run handlers in-process so + # If we're doing Parse Speakers for RPGMaker MV/MZ or ACE, run handlers in-process so # speaker collection is shared in this process and finalizeSpeakerParse() can run once. - is_mvmz = "mv/mz" in (self.module_info[0].lower() if isinstance(self.module_info[0], str) else "") + module_name_lower = self.module_info[0].lower() if isinstance(self.module_info[0], str) else "" + is_mvmz = "mv/mz" in module_name_lower + is_ace = "ace" in module_name_lower # Change to project directory for module execution old_cwd = os.getcwd() os.chdir(str(self.project_root)) try: - if self.parse_speakers and is_mvmz: + if self.parse_speakers and (is_mvmz or is_ace): # Run handlers sequentially in this worker process so globals are shared try: - from modules.rpgmakermvmz import handleMVMZ, setSpeakerParseMode, finalizeSpeakerParse, TOKENS, calculateCost, MODEL + if is_mvmz: + from modules.rpgmakermvmz import handleMVMZ as handler, setSpeakerParseMode, finalizeSpeakerParse, TOKENS, calculateCost, MODEL + elif is_ace: + from modules.rpgmakerace import handleACE as handler, setSpeakerParseMode, finalizeSpeakerParse, TOKENS, calculateCost, MODEL except Exception as e: - self.emit_log(f"❌ Could not import rpgmakermvmz for speaker-parse: {e}") + engine_name = "rpgmakermvmz" if is_mvmz else "rpgmakerace" + self.emit_log(f"❌ Could not import {engine_name} for speaker-parse: {e}") self.finished_signal.emit(False, str(e)) return @@ -335,7 +341,7 @@ class TranslationWorker(QThread): break # Run handler in-process try: - result = handleMVMZ(filename, self.estimate_only) + result = handler(filename, self.estimate_only) completed_count += 1 self.emit_progress(completed_count, total_files, filename) # Handler prints cost lines via tqdm.write; capture nothing here @@ -1070,8 +1076,8 @@ class TranslationTab(QWidget): self.mode_combo.addItem("Translate") self.mode_combo.addItem("Estimate") - # Add Parse Speakers for RPG Maker MV/MZ - if "mv/mz" in lowered: + # Add Parse Speakers for RPG Maker MV/MZ and RPG Maker Ace + if "mv/mz" in lowered or "ace" in lowered: self.mode_combo.addItem("Parse Speakers") # Restore previous selection if it still exists diff --git a/modules/main.py b/modules/main.py index 6387613..906e0b0 100644 --- a/modules/main.py +++ b/modules/main.py @@ -34,8 +34,8 @@ if envMissing: these values using an .env file, for an example see .env.example" ) -from modules.rpgmakermvmz import handleMVMZ, setSpeakerParseMode, finalizeSpeakerParse -from modules.rpgmakerace import handleACE +from modules.rpgmakermvmz import handleMVMZ, setSpeakerParseMode as setSpeakerParseMVMZ, finalizeSpeakerParse as finalizeSpeakerParseMVMZ +from modules.rpgmakerace import handleACE, setSpeakerParseMode as setSpeakerParseACE, finalizeSpeakerParse as finalizeSpeakerParseACE from modules.csv import handleCSV from modules.tyrano import handleTyrano from modules.kirikiri import handleKirikiri @@ -118,11 +118,13 @@ def main(): files to translate are in the /files folder and that you picked the right game engine." ) - # If translating RPGMaker MV/MZ (index 0) prompt for speaker parse mode - if version == 0 and not estimate: + # If translating RPGMaker MV/MZ (index 0) or RPGMaker ACE (index 2) prompt for speaker parse mode + speaker_parse = False + if version in [0, 2] and not estimate: sub = "" + engine_name = "RPGMaker MV/MZ" if version == 0 else "RPGMaker ACE" while sub == "": - sub = input("RPGMaker MV/MZ options:\n\n 1. Standard Translate\n 2. Parse Speakers (collect speaker names only)\n") + sub = input(f"{engine_name} options:\n\n 1. Standard Translate\n 2. Parse Speakers (collect speaker names only)\n") match sub: case "1": speaker_parse = False @@ -131,7 +133,10 @@ files to translate are in the /files folder and that you picked the right game e case _: sub = "" if speaker_parse: - setSpeakerParseMode(True) + if version == 0: + setSpeakerParseMVMZ(True) + elif version == 2: + setSpeakerParseACE(True) # Open File (Threads) - recursively walk 'files' and preserve directory structure # Prepare per-run log file so CLI runs also write to a run-specific history file @@ -238,7 +243,10 @@ files to translate are in the /files folder and that you picked the right game e # Finalize speaker parse mode by writing collected speakers to vocab if speaker_parse: - finalizeSpeakerParse() + if version == 0: + finalizeSpeakerParseMVMZ() + elif version == 2: + finalizeSpeakerParseACE() # Delete Tmp Files if os.path.isfile("csv.tmp"):