This commit is contained in:
恍兮惚兮 2024-06-15 22:47:32 +08:00
parent 013c564c1b
commit 92afae4ac5
29 changed files with 126 additions and 82 deletions

View File

@ -697,19 +697,6 @@ class MAINUI:
needinserthookcode=needinserthookcode, needinserthookcode=needinserthookcode,
) )
onloadautoswitchsrclang = savehook_new_data[name_][
"onloadautoswitchsrclang"
]
if onloadautoswitchsrclang > 0:
try:
self.settin_ui.srclangswitcher.setCurrentIndex(
onloadautoswitchsrclang - 1
)
except:
globalconfig["srclang3"] = (
onloadautoswitchsrclang - 1
)
break
else: else:
pids = self.textsource.pids pids = self.textsource.pids

View File

@ -1,4 +1,4 @@
from myutils.config import getlangsrc from myutils.utils import getlangsrc
import requests import requests
from urllib.parse import quote from urllib.parse import quote
import re, os import re, os

View File

@ -712,6 +712,7 @@ class dialog_setting_game_internal(QWidget):
[ [
"启动", "启动",
"HOOK", "HOOK",
"语言",
"文本处理", "文本处理",
"画廊", "画廊",
"标签", "标签",
@ -724,6 +725,7 @@ class dialog_setting_game_internal(QWidget):
[ [
functools.partial(self.doaddtab, self.starttab, exepath), functools.partial(self.doaddtab, self.starttab, exepath),
functools.partial(self.doaddtab, self.gethooktab, exepath), functools.partial(self.doaddtab, self.gethooktab, exepath),
functools.partial(self.doaddtab, self.getlangtab, exepath),
functools.partial(self.doaddtab, self.gettextproc, exepath), functools.partial(self.doaddtab, self.gettextproc, exepath),
functools.partial(self.doaddtab, self.fengmiantab, exepath), functools.partial(self.doaddtab, self.fengmiantab, exepath),
functools.partial(self.doaddtab, self.getlabelsetting, exepath), functools.partial(self.doaddtab, self.getlabelsetting, exepath),
@ -872,16 +874,6 @@ class dialog_setting_game_internal(QWidget):
"onloadautochangemode2", "onloadautochangemode2",
), ),
) )
formLayout.addRow(
_TR("自动切换源语言"),
getsimplecombobox(
_TRL(["不切换"]) + _TRL(static_data["language_list_translator"]),
savehook_new_data[exepath],
"onloadautoswitchsrclang",
),
)
return _w return _w
def getstatistic(self, exepath): def getstatistic(self, exepath):
@ -1279,6 +1271,54 @@ class dialog_setting_game_internal(QWidget):
], ],
) )
def getlangtab(self, exepath):
_w = QWidget()
formLayout = QFormLayout()
_vbox = QVBoxLayout()
_vbox.setAlignment(Qt.AlignmentFlag.AlignTop)
_w.setLayout(_vbox)
_vbox.addLayout(formLayout)
__extraw = QWidget()
formLayout.addRow(
_TR("跟随默认"),
getsimpleswitch(
savehook_new_data[exepath],
"lang_follow_default",
callback=lambda _: __extraw.setEnabled(not _),
),
)
__extraw.setEnabled(not savehook_new_data[exepath]["lang_follow_default"])
savehook_new_data[exepath]["private_tgtlang"] = savehook_new_data[exepath].get(
"private_tgtlang", globalconfig["tgtlang3"]
)
savehook_new_data[exepath]["private_srclang"] = savehook_new_data[exepath].get(
"private_srclang", globalconfig["srclang3"]
)
_vbox.addWidget(__extraw)
formLayout2 = QFormLayout()
formLayout2.setContentsMargins(0, 0, 0, 0)
__extraw.setLayout(formLayout2)
formLayout2.addRow(
_TR("源语言"),
getsimplecombobox(
_TRL(static_data["language_list_translator"]),
savehook_new_data[exepath],
"private_srclang",
),
)
formLayout2.addRow(
_TR("目标语言"),
getsimplecombobox(
_TRL(static_data["language_list_translator"]),
savehook_new_data[exepath],
"private_tgtlang",
),
)
return _w
def gethooktab(self, exepath): def gethooktab(self, exepath):
_w = QWidget() _w = QWidget()
formLayout = QFormLayout() formLayout = QFormLayout()

View File

@ -14,7 +14,7 @@ from gui.usefulwidget import (
getsimpleswitch, getsimpleswitch,
textbrowappendandmovetoend, textbrowappendandmovetoend,
FocusSpin, FocusSpin,
FocusCombo FocusCombo,
) )
@ -860,19 +860,18 @@ class hookselect(closeashidewindow):
def accept(self, key, select): def accept(self, key, select):
try: try:
hc, hn, tp = key
if key in gobject.baseobject.textsource.selectedhook: if key in gobject.baseobject.textsource.selectedhook:
gobject.baseobject.textsource.selectedhook.remove(key) gobject.baseobject.textsource.selectedhook.remove(key)
if select: if select:
gobject.baseobject.textsource.selectedhook.append(key) gobject.baseobject.textsource.selectedhook.append(key)
if key[-2][:8] == "UserHook": if hn[:8] == "UserHook":
needinserthookcode = savehook_new_data[ needinserthookcode = savehook_new_data[
gobject.baseobject.textsource.pname gobject.baseobject.textsource.pname
]["needinserthookcode"] ]["needinserthookcode"]
needinserthookcode = list(set(needinserthookcode + [key[-1]])) needinserthookcode = list(set(needinserthookcode + [hc]))
savehook_new_data[gobject.baseobject.textsource.pname].update( savehook_new_data[gobject.baseobject.textsource.pname].update(
{"needinserthookcode": needinserthookcode} {"needinserthookcode": needinserthookcode}
) )

View File

