srclang auto switch && custom command

This commit is contained in:
恍兮惚兮 2024-03-01 22:06:50 +08:00
parent 4cb27e46e5
commit c54325d7ba
24 changed files with 100 additions and 33 deletions

View File

@ -528,6 +528,11 @@ class MAINUI() :
self.textsource=texthook(pids,hwnd,name_ ,autostarthookcode=savehook_new_data[name_]['hook'],needinserthookcode=needinserthookcode) self.textsource=texthook(pids,hwnd,name_ ,autostarthookcode=savehook_new_data[name_]['hook'],needinserthookcode=needinserthookcode)
elif len(pids)==1 and globalconfig['sourcestatus2']['fridahook']['use'] and savehook_new_data[name_]['fridahook']['loadmethod']==0: elif len(pids)==1 and globalconfig['sourcestatus2']['fridahook']['use'] and savehook_new_data[name_]['fridahook']['loadmethod']==0:
self.textsource=fridahook(0,savehook_new_data[name_]['fridahook']['js'],name_,pids[0],hwnd) self.textsource=fridahook(0,savehook_new_data[name_]['fridahook']['js'],name_,pids[0],hwnd)
onloadautoswitchsrclang=savehook_new_data[name_]['onloadautoswitchsrclang']
if onloadautoswitchsrclang>0:
self.settin_ui.srclangswitcher.setCurrentIndex(onloadautoswitchsrclang-1)
break break
else: else:

View File

