Skip to content

Commit

Permalink
修改特殊码格式检查的位置
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Mar 29, 2023
1 parent 2d47927 commit 5f13518
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 3 additions & 9 deletions LunaTranslator/LunaTranslator/gui/selecthook.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from PyQt5.QtCore import Qt,pyqtSignal,QSize,QModelIndex
import qtawesome
from gui.dialog_savedgame import dialog_setting_game
from utils.hookcode import Parsecode
import re
import os,time
from utils.config import globalconfig ,_TR,_TRL,checkifnewgame
Expand Down Expand Up @@ -333,23 +332,18 @@ def searchtextfunc(self):
#self.ttCombo.setItemData(index,'',Qt.UserRole-(1 if ishide else 0))
#self.ttCombo.setRowHidden(index,ishide)
def inserthook(self):
hookcode=self.userhook.text().replace('\r','').replace('\n','').replace('\t','')
hookcode=self.userhook.text()
if len(hookcode)==0:
return
x=Parsecode(hookcode)
#print(hookcode,x.stdout[0])
if(x is None):
self.getnewsentence(_TR('!特殊码格式错误!'))
return

if self.object.textsource:

if len(self.object.textsource.pids)==1:
pid=self.object.textsource.pids[0]
else:
pid=int(self.selectpid.currentText())
self.object.textsource.inserthook(hookcode,pid)
self.saveinserthook.append(hookcode)
if self.object.textsource.inserthook(hookcode,pid):
self.saveinserthook.append(hookcode)

else:
self.getnewsentence(_TR('!未选定进程!'))
Expand Down
11 changes: 9 additions & 2 deletions LunaTranslator/LunaTranslator/textsource/textractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import time
from traceback import print_exc
from collections import OrderedDict
import os
from utils.hookcode import Parsecode
from utils import somedef
from utils.config import globalconfig ,savehook_new_data
from utils.config import globalconfig ,savehook_new_data ,_TR
from utils.subproc import u16lesubprocess
from utils.hwnd import getarch
from textsource.textsourcebase import basetext
Expand Down Expand Up @@ -96,7 +96,14 @@ def findhook(self,pid):
self.u16lesubprocess.writer(f'find -P{pid}',0)
def inserthook(self,hookcode,pid):
hookcode=hookcode.replace('\r','').replace('\n','').replace('\t','')
x=Parsecode(hookcode)
#print(hookcode,x.stdout[0])
if(x is None):
self.hookselectdialog.getnewsentencesignal.emit(_TR('!特殊码格式错误!'))
return False

self.u16lesubprocess.writer(f'{hookcode} -P{pid}',0)
return True
def attach(self):
self.pidswrite('attach')
def detach(self):
Expand Down

0 comments on commit 5f13518

Please sign in to comment.