Fix 657 and remove wrap prompt
This commit is contained in:
parent
d27f49e873
commit
1421cc431b
2 changed files with 75 additions and 54 deletions
|
|
@ -1251,22 +1251,14 @@ class WorkflowTab(QWidget):
|
||||||
wrap_inner.setSpacing(6)
|
wrap_inner.setSpacing(6)
|
||||||
|
|
||||||
wrap_hint = QLabel(
|
wrap_hint = QLabel(
|
||||||
"Copy the prompt, paste it into Copilot with System.json and plugins.js attached. "
|
"Start with the default values (60 / 70 / 60) and run a test translation. "
|
||||||
"It will calculate how many English characters fit per line for each window type. "
|
"If lines overflow or wrap too early in-game, adjust the values here and re-translate. "
|
||||||
"Enter the recommended values and click Apply to update .env."
|
"Click Apply to write the values to .env."
|
||||||
)
|
)
|
||||||
wrap_hint.setWordWrap(True)
|
wrap_hint.setWordWrap(True)
|
||||||
wrap_hint.setStyleSheet("color:#888;font-size:10px;")
|
wrap_hint.setStyleSheet("color:#888;font-size:10px;")
|
||||||
wrap_inner.addWidget(wrap_hint)
|
wrap_inner.addWidget(wrap_hint)
|
||||||
|
|
||||||
copy_wrap_row = QHBoxLayout()
|
|
||||||
copy_wrap_btn = _make_btn("📋 Copy Wrap Prompt", "#555")
|
|
||||||
copy_wrap_btn.setToolTip("Copy the text-wrap analysis prompt to clipboard")
|
|
||||||
copy_wrap_btn.clicked.connect(self._copy_wrap_prompt)
|
|
||||||
copy_wrap_row.addWidget(copy_wrap_btn)
|
|
||||||
copy_wrap_row.addStretch()
|
|
||||||
wrap_inner.addLayout(copy_wrap_row)
|
|
||||||
|
|
||||||
def _spin_pair(label_text: str, default: int):
|
def _spin_pair(label_text: str, default: int):
|
||||||
lbl = QLabel(label_text)
|
lbl = QLabel(label_text)
|
||||||
lbl.setStyleSheet("color:#aaa;font-size:10px;")
|
lbl.setStyleSheet("color:#aaa;font-size:10px;")
|
||||||
|
|
@ -1281,7 +1273,7 @@ class WorkflowTab(QWidget):
|
||||||
return lbl, sp
|
return lbl, sp
|
||||||
|
|
||||||
lbl_w, self.wrap_width_spin = _spin_pair("Dialogue (width)", 60)
|
lbl_w, self.wrap_width_spin = _spin_pair("Dialogue (width)", 60)
|
||||||
lbl_lw, self.wrap_list_spin = _spin_pair("List/Help (listWidth)", 80)
|
lbl_lw, self.wrap_list_spin = _spin_pair("List/Help (listWidth)", 70)
|
||||||
lbl_nw, self.wrap_note_spin = _spin_pair("Notes (noteWidth)", 60)
|
lbl_nw, self.wrap_note_spin = _spin_pair("Notes (noteWidth)", 60)
|
||||||
|
|
||||||
for lbl, sp in [(lbl_w, self.wrap_width_spin),
|
for lbl, sp in [(lbl_w, self.wrap_width_spin),
|
||||||
|
|
|
||||||
|
|
@ -186,14 +186,12 @@ HEADER_MAPPINGS_357 = {
|
||||||
"EventLabel": (["text"], None),
|
"EventLabel": (["text"], None),
|
||||||
"KN_MapBattle": (["enemyName"], None),
|
"KN_MapBattle": (["enemyName"], None),
|
||||||
"KN_Shop": (["goodsType"], None),
|
"KN_Shop": (["goodsType"], None),
|
||||||
|
"KN_StillManager": (["label"], None), # OPEN_GALLERY category label in parameters[3]
|
||||||
"Mano_CurrencyUnit": (["unit"], None),
|
"Mano_CurrencyUnit": (["unit"], None),
|
||||||
"SceneGlossary": (["category"], None),
|
"SceneGlossary": (["category"], None),
|
||||||
# No visible text — keys hold asset/internal IDs, not display text:
|
|
||||||
"KN_StillManager": (["id"], None),
|
|
||||||
"TemplateEvent": (["eventId"], None),
|
|
||||||
}
|
}
|
||||||
# Subset of HEADER_MAPPINGS_357 keys that should be processed (empty = none).
|
# Subset of HEADER_MAPPINGS_357 keys that should be processed (empty = none).
|
||||||
ENABLED_PLUGINS_357: set = set()
|
ENABLED_PLUGINS_357: set = {"KN_StillManager"}
|
||||||
|
|
||||||
# All known code-355/655 script patterns. Enable entries via ENABLED_PATTERNS_355655.
|
# All known code-355/655 script patterns. Enable entries via ENABLED_PATTERNS_355655.
|
||||||
PATTERNS_355655 = {
|
PATTERNS_355655 = {
|
||||||
|
|
@ -1696,6 +1694,7 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
list324 = jobList[6]
|
list324 = jobList[6]
|
||||||
list408 = jobList[7]
|
list408 = jobList[7]
|
||||||
list325 = jobList[8]
|
list325 = jobList[8]
|
||||||
|
list657 = jobList[9]
|
||||||
setData = False
|
setData = False
|
||||||
else:
|
else:
|
||||||
list401 = []
|
list401 = []
|
||||||
|
|
@ -1707,6 +1706,7 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
list324 = []
|
list324 = []
|
||||||
list408 = []
|
list408 = []
|
||||||
list325 = []
|
list325 = []
|
||||||
|
list657 = []
|
||||||
setData = True
|
setData = True
|
||||||
textHistory = []
|
textHistory = []
|
||||||
match = []
|
match = []
|
||||||
|
|
@ -2329,6 +2329,25 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
for argVar in argVars:
|
for argVar in argVars:
|
||||||
translatePlugins(argVar, font)
|
translatePlugins(argVar, font)
|
||||||
|
|
||||||
|
# KN_StillManager: translate parameters[2] (the display label, e.g. "ギャラリーを開く")
|
||||||
|
# Only OPEN_GALLERY has a player-visible label in parameters[2].
|
||||||
|
# Other commands (SHOW_BY_ID, HIDE, etc.) use parameters[2] as an internal label.
|
||||||
|
if (headerString == "KN_StillManager" and "KN_StillManager" in ENABLED_PLUGINS_357
|
||||||
|
and len(codeList[i]["parameters"]) > 2
|
||||||
|
and len(codeList[i]["parameters"]) > 1
|
||||||
|
and codeList[i]["parameters"][1] == "OPEN_GALLERY"):
|
||||||
|
p2 = codeList[i]["parameters"][2]
|
||||||
|
if isinstance(p2, str) and p2.strip():
|
||||||
|
if not (IGNORETLTEXT and not re.search(LANGREGEX, p2)):
|
||||||
|
if setData:
|
||||||
|
list357.append(p2)
|
||||||
|
else:
|
||||||
|
if len(list357) > 0:
|
||||||
|
translatedText = list357[0]
|
||||||
|
list357.pop(0)
|
||||||
|
translatedText = translatedText.replace('"', "")
|
||||||
|
codeList[i]["parameters"][2] = translatedText
|
||||||
|
|
||||||
# AdvExtention plugin support (message event)
|
# AdvExtention plugin support (message event)
|
||||||
if headerString == "AdvExtentionllk" and len(codeList[i]["parameters"]) > 3:
|
if headerString == "AdvExtentionllk" and len(codeList[i]["parameters"]) > 3:
|
||||||
try:
|
try:
|
||||||
|
|
@ -2472,56 +2491,53 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
|
|
||||||
## Event Code: 657 [Picture Text] [Optional]
|
## Event Code: 657 [Picture Text] [Optional]
|
||||||
if "code" in codeList[i] and codeList[i]["code"] == 657 and CODE657 is True:
|
if "code" in codeList[i] and codeList[i]["code"] == 657 and CODE657 is True:
|
||||||
if "text" in codeList[i]["parameters"][0]:
|
jaString = codeList[i]["parameters"][0]
|
||||||
jaString = codeList[i]["parameters"][0]
|
if not isinstance(jaString, str):
|
||||||
if not isinstance(jaString, str):
|
i += 1
|
||||||
i += 1
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
# Definitely don't want to mess with files
|
# Definitely don't want to mess with files
|
||||||
if "_" in jaString:
|
if "_" in jaString:
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Only translate 'メッセージ = <value>' key/value pairs.
|
||||||
|
# All other keys (ページ番号, イベントID, アイコンID, etc.) are internal references.
|
||||||
|
kvMatch = re.match(r"^'?([^=]+?)\s*=\s*(.*?)'?$", jaString, re.DOTALL)
|
||||||
|
if kvMatch:
|
||||||
|
kvKey = kvMatch.group(1).strip()
|
||||||
|
kvValue = kvMatch.group(2).strip()
|
||||||
|
# Strip any outer single-quotes wrapping the value
|
||||||
|
kvValue = re.sub(r"^'(.*)'$", r"\1", kvValue)
|
||||||
|
|
||||||
|
if kvKey != 'メッセージ':
|
||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Skip if IGNORETLTEXT is enabled and no Japanese text
|
# Skip if IGNORETLTEXT is enabled and no Japanese text
|
||||||
if IGNORETLTEXT and not re.search(LANGREGEX, jaString):
|
if IGNORETLTEXT and not re.search(LANGREGEX, kvValue):
|
||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Remove outside text
|
if not kvValue.strip():
|
||||||
startString = re.search(r"^[^一-龠ぁ-ゔァ-ヴー\<\>【】\\]+", jaString)
|
i += 1
|
||||||
jaString = re.sub(r"^[^一-龠ぁ-ゔァ-ヴー\<\>【】\\]+", "", jaString)
|
continue
|
||||||
endString = re.search(r"[^一-龠ぁ-ゔァ-ヴー\<\>【】。!?\\]+$", jaString)
|
|
||||||
jaString = re.sub(r"[^一-龠ぁ-ゔァ-ヴー\<\>【】。!?\\]+$", "", jaString)
|
|
||||||
if startString is None:
|
|
||||||
startString = ""
|
|
||||||
else:
|
|
||||||
startString = startString.group()
|
|
||||||
if endString is None:
|
|
||||||
endString = ""
|
|
||||||
else:
|
|
||||||
endString = endString.group()
|
|
||||||
|
|
||||||
# Remove any textwrap
|
# Remove any textwrap
|
||||||
jaString = re.sub(r"\n", " ", jaString)
|
kvValue = re.sub(r"\n", " ", kvValue)
|
||||||
|
|
||||||
# Translate
|
# Pass 1 – collect value for batch translation
|
||||||
response = translateAI(jaString, "", True)
|
if setData:
|
||||||
totalTokens[0] += response[1][0]
|
list657.append(kvValue)
|
||||||
totalTokens[1] += response[1][1]
|
|
||||||
translatedText = response[0]
|
|
||||||
|
|
||||||
# Remove characters that may break scripts
|
# Pass 2 – apply translated value
|
||||||
charList = [".", '"', "'"]
|
else:
|
||||||
for char in charList:
|
if len(list657) > 0:
|
||||||
translatedText = translatedText.replace(char, "")
|
translatedText = list657[0]
|
||||||
|
list657.pop(0)
|
||||||
# Textwrap
|
for char in ['"', "'"]:
|
||||||
translatedText = dazedwrap.wrapText(translatedText, width=WIDTH)
|
translatedText = translatedText.replace(char, "")
|
||||||
translatedText = startString + translatedText + endString
|
codeList[i]["parameters"][0] = f"'{kvKey} = {translatedText}'"
|
||||||
|
|
||||||
# Set Data
|
|
||||||
codeList[i]["parameters"][0] = translatedText
|
|
||||||
|
|
||||||
## Event Code: 101 [Name] [Optional]
|
## Event Code: 101 [Name] [Optional]
|
||||||
if "code" in codeList[i] and codeList[i]["code"] == 101 and CODE101 is True:
|
if "code" in codeList[i] and codeList[i]["code"] == 101 and CODE101 is True:
|
||||||
|
|
@ -3589,6 +3605,7 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
list355655TL = []
|
list355655TL = []
|
||||||
list108TL = []
|
list108TL = []
|
||||||
list325TL = []
|
list325TL = []
|
||||||
|
list657TL = []
|
||||||
PBAR = pbar
|
PBAR = pbar
|
||||||
|
|
||||||
# 401
|
# 401
|
||||||
|
|
@ -3660,6 +3677,17 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
if filename not in MISMATCH:
|
if filename not in MISMATCH:
|
||||||
MISMATCH.append(filename)
|
MISMATCH.append(filename)
|
||||||
|
|
||||||
|
# 657
|
||||||
|
if len(list657) > 0:
|
||||||
|
response = translateAI(list657, textHistory, True)
|
||||||
|
list657TL = response[0]
|
||||||
|
totalTokens[0] += response[1][0]
|
||||||
|
totalTokens[1] += response[1][1]
|
||||||
|
if len(list657TL) != len(list657):
|
||||||
|
with LOCK:
|
||||||
|
if filename not in MISMATCH:
|
||||||
|
MISMATCH.append(filename)
|
||||||
|
|
||||||
# 408
|
# 408
|
||||||
if len(list408) > 0:
|
if len(list408) > 0:
|
||||||
response = translateAI(list408, "", True)
|
response = translateAI(list408, "", True)
|
||||||
|
|
@ -3710,6 +3738,7 @@ def searchCodes(page, pbar, jobList, filename):
|
||||||
list324TL,
|
list324TL,
|
||||||
list408TL,
|
list408TL,
|
||||||
list325TL,
|
list325TL,
|
||||||
|
list657TL,
|
||||||
],
|
],
|
||||||
filename,
|
filename,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue