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