mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
fix
This commit is contained in:
parent
5bf9eeb490
commit
49494806ee
@ -5,6 +5,7 @@ from myutils.config import globalconfig, _TR
|
||||
from myutils.utils import autosql
|
||||
from gui.usefulwidget import getQMessageBox, LFocusCombo
|
||||
from gui.dynalang import LFormLayout, LPushButton, LDialog
|
||||
from textsource.texthook import splitembedlines
|
||||
|
||||
|
||||
def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
||||
@ -95,6 +96,8 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
||||
for k in existsjs:
|
||||
if k not in js_format2 or js_format2[k] == "":
|
||||
js_format2[k] = existsjs[k]
|
||||
for _ in js_format2:
|
||||
js_format2[_] = splitembedlines(js_format2[_])
|
||||
os.makedirs(os.path.dirname(target), exist_ok=True)
|
||||
with open(target, "w", encoding="utf8") as ff:
|
||||
ff.write(
|
||||
|
@ -88,6 +88,21 @@ HookInsertHandler = CFUNCTYPE(None, c_uint64, c_wchar_p)
|
||||
EmbedCallback = CFUNCTYPE(None, c_wchar_p, ThreadParam)
|
||||
|
||||
|
||||
def splitembedlines(trans):
|
||||
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)
|
||||
return trans
|
||||
|
||||
|
||||
class texthook(basetext):
|
||||
autofindpids = False
|
||||
|
||||
@ -369,18 +384,7 @@ class texthook(basetext):
|
||||
self.embedcallback(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)
|
||||
trans = splitembedlines(trans)
|
||||
for pid in self.pids.copy():
|
||||
self.Luna_embedcallback(pid, text, trans)
|
||||
|
||||
|
@ -92,7 +92,7 @@ std::map<std::string, std::string> translation;
|
||||
std::unordered_set<DWORD> connectedpids;
|
||||
void (*Luna_Start)(ProcessEvent Connect, ProcessEvent Disconnect, ThreadEvent Create, ThreadEvent Destroy, OutputCallback Output, ConsoleHandler console, HookInsertHandler hookinsert, EmbedCallback embed);
|
||||
void (*Luna_Inject)(DWORD pid, LPCWSTR basepath);
|
||||
void (*Luna_EmbedSettings)(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, UINT32 spaceadjustpolicy, UINT32 keeprawtext, bool fastskipignore, UINT32 line_text_length_limit);
|
||||
void (*Luna_EmbedSettings)(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, UINT32 spaceadjustpolicy, UINT32 keeprawtext, bool fastskipignore);
|
||||
void (*Luna_useembed)(DWORD pid, uint64_t address, uint64_t ctx1, uint64_t ctx2, bool use);
|
||||
bool (*Luna_checkisusingembed)(DWORD pid, uint64_t address, uint64_t ctx1, uint64_t ctx2);
|
||||
void (*Luna_embedcallback)(DWORD pid, LPCWSTR text, LPCWSTR trans);
|
||||
@ -120,7 +120,7 @@ public:
|
||||
Luna_Start(
|
||||
[](DWORD pid)
|
||||
{
|
||||
Luna_EmbedSettings(pid, 1000 * config["embedsettings"]["timeout_translate"], 2, false, config["embedsettings"]["changefont"] ? (StringToWideString(config["embedsettings"]["changefont_font"]).data()) : L"", config["embedsettings"]["insertspace_policy"], config["embedsettings"]["keeprawtext"], false, config["embedsettings"]["limittextlength_use"] ? config["embedsettings"]["limittextlength_length"] : 0);
|
||||
Luna_EmbedSettings(pid, 1000 * config["embedsettings"]["timeout_translate"], 2, false, config["embedsettings"]["changefont"] ? (StringToWideString(config["embedsettings"]["changefont_font"]).data()) : L"", config["embedsettings"]["insertspace_policy"], config["embedsettings"]["keeprawtext"], false);
|
||||
connectedpids.insert(pid);
|
||||
},
|
||||
[](DWORD pid)
|
||||
|
Loading…
x
Reference in New Issue
Block a user