@ -509,8 +509,8 @@ class Textbrowser(QLabel):
self.textcursor.setPosition(pos + l) self.textcursor.setPosition(pos + l)
self.textbrowser.setTextCursor(self.textcursor) self.textbrowser.setTextCursor(self.textcursor)
__fm = self.getfh(False, getfm=True) __fm = self.getfh(False, getfm=True)
w1 = __fm.size(0, word["orig"][:__i]).width() w1 = int(__fm.size(0, word["orig"][:__i]).width())
w2 = __fm.size(0, word["orig"][__i:]).width() w2 = int(__fm.size(0, word["orig"][__i:]).width())
pos1 = ( pos1 = (
tl1.x() + 1, tl1.x() + 1,

View File

@ -1,5 +1,6 @@
from myutils.proxy import getproxy from myutils.proxy import getproxy
from myutils.config import getlangtgt, _TR, static_data, getlangsrc from myutils.utils import getlangtgt, getlangsrc
from myutils.config import _TR, static_data
from myutils.wrapper import stripwrapper from myutils.wrapper import stripwrapper
import requests import requests

View File

@ -66,11 +66,14 @@ def getdefaultsavehook(gamepath, title=None):
"save_text_process_info": { "save_text_process_info": {
"postprocessconfig": {}, "postprocessconfig": {},
"rank": [], "rank": [],
# "mypost": # "mypost":# 设置时再加载
}, },
"lang_follow_default": True,
#"private_srclang": 0,# 显示时再加载缺省用global中的键
#"private_tgtlang": 0,
"localeswitcher": 0, "localeswitcher": 0,
"onloadautochangemode2": 0, "onloadautochangemode2": 0,
"onloadautoswitchsrclang": 0,
"needinserthookcode": [], "needinserthookcode": [],
"embedablehook": [], "embedablehook": [],
"statistic_playtime": 0, "statistic_playtime": 0,
@ -223,14 +226,6 @@ def getlanguse():
return static_data["language_list_translator_inner"][language] return static_data["language_list_translator_inner"][language]
def getlangsrc():
return static_data["language_list_translator_inner"][globalconfig["srclang3"]]
def getlangtgt():
return static_data["language_list_translator_inner"][globalconfig["tgtlang3"]]
def setlanguage(): def setlanguage():
global language, languageshow global language, languageshow
language = globalconfig["languageuse"] language = globalconfig["languageuse"]

View File

@ -2,12 +2,11 @@ import re, codecs, inspect
from traceback import print_exc from traceback import print_exc
from collections import Counter from collections import Counter
import importlib, gobject import importlib, gobject
from myutils.utils import getfilemd5, LRUCache from myutils.utils import getfilemd5, LRUCache, getlangsrc
from myutils.config import ( from myutils.config import (
postprocessconfig, postprocessconfig,
globalconfig, globalconfig,
savehook_new_data, savehook_new_data,
getlangsrc,
) )
lrucache = LRUCache(0) lrucache = LRUCache(0)
@ -374,7 +373,7 @@ def POSTSOLVE(line):
usemypostpath = "./userconfig/mypost.py" usemypostpath = "./userconfig/mypost.py"
usemodule = "mypost" usemodule = "mypost"
try: try:
if "pname" in dir(gobject.baseobject.textsource): if gobject.baseobject.textsource and ("pname" in dir(gobject.baseobject.textsource)):
exepath = gobject.baseobject.textsource.pname exepath = gobject.baseobject.textsource.pname
if not savehook_new_data[exepath]["textproc_follow_default"]: if not savehook_new_data[exepath]["textproc_follow_default"]:
useranklist = savehook_new_data[exepath]["save_text_process_info"][ useranklist = savehook_new_data[exepath]["save_text_process_info"][

View File

@ -24,6 +24,35 @@ import re, heapq, winsharedutils
from myutils.wrapper import tryprint from myutils.wrapper import tryprint
def __internal__getlang(k1, k2):
try:
for _ in (0,):
if not gobject.baseobject.textsource:
break
if "pname" not in dir(gobject.baseobject.textsource):
break
exepath = gobject.baseobject.textsource.pname
if savehook_new_data[exepath]["lang_follow_default"]:
break
return static_data["language_list_translator_inner"][
savehook_new_data[exepath][k1]
]
except:
pass
return static_data["language_list_translator_inner"][globalconfig[k2]]
def getlangsrc():
return __internal__getlang("private_srclang", "srclang3")
def getlangtgt():
return __internal__getlang("private_tgtlang", "tgtlang3")
def findenclose(text, tag): def findenclose(text, tag):
i = 0 i = 0
tags = f"<{tag}" tags = f"<{tag}"
@ -196,6 +225,7 @@ def trysearchfordata(gamepath, key, vid):
savehook_new_data[gamepath]["developers"] = developers savehook_new_data[gamepath]["developers"] = developers
return True return True
def everymethodsthread(): def everymethodsthread():
while True: while True:
_ = searchvndbqueue.get() _ = searchvndbqueue.get()
@ -204,14 +234,20 @@ def everymethodsthread():
if _type == 0: if _type == 0:
infoid = trysearchforid(gamepath, arg) infoid = trysearchforid(gamepath, arg)
key, vid = infoid key, vid = infoid
gobject.baseobject.translation_ui.displayglobaltooltip.emit(f"{key}: found {vid}") gobject.baseobject.translation_ui.displayglobaltooltip.emit(
f"{key}: found {vid}"
)
elif _type == 1: elif _type == 1:
key, vid = arg key, vid = arg
if trysearchfordata(gamepath, key, vid): if trysearchfordata(gamepath, key, vid):
gobject.baseobject.translation_ui.displayglobaltooltip.emit(f"{key}: {vid} data loaded") gobject.baseobject.translation_ui.displayglobaltooltip.emit(
f"{key}: {vid} data loaded"
)
else: else:
gobject.baseobject.translation_ui.displayglobaltooltip.emit(f"{key}: {vid} load failed") gobject.baseobject.translation_ui.displayglobaltooltip.emit(
f"{key}: {vid} load failed"
)
except: except:
print_exc() print_exc()

View File

@ -1,17 +1,16 @@
import os import os
from myutils.config import globalconfig, _TR, getlangsrc from myutils.utils import getlangsrc
from myutils.config import globalconfig, _TR
from ocrengines.baseocrclass import baseocr from ocrengines.baseocrclass import baseocr
from ctypes import ( from ctypes import (
CDLL, CDLL,
c_char_p, c_char_p,
create_string_buffer,
c_size_t, c_size_t,
c_void_p, c_void_p,
c_int32, c_int32,
POINTER, POINTER,
Structure, Structure,
pointer, pointer,
cast,
c_char_p, c_char_p,
) )
import os import os

View File

@ -441,21 +441,26 @@ class texthook(basetext):
@threader @threader
def delaycollectallselectedoutput(self): def delaycollectallselectedoutput(self):
collector = []
while True: while True:
time.sleep(self.config["textthreaddelay"] / 1000)
if self.newline_delaywait.empty(): _data, tms = self.newline_delaywait.get()
collector.append(_data)
now = time.time()
time.sleep(min(now - tms, self.config["textthreaddelay"])/1000)
if not self.newline_delaywait.empty():
continue continue
collector = []
while self.newline_delaywait.empty() == False:
collector.append(self.newline_delaywait.get())
try: try:
collector.sort(key=lambda xx: self.selectedhook.index(xx[0])) collector.sort(key=lambda xx: self.selectedhook.index(xx[0]))
except: except:
pass pass
collector = "\n".join([_[1] for _ in collector]) _collector = "\n".join([_[1] for _ in collector])
self.newline.put(collector) self.newline.put(_collector)
self.runonce_line = collector self.runonce_line = _collector
collector.clear()
def handle_output(self, hc, hn, tp, output): def handle_output(self, hc, hn, tp, output):
@ -471,7 +476,7 @@ class texthook(basetext):
self.runonce_line = output self.runonce_line = output
else: else:
if key in self.selectedhook: if key in self.selectedhook:
self.newline_delaywait.put((key, output)) self.newline_delaywait.put(((key, output), time.time()))
if key == self.selectinghook: if key == self.selectinghook:
gobject.baseobject.hookselectdialog.getnewsentencesignal.emit(output) gobject.baseobject.hookselectdialog.getnewsentencesignal.emit(output)

View File

@ -1,15 +1,13 @@
from traceback import print_exc from traceback import print_exc
from queue import Queue from queue import Queue
from myutils.config import globalconfig, translatorsetting, getlangtgt
from threading import Thread from threading import Thread
import time, types import time, types
import zhconv, gobject import zhconv, gobject
import sqlite3, os import sqlite3, os
from myutils.commonbase import commonbase
import functools import functools
from myutils.utils import stringfyerror, autosql, PriorityQueue from myutils.config import globalconfig, translatorsetting
from myutils.commonbase import ArgsEmptyExc from myutils.utils import stringfyerror, autosql, PriorityQueue, getlangtgt
from myutils.commonbase import ArgsEmptyExc, commonbase
class TimeOut(Exception): class TimeOut(Exception):

View File

@ -598,7 +598,7 @@ class gTTSError(Exception):
from tts.basettsclass import TTSbase from tts.basettsclass import TTSbase
from myutils.config import getlangsrc from myutils.utils import getlangsrc
class TTS(TTSbase): class TTS(TTSbase):

View File

@ -638,7 +638,6 @@
"记忆选定区域": "اختيار الذاكرة", "记忆选定区域": "اختيار الذاكرة",
"关闭": "غلق", "关闭": "غلق",
"TGW语言模型": "TGW نموذج اللغة", "TGW语言模型": "TGW نموذج اللغة",
"自动切换源语言": "التبديل التلقائي لغة المصدر",
"命令行启动": "بدء تشغيل سطر الأوامر", "命令行启动": "بدء تشغيل سطر الأوامر",
"文本相似度阈值": "نص التشابه العتبة", "文本相似度阈值": "نص التشابه العتبة",
"正则": "الكنسي", "正则": "الكنسي",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "記憶選定區域", "记忆选定区域": "記憶選定區域",
"关闭": "關閉", "关闭": "關閉",
"TGW语言模型": "TGW語言模型", "TGW语言模型": "TGW語言模型",
"自动切换源语言": "自動切換源語言",
"命令行启动": "命令列啟動", "命令行启动": "命令列啟動",
"文本相似度阈值": "文字相似度閾值", "文本相似度阈值": "文字相似度閾值",
"正则": "正則", "正则": "正則",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Memory selection area", "记忆选定区域": "Memory selection area",
"关闭": "close", "关闭": "close",
"TGW语言模型": "TGW language model", "TGW语言模型": "TGW language model",
"自动切换源语言": "Automatically switch source language",
"命令行启动": "Command line startup", "命令行启动": "Command line startup",
"文本相似度阈值": "Text similarity threshold", "文本相似度阈值": "Text similarity threshold",
"正则": "Regular", "正则": "Regular",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Área seleccionada de memoria", "记忆选定区域": "Área seleccionada de memoria",
"关闭": "Cierre", "关闭": "Cierre",
"TGW语言模型": "Modelo lingüístico tgw", "TGW语言模型": "Modelo lingüístico tgw",
"自动切换源语言": "Cambiar automáticamente el lenguaje fuente",
"命令行启动": "Se inicia la línea de órdenes", "命令行启动": "Se inicia la línea de órdenes",
"文本相似度阈值": "Umbral de similitud de texto", "文本相似度阈值": "Umbral de similitud de texto",
"正则": "Regular", "正则": "Regular",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Mémoriser la zone sélectionnée", "记忆选定区域": "Mémoriser la zone sélectionnée",
"关闭": "Fermé", "关闭": "Fermé",
"TGW语言模型": "Modèle de langage tgw", "TGW语言模型": "Modèle de langage tgw",
"自动切换源语言": "Changement automatique de langue source",
"命令行启动": "Démarrage de la ligne de commande", "命令行启动": "Démarrage de la ligne de commande",
"文本相似度阈值": "Seuil de similarité du texte", "文本相似度阈值": "Seuil de similarité du texte",
"正则": "Régulière", "正则": "Régulière",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Area di selezione della memoria", "记忆选定区域": "Area di selezione della memoria",
"关闭": "chiudi", "关闭": "chiudi",
"TGW语言模型": "Modello linguistico TGW", "TGW语言模型": "Modello linguistico TGW",
"自动切换源语言": "Cambia automaticamente la lingua sorgente",
"命令行启动": "Avvio della riga di comando", "命令行启动": "Avvio della riga di comando",
"文本相似度阈值": "Soglia di somiglianza del testo", "文本相似度阈值": "Soglia di somiglianza del testo",
"正则": "regolare", "正则": "regolare",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "メモリ選択領域", "记忆选定区域": "メモリ選択領域",
"关闭": "閉じる", "关闭": "閉じる",
"TGW语言模型": "TGW言語モデル", "TGW语言模型": "TGW言語モデル",
"自动切换源语言": "ソース言語の自動切り替え",
"命令行启动": "コマンドライン起動", "命令行启动": "コマンドライン起動",
"文本相似度阈值": "テキスト類似度しきい値", "文本相似度阈值": "テキスト類似度しきい値",
"正则": "正則", "正则": "正則",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "선택한 영역 기억하기", "记忆选定区域": "선택한 영역 기억하기",
"关闭": "닫기", "关闭": "닫기",
"TGW语言模型": "TGW 언어 모델", "TGW语言模型": "TGW 언어 모델",
"自动切换源语言": "소스 언어 자동 전환",
"命令行启动": "명령줄 시작", "命令行启动": "명령줄 시작",
"文本相似度阈值": "텍스트 유사도 임계값", "文本相似度阈值": "텍스트 유사도 임계값",
"正则": "정규", "正则": "정규",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Obszar wyboru pamięci", "记忆选定区域": "Obszar wyboru pamięci",
"关闭": "zamknij", "关闭": "zamknij",
"TGW语言模型": "Model językowy TGW", "TGW语言模型": "Model językowy TGW",
"自动切换源语言": "Automatycznie przełączaj język źródłowy",
"命令行启动": "Uruchamianie wiersza poleceń", "命令行启动": "Uruchamianie wiersza poleceń",
"文本相似度阈值": "Próg podobieństwa tekstu", "文本相似度阈值": "Próg podobieństwa tekstu",
"正则": "regularne", "正则": "regularne",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Запоминание выбранной области", "记忆选定区域": "Запоминание выбранной области",
"关闭": "Закрыть", "关闭": "Закрыть",
"TGW语言模型": "Языковая модель TGW", "TGW语言模型": "Языковая модель TGW",
"自动切换源语言": "Автоматическое переключение исходного языка",
"命令行启动": "Запуск командной строки", "命令行启动": "Запуск командной строки",
"文本相似度阈值": "Порог сходства текста", "文本相似度阈值": "Порог сходства текста",
"正则": "Регулярно", "正则": "Регулярно",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "หน่วยความจำพื้นที่ที่เลือก", "记忆选定区域": "หน่วยความจำพื้นที่ที่เลือก",
"关闭": "ปิด", "关闭": "ปิด",
"TGW语言模型": "รูปแบบภาษา TGW", "TGW语言模型": "รูปแบบภาษา TGW",
"自动切换源语言": "สลับภาษาต้นทางโดยอัตโนมัติ",
"命令行启动": "เริ่มบรรทัดคำสั่ง", "命令行启动": "เริ่มบรรทัดคำสั่ง",
"文本相似度阈值": "เกณฑ์ความคล้ายคลึงกันของข้อความ", "文本相似度阈值": "เกณฑ์ความคล้ายคลึงกันของข้อความ",
"正则": "กฎทั่วไป", "正则": "กฎทั่วไป",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Hafıza seçim alanı", "记忆选定区域": "Hafıza seçim alanı",
"关闭": "kapat", "关闭": "kapat",
"TGW语言模型": "TGW dil modeli", "TGW语言模型": "TGW dil modeli",
"自动切换源语言": "Avtomatik kaynak dilini değiştir",
"命令行启动": "Komut satırı başlatma", "命令行启动": "Komut satırı başlatma",
"文本相似度阈值": "Metin benzerliği eşiği", "文本相似度阈值": "Metin benzerliği eşiği",
"正则": "normal", "正则": "normal",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Область вибору пам' яті", "记忆选定区域": "Область вибору пам' яті",
"关闭": "закрити", "关闭": "закрити",
"TGW语言模型": "Модель мови TGW", "TGW语言模型": "Модель мови TGW",
"自动切换源语言": "Автоматично перемикати мову джерела",
"命令行启动": "Запуск командного рядка", "命令行启动": "Запуск командного рядка",
"文本相似度阈值": "Праг подібності до тексту", "文本相似度阈值": "Праг подібності до тексту",
"正则": "звичайний", "正则": "звичайний",

View File

@ -638,7 +638,6 @@
"记忆选定区域": "Ghi nhớ vùng chọn", "记忆选定区域": "Ghi nhớ vùng chọn",
"关闭": "Đóng cửa", "关闭": "Đóng cửa",
"TGW语言模型": "Mô hình ngôn ngữ TGW", "TGW语言模型": "Mô hình ngôn ngữ TGW",
"自动切换源语言": "Tự động chuyển đổi ngôn ngữ nguồn",
"命令行启动": "Chạy dòng lệnh", "命令行启动": "Chạy dòng lệnh",
"文本相似度阈值": "Ngưỡng tương tự văn bản", "文本相似度阈值": "Ngưỡng tương tự văn bản",
"正则": "Chính quy", "正则": "Chính quy",

View File

@ -640,7 +640,6 @@
"记忆选定区域": "", "记忆选定区域": "",
"关闭": "", "关闭": "",
"TGW语言模型": "", "TGW语言模型": "",
"自动切换源语言": "",
"命令行启动": "", "命令行启动": "",
"文本相似度阈值": "", "文本相似度阈值": "",
"正则": "", "正则": "",

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 3) set(VERSION_MAJOR 3)
set(VERSION_MINOR 6) set(VERSION_MINOR 6)
set(VERSION_PATCH 3) set(VERSION_PATCH 4)
add_library(pch pch.cpp) add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h) target_precompile_headers(pch PUBLIC pch.h)