Formatting and keep format codes in text
This commit is contained in:
parent
fdac11eaef
commit
d5fe55aa2a
5 changed files with 41 additions and 43 deletions
|
|
@ -208,7 +208,7 @@ def stringToImage(text, width, height, font_path="fonts/TsunagiGothic.ttf", scal
|
|||
text_width = text_bbox[2] - text_bbox[0]
|
||||
text_height = text_bbox[3] - text_bbox[1] + 20
|
||||
x = 0
|
||||
|
||||
|
||||
x = (scaled_width - text_width) // 2
|
||||
y = (scaled_height - text_height) // 2
|
||||
|
||||
|
|
@ -223,12 +223,14 @@ def stringToImage(text, width, height, font_path="fonts/TsunagiGothic.ttf", scal
|
|||
|
||||
return image
|
||||
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
|
||||
def stringToImageOutline(text, width, height, font_path="fonts/TsunagiGothic.ttf", scale_factor=4):
|
||||
# Outline
|
||||
outline_color=(0, 0, 0, 255)
|
||||
outline_thickness=4
|
||||
outline_color = (0, 0, 0, 255)
|
||||
outline_thickness = 4
|
||||
|
||||
# Increase the resolution
|
||||
scaled_width = int(width * scale_factor)
|
||||
|
|
@ -269,6 +271,7 @@ def stringToImageOutline(text, width, height, font_path="fonts/TsunagiGothic.ttf
|
|||
|
||||
return image
|
||||
|
||||
|
||||
def stringToImageBox(text, width, height, font_path="fonts/TsunagiGothic.ttf", scale_factor=4):
|
||||
# Increase the resolution
|
||||
scaled_width = int(width * scale_factor)
|
||||
|
|
@ -304,17 +307,10 @@ def stringToImageBox(text, width, height, font_path="fonts/TsunagiGothic.ttf", s
|
|||
y = (scaled_height - text_height) // 2
|
||||
|
||||
# Draw a black box with a white outline that fits the image dimensions precisely
|
||||
draw.rectangle(
|
||||
[0, 0, scaled_width - 1, scaled_height - 1],
|
||||
outline=(255, 255, 255, 255),
|
||||
width=1
|
||||
)
|
||||
draw.rectangle([0, 0, scaled_width - 1, scaled_height - 1], outline=(255, 255, 255, 255), width=1)
|
||||
|
||||
# Fill the inside box with black color
|
||||
draw.rectangle(
|
||||
[1, 1, scaled_width - 2, scaled_height - 2],
|
||||
fill=(0, 0, 0, 255)
|
||||
)
|
||||
draw.rectangle([1, 1, scaled_width - 2, scaled_height - 2], fill=(0, 0, 0, 255))
|
||||
|
||||
# Render the text within the image
|
||||
draw.text((x, y), text, font=font, fill=(255, 255, 255, 255))
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ CODE122 = False
|
|||
|
||||
# Other
|
||||
CODE355655 = False
|
||||
CODE357 = True
|
||||
CODE357 = False
|
||||
CODE657 = False
|
||||
CODE356 = False
|
||||
CODE320 = False
|
||||
|
|
@ -246,7 +246,16 @@ def parseMap(data, filename):
|
|||
|
||||
# Get total for progress bar
|
||||
for event in events:
|
||||
if event is not None:
|
||||
if event:
|
||||
if "<LB>" in event["note"]:
|
||||
response = translateGPT(
|
||||
event["name"],
|
||||
"Reply with only the " + LANGUAGE + " translation of the RPG location name",
|
||||
False,
|
||||
)
|
||||
totalTokens[0] += response[1][0]
|
||||
totalTokens[1] += response[1][1]
|
||||
event["name"] = response[0].replace('"', "")
|
||||
for page in event["pages"]:
|
||||
totalLines += len(page["list"])
|
||||
|
||||
|
|
@ -1057,12 +1066,6 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
for match in rcodeMatch:
|
||||
finalJAString = finalJAString.replace(match[0], match[1])
|
||||
|
||||
# Formatting
|
||||
formatMatch = re.findall(r"[\\]+[!><.|#^{}]", finalJAString)
|
||||
if len(formatMatch) > 0:
|
||||
for match in formatMatch:
|
||||
finalJAString = finalJAString.replace(match, "")
|
||||
|
||||
# Remove any RPGMaker Code at start
|
||||
ffMatch = re.search(
|
||||
r"^(\s*[\\]+[aAbBdDeEfFgGhHjJlLmMoOpPqQrRsStTuUwWxXyYzZ]+\[[\w\d\[\]\\]+?\])",
|
||||
|
|
@ -1181,7 +1184,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(410, 430)):
|
||||
if codeList[i]["parameters"][0] not in list(range(18, 19)):
|
||||
i += 1
|
||||
continue
|
||||
|
||||
|
|
@ -1282,7 +1285,7 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
# Textwrap
|
||||
translatedText = textwrap.fill(translatedText, 80)
|
||||
translatedText = translatedText.replace("\n", "\\n")
|
||||
translatedText = re.sub(r"[\\]+c", r"\\\\c", translatedText)
|
||||
# translatedText = re.sub(r"[\\]+c", r"\\\\c", translatedText)
|
||||
translatedText = re.sub(r"[\\]+\*item", r"\\\\*item", translatedText)
|
||||
|
||||
# Center Text
|
||||
|
|
@ -1309,6 +1312,7 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
"TorigoyaMZ_NotifyMessage": ("message", None),
|
||||
"SoR_GabWindow": ("arg1", None),
|
||||
"DarkPlasma_CharacterText": ("text", None),
|
||||
"DTextPicture": ("text", None),
|
||||
}
|
||||
|
||||
for key, (argVar, font) in headerMappings.items():
|
||||
|
|
@ -1497,7 +1501,7 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
## Event Code: 355 or 655 Scripts [Optional]
|
||||
if "code" in codeList[i] and (codeList[i]["code"] == 355 or codeList[i]["code"] == 655) and CODE355655 is True:
|
||||
jaString = codeList[i]["parameters"][0]
|
||||
regexPatterns = [r"テキスト-(.*)"]
|
||||
regexPatterns = [r'setValue\((.+)\)']
|
||||
|
||||
# Iterate over the list of regex patterns
|
||||
for regex in regexPatterns:
|
||||
|
|
|
|||
|
|
@ -234,21 +234,21 @@ def translateTyrano(data, translatedList):
|
|||
|
||||
# Combine w/ next line if necessary
|
||||
repeatRegex = r"(.+?)\[[rpl]\]"
|
||||
match = re.search(repeatRegex, data[i+1])
|
||||
match = re.search(repeatRegex, data[i + 1])
|
||||
while match and "[p]" not in data[i]:
|
||||
jaString = jaString + match.group(1)
|
||||
jaString = jaString.replace("_ ", "")
|
||||
if "[p]" in data[i+1]:
|
||||
if "[p]" in data[i + 1]:
|
||||
data[i] = f"{jaString}[p]\n"
|
||||
else:
|
||||
data[i] = jaString
|
||||
del data[i+1]
|
||||
match = re.search(repeatRegex, data[i+1])
|
||||
del data[i + 1]
|
||||
match = re.search(repeatRegex, data[i + 1])
|
||||
|
||||
originalString = jaString
|
||||
|
||||
# Pass 1
|
||||
if not translatedList:
|
||||
if not translatedList:
|
||||
# Remove any textwrap and commands
|
||||
jaString = jaString.replace("[r]", " ")
|
||||
jaString = jaString.replace("[l]", "")
|
||||
|
|
@ -290,7 +290,7 @@ def translateTyrano(data, translatedList):
|
|||
|
||||
# Textwrap
|
||||
translatedText = textwrap.fill(translatedText, width=WIDTH)
|
||||
translatedText = translatedText.replace('\n', '[r]')
|
||||
translatedText = translatedText.replace("\n", "[r]")
|
||||
|
||||
# Set Data
|
||||
data[i] = data[i].replace(originalString, translatedText)
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ def searchCodes(events, pbar, jobList, filename):
|
|||
|
||||
# Set nametag and remove from string
|
||||
codeList[i]["stringArgs"][0] = codeList[i]["stringArgs"][0].replace(match.group(1), speaker)
|
||||
|
||||
|
||||
# Grab Only Text
|
||||
match = re.search(r"\n\s+([\w\W\n]+)", codeList[i]["stringArgs"][0])
|
||||
if match:
|
||||
|
|
|
|||
24
vocab.txt
24
vocab.txt
|
|
@ -1,19 +1,17 @@
|
|||
Here are some vocabulary and terms so that you know the proper spelling and translation.
|
||||
```
|
||||
# Game Characters
|
||||
ジロウ (Jirou) - Male
|
||||
サクラ (Sakura) - Female
|
||||
ゼフ (Zeff) - Male
|
||||
ヨモダ (Yomada) - Male
|
||||
グダ (Guda) - Male
|
||||
フジワラ (Fujiwara) - Male
|
||||
ナオ (Nao) - Female
|
||||
タジ (Taji) - Male
|
||||
カリン (Karin) - Female
|
||||
セリナ (Serina) - Female
|
||||
ラグ (Ragu) - Male
|
||||
ハッカイ (Hakkai) - Male
|
||||
|
||||
アイ (Ai) - Female
|
||||
シオン (Sion) - Female
|
||||
エリス (Eris) - Female
|
||||
杉浦 (Sugiura) - Female
|
||||
獏木 (Bakuki) - Female
|
||||
千里 (Chisato) - Female
|
||||
ハルカ (Haruka) - Female
|
||||
間根山 (Manemaya) - Female
|
||||
ミズキ (Mizuki) - Female
|
||||
ツヨシ (Tsuyoshi) - Male
|
||||
|
||||
# Lewd Terms
|
||||
マンコ (pussy)
|
||||
おまんこ (vagina)
|
||||
|
|
|
|||
Loading…
Reference in a new issue