From 2fdd5621ecdbfea122a5200c4fbff44fa050f6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Thu, 15 Aug 2024 00:47:00 +0800 Subject: [PATCH] fix --- .gitignore | 1 + LunaTranslator/LunaTranslator/LunaTranslator.py | 9 +++++---- LunaTranslator/LunaTranslator/gui/selecthook.py | 4 ++-- .../LunaTranslator/textsource/texthook.py | 4 +++- .../LunaTranslator/textsource/textsourcebase.py | 13 +++++++++---- plugins/CMakeLists.txt | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index ac3c25d3..7033b5c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ LunaTranslator/userconfig +LunaTranslator/userconfig1 lunatranslator/cache *.pyc diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 55de79c9..5d1ea8f3 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -662,12 +662,13 @@ class MAINUI: found = findgameuidofpath(pexe) if found: gameuid, reflist = found + if globalconfig["startgamenototop"] == False: + idx = reflist.index(gameuid) + reflist.insert(0, reflist.pop(idx)) else: gameuid = find_or_create_uid(savehook_new_list, pexe, title) - reflist = savehook_new_list - if globalconfig["startgamenototop"] == False: - idx = reflist.index(gameuid) - reflist.insert(0, reflist.pop(idx)) + savehook_new_list.insert(0, gameuid) + self.textsource = texthook(pids, hwnd, pexe, gameuid, autostart=False) self.textsource.start() diff --git a/LunaTranslator/LunaTranslator/gui/selecthook.py b/LunaTranslator/LunaTranslator/gui/selecthook.py index aae9dd60..a3cd514a 100644 --- a/LunaTranslator/LunaTranslator/gui/selecthook.py +++ b/LunaTranslator/LunaTranslator/gui/selecthook.py @@ -383,7 +383,7 @@ class hookselect(closeashidewindow): addnewhooksignal = pyqtSignal(tuple, bool) getnewsentencesignal = pyqtSignal(str) sysmessagesignal = pyqtSignal(str) - changeprocessclearsignal = pyqtSignal(dict) + changeprocessclearsignal = pyqtSignal() removehooksignal = pyqtSignal(tuple) getfoundhooksignal = pyqtSignal(dict) update_item_new_line = pyqtSignal(tuple, str) @@ -444,7 +444,7 @@ class hookselect(closeashidewindow): 1, QHeaderView.ResizeMode.ResizeToContents ) - def changeprocessclear(self, config): + def changeprocessclear(self): # self.ttCombo.clear() self.ttCombomodelmodel.clear() self.save = [] diff --git a/LunaTranslator/LunaTranslator/textsource/texthook.py b/LunaTranslator/LunaTranslator/textsource/texthook.py index d8c01160..ec39ef23 100644 --- a/LunaTranslator/LunaTranslator/textsource/texthook.py +++ b/LunaTranslator/LunaTranslator/textsource/texthook.py @@ -86,6 +86,8 @@ EmbedCallback = CFUNCTYPE(None, c_wchar_p, ThreadParam) class texthook(basetext): + autofindpids = False + @property def config(self): if savehook_new_data[self.gameuid]["hooksetting_follow_default"]: @@ -135,7 +137,7 @@ class texthook(basetext): self.pids = pids self.is64bit = Is64bit(pids[0]) self.hwnd = hwnd - gobject.baseobject.hookselectdialog.changeprocessclearsignal.emit(self.config) + gobject.baseobject.hookselectdialog.changeprocessclearsignal.emit() self.isremoveuseless = self.config["removeuseless"] and len( self.autostarthookcode ) diff --git a/LunaTranslator/LunaTranslator/textsource/textsourcebase.py b/LunaTranslator/LunaTranslator/textsource/textsourcebase.py index 53696823..183ae690 100644 --- a/LunaTranslator/LunaTranslator/textsource/textsourcebase.py +++ b/LunaTranslator/LunaTranslator/textsource/textsourcebase.py @@ -53,6 +53,8 @@ class hwndchecker: class basetext: + autofindpids = True + @property def hwnd(self): @@ -65,14 +67,17 @@ class basetext: if self.__hwnd: self.__hwnd.end = True self.__hwnd = None - self.pids = [] - self.gameuid = None - self.md5 = "0" - self.basename = self.__basename + if self.autofindpids: + self.pids = [] + self.gameuid = None + self.md5 = "0" + self.basename = self.__basename if _hwnd: self.__hwnd = hwndchecker(_hwnd, self) + if not self.autofindpids: + return self.pids = [windows.GetWindowThreadProcessId(_hwnd)] gameuid = findgameuidofpath(getpidexe(self.pids[0])) if gameuid: diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 1d38afb9..2d48301d 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 5) set(VERSION_MINOR 26) -set(VERSION_PATCH 9) +set(VERSION_PATCH 10) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)