@ -478,13 +478,6 @@ class dialog_setting_game(QDialog):
b=windows.GetBinaryType(exepath) b=windows.GetBinaryType(exepath)
if type==2:
formLayout.addLayout(getboxlayout([
QLabel(_TR("转区启动")),
getsimpleswitch(savehook_new_data[exepath],'leuse')
]))
if b==6: if b==6:
_methods=['','Locale_Remulator','Ntleas' ] _methods=['','Locale_Remulator','Ntleas' ]
else: else:
@ -492,15 +485,31 @@ class dialog_setting_game(QDialog):
if b==6 and savehook_new_data[exepath]['localeswitcher']==0: if b==6 and savehook_new_data[exepath]['localeswitcher']==0:
savehook_new_data[exepath]['localeswitcher']=2 savehook_new_data[exepath]['localeswitcher']=2
formLayout.addLayout(getboxlayout([ formLayout.addLayout(getboxlayout([
QLabel(_TR("转区方法")),getsimplecombobox(_TRL(_methods),savehook_new_data[exepath],'localeswitcher') QLabel(_TR("转区启动")),
getsimpleswitch(savehook_new_data[exepath],'leuse'),
QLabel(_TR("转区方法")),
getsimplecombobox(_TRL(_methods),savehook_new_data[exepath],'localeswitcher')
][(type!=2)*2:]))
editcmd=QLineEdit(savehook_new_data[exepath]['startcmd'])
editcmd.textEdited.connect(lambda _:savehook_new_data[exepath].__setitem__('startcmd',_))
formLayout.addLayout(getboxlayout([
QLabel(_TR("命令行启动")),
getsimpleswitch(savehook_new_data[exepath],'startcmduse'),
editcmd
])) ]))
formLayout.addLayout(getboxlayout([ formLayout.addLayout(getboxlayout([
QLabel(_TR("自动切换到模式")), QLabel(_TR("自动切换到模式")),
getsimplecombobox(_TRL(['不切换','HOOK','剪贴板','OCR','FridaHook']),savehook_new_data[exepath],'onloadautochangemode2') getsimplecombobox(_TRL(['不切换','HOOK','剪贴板','OCR','FridaHook']),savehook_new_data[exepath],'onloadautochangemode2')
])) ]))
formLayout.addLayout(getboxlayout([
QLabel(_TR("自动切换源语言")),
getsimplecombobox(_TRL(['不切换'])+_TRL(static_data['language_list_translator']),savehook_new_data[exepath],'onloadautoswitchsrclang')
]))
methodtab=QTabWidget() methodtab=QTabWidget()
methodtab.addTab(self.gethooktab(exepath),"HOOK") methodtab.addTab(self.gethooktab(exepath),"HOOK")
@ -655,9 +664,7 @@ def startgame(game):
try: try:
if os.path.exists(game): if os.path.exists(game):
mode=savehook_new_data[game]['onloadautochangemode2'] mode=savehook_new_data[game]['onloadautochangemode2']
if mode==0: if mode>0:
pass
else:
_={ _={
1:'texthook', 1:'texthook',
2:'copy', 2:'copy',
@ -672,14 +679,20 @@ def startgame(game):
if globalconfig['sourcestatus2']['fridahook']['use'] and savehook_new_data[game]['fridahook'].get('loadmethod')==1: if globalconfig['sourcestatus2']['fridahook']['use'] and savehook_new_data[game]['fridahook'].get('loadmethod')==1:
gobject.baseobject.textsource=fridahook(1,savehook_new_data[game]['fridahook'].get('js'),game) gobject.baseobject.textsource=fridahook(1,savehook_new_data[game]['fridahook'].get('js'),game)
return return
dirpath=os.path.dirname(game)
if savehook_new_data[game]['startcmduse']:
usearg=savehook_new_data[game]['startcmd'].format(exepath=game)
windows.CreateProcess(None,usearg, None,None,False,0,None, dirpath, windows.STARTUPINFO() )
return
if savehook_new_data[game]['leuse']==False or (game.lower()[-4:] not in ['.lnk','.exe']): if savehook_new_data[game]['leuse']==False or (game.lower()[-4:] not in ['.lnk','.exe']):
#对于其他文件需要AssocQueryStringW获取命令行才能正确le太麻烦放弃。 #对于其他文件需要AssocQueryStringW获取命令行才能正确le太麻烦放弃。
windows.ShellExecute(None, "open", game, "", os.path.dirname(game), windows.SW_SHOW) windows.ShellExecute(None, "open", game, "", dirpath, windows.SW_SHOW)
return return
execheck3264=game execheck3264=game
usearg='"{}"'.format(game) usearg='"{}"'.format(game)
dirpath=os.path.dirname(game)
if game.lower()[-4:]=='.lnk': if game.lower()[-4:]=='.lnk':
exepath,args,iconpath,dirp=(winsharedutils.GetLnkTargetPath(game)) exepath,args,iconpath,dirp=(winsharedutils.GetLnkTargetPath(game))

View File

@ -15,7 +15,7 @@ from gui.settingpage_xianshishezhi import setTabThree ,setTabThree_direct
from gui.settingpage_tts import setTab5 ,setTab5_direct from gui.settingpage_tts import setTab5 ,setTab5_direct
from gui.settingpage_cishu import setTabcishu from gui.settingpage_cishu import setTabcishu
from gui.settingpage_quick import setTab_quick,setTab_quick_direct from gui.settingpage_quick import setTab_quick,setTab_quick_direct
from gui.setting_lang import setTablang from gui.setting_lang import setTablang,setTablangd
from gui.setting_proxy import setTab_proxy from gui.setting_proxy import setTab_proxy
from gui.settingpage7 import setTab7 ,settab7direct from gui.settingpage7 import setTab7 ,settab7direct
from gui.settingpage_about import setTab_about,setTab_about_dicrect from gui.settingpage_about import setTab_about,setTab_about_dicrect
@ -111,7 +111,7 @@ class Settin(closeashidewindow) :
setTabThree_direct(self) setTabThree_direct(self)
setTab5_direct(self) setTab5_direct(self)
setTab_quick_direct(self) setTab_quick_direct(self)
setTablangd(self)
setTab_about_dicrect(self) setTab_about_dicrect(self)
self.setstylesheet() self.setstylesheet()

View File

@ -4,11 +4,14 @@ from myutils.config import globalconfig ,_TR,_TRL ,static_data
from gui.usefulwidget import getsimplecombobox,getcolorbutton from gui.usefulwidget import getsimplecombobox,getcolorbutton
def setTablang(self) : def setTablang(self) :
self.tabadd_lazy(self.tab_widget, ('语言设置'), lambda :setTablanglz(self)) self.tabadd_lazy(self.tab_widget, ('语言设置'), lambda :setTablanglz(self))
def setTablangd(self):
self.srclangswitcher=getsimplecombobox(_TRL(static_data['language_list_translator']),globalconfig,'srclang3')
def setTablanglz(self) : def setTablanglz(self) :
grids=[ grids=[
[('翻译及OCR语言',15)], [('翻译及OCR语言',15)],
[ [
("源语言",5),(getsimplecombobox(_TRL(static_data['language_list_translator'] ),globalconfig,'srclang3'),5),], ("源语言",5),(self.srclangswitcher,5),],
[ [
("目标语言",5),(getsimplecombobox(_TRL(static_data['language_list_translator'] ),globalconfig,'tgtlang3'),5) , ("目标语言",5),(getsimplecombobox(_TRL(static_data['language_list_translator'] ),globalconfig,'tgtlang3'),5) ,
], ],

View File

@ -50,6 +50,7 @@ def getdefaultsavehook(gamepath,title=None):
default={ default={
'localeswitcher':0, 'localeswitcher':0,
'onloadautochangemode2':0, 'onloadautochangemode2':0,
'onloadautoswitchsrclang':0,
'needinserthookcode':[], 'needinserthookcode':[],
'embedablehook':[], 'embedablehook':[],
'imagepath':None, 'imagepath':None,
@ -59,6 +60,8 @@ def getdefaultsavehook(gamepath,title=None):
'statistic_wordcount':0, 'statistic_wordcount':0,
'statistic_wordcount_nodump':0, 'statistic_wordcount_nodump':0,
'leuse':True, 'leuse':True,
'startcmd':'"{exepath}"',
'startcmduse':False,
'hook':[], 'hook':[],
'inserthooktimeout':0, 'inserthooktimeout':0,
'needinserthookcode':[], 'needinserthookcode':[],

View File

@ -711,5 +711,7 @@
"多重区域模式": "وضع منطقة متعددة", "多重区域模式": "وضع منطقة متعددة",
"记忆选定区域": "اختيار الذاكرة", "记忆选定区域": "اختيار الذاكرة",
"关闭": "غلق", "关闭": "غلق",
"TGW语言模型": "TGW نموذج اللغة" "TGW语言模型": "TGW نموذج اللغة",
"自动切换源语言": "التبديل التلقائي لغة المصدر",
"命令行启动": "بدء تشغيل سطر الأوامر"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "多重區域模式", "多重区域模式": "多重區域模式",
"记忆选定区域": "記憶選定區域", "记忆选定区域": "記憶選定區域",
"关闭": "關閉", "关闭": "關閉",
"TGW语言模型": "TGW語言模型" "TGW语言模型": "TGW語言模型",
"自动切换源语言": "自動切換源語言",
"命令行启动": "命令列啟動"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Multi region mode", "多重区域模式": "Multi region mode",
"记忆选定区域": "Memory selection area", "记忆选定区域": "Memory selection area",
"关闭": "close", "关闭": "close",
"TGW语言模型": "TGW language model" "TGW语言模型": "TGW language model",
"自动切换源语言": "Automatically switch source language",
"命令行启动": "Command line startup"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Modelo multiregional", "多重区域模式": "Modelo multiregional",
"记忆选定区域": "Á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"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Mode Multi - zones", "多重区域模式": "Mode Multi - zones",
"记忆选定区域": "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"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Modalità multi regione", "多重区域模式": "Modalità multi regione",
"记忆选定区域": "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"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "複数領域モード", "多重区域模式": "複数領域モード",
"记忆选定区域": "メモリ選択領域", "记忆选定区域": "メモリ選択領域",
"关闭": "閉じる", "关闭": "閉じる",
"TGW语言模型": "TGW言語モデル" "TGW语言模型": "TGW言語モデル",
"自动切换源语言": "ソース言語の自動切り替え",
"命令行启动": "コマンドライン起動"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "다중 영역 모드", "多重区域模式": "다중 영역 모드",
"记忆选定区域": "선택한 영역 기억하기", "记忆选定区域": "선택한 영역 기억하기",
"关闭": "닫기", "关闭": "닫기",
"TGW语言模型": "TGW 언어 모델" "TGW语言模型": "TGW 언어 모델",
"自动切换源语言": "소스 언어 자동 전환",
"命令行启动": "명령줄 시작"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Tryb wielu regionów", "多重区域模式": "Tryb wielu regionów",
"记忆选定区域": "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ń"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Многорегиональная модель", "多重区域模式": "Многорегиональная модель",
"记忆选定区域": "Запоминание выбранной области", "记忆选定区域": "Запоминание выбранной области",
"关闭": "Закрыть", "关闭": "Закрыть",
"TGW语言模型": "Языковая модель TGW" "TGW语言模型": "Языковая модель TGW",
"自动切换源语言": "Автоматическое переключение исходного языка",
"命令行启动": "Запуск командной строки"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "โหมดหลายโซน", "多重区域模式": "โหมดหลายโซน",
"记忆选定区域": "หน่วยความจำพื้นที่ที่เลือก", "记忆选定区域": "หน่วยความจำพื้นที่ที่เลือก",
"关闭": "ปิด", "关闭": "ปิด",
"TGW语言模型": "รูปแบบภาษา TGW" "TGW语言模型": "รูปแบบภาษา TGW",
"自动切换源语言": "สลับภาษาต้นทางโดยอัตโนมัติ",
"命令行启动": "เริ่มบรรทัดคำสั่ง"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Çok bölge modu", "多重区域模式": "Çok bölge modu",
"记忆选定区域": "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"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Режим декількох регіонів", "多重区域模式": "Режим декількох регіонів",
"记忆选定区域": "Область вибору пам' яті", "记忆选定区域": "Область вибору пам' яті",
"关闭": "закрити", "关闭": "закрити",
"TGW语言模型": "Модель мови TGW" "TGW语言模型": "Модель мови TGW",
"自动切换源语言": "Автоматично перемикати мову джерела",
"命令行启动": "Запуск командного рядка"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "Chế độ đa vùng", "多重区域模式": "Chế độ đa vùng",
"记忆选定区域": "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"
} }

View File

@ -711,5 +711,7 @@
"多重区域模式": "", "多重区域模式": "",
"记忆选定区域": "", "记忆选定区域": "",
"关闭": "", "关闭": "",
"TGW语言模型": "" "TGW语言模型": "",
"自动切换源语言": "",
"命令行启动": ""
} }

View File

@ -1,6 +1,6 @@
import sys,time import sys,time
sys.path.append('./LunaTranslator') sys.path.append('./LunaTranslator')
from translator.baiduapi import TS from translator.baidu import TS
class TS1(TS): class TS1(TS):
@property @property

View File

@ -1,2 +1,3 @@
cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86 cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86
cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14 cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14
python copytarget.py 1

View File

@ -1,2 +1,3 @@
cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64 cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64
cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14 cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14
python copytarget.py 0

View File

@ -0,0 +1,11 @@
import shutil,sys
x86=int(sys.argv[1])
if x86:
shutil.copy('../builds/_x86/shareddllproxy32.exe','../../LunaTranslator/files/plugins')
shutil.copy('../builds/_x86/winrtutils32.dll','../../LunaTranslator/files/plugins/DLL32')
shutil.copy('../builds/_x86/winsharedutils32.dll','../../LunaTranslator/files/plugins/DLL32')
else:
shutil.copy('../builds/_x64/shareddllproxy64.exe','../../LunaTranslator/files/plugins')
shutil.copy('../builds/_x64/hookmagpie.dll','../../LunaTranslator/files/plugins')
shutil.copy('../builds/_x64/winrtutils64.dll','../../LunaTranslator/files/plugins/DLL64')
shutil.copy('../builds/_x64/winsharedutils64.dll','../../LunaTranslator/files/plugins/DLL64')