mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
fix
This commit is contained in:
parent
49494806ee
commit
8875656b82
@ -79,6 +79,8 @@ class MAINUI:
|
||||
self._internal_reader = None
|
||||
self.reader_uid = None
|
||||
self.__hwnd = None
|
||||
self.gameuid = 0
|
||||
self.autoswitchgameuid = True
|
||||
|
||||
@property
|
||||
def reader(self):
|
||||
@ -112,36 +114,38 @@ class MAINUI:
|
||||
self.translation_ui.isbindedwindow = False
|
||||
self.translation_ui.refreshtooliconsignal.emit()
|
||||
self.translation_ui.thistimenotsetop = False
|
||||
if self.autoswitchgameuid:
|
||||
self.gameuid = 0
|
||||
else:
|
||||
_mute = winsharedutils.GetProcessMute(
|
||||
windows.GetWindowThreadProcessId(__hwnd)
|
||||
)
|
||||
self.translation_ui.processismuteed = _mute
|
||||
self.translation_ui.isbindedwindow = True
|
||||
self.translation_ui.refreshtooliconsignal.emit()
|
||||
try:
|
||||
if not self.textsource:
|
||||
return
|
||||
if not self.textsource.autofindpids:
|
||||
return
|
||||
self.textsource.pids = [windows.GetWindowThreadProcessId(__hwnd)]
|
||||
gameuid = findgameuidofpath(getpidexe(self.textsource.pids[0]))
|
||||
if gameuid:
|
||||
self.textsource.gameuid = gameuid[0]
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
_pid = windows.GetWindowThreadProcessId(__hwnd)
|
||||
if _pid:
|
||||
_mute = winsharedutils.GetProcessMute(_pid)
|
||||
self.translation_ui.processismuteed = _mute
|
||||
self.translation_ui.isbindedwindow = True
|
||||
self.translation_ui.refreshtooliconsignal.emit()
|
||||
try:
|
||||
if self.autoswitchgameuid:
|
||||
gameuid = findgameuidofpath(getpidexe(_pid))
|
||||
if gameuid:
|
||||
self.gameuid = gameuid[0]
|
||||
except:
|
||||
print_exc()
|
||||
else:
|
||||
if self.autoswitchgameuid:
|
||||
self.gameuid = 0
|
||||
if globalconfig["keepontop"]:
|
||||
self.translation_ui.settop()
|
||||
|
||||
@textsource.setter
|
||||
def textsource(self, _):
|
||||
if _ is None and self.textsource_p:
|
||||
try:
|
||||
self.textsource_p.endX()
|
||||
except:
|
||||
print_exc()
|
||||
if _ is None:
|
||||
if self.textsource_p:
|
||||
try:
|
||||
self.textsource_p.endX()
|
||||
except:
|
||||
print_exc()
|
||||
self.hwnd = None
|
||||
self.autoswitchgameuid = True
|
||||
self.textsource_p = _
|
||||
|
||||
@threader
|
||||
@ -517,11 +521,7 @@ class MAINUI:
|
||||
|
||||
try:
|
||||
for _ in (0,):
|
||||
|
||||
if not self.textsource:
|
||||
break
|
||||
|
||||
gameuid = self.textsource.gameuid
|
||||
gameuid = self.gameuid
|
||||
if not gameuid:
|
||||
break
|
||||
if savehook_new_data[gameuid]["tts_follow_default"]:
|
||||
|
@ -32,11 +32,11 @@ class dialog_memory(saveposwindow):
|
||||
formLayout = QVBoxLayout() #
|
||||
self.showtext = QTextEdit()
|
||||
self.rwpath = gobject.getuserconfigdir(
|
||||
"memory/{}.html".format(gobject.baseobject.textsource.gameuid)
|
||||
"memory/{}.html".format(gobject.baseobject.gameuid)
|
||||
)
|
||||
try:
|
||||
if os.path.exists(self.rwpath) == False:
|
||||
md5 = getfilemd5(uid2gamepath[gobject.baseobject.textsource.gameuid])
|
||||
md5 = getfilemd5(uid2gamepath[gobject.baseobject.gameuid])
|
||||
f2 = gobject.getuserconfigdir("memory/{}.html".format(md5))
|
||||
try:
|
||||
os.rename(f2, self.rwpath)
|
||||
|
@ -3,24 +3,27 @@ import sqlite3, os, json, functools
|
||||
from traceback import print_exc
|
||||
from myutils.config import globalconfig, _TR
|
||||
from myutils.utils import autosql
|
||||
from gui.usefulwidget import getQMessageBox, LFocusCombo
|
||||
from gui.usefulwidget import getQMessageBox, LFocusCombo, getsimplepatheditor
|
||||
from gui.dynalang import LFormLayout, LPushButton, LDialog
|
||||
from textsource.texthook import splitembedlines
|
||||
from collections import Counter
|
||||
from myutils.wrapper import tryprint
|
||||
|
||||
|
||||
def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
||||
@tryprint
|
||||
def sqlite2json2(
|
||||
self, sqlitefile, targetjson=None, existsmerge=False, isforembed=False
|
||||
):
|
||||
try:
|
||||
sql = autosql(sqlite3.connect(sqlitefile, check_same_thread=False))
|
||||
ret = sql.execute("SELECT * FROM artificialtrans ").fetchall()
|
||||
js_format2 = {}
|
||||
collect = set()
|
||||
collect = []
|
||||
for _aret in ret:
|
||||
if len(_aret) == 4:
|
||||
|
||||
_id, source, mt, source_origin = _aret
|
||||
if targetjson:
|
||||
source = source_origin
|
||||
|
||||
js_format2[source] = mt
|
||||
elif len(_aret) == 3:
|
||||
_id, source, mt = _aret
|
||||
@ -31,14 +34,13 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
||||
mtjs = mt
|
||||
js_format2[source] = mtjs
|
||||
|
||||
collect = collect.union(set(mtjs.keys()))
|
||||
collect = list(collect)
|
||||
collect.extend(list(mtjs.keys()))
|
||||
except:
|
||||
print_exc()
|
||||
getQMessageBox(self, "错误", "所选文件格式错误!")
|
||||
return
|
||||
_collect = []
|
||||
for _ in collect:
|
||||
for _, __ in Counter(collect).most_common():
|
||||
if _ in globalconfig["fanyi"]:
|
||||
_collect.append(_)
|
||||
collect = _collect
|
||||
@ -52,7 +54,6 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
||||
combo.addItems([globalconfig["fanyi"][_]["name"] for _ in collect])
|
||||
|
||||
formLayout.addRow("首选翻译", combo)
|
||||
|
||||
e = QLineEdit(sqlitefile[: -(len(".sqlite"))])
|
||||
|
||||
bu = LPushButton("选择路径")
|
||||
@ -79,7 +80,7 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
||||
formLayout.addRow(button)
|
||||
button.rejected.connect(dialog.close)
|
||||
|
||||
def __savefunction(target, existsmerge):
|
||||
def __savefunction(target, existsmerge, isforembed):
|
||||
if len(collect) > 0:
|
||||
transkirokuuse = collect[combo.currentIndex()]
|
||||
for k in js_format2:
|
||||
@ -96,8 +97,9 @@ 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[_])
|
||||
if isforembed:
|
||||
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(
|
||||
@ -105,7 +107,9 @@ def sqlite2json2(self, sqlitefile, targetjson=None, existsmerge=False):
|
||||
)
|
||||
dialog.close()
|
||||
|
||||
button.accepted.connect(functools.partial(__savefunction, targetjson, existsmerge))
|
||||
button.accepted.connect(
|
||||
functools.partial(__savefunction, targetjson, existsmerge, isforembed)
|
||||
)
|
||||
button.button(QDialogButtonBox.StandardButton.Ok).setText(_TR("确定"))
|
||||
button.button(QDialogButtonBox.StandardButton.Cancel).setText(_TR("取消"))
|
||||
dialog.show()
|
||||
|
@ -82,42 +82,6 @@ class QButtonGroup_switch_widegt(QWidget):
|
||||
self.wlist.append(widget)
|
||||
|
||||
|
||||
def listprocessm():
|
||||
cachefname = gobject.gettempdir("{}.txt".format(time.time()))
|
||||
arch = "64" if gobject.baseobject.textsource.is64bit else "32"
|
||||
exe = os.path.abspath("./files/plugins/shareddllproxy{}.exe".format(arch))
|
||||
pid = " ".join([str(_) for _ in gobject.baseobject.textsource.pids])
|
||||
subprocess.run('"{}" listpm "{}" {}'.format(exe, cachefname, pid))
|
||||
|
||||
with open(cachefname, "r", encoding="utf-16-le") as ff:
|
||||
readf = ff.read()
|
||||
|
||||
os.remove(cachefname)
|
||||
_list = readf.split("\n")[:-1]
|
||||
if len(_list) == 0:
|
||||
return []
|
||||
|
||||
ret = []
|
||||
hasprogram = "c:\\program files" in _list[0].lower()
|
||||
for name_ in _list:
|
||||
name = name_.lower()
|
||||
if (
|
||||
":\\windows\\" in name
|
||||
or "\\microsoft\\" in name
|
||||
or "\\windowsapps\\" in name
|
||||
):
|
||||
continue
|
||||
if hasprogram == False and "c:\\program files" in name:
|
||||
continue
|
||||
fn = name_.split("\\")[-1]
|
||||
if fn in ret:
|
||||
continue
|
||||
if fn.lower() in ["lunahook32.dll", "lunahook64.dll"]:
|
||||
continue
|
||||
ret.append(fn)
|
||||
return ret
|
||||
|
||||
|
||||
hookcodehelp = r"""
|
||||
1、内存读取
|
||||
R{S|Q|V|U}[codepage#]@addr
|
||||
@ -261,12 +225,10 @@ class searchhookparam(LDialog):
|
||||
|
||||
layout1 = QHBoxLayout()
|
||||
layout1.addWidget(LLabel("代码页"))
|
||||
if savehook_new_data[gobject.baseobject.textsource.gameuid][
|
||||
"hooksetting_follow_default"
|
||||
]:
|
||||
if savehook_new_data[gobject.baseobject.gameuid]["hooksetting_follow_default"]:
|
||||
cp = globalconfig["codepage_index"]
|
||||
else:
|
||||
cp = savehook_new_data[gobject.baseobject.textsource.gameuid][
|
||||
cp = savehook_new_data[gobject.baseobject.gameuid][
|
||||
"hooksetting_private"
|
||||
].get("codepage_index", globalconfig["codepage_index"])
|
||||
self.codepagesave = {"spcp": cp}
|
||||
@ -357,7 +319,7 @@ class searchhookparam(LDialog):
|
||||
usestruct.boundaryModule,
|
||||
2,
|
||||
uselayout=offaddrl,
|
||||
getlistcall=listprocessm,
|
||||
getlistcall=gobject.baseobject.textsource.listprocessm,
|
||||
)
|
||||
autoaddline(
|
||||
"offstartaddr",
|
||||
@ -565,11 +527,11 @@ class hookselect(closeashidewindow):
|
||||
if _isusing:
|
||||
|
||||
if hn[:8] == "UserHook":
|
||||
needinserthookcode = savehook_new_data[
|
||||
gobject.baseobject.textsource.gameuid
|
||||
]["needinserthookcode"]
|
||||
needinserthookcode = savehook_new_data[gobject.baseobject.gameuid][
|
||||
"needinserthookcode"
|
||||
]
|
||||
needinserthookcode = list(set(needinserthookcode + [hc]))
|
||||
savehook_new_data[gobject.baseobject.textsource.gameuid].update(
|
||||
savehook_new_data[gobject.baseobject.gameuid].update(
|
||||
{"needinserthookcode": needinserthookcode}
|
||||
)
|
||||
else:
|
||||
@ -581,21 +543,17 @@ class hookselect(closeashidewindow):
|
||||
gobject.baseobject.textsource.useembed(tp.addr, tp.ctx, tp.ctx2, _)
|
||||
_use = self._check_tp_using(key)
|
||||
if _use:
|
||||
savehook_new_data[gobject.baseobject.textsource.gameuid][
|
||||
"embedablehook"
|
||||
].append([hc, tp.addr, tp.ctx, tp.ctx2])
|
||||
savehook_new_data[gobject.baseobject.gameuid]["embedablehook"].append(
|
||||
[hc, tp.addr, tp.ctx, tp.ctx2]
|
||||
)
|
||||
else:
|
||||
save = []
|
||||
for _ in savehook_new_data[gobject.baseobject.textsource.gameuid][
|
||||
"embedablehook"
|
||||
]:
|
||||
for _ in savehook_new_data[gobject.baseobject.gameuid]["embedablehook"]:
|
||||
hc, ad, c1, c2 = _
|
||||
if (hc, 0, c1, c2) == (hc, 0, tp.ctx, tp.ctx2):
|
||||
save.append(_)
|
||||
for _ in save:
|
||||
savehook_new_data[gobject.baseobject.textsource.gameuid][
|
||||
"embedablehook"
|
||||
].remove(_)
|
||||
savehook_new_data[gobject.baseobject.gameuid]["embedablehook"].remove(_)
|
||||
|
||||
def setupUi(self):
|
||||
self.widget = QWidget()
|
||||
@ -740,13 +698,13 @@ class hookselect(closeashidewindow):
|
||||
|
||||
def opensolvetext(self):
|
||||
try:
|
||||
dialog_setting_game(self, gobject.baseobject.textsource.gameuid, 3)
|
||||
dialog_setting_game(self, gobject.baseobject.gameuid, 3)
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
def opengamesetting(self):
|
||||
try:
|
||||
dialog_setting_game(self, gobject.baseobject.textsource.gameuid, 1)
|
||||
dialog_setting_game(self, gobject.baseobject.gameuid, 1)
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
@ -900,17 +858,17 @@ class hookselect(closeashidewindow):
|
||||
gobject.baseobject.textsource.selectedhook.append(key)
|
||||
|
||||
if hn[:8] == "UserHook":
|
||||
needinserthookcode = savehook_new_data[
|
||||
gobject.baseobject.textsource.gameuid
|
||||
]["needinserthookcode"]
|
||||
needinserthookcode = savehook_new_data[gobject.baseobject.gameuid][
|
||||
"needinserthookcode"
|
||||
]
|
||||
needinserthookcode = list(set(needinserthookcode + [hc]))
|
||||
savehook_new_data[gobject.baseobject.textsource.gameuid].update(
|
||||
savehook_new_data[gobject.baseobject.gameuid].update(
|
||||
{"needinserthookcode": needinserthookcode}
|
||||
)
|
||||
else:
|
||||
pass
|
||||
|
||||
savehook_new_data[gobject.baseobject.textsource.gameuid].update(
|
||||
savehook_new_data[gobject.baseobject.gameuid].update(
|
||||
{"hook": gobject.baseobject.textsource.serialselectedhook()}
|
||||
)
|
||||
except:
|
||||
|
@ -249,6 +249,7 @@ def exportchspatch(self):
|
||||
sqlfname_all,
|
||||
os.path.join(os.path.dirname(exe), "translation.json"),
|
||||
existsmerge=True,
|
||||
isforembed=True,
|
||||
)
|
||||
|
||||
|
||||
|
@ -643,15 +643,13 @@ class TranslatorWindow(resizableframeless):
|
||||
"open_relative_link",
|
||||
lambda: browserdialog(
|
||||
gobject.baseobject.commonstylebase,
|
||||
trypass(lambda: gobject.baseobject.textsource.gameuid)(),
|
||||
trypass(lambda: gobject.baseobject.gameuid)(),
|
||||
),
|
||||
),
|
||||
(
|
||||
"open_game_setting",
|
||||
lambda: dialog_setting_game(
|
||||
gobject.baseobject.commonstylebase,
|
||||
gobject.baseobject.textsource.gameuid,
|
||||
1,
|
||||
gobject.baseobject.commonstylebase, gobject.baseobject.gameuid, 1
|
||||
),
|
||||
),
|
||||
("ocr_once", self.ocr_once_signal.emit),
|
||||
@ -1079,11 +1077,12 @@ class TranslatorWindow(resizableframeless):
|
||||
self.titlebar.setstyle(bottomr, bottomr3)
|
||||
|
||||
def muteprocessfuntion(self):
|
||||
if gobject.baseobject.textsource and gobject.baseobject.textsource.pids:
|
||||
self.processismuteed = not self.processismuteed
|
||||
self.refreshtoolicon()
|
||||
for pid in gobject.baseobject.textsource.pids:
|
||||
winsharedutils.SetProcessMute(pid, self.processismuteed)
|
||||
pid = windows.GetWindowThreadProcessId(gobject.baseobject.hwnd)
|
||||
if not pid:
|
||||
return
|
||||
self.processismuteed = not self.processismuteed
|
||||
self.refreshtoolicon()
|
||||
winsharedutils.SetProcessMute(pid, self.processismuteed)
|
||||
|
||||
def _externalfsend(self, current):
|
||||
self.isletgamefullscreened = current
|
||||
|
@ -22,10 +22,7 @@ def grabwindow(app="PNG", callback_origin=None):
|
||||
dirname = os.path.basename(gamepath).replace(
|
||||
"." + os.path.basename(gamepath).split(".")[-1], ""
|
||||
)
|
||||
try:
|
||||
uid = gobject.baseobject.textsource.gameuid
|
||||
except:
|
||||
uid = None
|
||||
uid = gobject.baseobject.gameuid
|
||||
fname = gobject.getcachedir(
|
||||
f"screenshot/{dirname}/"
|
||||
+ time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()),
|
||||
|
@ -393,25 +393,21 @@ def POSTSOLVE(line):
|
||||
usemypostpath = "./userconfig/mypost.py"
|
||||
usemodule = "mypost"
|
||||
try:
|
||||
if gobject.baseobject.textsource:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
if gameuid and not savehook_new_data[gameuid]["textproc_follow_default"]:
|
||||
useranklist = savehook_new_data[gameuid]["save_text_process_info"][
|
||||
"rank"
|
||||
]
|
||||
usedpostprocessconfig = savehook_new_data[gameuid][
|
||||
"save_text_process_info"
|
||||
]["postprocessconfig"]
|
||||
if savehook_new_data[gameuid]["save_text_process_info"].get(
|
||||
"mypost", None
|
||||
):
|
||||
usemodule = (
|
||||
"posts."
|
||||
+ savehook_new_data[gameuid]["save_text_process_info"]["mypost"]
|
||||
)
|
||||
usemypostpath = "./userconfig/posts/{}.py".format(
|
||||
savehook_new_data[gameuid]["save_text_process_info"]["mypost"]
|
||||
)
|
||||
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
if gameuid and not savehook_new_data[gameuid]["textproc_follow_default"]:
|
||||
useranklist = savehook_new_data[gameuid]["save_text_process_info"]["rank"]
|
||||
usedpostprocessconfig = savehook_new_data[gameuid][
|
||||
"save_text_process_info"
|
||||
]["postprocessconfig"]
|
||||
if savehook_new_data[gameuid]["save_text_process_info"].get("mypost", None):
|
||||
usemodule = (
|
||||
"posts."
|
||||
+ savehook_new_data[gameuid]["save_text_process_info"]["mypost"]
|
||||
)
|
||||
usemypostpath = "./userconfig/posts/{}.py".format(
|
||||
savehook_new_data[gameuid]["save_text_process_info"]["mypost"]
|
||||
)
|
||||
except:
|
||||
print_exc()
|
||||
for postitem in useranklist:
|
||||
|
@ -113,10 +113,14 @@ class playtimemanager:
|
||||
_hwnd = windows.GetForegroundWindow()
|
||||
_pid = windows.GetWindowThreadProcessId(_hwnd)
|
||||
try:
|
||||
if len(gobject.baseobject.textsource.pids) == 0:
|
||||
raise Exception()
|
||||
if _pid in gobject.baseobject.textsource.pids or _pid == os.getpid():
|
||||
isok(gobject.baseobject.textsource.gameuid)
|
||||
gamehwnd = gobject.baseobject.hwnd
|
||||
if not gamehwnd:
|
||||
raise
|
||||
gamepid = windows.GetWindowThreadProcessId(gamehwnd)
|
||||
if not gamepid:
|
||||
raise
|
||||
if _pid == gamepid or _pid == os.getpid():
|
||||
isok(gobject.baseobject.gameuid)
|
||||
else:
|
||||
self.__currentexe = None
|
||||
except:
|
||||
|
@ -40,11 +40,7 @@ def checkisusingwine():
|
||||
def __internal__getlang(k1, k2):
|
||||
try:
|
||||
for _ in (0,):
|
||||
|
||||
if not gobject.baseobject.textsource:
|
||||
break
|
||||
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
if not gameuid:
|
||||
break
|
||||
if savehook_new_data[gameuid]["lang_follow_default"]:
|
||||
@ -442,9 +438,7 @@ def minmaxmoveobservefunc(self):
|
||||
if hwnd == gobject.baseobject.hwnd:
|
||||
gobject.baseobject.hwnd = None
|
||||
return
|
||||
p_pids = gobject.baseobject.textsource.pids
|
||||
if not p_pids:
|
||||
return
|
||||
p_pids = windows.GetWindowThreadProcessId(gobject.baseobject.hwnd)
|
||||
_focusp = windows.GetWindowThreadProcessId(hwnd)
|
||||
if event != windows.EVENT_SYSTEM_FOREGROUND:
|
||||
return
|
||||
@ -456,7 +450,7 @@ def minmaxmoveobservefunc(self):
|
||||
"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", None
|
||||
):
|
||||
return
|
||||
if _focusp in p_pids:
|
||||
if _focusp == p_pids:
|
||||
gobject.baseobject.translation_ui.thistimenotsetop = False
|
||||
gobject.baseobject.translation_ui.settop()
|
||||
else:
|
||||
@ -590,9 +584,7 @@ def postusewhich(name1):
|
||||
merge = name1 + "_merge"
|
||||
for _ in (0,):
|
||||
try:
|
||||
if not gobject.baseobject.textsource:
|
||||
break
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
if not gameuid:
|
||||
break
|
||||
if savehook_new_data[gameuid]["transoptimi_followdefault"]:
|
||||
@ -638,9 +630,7 @@ loadpostsettingwindowmethod_private = functools.partial(
|
||||
def loadpostsettingwindowmethod_maybe(name, parent):
|
||||
for _ in (0,):
|
||||
try:
|
||||
if not gobject.baseobject.textsource:
|
||||
break
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
if not gameuid:
|
||||
break
|
||||
return loadpostsettingwindowmethod_private(name)(parent, gameuid)
|
||||
|
@ -118,7 +118,6 @@ class parselrc:
|
||||
|
||||
|
||||
class filetrans(basetext):
|
||||
autofindpids = False
|
||||
|
||||
def end(self):
|
||||
|
||||
|
@ -15,6 +15,7 @@ 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
|
||||
import subprocess
|
||||
|
||||
from ctypes import (
|
||||
CDLL,
|
||||
@ -88,7 +89,7 @@ HookInsertHandler = CFUNCTYPE(None, c_uint64, c_wchar_p)
|
||||
EmbedCallback = CFUNCTYPE(None, c_wchar_p, ThreadParam)
|
||||
|
||||
|
||||
def splitembedlines(trans):
|
||||
def splitembedlines(trans: str):
|
||||
if len(trans) and globalconfig["embedded"]["limittextlength_use"]:
|
||||
length = globalconfig["embedded"]["limittextlength_length"]
|
||||
lines = trans.split("\n")
|
||||
@ -104,7 +105,6 @@ def splitembedlines(trans):
|
||||
|
||||
|
||||
class texthook(basetext):
|
||||
autofindpids = False
|
||||
|
||||
@property
|
||||
def config(self):
|
||||
@ -188,7 +188,7 @@ class texthook(basetext):
|
||||
self.Luna_QueryThreadHistory = LunaHost.Luna_QueryThreadHistory
|
||||
self.Luna_QueryThreadHistory.argtypes = (ThreadParam,)
|
||||
self.Luna_QueryThreadHistory.restype = c_void_p
|
||||
|
||||
self.pids = []
|
||||
self.keepref = []
|
||||
self.hookdatacollecter = OrderedDict()
|
||||
self.reverse = {}
|
||||
@ -201,10 +201,46 @@ class texthook(basetext):
|
||||
self.multiselectedcollectorlock = threading.Lock()
|
||||
self.lastflushtime = 0
|
||||
self.runonce_line = ""
|
||||
gobject.baseobject.autoswitchgameuid = False
|
||||
self.delaycollectallselectedoutput()
|
||||
self.prepares()
|
||||
self.autohookmonitorthread()
|
||||
|
||||
def listprocessm(self):
|
||||
cachefname = gobject.gettempdir("{}.txt".format(time.time()))
|
||||
arch = "64" if self.is64bit else "32"
|
||||
exe = os.path.abspath("./files/plugins/shareddllproxy{}.exe".format(arch))
|
||||
pid = " ".join([str(_) for _ in self.pids])
|
||||
subprocess.run('"{}" listpm "{}" {}'.format(exe, cachefname, pid))
|
||||
|
||||
with open(cachefname, "r", encoding="utf-16-le") as ff:
|
||||
readf = ff.read()
|
||||
|
||||
os.remove(cachefname)
|
||||
_list = readf.split("\n")[:-1]
|
||||
if len(_list) == 0:
|
||||
return []
|
||||
|
||||
ret = []
|
||||
hasprogram = "c:\\program files" in _list[0].lower()
|
||||
for name_ in _list:
|
||||
name = name_.lower()
|
||||
if (
|
||||
":\\windows\\" in name
|
||||
or "\\microsoft\\" in name
|
||||
or "\\windowsapps\\" in name
|
||||
):
|
||||
continue
|
||||
if hasprogram == False and "c:\\program files" in name:
|
||||
continue
|
||||
fn = name_.split("\\")[-1]
|
||||
if fn in ret:
|
||||
continue
|
||||
if fn.lower() in ["lunahook32.dll", "lunahook64.dll"]:
|
||||
continue
|
||||
ret.append(fn)
|
||||
return ret
|
||||
|
||||
def connecthwnd(self, hwnd):
|
||||
if (
|
||||
gobject.baseobject.AttachProcessDialog
|
||||
@ -245,6 +281,8 @@ class texthook(basetext):
|
||||
|
||||
def start(self, hwnd, pids, gamepath, gameuid, autostart=False):
|
||||
gobject.baseobject.hwnd = hwnd
|
||||
gobject.baseobject.gameuid = gameuid
|
||||
self.gameuid = gameuid
|
||||
self.detachall()
|
||||
_filename, _ = os.path.splitext(os.path.basename(gamepath))
|
||||
sqlitef = gobject.gettranslationrecorddir(f"{_filename}_{gameuid}.sqlite")
|
||||
@ -272,7 +310,6 @@ class texthook(basetext):
|
||||
self.removedaddress = []
|
||||
|
||||
self.gamepath = gamepath
|
||||
self.gameuid = gameuid
|
||||
self.is64bit = Is64bit(pids[0])
|
||||
if (
|
||||
len(autostarthookcode) == 0
|
||||
|
@ -6,17 +6,13 @@ from myutils.utils import autosql
|
||||
|
||||
|
||||
class basetext:
|
||||
autofindpids = True
|
||||
|
||||
def gettextonce(self):
|
||||
return None
|
||||
|
||||
def init(self): ...
|
||||
def end(self): ...
|
||||
|
||||
def __init__(self):
|
||||
self.pids = []
|
||||
self.gameuid = None
|
||||
#
|
||||
|
||||
self.textgetmethod = gobject.baseobject.textgetmethod
|
||||
@ -96,7 +92,7 @@ class basetext:
|
||||
"SELECT * FROM artificialtrans WHERE source = ?", (src,)
|
||||
).fetchone()
|
||||
try:
|
||||
savehook_new_data[self.gameuid]["statistic_wordcount"] += lensrc
|
||||
savehook_new_data[gobject.baseobject.gameuid]["statistic_wordcount"] += lensrc
|
||||
except:
|
||||
pass
|
||||
if ret is None:
|
||||
@ -111,7 +107,7 @@ class basetext:
|
||||
(src, json.dumps({})),
|
||||
)
|
||||
try:
|
||||
savehook_new_data[self.gameuid][
|
||||
savehook_new_data[gobject.baseobject.gameuid][
|
||||
"statistic_wordcount_nodump"
|
||||
] += lensrc
|
||||
except:
|
||||
|
@ -11,7 +11,7 @@ import winsharedutils
|
||||
class TS(basetrans):
|
||||
def unsafegetcurrentgameconfig(self):
|
||||
try:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
_path = savehook_new_data[gameuid]["gamesqlitefile"]
|
||||
return _path
|
||||
except:
|
||||
|
@ -24,7 +24,7 @@ class TS(basetrans):
|
||||
|
||||
def unsafegetcurrentgameconfig(self):
|
||||
try:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
_path = savehook_new_data[gameuid]["gamejsonfile"]
|
||||
if isinstance(_path, str):
|
||||
_path = [_path]
|
||||
|
@ -49,10 +49,10 @@ class Process:
|
||||
if which == 1:
|
||||
return globalconfig["gptpromptdict"]
|
||||
elif which == 2:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
return savehook_new_data[gameuid]["gptpromptdict"]
|
||||
elif which == 3:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
return (
|
||||
savehook_new_data[gameuid]["gptpromptdict"]
|
||||
+ globalconfig["gptpromptdict"]
|
||||
|
@ -135,10 +135,10 @@ class Process:
|
||||
if which == 1:
|
||||
return globalconfig["noundictconfig"]
|
||||
elif which == 2:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
return savehook_new_data[gameuid]["noundictconfig"]
|
||||
elif which == 3:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
return (
|
||||
savehook_new_data[gameuid]["noundictconfig"]
|
||||
+ globalconfig["noundictconfig"]
|
||||
|
@ -39,10 +39,10 @@ class Process:
|
||||
if which == 1:
|
||||
return transerrorfixdictconfig["dict_v2"]
|
||||
elif which == 2:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
return savehook_new_data[gameuid]["transerrorfix"]
|
||||
elif which == 3:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
return (
|
||||
savehook_new_data[gameuid]["transerrorfix"]
|
||||
+ transerrorfixdictconfig["dict_v2"]
|
||||
|
@ -37,10 +37,10 @@ class Process:
|
||||
if which == 1:
|
||||
return globalconfig["global_namemap2"]
|
||||
elif which == 2:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
return savehook_new_data[gameuid]["namemap2"]
|
||||
elif which == 3:
|
||||
gameuid = gobject.baseobject.textsource.gameuid
|
||||
gameuid = gobject.baseobject.gameuid
|
||||
return (
|
||||
savehook_new_data[gameuid]["namemap2"] + globalconfig["global_namemap2"]
|
||||
)
|
||||
|
@ -28,8 +28,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version)
|
||||
include(generate_product_version)
|
||||
|
||||
set(VERSION_MAJOR 5)
|
||||
set(VERSION_MINOR 28)
|
||||
set(VERSION_PATCH 6)
|
||||
set(VERSION_MINOR 29)
|
||||
set(VERSION_PATCH 0)
|
||||
|
||||
add_library(pch pch.cpp)
|
||||
target_precompile_headers(pch PUBLIC pch.h)
|
||||
|
Loading…
x
Reference in New Issue
Block a user