Speaker Parsing in Ace too
This commit is contained in:
parent
5d0f3b53f3
commit
6438387cbd
2 changed files with 29 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"):
|
||||
|
|
|
|||
Loading…
Reference in a new issue