From 5d8ca201dde1260c5bd243daee931635237cca5a 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: Sat, 15 Jun 2024 01:28:56 +0800 Subject: [PATCH] merge --- .../LunaTranslator/LunaTranslator.py | 65 +++++++++---------- .../LunaTranslator/gui/dialog_savedgame.py | 2 +- .../LunaTranslator/textsource/texthook.py | 2 +- .../textsource/textsourcebase.py | 5 +- plugins/CMakeLists.txt | 2 +- 5 files changed, 34 insertions(+), 42 deletions(-) diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 1d43bbcc..dccf4a4a 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -162,44 +162,39 @@ class MAINUI: returnandembedcallback = lambda: embedcallback("") if embedcallback else "" - if type(text) == str: - if text.startswith(""): - self.translation_ui.displayres.emit( - dict( - color=globalconfig["rawtextcolor"], - res=text[len("") :], - onlytrans=onlytrans, - clear=True, - ) + if text.startswith(""): + self.translation_ui.displayres.emit( + dict( + color=globalconfig["rawtextcolor"], + res=text[len("") :], + onlytrans=onlytrans, + clear=True, ) - self.currenttext = text - self.currenttranslate = text - self.currentread = text - return - else: - msgs = [ - ("", globalconfig["rawtextcolor"], False), - ("", globalconfig["rawtextcolor"], True), - ("", "red", False), - ("", "red", True), - ] - for msg, color, refresh in msgs: - if text.startswith(msg): - self.translation_ui.displaystatus.emit( - text[len(msg) :], color, refresh, False - ) - return - if text == "" or len(text) > 100000: - return returnandembedcallback() + ) + self.currenttext = text + self.currenttranslate = text + self.currentread = text + return + else: + msgs = [ + ("", globalconfig["rawtextcolor"], False), + ("", globalconfig["rawtextcolor"], True), + ("", "red", False), + ("", "red", True), + ] + for msg, color, refresh in msgs: + if text.startswith(msg): + self.translation_ui.displaystatus.emit( + text[len(msg) :], color, refresh, False + ) + return + if text == "" or len(text) > 100000: + return returnandembedcallback() if onlytrans == False: self.currentsignature = time.time() try: - if type(text) == list: - origin = "\n".join(text) - text = "\n".join([self._POSTSOLVE(_) for _ in text]) - else: - origin = text - text = self._POSTSOLVE(text) + origin = text + text = self._POSTSOLVE(text) except Exception as e: msg = str(type(e))[8:-2] + " " + str(e).replace("\n", "").replace("\r", "") self.translation_ui.displaystatus.emit(msg, "red", True, True) @@ -725,7 +720,6 @@ class MAINUI: print_exc() - def autohookmonitorthread(self): while self.isrunning: self.onwindowloadautohook() @@ -895,6 +889,7 @@ class MAINUI: __t = time.time() time.sleep(1) _t = time.time() + def isok(name_): savehook_new_data[name_]["statistic_playtime"] += _t - __t if self.__currentexe == name_: diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index c3ab9501..383bf9d6 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -841,7 +841,7 @@ class dialog_setting_game_internal(QWidget): else: _methods = ["Locale-Emulator", "Locale_Remulator", "Ntleas"] if b == 6 and savehook_new_data[exepath]["localeswitcher"] == 0: - savehook_new_data[exepath]["localeswitcher"] = 2 + savehook_new_data[exepath]["localeswitcher"] = 1 formLayout.addRow( _TR("转区启动"), getboxlayout( diff --git a/LunaTranslator/LunaTranslator/textsource/texthook.py b/LunaTranslator/LunaTranslator/textsource/texthook.py index 3e77d361..0c377563 100644 --- a/LunaTranslator/LunaTranslator/textsource/texthook.py +++ b/LunaTranslator/LunaTranslator/textsource/texthook.py @@ -453,7 +453,7 @@ class texthook(basetext): collector.sort(key=lambda xx: self.selectedhook.index(xx[0])) except: pass - collector = [_[1] for _ in collector] + collector = "\n".join([_[1] for _ in collector]) self.newline.put(collector) self.runonce_line = collector diff --git a/LunaTranslator/LunaTranslator/textsource/textsourcebase.py b/LunaTranslator/LunaTranslator/textsource/textsourcebase.py index fc9b55c2..12c01c96 100644 --- a/LunaTranslator/LunaTranslator/textsource/textsourcebase.py +++ b/LunaTranslator/LunaTranslator/textsource/textsourcebase.py @@ -137,10 +137,7 @@ class basetext: try: t = self.gettextthread() if t and globalconfig["autorun"]: - if type(t) == tuple: - self.textgetmethod(*t) - else: - self.textgetmethod(t) + self.textgetmethod(t) except: print_exc() diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index fa843252..1ec496f5 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -29,7 +29,7 @@ include(generate_product_version) set(VERSION_MAJOR 3) set(VERSION_MINOR 6) -set(VERSION_PATCH 2) +set(VERSION_PATCH 3) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)