diff --git a/modules/rpgmakermvmz.py b/modules/rpgmakermvmz.py index f1f7605..7af829a 100644 --- a/modules/rpgmakermvmz.py +++ b/modules/rpgmakermvmz.py @@ -3,6 +3,7 @@ import json import os import re import textwrap +import util.dazedwrap as dazedwrap import threading import time import traceback @@ -324,7 +325,7 @@ def translateNote(event, regex, wordwrap=False): # Textwrap if wordwrap: - translatedText = textwrap.fill(translatedText, width=NOTEWIDTH) + translatedText = dazedwrap.wrapText(translatedText, width=NOTEWIDTH) translatedText = translatedText.replace('"', "") jaString = jaString.replace(initialJAString, translatedText) @@ -569,7 +570,7 @@ def searchNames(data, pbar, context): nameList.append(data[i]["name"]) if "description" in data[i] and data[i]["description"] != "": description = data[i]["description"] - # description = description.replace("\n", " ") + description = description.replace("\n", " ") descriptionList.append(description) if "") @@ -639,6 +640,10 @@ def searchNames(data, pbar, context): tokensResponse = translateNote(data[i], r"", True) totalTokens[0] += tokensResponse[0] totalTokens[1] += tokensResponse[1] + if "ExtendDesc" in data[i]["note"]: + tokensResponse = translateNote(data[i], r"", True) + totalTokens[0] += tokensResponse[0] + totalTokens[1] += tokensResponse[1] i += 1 @@ -762,7 +767,7 @@ def searchNames(data, pbar, context): data[j]["nickname"] = translatedNicknameBatch[0] translatedNicknameBatch.pop(0) if "profile" in data[j] and data[j]["profile"]: - data[j]["profile"] = textwrap.fill(translatedProfileBatch[0], LISTWIDTH) + data[j]["profile"] = dazedwrap.wrapText(translatedProfileBatch[0], LISTWIDTH) translatedProfileBatch.pop(0) # If Batch is empty. Move on. @@ -809,7 +814,7 @@ def searchNames(data, pbar, context): data[j]["name"] = translatedNameBatch[0] translatedNameBatch.pop(0) if "description" in data[j] and data[j]["description"] != "": - # translatedDescriptionBatch[0] = textwrap.fill(translatedDescriptionBatch[0], LISTWIDTH) + translatedDescriptionBatch[0] = dazedwrap.wrapText(translatedDescriptionBatch[0], LISTWIDTH) data[j]["description"] = translatedDescriptionBatch[0] translatedDescriptionBatch.pop(0) @@ -999,7 +1004,7 @@ def searchCodes(page, pbar, jobList, filename): if len(speakerList) == 0 and FIRSTLINESPEAKERS is True: # Remove any RPGMaker Code at start ffMatch = re.search( - r"^(\s*[\\]+[aAbBdDeEfFgGhHjJlLmMoOpPqQrRsStTuUwWxXyYzZ]+\[[\w\d\[\]\\]+\])", + r"^((?:[\\]+[^cCnNiIkKvV]+\[[\d\w]+\])+)", jaString, ) if ffMatch != None: @@ -1097,7 +1102,6 @@ def searchCodes(page, pbar, jobList, filename): codeList[i]["parameters"] = [finalJAString] ### \\n - nCase = None regex = r"([\\]+[kKnN][wWcCrRrEe]?[\[<](.*?)[>\]])" match = re.search(regex, finalJAString) @@ -1135,12 +1139,12 @@ def searchCodes(page, pbar, jobList, filename): # Remove any RPGMaker Code at start ffMatch = re.search( - r"^(\s*[\\]+[aAbBdDeEfFgGhHjJlLmMoOpPqQrRsStTuUwWxXyYzZ]+\[[\w\d\[\]\\]+?\])", + r"^((?:[\\]+[^cCnNiIkKvV]+\[[\d\w]+\])+)", finalJAString, ) if ffMatch != None: finalJAString = finalJAString.replace(ffMatch.group(1), "") - nametag += ffMatch.group(1) + nametag = ffMatch.group(1) + nametag # Remove _ABL Codes ffMatch = re.search(r"^(_ABL).*", finalJAString) @@ -1208,9 +1212,9 @@ def searchCodes(page, pbar, jobList, filename): finalJAString = finalJAString.replace("
", " ") if FIXTEXTWRAP is True and "_ABL" in nametag: - translatedText = textwrap.fill(translatedText, width=100) + translatedText = dazedwrap.wrapText(translatedText, width=100) elif FIXTEXTWRAP is True: - translatedText = textwrap.fill(translatedText, width=WIDTH) + translatedText = dazedwrap.wrapText(translatedText, width=WIDTH) # Formatting Code if instantLineFlag: @@ -1234,11 +1238,8 @@ def searchCodes(page, pbar, jobList, filename): translatedText = re.sub(r"[\\]+?ac\s+", r"\\ac ", translatedText) CLFlag = False - # Nametag - if nCase == 0: - translatedText = translatedText + nametag - else: - translatedText = nametag + translatedText + # Add Nametag Back In + translatedText = nametag + translatedText nametag = "" # Endtag @@ -1281,7 +1282,7 @@ def searchCodes(page, pbar, jobList, filename): ## Event Code: 122 [Set Variables] if "code" in codeList[i] and codeList[i]["code"] == 122 and CODE122 is True: # This is going to be the var being set. (IMPORTANT) - if codeList[i]["parameters"][0] not in list(range(150, 160)): + if codeList[i]["parameters"][0] not in list(range(0, 2000)): i += 1 continue @@ -1316,7 +1317,7 @@ def searchCodes(page, pbar, jobList, filename): matchedText = None if len(re.findall(r"([\'\"\`])", jaString)) >= 2: matchedText = re.search(r"[\'\"\`](.*)[\'\"\`]", jaString) - if matchedText and matchedText.group(1) != " ": + if matchedText and matchedText.group(1).strip(): # Remove Textwrap finalJAString = matchedText.group(1).replace("\\n", " ") @@ -1341,7 +1342,7 @@ def searchCodes(page, pbar, jobList, filename): translatedText = re.sub(r'(? 0: response = translateGPT( choiceList, - f"Previous text for context: {str(textHistory)}\n", + f"Reply with the English translation of the dialogue choice.\n\nPrevious text for context: {str(textHistory)}\n", True, ) translatedTextList = response[0] totalTokens[0] += response[1][0] totalTokens[1] += response[1][1] else: - response = translateGPT(choiceList, "", True) + response = translateGPT(choiceList, "Reply with the English translation of the dialogue choice.", True) translatedTextList = response[0] totalTokens[0] += response[1][0] totalTokens[1] += response[1][1] @@ -2313,7 +2315,7 @@ Translate 'Taroを倒した!' as 'Taro was defeated!'", if "description" in state: # Textwrap translatedText = descriptionResponse[0] - translatedText = textwrap.fill(translatedText, width=LISTWIDTH) + translatedText = dazedwrap.wrapText(translatedText, width=LISTWIDTH) state["description"] = translatedText.replace('"', "") if "message1" in state: state["message1"] = message1Response[0].replace('"', "").replace("Taro", "") diff --git a/modules/wolf.py b/modules/wolf.py index 0671048..1bb78f7 100644 --- a/modules/wolf.py +++ b/modules/wolf.py @@ -91,7 +91,7 @@ CODE150 = False # Other CODE210 = False CODE300 = False -CODE250 = False +CODE250 = True # Database SCENARIOFLAG = False @@ -677,11 +677,10 @@ def searchCodes(events, pbar, jobList, filename): ### Event Code: 250 DB Read/Writes if codeList[i]["code"] == 250 and CODE250 == True: # Validate size - stringArg = 0 + stringArg = 2 if len(codeList[i]["stringArgs"]) == 4: - if codeList[i]["stringArgs"][1] == "万能ウィンドウ一時DB"\ - and codeList[i]["stringArgs"][stringArg] != ""\ - and codeList[i]["intArgs"][0] == 13: + if codeList[i]["stringArgs"][1] == "unit"\ + and codeList[i]["stringArgs"][stringArg] != "": # Font Size fontSize = 0 @@ -930,7 +929,7 @@ def searchDB(events, pbar, jobList, filename): try: for table in tableList: # Grab NPCs - if table["name"] == "Hシナリオ" and NPCFLAG == True: + if table["name"] == "マップ選択画面" and NPCFLAG == True: with open("translations.txt", "a", encoding="utf-8") as file: if setData: file.write(f"\n#Actors\n") @@ -940,7 +939,7 @@ def searchDB(events, pbar, jobList, filename): # Parse for j in range(len(dataList)): # Name - if dataList[j].get("name") == "タイトル": + if dataList[j].get("name") == "マップ名": # Pass 1 (Grab Data) if setData == False: if dataList[j].get("value") != "": diff --git a/util/dazedwrap.py b/util/dazedwrap.py new file mode 100644 index 0000000..cea2c1e --- /dev/null +++ b/util/dazedwrap.py @@ -0,0 +1,54 @@ +import re + +def _get_visible_length(text: str) -> int: + """ + Calculate the visible length of text, ignoring RPG Maker color codes. + + Args: + text (str): The text to measure + + Returns: + int: The length of the text excluding color codes + """ + # Remove all color codes like \c[5] or \C[35] + cleaned_text = re.sub(r'[\\]+[cC]\[\d+\]', '', text) + return len(cleaned_text) + +def wrapText(text: str, width: int) -> str: + """ + Wrap text to the specified width, preserving RPG Maker color codes. + + Args: + text (str): The text to wrap + width (int): The maximum number of characters per line + + Returns: + str: The wrapped text with lines separated by \n + """ + if not text: + return "" + + words = text.split() + lines = [] + current_line = [] + current_length = 0 + + for word in words: + # Calculate visible length ignoring color codes + word_length = _get_visible_length(word) + + # Check if adding this word would exceed the width + if current_length + word_length + len(current_line) <= width: + current_line.append(word) + current_length += word_length + else: + if current_line: # Only add line if we have words + lines.append(" ".join(current_line)) + current_line = [word] + current_length = word_length + + # Add the last line if it has any words + if current_line: + lines.append(" ".join(current_line)) + + return "\n".join(lines) \ No newline at end of file diff --git a/vocab.txt b/vocab.txt index 5592a10..4cc4713 100644 --- a/vocab.txt +++ b/vocab.txt @@ -1,126 +1,35 @@ Here are some vocabulary and terms so that you know the proper spelling and translation. ``` # Game Characters -アイリス (Iris) -フランシスカ (Francisca) -リサ (Lisa) -エリーゼ (Elise) -エルフィナ (Elphina) -カリン (Karin) -リルナ (Riruna) -アルフォンス (Alphonse) -グスタフ (Gustav) -ルカ (Luca) -クラウディオ (Claudio) -ジェフリー (Jeffrey) -シオン (Sion) -エドワード (Edward) -シャルロット (Charlotte) -ジーク (Sieg) -オーディン (Odin) -アクア (Aqua) -フィーラ (Fira) -レイア (Leia) -サン (Sun) -ケイ (Kei) -トリーニヒ (Triuni) -エメラルダ (Emeralda) -転生ちゃん (Reincarnation-chan) -神楽ちゃん (Kagura-chan) -ミル (Miru) -メリッサ (Melissa) -クレア (Claire) -コレット (Colette) -モニカ (Monica) -ノーラ (Nora) -ルチア (Lucia) -シオン (Sion) -ミル (Miru) -女王カリーナ (Queen Karina) -竜のじいちゃん (Old Dragon) -ローナ (Rona) -ヒルト (Hilt) -ノエル (Noel) -ロベリア皇帝 (Emperor Lobelia) -ペトラ (Petra) -エルエス (Elles) -ナツメ (Natsume) -フブキ (Fubuki) -ノブチカ (Nobuchika) -ルビー (Ruby) -マルティナ (Martina) -マリー (Marie) -ブラック (Black) -悪魔アイリス (Devil Iris) -ロキ (Loki) -アイリスの子どもA (Iris's Child A) -アイリスの子どもB (Iris's Child B) -アイリスの子どもC (Iris's Child C) -衛兵 (Guard) -男吸血鬼 (Male Vampire) -騎士A (Knight A) -騎士B (Knight B) -騎士C (Knight C) -騎士たち (Knights) -観客たち (Audience) -ファンたち (Fans) -店長 (Manager) -ドワーフ (Dwarf) -スタッフ (Staff) -門番 (Gatekeeper) -城の従者 (Castle Servant) -吸血鬼 (Vampire) -エルフの村長 (Elf Village Chief) -竜族たち (Dragon Tribe) -魔物たち (Monsters) -神族の男 (Divine Man) -ロベリア騎士 (Lobelia Knight) -ロベリア騎士たち (Lobelia Knights) -メイド (Maid) -ペチュニア兵士 (Petunia Soldier) -ペチュニア騎士 (Petunia Knight) -フォクレー兄妹 (Forqueray Siblings) -アイリス変身用 (Iris Transformation) -天翔院ひいな (Hina Tenjouin) -園原あいり (Airi Sonohara) -瑠璃川えみり (Emiri Rurukawa) -頼州うめる (Umeru Yorisu) -穂香てまり (Temari Honoka) -夢宮ありす (Arisu Yumemiya) -相晴ひなた (Hinata Aihare) -猫田ぺぺろ (Pepero Nekota) -アイリス (Iris) - Female -フランシスカ (Francisca) - Female -リサ (Lisa) - Female -エリーゼ (Elise) - Female -エルフィナ (Elphina) - Female -カリン (Karin) - Female -リルナ (Riruna) - Female -アルフォンス (Alphonse) - Male -グスタフ (Gustav) - Male -ルカ (Luca) - Male -クラウディオ (Claudio) - Male -ジェフリー (Jeffrey) - Male -シオン (Sion) - Female -フォルクレー兄妹 (Forqueray) - Male & Female -(妹)(Sister) - Female -アクア (Aqua) - Male -フィーラ (Fira) -レイア (Leia) -サン (Sun) -ケイ (Kei) -トリウーニヒ (Triuni) -エメラルダ (Emeralda) -転生ちゃん (Reincarnation-chan) -神楽ちゃん (Kagura-chan) - Female -ミル (Miru) - Female -メリッサ (Melissa) - Female -クレア (Claire) - Female -コレット (Colette) - Female -モニカ (Monica) - Female -ノーラ (Nora) - Female -ルチア (Lucia) - Female -悪魔竜アイリス (Devil Dragon Iris) - Female +# Game Characters +アイカ (Aika) - Female +カナエ (Kanae) - Female +マドカ (Madoka) - Female +シズカ (Shizuka) - Female +ユウキ (Yuuki) - Male +ユキナ (Yukina) - Female +ヒカリ (Hikari) - Female +イッパツ (Ippatsu) - Male +ウユ (Uyu) - Female +ミキ (Miki) - Female +カズヨシ (Kazuyoshi) - Male +モモコ (Momoko) - Female +ライタ (Raita) - Male +ツヨシ (Tsuyoshi) - Male +レイキ (Reiki) - Male +センカ (Senka) - Female +タツオ (Tatsuo) - Male +チョウシン (Choushin) - Male +ヤワラ (Yawara) - Female +カンテツ (Kantetsu) - Male +ソラ (Sora) - Female +すすむ (Susumu) - Male +イリコ (Iriko) +レイナ (Reina) +ギンジ (Ginji) +ケンシロウ (Kenshirou) +カガミ (Kagami) +円 (Yen) - Female # Lewd Terms マンコ (pussy) @@ -263,6 +172,206 @@ w ((lol)) 』 (』) # Game Specific -神族 (Divine) +魔書館 (Magic Library) +風鳴山 (Kazename Mountain) +砂漠地帯 (Desert Area) +西の炭鉱 (Western Mine) +海岸地帯 (Coastal Area) +海辺の洞窟 (Seaside Cave) +森の広場 (Forest Clearing) +東の炭鉱 (East Mine) +野盗のアジト (Bandit Hideout) +魔法陣 (Magic Circle) +鏡の世界 (Mirror World) +大陸森 (Continent Forest) +闘技場 (Arena) +事務所 (Office) +聖域 (Sanctuary) +オークション会場 (Auction Hall) +王室 (Royal Room) +食堂 (Cafeteria) +屋上庭園 (Rooftop Garden) +山道 (Mountain Path) +大橋 (Great Bridge) +玉座の間 (Throne Room) +エルフの森 (Elf Forest) +迷いの路 (Lost Path) +カティポ (Katipo) +スコーピオ (Scorpio) +キングスコーピオ (King Scorpio) +トーロンマン (Tauron Man) +シンドバッド (Sindbad/Sinbad) +デスストーカー (Death Stalker) +ハトシェプスト (Hatshepsut) +タイパン (Taipan) +ヒュドラ (Hydra) +キロネックス (Chironex) +モンストロス (Monstros) +ワラキア (Wallachia) +アークホーン (Archhorn) +ゲノムスライム (Genome Slime) +バジリコック (Basilicock) +ホブオーク (Hoborc) +シャドウキマイラ (Shadow Chimera) +シャドウヒュドラ (Shadow Hydra) +シャドウラミア (Shadow Lamia) +シャドウグリフォン (Shadow Griffin) +シャドウクラーケン (Shadow Kraken) + +# Skills +攻撃 (Attack) +防御 (Defend) +連続攻撃 (Combo Attack) +2回攻撃 (Double Attack) +3回攻撃 (Triple Attack) +逃げる (Escape) +様子を見る (Observe) +攻撃 (Attack) +火の魔法 (Fire Magic) +水の魔法 (Water Magic) +風の魔法 (Wind Magic) +土の魔法 (Earth Magic) +火炎の魔法 (Flame Magic) +砲水の魔法 (Torrent Magic) +旋風の魔法 (Whirlwind Magic) +地穿の魔法 (Earth Piercing Magic) +灼熱の魔法 (Scorching Magic) +海嘯の魔法 (Tsunami Magic) +空断の魔法 (Sky Severing Magic) +激震の魔法 (Quake Magic) +癒やしの魔法 (Healing Magic) +治癒の魔法 (Cure Magic) +大治癒の魔法 (Greater Cure Magic) +バースト (Burst) +デトネーション (Detonation) +エクスプロード (Explode) +メテオフォール (Meteor Fall) +進撃の魔法 (Advance Magic) +守護の魔法 (Guardian Magic) +豪傑化の魔法 (Might Magic) +英雄化の魔法 (Heroic Magic) +筋力弱化の魔法 (Strength Weakening Magic) +魔力弱化の魔法 (Magic Weakening Magic) +脆弱化の魔法 (Vulnerability Magic) +無力化の魔法 (Nullification Magic) +毒の魔法 (Poison Magic) +暗闇の魔法 (Darkness Magic) +沈黙の魔法 (Silence Magic) +混乱の魔法 (Confusion Magic) +睡眠の魔法 (Sleep Magic) +混沌の魔法 (Chaos Magic) +夢幻の魔法 (Illusion Magic) +逃走の魔法 (Escape Magic) +逃走の魔法 (Escape Magic) +剣の舞 (Sword Dance) +チャーム (Charm) +発情の魔法 (Arousal Magic) +抑制の魔法 (Suppression Magic) +激昂 (Rage) +即死の魔法 (Death Magic) +猛毒の牙 (Venomous Fangs) +スピードスター (Speed Star) +切り裂く (Slash) +魅惑の視線 (Bewitching Gaze) +絶叫 (Scream) +大絶叫 (Great Scream) +毒針 (Poison Needle) +猛毒針 (Venom Needle) +神経毒針 (Neurotoxin Needle) +毒牙 (Poison Fangs) +猛毒牙 (Venomous Fang) +神経毒牙 (Neurotoxic Fang) +吸収攻撃 (Absorption Attack) +眠り粉 (Sleep Powder) +甘い息 (Sweet Breath) +捕縛攻撃 (Binding Attack) +眼光 (Glare) +混沌の牙 (Fangs of Chaos) +硬質化 (Hardening) +魅惑のダンス (Alluring Dance) +魅惑のダンス (Alluring Dance) +自爆 (Self-Destruct) +再生 (Regeneration) +激励 (Encourage) +強打 (Power Strike) +強連打 (Rapid Strikes) +三段突き (Triple Thrust) +影縫 (Shadow Stitch) +噛み砕く (Crunch) +猛毒の爪 (Venomous Claw) +ドラゴンブレス (Dragon Breath) +咆哮 (Roar) +フリーズ (Freeze) +フラッシュ (Flash) +ナノテクノロジー (Nanotechnology) +エマージェンシーモード (Emergency Mode) +ハードクラッシュ (Hard Crash) +デルタライトニング (Delta Lightning) +死突 (Death Thrust) +ハイポーション (Hi-Potion) +瞑想 (Meditation) +エクスポーション (Ex-Potion) +エリクサー (Elixir) +手加減しない (No Holding Back) +灼熱の魔符 (Blazing Talisman) +海嘯の魔符 (Tidal Talisman) +空断の魔符 (Sky-Cutting Talisman) +激震の魔符 (Quake Talisman) +火の魔法 (Fire Magic) +水の魔法 (Water Magic) +風の魔法 (Wind Magic) +土の魔法 (Earth Magic) +火炎の魔法 (Flame Magic) +砲水の魔法 (Torrent Magic) +旋風の魔法 (Whirlwind Magic) +地穿の魔法 (Earth-Piercing Magic) +灼熱の魔法 (Blazing Magic) +海嘯の魔法 (Tidal Magic) +空断の魔法 (Sky-Cutting Magic) +激震の魔法 (Quake Magic) +癒やしの魔法 (Healing Magic) +治癒の魔法 (Cure Magic) +大治癒の魔法 (Greater Cure Magic) +完治の魔法 (Full Cure Magic) +発狂 (Madness) +様子を見る (Observe) +集中 (Focus) +英雄の薬 (Hero's Elixir) +魔神の巾着袋 (Demon God's Pouch) +灼熱の魔符 (Blazing Talisman) +海嘯の魔符 (Tsunami Talisman) +空断の魔符 (Sky Severing Talisman) +激震の魔符 (Earthquake Talisman) +エリクサー (Elixir) +トマホーク (Tomahawk) +ダークマター (Dark Matter) +覚醒シスル行動 (Awakened Sysle Action) +溶解液 (Dissolving Fluid) +強溶解液 (Strong Dissolving Fluid) +吸引 (Suction) +強吸引 (Strong Suction) +分裂 (Division) +魅了の魔眼 (Bewitching Evil Eye) +魔道具創造 (Magic Tool Creation) +魔道具創造 (Magic Tool Creation) +魔道具創造 (Magic Tool Creation) +魔道具創造 (Magic Tool Creation) +ダークマター (Dark Matter) +魔力開放 (Mana Release) +マジカル太極拳 (Magical Tai Chi) +諸刃 (Double-Edged) +癒やしの魔法 (Healing Magic) +火の魔法 (Fire Magic) +水の魔法 (Water Magic) +風の魔法 (Wind Magic) +土の魔法 (Earth Magic) +強制勝利 (Forced Victory) +契約破棄の魔法 (Contract Nullification Magic) +魔道具破壊の魔法 (Magic Tool Destruction Magic) +魔力開放 (Mana Release) +ライフスティール (Life Steal) +エーテルスティール (Aether Steal) +インノケンティア (Innocentia) +魔道具破壊の魔法 (Magic Item Destruction) ``` \ No newline at end of file