mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
lines
This commit is contained in:
parent
f05fc33cee
commit
5bf9eeb490
@ -344,18 +344,8 @@ def gethookembedgrid(self):
|
||||
],
|
||||
[
|
||||
"限制每行字数",
|
||||
D_getsimpleswitch(
|
||||
globalconfig["embedded"],
|
||||
"limittextlength_use",
|
||||
callback=lambda _: gobject.baseobject.textsource.flashembedsettings(),
|
||||
),
|
||||
D_getspinbox(
|
||||
0,
|
||||
1000,
|
||||
globalconfig["embedded"],
|
||||
"limittextlength_length",
|
||||
callback=lambda x: gobject.baseobject.textsource.flashembedsettings(),
|
||||
),
|
||||
D_getsimpleswitch(globalconfig["embedded"], "limittextlength_use"),
|
||||
D_getspinbox(0, 1000, globalconfig["embedded"], "limittextlength_length"),
|
||||
],
|
||||
[
|
||||
"修改游戏字体",
|
||||
|
@ -7,6 +7,7 @@ from myutils.utils import (
|
||||
checkmd5reloadmodule,
|
||||
LRUCache,
|
||||
getlangsrc,
|
||||
getlanguagespace,
|
||||
parsemayberegexreplace,
|
||||
)
|
||||
from myutils.config import (
|
||||
@ -202,10 +203,7 @@ def _4_f(line):
|
||||
|
||||
def _6_fEX(line):
|
||||
srclang = getlangsrc()
|
||||
if srclang in ["zh", "ja", "cht"]:
|
||||
white = ""
|
||||
else:
|
||||
white = " "
|
||||
white = getlanguagespace(srclang)
|
||||
line = (
|
||||
line.replace("\r ", " ")
|
||||
.replace("\n ", " ")
|
||||
|
@ -81,6 +81,10 @@ def getlangtgt():
|
||||
return __internal__getlang("private_tgtlang_2", "tgtlang4")
|
||||
|
||||
|
||||
def getlanguagespace(lang):
|
||||
return "" if (lang in ("zh", "ja", "cht")) else " "
|
||||
|
||||
|
||||
def findenclose(text, tag):
|
||||
i = 0
|
||||
tags = f"<{tag}"
|
||||
|
@ -1,4 +1,5 @@
|
||||
from myutils.config import globalconfig, ocrsetting, ocrerrorfix
|
||||
from myutils.utils import getlanguagespace
|
||||
from myutils.commonbase import commonbase
|
||||
|
||||
|
||||
@ -18,10 +19,8 @@ class baseocr(commonbase):
|
||||
def space(self):
|
||||
if globalconfig["ocrmergelines"] == False:
|
||||
space = "\n"
|
||||
elif self.srclang_1 in ["zh", "ja", "cht"]:
|
||||
space = ""
|
||||
else:
|
||||
space = " "
|
||||
space = getlanguagespace(self.srclang_1)
|
||||
return space
|
||||
|
||||
############################################################
|
||||
|
@ -66,12 +66,8 @@ class OCR(baseocr):
|
||||
+ ", ".join([_TR(getlang_inner2show(f)) for f in _allsupport])
|
||||
)
|
||||
|
||||
if self.srclang in ["zh", "ja", "cht"]:
|
||||
space = ""
|
||||
else:
|
||||
space = " "
|
||||
|
||||
ret = winrtutils.OCR_f(imagebinary, self.supportmap[self.srclang], space)
|
||||
ret = winrtutils.OCR_f(imagebinary, self.supportmap[self.srclang], self.space)
|
||||
boxs = [_[1:] for _ in ret]
|
||||
texts = [_[0] for _ in ret]
|
||||
|
||||
|
@ -11,7 +11,7 @@ from myutils.config import (
|
||||
findgameuidofpath,
|
||||
)
|
||||
from textsource.textsourcebase import basetext
|
||||
from myutils.utils import checkchaos, getfilemd5
|
||||
from myutils.utils import checkchaos, getfilemd5, getlangtgt, getlanguagespace
|
||||
from myutils.hwnd import injectdll, test_injectable, ListProcess, getpidexe
|
||||
from myutils.wrapper import threader
|
||||
from traceback import print_exc
|
||||
@ -158,7 +158,6 @@ class texthook(basetext):
|
||||
c_uint32,
|
||||
c_uint32,
|
||||
c_bool,
|
||||
c_uint32,
|
||||
)
|
||||
self.Luna_checkisusingembed = LunaHost.Luna_checkisusingembed
|
||||
self.Luna_checkisusingembed.argtypes = DWORD, c_uint64, c_uint64, c_uint64
|
||||
@ -358,19 +357,30 @@ class texthook(basetext):
|
||||
@threader
|
||||
def getembedtext(self, text, tp):
|
||||
if self.safeembedcheck(text) == False:
|
||||
self.embedcallback(text, text)
|
||||
self.embedcallback(text, "")
|
||||
return
|
||||
if not self.isautorunning:
|
||||
self.embedcallback(text, text)
|
||||
self.embedcallback(text, "")
|
||||
return
|
||||
if self.checkisusingembed(tp.addr, tp.ctx, tp.ctx2):
|
||||
trans = self.waitfortranslation(text)
|
||||
if not trans:
|
||||
trans = text
|
||||
trans = ""
|
||||
self.embedcallback(text, trans)
|
||||
|
||||
def embedcallback(self, text, trans):
|
||||
|
||||
def embedcallback(self, text: str, trans: str):
|
||||
if len(trans) and globalconfig["embedded"]["limittextlength_use"]:
|
||||
length = globalconfig["embedded"]["limittextlength_length"]
|
||||
lines = trans.split("\n")
|
||||
newlines = []
|
||||
space = getlanguagespace(getlangtgt())
|
||||
for line in lines:
|
||||
line = line.split(space) if space else line
|
||||
while len(line):
|
||||
newlines.append(space.join(line[:length]))
|
||||
line = line[length:]
|
||||
trans = "\n".join(newlines)
|
||||
print(trans)
|
||||
for pid in self.pids.copy():
|
||||
self.Luna_embedcallback(pid, text, trans)
|
||||
|
||||
@ -393,11 +403,6 @@ class texthook(basetext):
|
||||
globalconfig["embedded"]["insertspace_policy"],
|
||||
globalconfig["embedded"]["keeprawtext"],
|
||||
True,
|
||||
(
|
||||
globalconfig["embedded"]["limittextlength_length"]
|
||||
if globalconfig["embedded"]["limittextlength_use"]
|
||||
else 0
|
||||
),
|
||||
)
|
||||
|
||||
def onremovehook(self, hc, hn, tp):
|
||||
|
@ -29,7 +29,7 @@ include(generate_product_version)
|
||||
|
||||
set(VERSION_MAJOR 5)
|
||||
set(VERSION_MINOR 28)
|
||||
set(VERSION_PATCH 5)
|
||||
set(VERSION_PATCH 6)
|
||||
|
||||
add_library(pch pch.cpp)
|
||||
target_precompile_headers(pch PUBLIC pch.h)
|
||||
|
Loading…
x
Reference in New Issue
Block a user