From 01d2354e45fc5e709d504fbf46a27fc4c43e09b4 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: Sun, 9 Jun 2024 12:18:53 +0800 Subject: [PATCH] some --- .../LunaTranslator/gui/dialog_savedgame.py | 475 +++++++++++++++--- .../LunaTranslator/gui/setting_textinput.py | 27 +- .../LunaTranslator/gui/setting_transopti.py | 59 +-- .../LunaTranslator/gui/usefulwidget.py | 17 +- .../{myutils => }/metadata/abstract.py | 15 + .../{myutils => }/metadata/bangumi.py | 10 +- .../{myutils => }/metadata/dlsite.py | 3 +- .../LunaTranslator/metadata/fanza.py | 181 +++++++ .../{myutils => }/metadata/vndb.py | 45 +- .../LunaTranslator/myutils/config.py | 18 +- LunaTranslator/LunaTranslator/myutils/post.py | 4 +- .../LunaTranslator/myutils/utils.py | 55 +- .../LunaTranslator/textsource/texthook.py | 41 +- .../files/defaultconfig/config.json | 16 +- LunaTranslator/files/lang/ar.json | 7 +- LunaTranslator/files/lang/cht.json | 7 +- LunaTranslator/files/lang/en.json | 7 +- LunaTranslator/files/lang/es.json | 7 +- LunaTranslator/files/lang/fr.json | 7 +- LunaTranslator/files/lang/it.json | 7 +- LunaTranslator/files/lang/ja.json | 7 +- LunaTranslator/files/lang/ko.json | 7 +- LunaTranslator/files/lang/pl.json | 7 +- LunaTranslator/files/lang/ru.json | 7 +- LunaTranslator/files/lang/th.json | 7 +- LunaTranslator/files/lang/tr.json | 7 +- LunaTranslator/files/lang/uk.json | 7 +- LunaTranslator/files/lang/vi.json | 7 +- LunaTranslator/files/lang/zh.json | 7 +- plugins/CMakeLists.txt | 4 +- 30 files changed, 798 insertions(+), 277 deletions(-) rename LunaTranslator/LunaTranslator/{myutils => }/metadata/abstract.py (90%) rename LunaTranslator/LunaTranslator/{myutils => }/metadata/bangumi.py (83%) rename LunaTranslator/LunaTranslator/{myutils => }/metadata/dlsite.py (97%) create mode 100644 LunaTranslator/LunaTranslator/metadata/fanza.py rename LunaTranslator/LunaTranslator/{myutils => }/metadata/vndb.py (81%) diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index ae25aea4..dc82583b 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -10,6 +10,7 @@ from myutils.config import ( savegametaged, _TR, _TRL, + postprocessconfig, globalconfig, static_data, ) @@ -20,9 +21,16 @@ from myutils.utils import ( str2rgba, gamdidchangedtask, titlechangedtask, + selectdebugfile, targetmod, ) -from gui.inputdialog import noundictconfigdialog1, autoinitdialog +from gui.codeacceptdialog import codeacceptdialog +from gui.inputdialog import ( + noundictconfigdialog1, + autoinitdialog, + autoinitdialog_items, + postconfigdialog, +) from gui.specialwidget import ( ScrollFlow, chartwidget, @@ -47,6 +55,7 @@ from gui.usefulwidget import ( makesubtab_lazy, tabadd_lazy, getsimpleswitch, + threebuttons, getspinbox, selectcolor, listediter, @@ -407,20 +416,8 @@ class browserdialog(saveposwindow): self.tagswidget.addTags(items) def startupnavi(self, exepath): - for idx in range(1, 100): - if idx == 1: - if exepath: - hasvndb = bool( - savehook_new_data[exepath]["infopath"] - and os.path.exists(savehook_new_data[exepath]["infopath"]) - ) - if hasvndb: - navitarget = self.parsehtml( - savehook_new_data[exepath]["infopath"] - ) - break - elif idx == 2: - + for idx in range(2, 100): + if idx == 2: if exepath: if len(savehook_new_data[exepath]["relationlinks"]): navitarget = savehook_new_data[exepath]["relationlinks"][-1][1] @@ -568,6 +565,67 @@ def calculate_centered_rect(original_rect: QRect, size: QSize) -> QRect: return new_rect +def maybehavebutton(self, game, post): + if post == "_11": + savehook_new_data[game]["save_text_process_info"]["mypost"] = str( + uuid.uuid4() + ).replace("-", "_") + return getcolorbutton( + globalconfig, + "", + callback=functools.partial( + selectdebugfile, + savehook_new_data[game]["save_text_process_info"]["mypost"], + ismypost=True, + ), + icon="fa.gear", + constcolor="#FF69B4", + ) + else: + if post not in postprocessconfig: + return + if post == "_remove_chaos": + return getcolorbutton( + globalconfig, + "", + icon="fa.gear", + constcolor="#FF69B4", + callback=lambda: codeacceptdialog(self), + ) + elif "args" in postprocessconfig[post]: + if isinstance(list(postprocessconfig[post]["args"].values())[0], dict): + callback = functools.partial( + postconfigdialog, + self, + savehook_new_data[game]["save_text_process_info"][ + "postprocessconfig" + ][post]["args"], + postprocessconfig[post]["name"], + ) + else: + items = autoinitdialog_items( + savehook_new_data[game]["save_text_process_info"][ + "postprocessconfig" + ][post] + ) + callback = functools.partial( + autoinitdialog, + self, + postprocessconfig[post]["name"], + 600, + items, + ) + return getcolorbutton( + globalconfig, + "", + callback=callback, + icon="fa.gear", + constcolor="#FF69B4", + ) + else: + return None + + class dialog_setting_game_internal(QWidget): def selectexe(self): f = QFileDialog.getOpenFileName(directory=self.exepath) @@ -626,30 +684,47 @@ class dialog_setting_game_internal(QWidget): functools.partial(savehook_new_data[exepath].__setitem__, "title") ) titleedit.returnPressed.connect(_titlechange) - formLayout.addRow(_TR("标题"), titleedit) + + formLayout.addRow( + _TR("标题"), + getboxlayout( + [ + titleedit, + getcolorbutton( + "", + "", + _titlechange, + icon="fa.search", + constcolor="#FF69B4", + ), + ] + ), + ) methodtab, do = makesubtab_lazy( _TRL( [ "启动", "HOOK", + "文本处理", "画廊", "标签", "元数据", "统计", - "预翻译", "语音", + "预翻译", "存档备份", ] ), [ functools.partial(self.doaddtab, self.starttab, exepath), functools.partial(self.doaddtab, self.gethooktab, exepath), + functools.partial(self.doaddtab, self.gettextproc, exepath), functools.partial(self.doaddtab, self.fengmiantab, exepath), functools.partial(self.doaddtab, self.getlabelsetting, exepath), functools.partial(self.doaddtab, self.metadataorigin, exepath), functools.partial(self.doaddtab, self.getstatistic, exepath), - functools.partial(self.doaddtab, self.getpretranstab, exepath), functools.partial(self.doaddtab, self.getttssetting, exepath), + functools.partial(self.doaddtab, self.getpretranstab, exepath), functools.partial(self.doaddtab, self.getbackup, exepath), ], delay=True, @@ -690,30 +765,41 @@ class dialog_setting_game_internal(QWidget): vndbid.returnPressed.connect( functools.partial(gamdidchangedtask, key, idname, exepath) ) + _vbox_internal = [ + vndbid, + getcolorbutton( + "", + "", + functools.partial(self.openrefmainpage, key, idname, exepath), + icon="fa.chrome", + constcolor="#FF69B4", + ), + getcolorbutton( + "", + "", + functools.partial(gamdidchangedtask, key, idname, exepath), + icon="fa.search", + constcolor="#FF69B4", + ), + ] + try: + __settting = targetmod[key].querysettingwindow + _vbox_internal.insert( + 1, + getcolorbutton( + "", + "", + functools.partial(__settting, self), + icon="fa.gear", + constcolor="#FF69B4", + ), + ) + except: + pass formLayout.addRow( key, - getboxlayout( - [ - vndbid, - getcolorbutton( - "", - "", - functools.partial( - self.openrefmainpage, key, idname, exepath - ), - icon="fa.chrome", - constcolor="#FF69B4", - ), - getcolorbutton( - "", - "", - functools.partial(gamdidchangedtask, key, idname, exepath), - icon="fa.search", - constcolor="#FF69B4", - ), - ] - ), + getboxlayout(_vbox_internal), ) return _w @@ -1068,24 +1154,171 @@ class dialog_setting_game_internal(QWidget): ) return _w + def gettextproc(self, exepath): + _w = QWidget() + + formLayout = QFormLayout() + _w.setLayout(formLayout) + __extra = QWidget() + + def __function(_): + __extra.setEnabled(not _) + + formLayout.addRow( + _TR("跟随默认"), + getsimpleswitch( + savehook_new_data[exepath], + "textproc_follow_default", + callback=__function, + ), + ) + __extra.setEnabled(not savehook_new_data[exepath]["textproc_follow_default"]) + vbox = QVBoxLayout() + vbox.setContentsMargins(0, 0, 0, 0) + __extra.setLayout(vbox) + formLayout.addWidget(__extra) + + model = QStandardItemModel() + model.setHorizontalHeaderLabels(_TRL(["使用", "预处理方法", "设置"])) + + table = QTableView() + + table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch) + table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers) + table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows) + table.setSelectionMode((QAbstractItemView.SelectionMode.SingleSelection)) + table.setWordWrap(False) + table.setModel(model) + + table.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) + table.customContextMenuRequested.connect(self.__privatetextproc_showmenu) + self.__textprocinternaltable = table + self.__textprocinternalmodel = model + self.__privatetextproc_exe = exepath + for row, k in enumerate( + savehook_new_data[exepath]["save_text_process_info"]["rank"] + ): # 2 + self.__checkaddnewmethod(row, k) + vbox.addWidget(table) + buttons = threebuttons(btns=2, texts=_TRL(["添加行", "删除行"])) + buttons.btn1clicked.connect(self.__privatetextproc_btn1) + buttons.btn2clicked.connect(self.__privatetextproc_btn2) + vbox.addWidget(buttons) + return _w + + def __privatetextproc_showmenu(self, p): + r = self.__textprocinternaltable.currentIndex().row() + if r < 0: + return + menu = QMenu(self.__textprocinternaltable) + remove = QAction(_TR("删除")) + up = QAction(_TR("上移")) + down = QAction(_TR("下移")) + menu.addAction(remove) + menu.addAction(up) + menu.addAction(down) + action = menu.exec(self.__textprocinternaltable.cursor().pos()) + + if action == remove: + self.__privatetextproc_btn2() + elif action == up: + self.__privatetextproc_moverank(-1) + elif action == down: + self.__privatetextproc_moverank(1) + + def __privatetextproc_moverank(self, dy): + __row = self.__textprocinternaltable.currentIndex().row() + + __list = savehook_new_data[self.__privatetextproc_exe][ + "save_text_process_info" + ]["rank"] + game = __list[__row] + idx1 = __list.index(game) + idx2 = (idx1 + dy) % len(__list) + __list.insert(idx2, __list.pop(idx1)) + self.__textprocinternalmodel.removeRow(idx1) + self.__checkaddnewmethod(idx2, game) + self.__textprocinternaltable.setCurrentIndex( + self.__textprocinternalmodel.index(__row, 0) + ) + + def __checkaddnewmethod(self, row, _internal): + self.__textprocinternalmodel.insertRow( + row, + [ + QStandardItem(), + QStandardItem(postprocessconfig[_internal]["name"]), + QStandardItem(), + ], + ) + __dict = savehook_new_data[self.__privatetextproc_exe][ + "save_text_process_info" + ]["postprocessconfig"] + if _internal not in __dict: + __dict[_internal] = postprocessconfig[_internal] + __dict[_internal]["use"] = True + btn = maybehavebutton(self, self.__privatetextproc_exe, _internal) + + self.__textprocinternaltable.setIndexWidget( + self.__textprocinternalmodel.index(row, 0), + getsimpleswitch(__dict[_internal], "use"), + ) + if btn: + self.__textprocinternaltable.setIndexWidget( + self.__textprocinternalmodel.index(row, 2), + btn, + ) + + def __privatetextproc_btn2(self): + row = self.__textprocinternaltable.currentIndex().row() + if row < 0: + return + self.__textprocinternalmodel.removeRow(row) + _dict = savehook_new_data[self.__privatetextproc_exe]["save_text_process_info"] + post = _dict["rank"][row] + _dict["rank"].pop(row) + if post in _dict["postprocessconfig"]: + _dict["postprocessconfig"].pop(post) + + def __privatetextproc_btn1(self): + __viss = [ + postprocessconfig[_internal]["name"] for _internal in postprocessconfig + ] + + def __callback(d): + __ = list(postprocessconfig.keys())[d["k"]] + __list = savehook_new_data[self.__privatetextproc_exe][ + "save_text_process_info" + ]["rank"] + if __ in __list: + return + __list.insert(0, __) + self.__checkaddnewmethod(0, __) + + __d = {"k": 0} + autoinitdialog( + self, + _TR("预处理方法"), + 400, + [ + { + "type": "combo", + "name": _TR("预处理方法"), + "d": __d, + "k": "k", + "list": __viss, + }, + { + "type": "okcancel", + "callback": functools.partial(__callback, __d), + }, + ], + ) + def gethooktab(self, exepath): _w = QWidget() formLayout = QFormLayout() _w.setLayout(formLayout) - formLayout.addRow( - _TR("代码页"), - getsimplecombobox( - _TRL(static_data["codepage_display"]), - savehook_new_data[exepath], - "codepage_index", - lambda x: gobject.baseobject.textsource.setsettings(), - ), - ) - - formLayout.addRow( - _TR("移除非选定hook"), - getsimpleswitch(savehook_new_data[exepath], "removeuseless"), - ) formLayout.addRow( _TR("特殊码"), @@ -1100,14 +1333,120 @@ class dialog_setting_game_internal(QWidget): _TR("插入特殊码延迟(ms)"), getspinbox(0, 1000000, savehook_new_data[exepath], "inserthooktimeout"), ) - if ( - savehook_new_data[exepath]["use_saved_text_process"] - or "save_text_process_info" in savehook_new_data[exepath] - ): - formLayout.addRow( - _TR("使用保存的文本处理流程"), - getsimpleswitch(savehook_new_data[exepath], "use_saved_text_process"), - ) + __extraw = QWidget() + + def __function(_): + __extraw.setEnabled(not _) + try: + gobject.baseobject.textsource.setsettings() + except: + pass + + formLayout.addRow( + _TR("跟随默认"), + getsimpleswitch( + savehook_new_data[exepath], + "hooksetting_follow_default", + callback=__function, + ), + ) + __extraw.setEnabled( + not savehook_new_data[exepath]["hooksetting_follow_default"] + ) + + for k in [ + "codepage_index", + "removeuseless", + "direct_filterrepeat", + "textthreaddelay", + "maxBufferSize", + "maxHistorySize", + "filter_chaos_code", + "allow_set_text_name", + "use_yapi", + ]: + if k not in savehook_new_data[exepath]["hooksetting_private"]: + savehook_new_data[exepath]["hooksetting_private"][k] = globalconfig[k] + formLayout.addWidget(__extraw) + formLayout2 = QFormLayout() + formLayout2.setContentsMargins(0, 0, 0, 0) + __extraw.setLayout(formLayout2) + formLayout2.addRow( + _TR("代码页"), + getsimplecombobox( + _TRL(static_data["codepage_display"]), + savehook_new_data[exepath]["hooksetting_private"], + "codepage_index", + lambda x: gobject.baseobject.textsource.setsettings(), + ), + ) + formLayout2.addRow( + _TR("过滤反复刷新的句子"), + getsimpleswitch( + savehook_new_data[exepath]["hooksetting_private"], + "direct_filterrepeat", + callback=lambda x: gobject.baseobject.textsource.setsettings(), + ), + ) + + formLayout2.addRow( + _TR("移除非选定hook"), + getsimpleswitch( + savehook_new_data[exepath]["hooksetting_private"], "removeuseless" + ), + ) + formLayout2.addRow( + _TR("刷新延迟(ms)"), + getspinbox( + 0, + 10000, + savehook_new_data[exepath]["hooksetting_private"], + "textthreaddelay", + callback=lambda x: gobject.baseobject.textsource.setsettings(), + ), + ) + formLayout2.addRow( + _TR("最大缓冲区长度"), + getspinbox( + 0, + 1000000, + savehook_new_data[exepath]["hooksetting_private"], + "maxBufferSize", + callback=lambda x: gobject.baseobject.textsource.setsettings(), + ), + ) + formLayout2.addRow( + _TR("最大缓存文本长度"), + getspinbox( + 0, + 1000000000, + savehook_new_data[exepath]["hooksetting_private"], + "maxHistorySize", + callback=lambda x: gobject.baseobject.textsource.setsettings(), + ), + ) + formLayout2.addRow( + _TR("过滤包含乱码的文本行"), + getsimpleswitch( + savehook_new_data[exepath]["hooksetting_private"], + "filter_chaos_code", + ), + ) + formLayout2.addRow( + _TR("区分人名和文本"), + getsimpleswitch( + savehook_new_data[exepath]["hooksetting_private"], + "allow_set_text_name", + ), + ) + formLayout2.addRow( + _TR("使用YAPI注入"), + getsimpleswitch( + savehook_new_data[exepath]["hooksetting_private"], + "use_yapi", + ), + ) + return _w @@ -2091,18 +2430,20 @@ class pixwrapper(QWidget): self.visidx() def visidx(self): - if self.k and len(self.pixmaps) == 0: + if len(self.pixmaps) == 0: + if not self.k: + return pixmap = getExeIcon(self.k, False, cache=True) pixmap.setDevicePixelRatio(self.devicePixelRatioF()) self.pixview.setPixmap(self.scalepix(pixmap)) - elif self.pixmapi < len(self.pixmaps): - pixmap = self.pixmaps[self.pixmapi] - - savehook_new_data[self.k]["currentvisimage"] = pixmap - pixmap = QPixmap.fromImage(QImage(pixmap)) + else: + self.pixmapi = min(len(self.pixmaps) - 1, self.pixmapi) + pixmap_ = self.pixmaps[self.pixmapi] + pixmap = QPixmap.fromImage(QImage(pixmap_)) if pixmap is None or pixmap.isNull(): self.pixmaps.pop(self.pixmapi) return self.visidx() + savehook_new_data[self.k]["currentvisimage"] = pixmap_ pixmap.setDevicePixelRatio(self.devicePixelRatioF()) self.pixview.setPixmap(self.scalepix(pixmap)) diff --git a/LunaTranslator/LunaTranslator/gui/setting_textinput.py b/LunaTranslator/LunaTranslator/gui/setting_textinput.py index 7b4c6211..36e44ea4 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_textinput.py +++ b/LunaTranslator/LunaTranslator/gui/setting_textinput.py @@ -2,7 +2,14 @@ from qtsymbols import * import functools, os, json import windows, gobject from myutils.utils import makehtml, getfilemd5 -from myutils.config import globalconfig, _TR, _TRL, savehook_new_data, savehook_new_list +from myutils.config import ( + globalconfig, + _TR, + _TRL, + savehook_new_data, + savehook_new_list, + static_data, +) from gui.pretransfile import sqlite2json2 from gui.codeacceptdialog import codeacceptdialog from gui.setting_textinput_ocr import getocrgrid @@ -73,6 +80,22 @@ def gethookgrid(self): ), ], [], + [ + ("代码页", 5), + ( + D_getsimplecombobox( + _TRL(static_data["codepage_display"]), + globalconfig, + "codepage_index", + lambda x: gobject.baseobject.textsource.setsettings(), + ), + 8, + ), + ], + [ + ("移除非选定hook", 5), + (D_getsimpleswitch(globalconfig, "removeuseless"), 1), + ], [ ("过滤反复刷新的句子", 5), (D_getsimpleswitch(globalconfig, "direct_filterrepeat"), 1), @@ -116,7 +139,6 @@ def gethookgrid(self): 3, ), ], - [], [ ("过滤包含乱码的文本行", 5), (D_getsimpleswitch(globalconfig, "filter_chaos_code"), 1), @@ -131,7 +153,6 @@ def gethookgrid(self): 1, ), ], - [], [("区分人名和文本", 5), D_getsimpleswitch(globalconfig, "allow_set_text_name")], [("使用YAPI注入", 5), D_getsimpleswitch(globalconfig, "use_yapi")], ] diff --git a/LunaTranslator/LunaTranslator/gui/setting_transopti.py b/LunaTranslator/LunaTranslator/gui/setting_transopti.py index 1b792fe3..b805306a 100644 --- a/LunaTranslator/LunaTranslator/gui/setting_transopti.py +++ b/LunaTranslator/LunaTranslator/gui/setting_transopti.py @@ -1,7 +1,5 @@ from qtsymbols import * -import functools, copy, os -from traceback import print_exc -import gobject +import functools from myutils.post import POSTSOLVE from myutils.utils import ( selectdebugfile, @@ -13,8 +11,6 @@ from myutils.config import ( postprocessconfig, static_data, _TRL, - savehook_new_data, - _TR, ) from gui.codeacceptdialog import codeacceptdialog from gui.usefulwidget import ( @@ -32,40 +28,6 @@ from gui.inputdialog import ( ) -def savegameprocesstext(): - try: - try: - with open("./userconfig/mypost.py", "r", encoding="utf8") as ff: - _mypost = ff.read() - os.makedirs("./userconfig/posts", exist_ok=True) - with open( - "./userconfig/posts/{}.py".format(gobject.baseobject.textsource.uuname), - "w", - encoding="utf8", - ) as ff: - ff.write(_mypost) - except: - _mypost = None - ranklist = [] - postargs = {} - for postitem in globalconfig["postprocess_rank"]: - if postitem not in postprocessconfig: - continue - if postprocessconfig[postitem]["use"]: - ranklist.append(postitem) - postargs[postitem] = copy.deepcopy(postprocessconfig[postitem]) - exepath = gobject.baseobject.textsource.pname - savehook_new_data[exepath]["save_text_process_info"] = { - "postprocessconfig": postargs, - "rank": ranklist, - "mypost": gobject.baseobject.textsource.uuname, - } - if savehook_new_data[exepath]["use_saved_text_process"] == False: - savehook_new_data[exepath]["use_saved_text_process"] = True - except: - print_exc() - - def delaysetcomparetext(self, s): try: self.__fromtext.setPlainText(s) @@ -234,24 +196,7 @@ def setTab7_lazy(self, basel): def ___(lay): vboxw, vbox = getvboxwidget() lay.addWidget(vboxw) - _w = makescrollgrid(grids, vbox, True, savelist, savelay) - _w.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) - - def showmenu(p: QPoint): - - try: - gobject.baseobject.textsource.pname # 检查是否为texthook - - menu = QMenu(_w) - save = QAction(_TR("保存当前游戏的文本处理流程")) - menu.addAction(save) - action = menu.exec(_w.cursor().pos()) - if action == save: - savegameprocesstext() - except: - pass - - _w.customContextMenuRequested.connect(showmenu) + makescrollgrid(grids, vbox, True, savelist, savelay) vbox.addWidget(getcomparelayout(self)) diff --git a/LunaTranslator/LunaTranslator/gui/usefulwidget.py b/LunaTranslator/LunaTranslator/gui/usefulwidget.py index 76fe992e..3db257a4 100644 --- a/LunaTranslator/LunaTranslator/gui/usefulwidget.py +++ b/LunaTranslator/LunaTranslator/gui/usefulwidget.py @@ -892,22 +892,31 @@ class threebuttons(QWidget): btn2clicked = pyqtSignal() btn3clicked = pyqtSignal() - def __init__(self, btns=3): + def __init__(self, btns=3, texts=None): super().__init__() layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) button = QPushButton(self) - button.setText(_TR("添加行")) + if texts: + button.setText(texts[0]) + else: + button.setText(_TR("添加行")) button.clicked.connect(self.btn1clicked) button2 = QPushButton(self) - button2.setText(_TR("删除选中行")) + if texts: + button2.setText(texts[1]) + else: + button2.setText(_TR("删除行")) button2.clicked.connect(self.btn2clicked) layout.addWidget(button) layout.addWidget(button2) if btns == 3: button3 = QPushButton(self) - button3.setText(_TR("立即应用")) + if texts: + button3.setText(texts[2]) + else: + button3.setText(_TR("立即应用")) button3.clicked.connect(self.btn3clicked) layout.addWidget(button3) diff --git a/LunaTranslator/LunaTranslator/myutils/metadata/abstract.py b/LunaTranslator/LunaTranslator/metadata/abstract.py similarity index 90% rename from LunaTranslator/LunaTranslator/myutils/metadata/abstract.py rename to LunaTranslator/LunaTranslator/metadata/abstract.py index a2cd6742..85d293fb 100644 --- a/LunaTranslator/LunaTranslator/myutils/metadata/abstract.py +++ b/LunaTranslator/LunaTranslator/metadata/abstract.py @@ -17,6 +17,21 @@ class common: def getidbytitle(title): return None + @property + def config(self): + return self.config_all["args"] + + @property + def config_all(self): + try: + return globalconfig["metadata"][self.typename] + except: + return {} + + @property + def name(self): + return self.config_all.get("name", self.typename) + @property def proxy(self): return getproxy(("metadata", self.typename)) diff --git a/LunaTranslator/LunaTranslator/myutils/metadata/bangumi.py b/LunaTranslator/LunaTranslator/metadata/bangumi.py similarity index 83% rename from LunaTranslator/LunaTranslator/myutils/metadata/bangumi.py rename to LunaTranslator/LunaTranslator/metadata/bangumi.py index 56481272..2f2a843e 100644 --- a/LunaTranslator/LunaTranslator/myutils/metadata/bangumi.py +++ b/LunaTranslator/LunaTranslator/metadata/bangumi.py @@ -1,7 +1,11 @@ -from myutils.metadata.abstract import common +from metadata.abstract import common +from gui.inputdialog import autoinitdialog, autoinitdialog_items class searcher(common): + def querysettingwindow(self, parent): + items = autoinitdialog_items(self.config_all) + autoinitdialog(parent, self.name, 800, items) def getidbytitle(self, title): @@ -36,7 +40,8 @@ class searcher(common): "accept": "application/json", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", } - + if self.config["access-token"].strip() != "": + headers["Authorization"] = ("Bearer " + self.config["access-token"],) response = self.proxysession.get( f"https://api.bgm.tv/v0/subjects/{sid}", headers=headers ) @@ -59,7 +64,6 @@ class searcher(common): return { # "namemap": namemap, "title": response["name_cn"], - # "infopath": parsehtmlmethod(vndbdowloadinfo(vid)), "imagepath_all": [imagepath], "webtags": vndbtags, "developers": developers, diff --git a/LunaTranslator/LunaTranslator/myutils/metadata/dlsite.py b/LunaTranslator/LunaTranslator/metadata/dlsite.py similarity index 97% rename from LunaTranslator/LunaTranslator/myutils/metadata/dlsite.py rename to LunaTranslator/LunaTranslator/metadata/dlsite.py index 6d94c0cc..d0fef5ed 100644 --- a/LunaTranslator/LunaTranslator/myutils/metadata/dlsite.py +++ b/LunaTranslator/LunaTranslator/metadata/dlsite.py @@ -2,7 +2,7 @@ import requests, re from myutils.utils import simplehtmlparser -from myutils.metadata.abstract import common +from metadata.abstract import common class searcher(common): @@ -115,7 +115,6 @@ class searcher(common): return { # "namemap": namemap, "title": title, - # "infopath": parsehtmlmethod(vndbdowloadinfo(vid)), "imagepath_all": [self.dispatchdownloadtask(_) for _ in imags1 + imags2], "webtags": tags, "developers": [devp], diff --git a/LunaTranslator/LunaTranslator/metadata/fanza.py b/LunaTranslator/LunaTranslator/metadata/fanza.py new file mode 100644 index 00000000..ec7f6ac3 --- /dev/null +++ b/LunaTranslator/LunaTranslator/metadata/fanza.py @@ -0,0 +1,181 @@ +import requests, re +from myutils.utils import simplehtmlparser + + +from metadata.abstract import common + + +class searcher(common): + def getidbytitle(self, title): + cookies = { + "top_pv_uid": "764317a4-3d99-46be-8f5a-6e6762b6059d", + "top_dummy": "d1776405-0683-4936-824a-d48d2660ccd2", + "guest_id": "DRNHXB5TDV9XVA__", + "ckcy": "1", + "mbox": "check#true#1717923986|session#1717923925784-847103#1717925786", + "is_intarnal": "true", + "__utma": "125690133.86996065.1717923926.1717923926.1717923926.1", + "__utmb": "125690133.0.10.1717923926", + "__utmc": "125690133", + "__utmz": "125690133.1717923926.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)", + "_gcl_au": "1.1.745157082.1717923927", + "rieSh3Ee_ga": "GA1.1.1543544133.1717923927", + "AMP_TOKEN": "%24NOT_FOUND", + "_dga": "GA1.3.86996065.1717923926", + "_dga_gid": "GA1.3.1715736403.1717923928", + "_dc_gtm_UA-48257133-2": "1", + "i3_ab": "93b99577-b74d-4fef-bba7-7ba426cf40ae", + "age_check_done": "1", + "dlsoft_check_item_history": "WyJuYXZlbF8wMDEzQDAiXQ%3D%3D", + "cklg": "ja", + "_yjsu_yjad": "1717923940.9d45754c-50f7-4219-8b50-e541815f4906", + "_dga": "GA1.4.86996065.1717923926", + "_dga_gid": "GA1.4.1715736403.1717923928", + "__rtbh.uid": "%7B%22eventType%22%3A%22uid%22%2C%22id%22%3A%22unknown%22%7D", + "rieSh3Ee_ga_KQYE0DE5JW": "GS1.1.1717923926.1.1.1717923942.0.0.405570256", + "cto_bundle": "yi6GA19QYzZmZHhXT0tWaFZZN2o4Y2NBb0lFSUFiWCUyQmJ3OWlTZ05VaWtEeXpoR201SnEyYnVIU3BqRENGeXJDN1VLUU5GOGxVRCUyRjVBa2dZUGFSc2kzSHNoa1FlUGx5Z2xoTElmTE5uc0l1WXpFclFGV1B0TiUyRldXT2ZaV0lXUEV5a2k4and0c2cxJTJGUDZCMWpNV0Q3bExiQktKZyUzRCUzRA", + "XSRF-TOKEN": "eyJpdiI6ImIyY21vbVJQZloxOUR3ZmJyaWhRdUE9PSIsInZhbHVlIjoiWTRaZ1VTOUw4UmFidnhvbWJkaU11SjZGRmljeWRiQ0cwODIybXI3T29VVmt2VXpub2dZdnBEUTFtN0pZa1BSeWZUQVhzOGR5UXlhVWxPUm1CN2Rwc3c9PSIsIm1hYyI6IjY5OTQ0ZjRmZjBhMGViZGRlN2VlMTQ2M2U3MDRiYjZlODllZWUyMDNlODg4YjQxOTA3ZmQyZDkzZWFhMjM0NmIiLCJ0YWciOiIifQ%3D%3D", + "laravel_session": "eyJpdiI6Ik41QzkzTkg1alBGVVVmeUdXOWpQWGc9PSIsInZhbHVlIjoia3lYNzVMOEZ3dm15SFNCb3RlYXNQTU9vZkZCeXBzK3BVOVF2dUY0d1c3QktQczVsU2ZRdTUxdkQ4VlBTcmdjdklQMHV3cFVsRVVcL3BCRGIybTNkVUhRPT0iLCJtYWMiOiJhYjkzMjNhZDg2OWI0ZjkyMTlmNzkzNTExOTlmZTBjNDU3NmJlZWUyYmM5ZTQ5NWI4MjAxZDdmNjZiZDA5NTJjIn0%3D", + "_dd_s": "logs=0&expire=1717924840754", + } + + headers = { + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", + "Accept-Language": "zh-CN,zh;q=0.9,ar;q=0.8,sq;q=0.7,ru;q=0.6", + "Cache-Control": "max-age=0", + "Connection": "keep-alive", + "Referer": "https://www.dmm.co.jp/", + "Sec-Fetch-Dest": "document", + "Sec-Fetch-Mode": "navigate", + "Sec-Fetch-Site": "same-site", + "Sec-Fetch-User": "?1", + "Upgrade-Insecure-Requests": "1", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", + "sec-ch-ua": '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + } + + response = self.proxysession.get( + f"https://dlsoft.dmm.co.jp/search/?floor=digital_pcgame&searchstr={title}&service=pcgame", + headers=headers, + cookies=cookies, + ) + _id = re.search( + "https://pics.dmm.co.jp/digital/pcgame/(.*?)/", response.text + ).groups()[0] + return _id + + def refmainpage(self, _id): + return f"https://dlsoft.dmm.co.jp/detail/{_id}/" + + def searchfordata(self, RJ): + cookies = { + "top_pv_uid": "764317a4-3d99-46be-8f5a-6e6762b6059d", + "top_dummy": "d1776405-0683-4936-824a-d48d2660ccd2", + "guest_id": "DRNHXB5TDV9XVA__", + "ckcy": "1", + "mbox": "check#true#1717923986|session#1717923925784-847103#1717925786", + "is_intarnal": "true", + "__utma": "125690133.86996065.1717923926.1717923926.1717923926.1", + "__utmb": "125690133.0.10.1717923926", + "__utmc": "125690133", + "__utmz": "125690133.1717923926.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)", + "_gcl_au": "1.1.745157082.1717923927", + "rieSh3Ee_ga": "GA1.1.1543544133.1717923927", + "AMP_TOKEN": "%24NOT_FOUND", + "_dga": "GA1.3.86996065.1717923926", + "_dga_gid": "GA1.3.1715736403.1717923928", + "_dc_gtm_UA-48257133-2": "1", + "i3_ab": "93b99577-b74d-4fef-bba7-7ba426cf40ae", + "age_check_done": "1", + "dlsoft_check_item_history": "WyJuYXZlbF8wMDEzQDAiXQ%3D%3D", + "cklg": "ja", + "_yjsu_yjad": "1717923940.9d45754c-50f7-4219-8b50-e541815f4906", + "_dga": "GA1.4.86996065.1717923926", + "_dga_gid": "GA1.4.1715736403.1717923928", + "__rtbh.uid": "%7B%22eventType%22%3A%22uid%22%2C%22id%22%3A%22unknown%22%7D", + "rieSh3Ee_ga_KQYE0DE5JW": "GS1.1.1717923926.1.1.1717923942.0.0.405570256", + "cto_bundle": "yi6GA19QYzZmZHhXT0tWaFZZN2o4Y2NBb0lFSUFiWCUyQmJ3OWlTZ05VaWtEeXpoR201SnEyYnVIU3BqRENGeXJDN1VLUU5GOGxVRCUyRjVBa2dZUGFSc2kzSHNoa1FlUGx5Z2xoTElmTE5uc0l1WXpFclFGV1B0TiUyRldXT2ZaV0lXUEV5a2k4and0c2cxJTJGUDZCMWpNV0Q3bExiQktKZyUzRCUzRA", + "XSRF-TOKEN": "eyJpdiI6ImIyY21vbVJQZloxOUR3ZmJyaWhRdUE9PSIsInZhbHVlIjoiWTRaZ1VTOUw4UmFidnhvbWJkaU11SjZGRmljeWRiQ0cwODIybXI3T29VVmt2VXpub2dZdnBEUTFtN0pZa1BSeWZUQVhzOGR5UXlhVWxPUm1CN2Rwc3c9PSIsIm1hYyI6IjY5OTQ0ZjRmZjBhMGViZGRlN2VlMTQ2M2U3MDRiYjZlODllZWUyMDNlODg4YjQxOTA3ZmQyZDkzZWFhMjM0NmIiLCJ0YWciOiIifQ%3D%3D", + "laravel_session": "eyJpdiI6Ik41QzkzTkg1alBGVVVmeUdXOWpQWGc9PSIsInZhbHVlIjoia3lYNzVMOEZ3dm15SFNCb3RlYXNQTU9vZkZCeXBzK3BVOVF2dUY0d1c3QktQczVsU2ZRdTUxdkQ4VlBTcmdjdklQMHV3cFVsRVVcL3BCRGIybTNkVUhRPT0iLCJtYWMiOiJhYjkzMjNhZDg2OWI0ZjkyMTlmNzkzNTExOTlmZTBjNDU3NmJlZWUyYmM5ZTQ5NWI4MjAxZDdmNjZiZDA5NTJjIn0%3D", + "_dd_s": "logs=0&expire=1717924840754", + } + + headers = { + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", + "Accept-Language": "zh-CN,zh;q=0.9,ar;q=0.8,sq;q=0.7,ru;q=0.6", + "Cache-Control": "max-age=0", + "Connection": "keep-alive", + "Referer": "https://www.dmm.co.jp/", + "Sec-Fetch-Dest": "document", + "Sec-Fetch-Mode": "navigate", + "Sec-Fetch-Site": "same-site", + "Sec-Fetch-User": "?1", + "Upgrade-Insecure-Requests": "1", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", + "sec-ch-ua": '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + } + print(self.refmainpage(RJ)) + response = self.proxysession.get( + self.refmainpage(RJ), headers=headers, cookies=cookies + ) + + title = re.search( + '

(.*?)

', response.text + ).groups()[1] + print(title) + devp = re.findall( + "
  • ([\\s\\S]*?)
  • ", + response.text, + )[2] + print(devp) + devp = ( + re.search("([\\s\\S]*?)", devp) + .groups()[1] + .replace("\n", "") + .strip() + ) + print(devp) + + __text = response.text + tags = [] + while True: + if __text.find('') == -1: + break + __text = __text[ + __text.find('') : + ] + tags = simplehtmlparser( + __text, + "tr", + '', + ) + __text = __text[1:] + if "ジャンル" not in tags: + continue + tags = re.findall(">(.*?)", tags) + break + + inner = simplehtmlparser( + response.text, + "div", + '
    ', + ) + + imags2 = [_[0] for _ in re.findall('', inner)] + print(imags2) + + inner = simplehtmlparser(response.text, "div", '
    ", '') - ##删除header - text = re.sub("
    ([\\s\\S]*?)
    ", "", text) - text = re.sub("
    ([\\s\\S]*?)
    ", "", text) - text = re.sub('
    ', "", text) - text = re.sub('
    ', "", text) - text = re.sub('
    ', "", text) - - text = re.sub("", "", text) - text = re.sub('

    ([\\s\\S]*?)

    ', "", text) - text = re.sub('
    ([\\s\\S]*?)
    ', "", text) - text = re.sub('
    ([\\s\\S]*?)
    ', "", text) - resavepath = infopath + "parsed.html" - - if globalconfig["languageuse"] == 0: - text = re.sub( - '(.*?)', - '\\2', - text, - ) - - with open(resavepath, "w", encoding="utf8") as ff: - ff.write(text) - - return resavepath - def gettagfromhtml(path): if path and os.path.exists(path): @@ -302,11 +268,6 @@ class searcher(common): return { "namemap": namemap, "title": title, - "infopath": parsehtmlmethod( - self.dispatchdownloadtask( - self.refmainpage(_vid), ishtml=True, delay=False - ) - ), "imagepath_all": __, "webtags": vndbtags, "developers": developers, diff --git a/LunaTranslator/LunaTranslator/myutils/config.py b/LunaTranslator/LunaTranslator/myutils/config.py index 757d2e3e..4c90a9c9 100644 --- a/LunaTranslator/LunaTranslator/myutils/config.py +++ b/LunaTranslator/LunaTranslator/myutils/config.py @@ -1,5 +1,5 @@ import json -import os, time +import os, time, uuid from traceback import print_exc @@ -60,6 +60,14 @@ ocrsetting = tryreadconfig("ocrsetting.json") def getdefaultsavehook(gamepath, title=None): default = { + "hooksetting_follow_default": True, + "hooksetting_private": {}, # 显示时再加载,缺省用global中的键 + "textproc_follow_default": True, + "save_text_process_info": { + "postprocessconfig": {}, + "rank": [], + # "mypost": + }, "localeswitcher": 0, "onloadautochangemode2": 0, "onloadautoswitchsrclang": 0, @@ -74,8 +82,6 @@ def getdefaultsavehook(gamepath, title=None): "hook": [], "inserthooktimeout": 0, "needinserthookcode": [], - "removeuseless": False, - "codepage_index": 0, # "allow_tts_auto_names": "",#->v4 "allow_tts_auto_names_v4": [], "tts_repair": False, @@ -101,14 +107,16 @@ def getdefaultsavehook(gamepath, title=None): # "vid": 0, "bgmsid": 0, - "dlsiteid": 'RJ', + "dlsiteid": "RJ/VJXXXX", + "fanzaid": "", + "title": "", # "imagepath": None, # 封面->imagepath_all[0] # "imagepath_much2": [], # 截图->imagepath_all[1:] "imagepath_all": [], "developers": [], "webtags": [], # 标签 - "infopath": None, # 离线存储的主页 + # "infopath": None, # 离线存储的主页 } if title and len(title): default["title"] = title # metadata diff --git a/LunaTranslator/LunaTranslator/myutils/post.py b/LunaTranslator/LunaTranslator/myutils/post.py index 3fc2c970..528139df 100644 --- a/LunaTranslator/LunaTranslator/myutils/post.py +++ b/LunaTranslator/LunaTranslator/myutils/post.py @@ -357,7 +357,7 @@ def POSTSOLVE(line): try: if "pname" in dir(gobject.baseobject.textsource): exepath = gobject.baseobject.textsource.pname - if savehook_new_data[exepath]["use_saved_text_process"]: + if not savehook_new_data[exepath]["textproc_follow_default"]: useranklist = savehook_new_data[exepath]["save_text_process_info"][ "rank" ] @@ -398,7 +398,7 @@ def POSTSOLVE(line): if usedpostprocessconfig[postitem]["use"]: try: _f = functions[postitem] - + sig = inspect.signature(_f) np = len(sig.parameters) if np == 1: diff --git a/LunaTranslator/LunaTranslator/myutils/utils.py b/LunaTranslator/LunaTranslator/myutils/utils.py index 8ccc1171..c269bb7e 100644 --- a/LunaTranslator/LunaTranslator/myutils/utils.py +++ b/LunaTranslator/LunaTranslator/myutils/utils.py @@ -98,21 +98,6 @@ class PriorityQueue: searchvndbqueue = PriorityQueue() -def checkinfo(gamepath): - return (savehook_new_data[gamepath]["infopath"] is None) or ( - (savehook_new_data[gamepath]["infopath"][:4].lower() != "http") - and os.path.exists(savehook_new_data[gamepath]["infopath"]) == False - ) - - -def checkvid(gamepath): - - return checkinfo(gamepath) or ( - (len(savehook_new_data[gamepath]["webtags"]) == 0) - and (len(savehook_new_data[gamepath]["developers"]) == 0) - ) - - def guessmaybetitle(gamepath): __t = [] @@ -145,8 +130,6 @@ def guessmaybetitle(gamepath): targetmod = {} -for k in globalconfig["metadata"]: - targetmod[k] = importlib.import_module(f"myutils.metadata.{k}").searcher(k) def trysearchforid(gamepath, searchargs: list): @@ -181,8 +164,8 @@ def trysearchfordata(gamepath, arg): try: data = targetmod[key].searchfordata(vid) except: + print_exc() data = {} - infopath = data.get("infopath", None) title = data.get("title", None) namemap = data.get("namemap", None) developers = data.get("developers", []) @@ -194,10 +177,16 @@ def trysearchfordata(gamepath, arg): continue if _ not in savehook_new_data[gamepath]["imagepath_all"]: savehook_new_data[gamepath]["imagepath_all"].append(_) - if title and (not savehook_new_data[gamepath]["istitlesetted"]): - savehook_new_data[gamepath]["title"] = title - if infopath: - savehook_new_data[gamepath]["infopath"] = infopath + if title: + if not savehook_new_data[gamepath]["istitlesetted"]: + savehook_new_data[gamepath]["title"] = title + _vis = globalconfig["metadata"][key]["name"] + _url = targetmod[key].refmainpage(vid) + _urls = [_[1] for _ in savehook_new_data[gamepath]["relationlinks"]] + if _url not in _urls: + savehook_new_data[gamepath]["relationlinks"].append( + (_vis, targetmod[key].refmainpage(vid)) + ) if namemap: savehook_new_data[gamepath]["namemap"] = namemap if len(webtags): @@ -228,9 +217,6 @@ def everymethodsthread(): print_exc() -threading.Thread(target=everymethodsthread).start() - - def gamdidchangedtask(key, idname, gamepath): vid = savehook_new_data[gamepath][idname] if vid == "": @@ -256,8 +242,8 @@ def titlechangedtask(gamepath, title): def checkifnewgame(targetlist, gamepath, title=None): - isnew = gamepath in targetlist - if not isnew: + isnew = gamepath not in targetlist + if isnew: targetlist.insert(0, gamepath) if gamepath not in savehook_new_data: savehook_new_data[gamepath] = getdefaultsavehook(gamepath, title) @@ -368,9 +354,11 @@ class wavmp3player: return durationms -def selectdebugfile(path): - +def selectdebugfile(path: str, ismypost=False): + if ismypost: + path = f"./userconfig/posts/{path}.py" p = os.path.abspath((path)) + os.makedirs(os.path.dirname(p), exist_ok=True) if os.path.exists(p) == False: with open(p, "w", encoding="utf8") as ff: @@ -385,7 +373,7 @@ class TS(basetrans): return content """ ) - elif path == "./userconfig/mypost.py": + elif path == "./userconfig/mypost.py" or ismypost: ff.write( """ def POSTSOLVE(line): @@ -740,3 +728,10 @@ class LRUCache: if not _: self.put(key) return _ + + +for k in globalconfig["metadata"]: + targetmod[k] = importlib.import_module(f"metadata.{k}").searcher(k) + + +threading.Thread(target=everymethodsthread).start() diff --git a/LunaTranslator/LunaTranslator/textsource/texthook.py b/LunaTranslator/LunaTranslator/textsource/texthook.py index 003dcae2..3e77d361 100644 --- a/LunaTranslator/LunaTranslator/textsource/texthook.py +++ b/LunaTranslator/LunaTranslator/textsource/texthook.py @@ -83,6 +83,21 @@ EmbedCallback = CFUNCTYPE(None, c_wchar_p, ThreadParam) class texthook(basetext): + @property + def config(self): + if savehook_new_data[self.pname]["hooksetting_follow_default"]: + return globalconfig + else: + + class __shitdict(dict): + def __getitem__(self, key): + if key in self: + return super().__getitem__(key) + else: + return globalconfig[key] + + return __shitdict(savehook_new_data[self.pname]["hooksetting_private"]) + def __init__( self, pids, hwnd, pname, autostarthookcode=None, needinserthookcode=None ): @@ -90,6 +105,9 @@ class texthook(basetext): autostarthookcode = [] if needinserthookcode is None: needinserthookcode = [] + self.pname = pname + self.pids = pids + self.hwnd = hwnd self.keepref = [] self.newline = Queue() self.newline_delaywait = Queue() @@ -102,15 +120,12 @@ class texthook(basetext): self.selectinghook = None self.selectedhook = [] self.selectedhookidx = [] - self.allow_set_text_name = globalconfig["allow_set_text_name"] + self.allow_set_text_name = self.config["allow_set_text_name"] - self.pids = pids self.connectedpids = [] - self.pname = pname - self.hwnd = hwnd self.runonce_line = "" self.autostarthookcode = [self.deserial(__) for __ in autostarthookcode] - self.isremoveuseless = savehook_new_data[self.pname]["removeuseless"] and len( + self.isremoveuseless = self.config["removeuseless"] and len( self.autostarthookcode ) self.needinserthookcode = needinserthookcode @@ -221,7 +236,7 @@ class texthook(basetext): injectpids = [] for pid in self.pids: - if globalconfig["use_yapi"]: + if self.config["use_yapi"]: self.Luna_Inject(pid, os.path.abspath("./files/plugins/LunaHook")) else: if self.Luna_CreatePipeAndCheck(pid): @@ -347,16 +362,16 @@ class texthook(basetext): def setsettings(self): self.Luna_Settings( - globalconfig["textthreaddelay"], - globalconfig["direct_filterrepeat"], + self.config["textthreaddelay"], + self.config["direct_filterrepeat"], self.codepage(), - globalconfig["maxBufferSize"], - globalconfig["maxHistorySize"], + self.config["maxBufferSize"], + self.config["maxHistorySize"], ) def codepage(self): try: - cpi = savehook_new_data[self.pname]["codepage_index"] + cpi = self.config["codepage_index"] cp = static_data["codepage_real"][cpi] except: cp = 932 @@ -427,7 +442,7 @@ class texthook(basetext): @threader def delaycollectallselectedoutput(self): while True: - time.sleep(globalconfig["textthreaddelay"] / 1000) + time.sleep(self.config["textthreaddelay"] / 1000) if self.newline_delaywait.empty(): continue @@ -444,7 +459,7 @@ class texthook(basetext): def handle_output(self, hc, hn, tp, output): - if globalconfig["filter_chaos_code"] and checkchaos(output): + if self.config["filter_chaos_code"] and checkchaos(output): return False key = (hc, hn.decode("utf8"), tp) diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 9547d102..f345644b 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -38,7 +38,17 @@ "downloadtasks": [], "useproxy": true, "target": "bgmsid", - "idtype": 0 + "idtype": 0, + "args": { + "access-token": "" + } + }, + "fanza": { + "name": "FanzaGames", + "downloadtasks": [], + "useproxy": true, + "target": "fanzaid", + "idtype": 1 } }, "relationlinks": [ @@ -171,8 +181,10 @@ 500, 500 ], + "codepage_index": 0, + "removeuseless": false, "vispolicy": 0, - "currvislistuid" : null, + "currvislistuid": null, "multiregion": false, "rememberocrregions": false, "ocrregions": [], diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index fae70990..3705bf19 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -43,7 +43,6 @@ "越南语(CP1258)": "الفيتنامية ( cp1258 ) .", "游戏失去焦点时窗口隐藏": "لعبة نافذة مخفية عندما يفقد التركيز", "选择游戏": "اختيار اللعبة", - "删除选中行": "حذف صف", "百度": "بايدو .", "東北イタコ/东北伊达子": "شمال شرق イコ / شمال شرق عدن", "琴葉茜": "كين يي تشيان", @@ -626,7 +625,6 @@ "片假名": "كاتاكانا", "罗马音": "نغمة رومانية", "日语注音方案": "نظام صوتي ياباني", - "保存当前游戏的文本处理流程": "حفظ النص الحالي في اللعبة", "使用保存的文本处理流程": "استخدام عملية حفظ النص", "Sakura大模型": "ساكورا غراند موديل", "Magpie路径": "ماغبي تريل", @@ -831,5 +829,8 @@ "显示的项目": "عرض البنود", "首位的": "أولا", "指定的": "محدد", - "设为显示的项目": "عرض البند" + "设为显示的项目": "عرض البند", + "跟随默认": "اتبع التقصير", + "删除行": "حذف صف", + "使用": "إستعمال" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index d153e1ef..5b069f71 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -176,7 +176,6 @@ "記号": "記號", "选择文件": "選擇檔案", "缩放时禁用窗口大小调整": "縮放時禁用視窗大小調整", - "删除选中行": "删除選中行", "图标": "圖標", "指示詞": "訓示詞", "動詞": "動詞", @@ -626,7 +625,6 @@ "片假名": "片假名", "罗马音": "羅馬音", "日语注音方案": "日語注音方案", - "保存当前游戏的文本处理流程": "保存當前遊戲的文字處理流程", "使用保存的文本处理流程": "使用保存的文字處理流程", "Sakura大模型": "Sakura大模型", "Magpie路径": "Magpie路徑", @@ -831,5 +829,8 @@ "显示的项目": "顯示的項目", "首位的": "首位的", "指定的": "指定的", - "设为显示的项目": "設為顯示的項目" + "设为显示的项目": "設為顯示的項目", + "跟随默认": "跟隨默認", + "删除行": "删除行", + "使用": "使用" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 50d946e2..bd2f5244 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -42,7 +42,6 @@ "自动朗读": "Automatic reading", "缩放时禁用窗口大小调整": "Disable window resizing when zooming", "导出sqlite文件为json文件": "Export sqlite file as json file", - "删除选中行": "Delete Selected Row", "图标": "Icon", "游戏失去焦点时窗口隐藏": "The window is hidden when the game loses focus", "指示詞": "Deictic word", @@ -626,7 +625,6 @@ "片假名": "Katakana", "罗马音": "Romanic sound", "日语注音方案": "Japanese phonetic scheme", - "保存当前游戏的文本处理流程": "Save the text processing process for the current game", "使用保存的文本处理流程": "Using a saved text processing process", "Sakura大模型": "Sakura Large Model", "Magpie路径": "Magpie Path", @@ -831,5 +829,8 @@ "显示的项目": "Displayed items", "首位的": "First place", "指定的": "Designated", - "设为显示的项目": "Set as Displayed Project" + "设为显示的项目": "Set as Displayed Project", + "跟随默认": "Follow default", + "删除行": "Delete Rows", + "使用": "apply" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index 71581e24..a79253bf 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -176,7 +176,6 @@ "記号": "Marca", "选择文件": "Seleccionar archivo", "缩放时禁用窗口大小调整": "Desactivar el ajuste de tamaño de la ventana al ampliar", - "删除选中行": "Eliminar la línea seleccionada", "图标": "Iconos", "指示詞": "Instrucción", "動詞": "Verbos", @@ -626,7 +625,6 @@ "片假名": "Seudónimo de película", "罗马音": "Acento Romano", "日语注音方案": "Programa de fonética japonesa", - "保存当前游戏的文本处理流程": "Guardar el proceso de procesamiento de texto del juego actual", "使用保存的文本处理流程": "Usar el proceso de procesamiento de texto guardado", "Sakura大模型": "Gran modelo Sakura", "Magpie路径": "Ruta magpie", @@ -831,5 +829,8 @@ "显示的项目": "Los proyectos mostrados", "首位的": "Primero", "指定的": "Designado", - "设为显示的项目": "Artículos configurados para mostrar" + "设为显示的项目": "Artículos configurados para mostrar", + "跟随默认": "Sigue el predeterminado", + "删除行": "Eliminar filas", + "使用": "Uso" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index af15a245..38099268 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -176,7 +176,6 @@ "記号": "Marque", "选择文件": "Sélectionner un fichier", "缩放时禁用窗口大小调整": "Désactiver le redimensionnement de la fenêtre lors du zoom", - "删除选中行": "Supprimer la ligne sélectionnée", "图标": "Icônes", "指示詞": "Mot indicateur", "動詞": "Verbes", @@ -626,7 +625,6 @@ "片假名": "Nom du film", "罗马音": "Voix romaine", "日语注音方案": "Programme d'accent japonais", - "保存当前游戏的文本处理流程": "Enregistrer le processus de traitement de texte du jeu actuel", "使用保存的文本处理流程": "Utiliser le processus de traitement de texte sauvegardé", "Sakura大模型": "Sakura Grand Modèle", "Magpie路径": "Le chemin Magpie", @@ -831,5 +829,8 @@ "显示的项目": "Projets affichés", "首位的": "La première", "指定的": "Spécifié", - "设为显示的项目": "Les éléments à afficher" + "设为显示的项目": "Les éléments à afficher", + "跟随默认": "Suivre par défaut", + "删除行": "Supprimer une ligne", + "使用": "Utilisation" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index fe36bf8f..bd7e358b 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -170,7 +170,6 @@ "記号": "Simbolo", "选择文件": "Seleziona file", "缩放时禁用窗口大小调整": "Disabilita il ridimensionamento delle finestre durante lo zoom", - "删除选中行": "Elimina righe selezionate", "图标": "icona", "指示詞": "Parole dimostrative", "動詞": "Verbi", @@ -626,7 +625,6 @@ "片假名": "Katakana", "罗马音": "Suono romanico", "日语注音方案": "Schema fonetico giapponese", - "保存当前游戏的文本处理流程": "Salva il processo di elaborazione del testo per il gioco corrente", "使用保存的文本处理流程": "Utilizzo di un processo di elaborazione del testo salvato", "Sakura大模型": "Modello Sakura Large", "Magpie路径": "Percorso magpie", @@ -831,5 +829,8 @@ "显示的项目": "Articoli visualizzati", "首位的": "Primo posto", "指定的": "Designato", - "设为显示的项目": "Imposta come progetto visualizzato" + "设为显示的项目": "Imposta come progetto visualizzato", + "跟随默认": "Segui default", + "删除行": "Elimina righe", + "使用": "applicare" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index a7f3822c..f9458c19 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -176,7 +176,6 @@ "記号": "記号", "选择文件": "ファイルを選択", "缩放时禁用窗口大小调整": "ズーム時にウィンドウのサイズ変更を無効にする", - "删除选中行": "選択した行を削除", "图标": "アイコン", "指示詞": "指示語", "動詞": "動詞", @@ -626,7 +625,6 @@ "片假名": "カタカナ", "罗马音": "ローマ字", "日语注音方案": "日本語の表記方法", - "保存当前游戏的文本处理流程": "現在のゲームを保存するためのテキスト処理の流れ", "使用保存的文本处理流程": "保存されたテキスト処理プロセスの使用", "Sakura大模型": "Sakuraビッグモデル", "Magpie路径": "Magpieパス", @@ -831,5 +829,8 @@ "显示的项目": "表示されるアイテム", "首位的": "トップ", "指定的": "指定された", - "设为显示的项目": "表示する項目として設定" + "设为显示的项目": "表示する項目として設定", + "跟随默认": "デフォルトに従う", + "删除行": "行の削除", + "使用": "使用" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index 49a454a4..4927cb5e 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -176,7 +176,6 @@ "記号": "기호", "选择文件": "파일 선택", "缩放时禁用窗口大小调整": "확대 / 축소 시 창 크기 조정 비활성화", - "删除选中行": "선택한 행 삭제", "图标": "아이콘", "指示詞": "지시어", "動詞": "동사", @@ -626,7 +625,6 @@ "片假名": "가명", "罗马音": "로마음", "日语注音方案": "일본어 주음 방안", - "保存当前游戏的文本处理流程": "현재 게임의 텍스트 처리 프로세스 저장", "使用保存的文本处理流程": "저장된 텍스트 프로세스 사용", "Sakura大模型": "Sakura 대형 모델", "Magpie路径": "Magpie 경로", @@ -831,5 +829,8 @@ "显示的项目": "표시된 항목", "首位的": "수위의", "指定的": "지정된", - "设为显示的项目": "표시할 항목으로 설정" + "设为显示的项目": "표시할 항목으로 설정", + "跟随默认": "기본 따르기", + "删除行": "행 삭제", + "使用": "사용" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index 67b9be96..10bb138c 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -176,7 +176,6 @@ "記号": "Symbol", "选择文件": "Wybierz plik", "缩放时禁用窗口大小调整": "Wyłącz zmianę rozmiaru okna podczas powiększania", - "删除选中行": "Usuń zaznaczone wiersze", "图标": "Ikona", "指示詞": "Słowa demonstracyjne", "動詞": "Czasowniki", @@ -626,7 +625,6 @@ "片假名": "KatakanaName", "罗马音": "Dźwięk romański", "日语注音方案": "Japoński schemat fonetyczny", - "保存当前游戏的文本处理流程": "Zapisz proces przetwarzania tekstu dla bieżącej gry", "使用保存的文本处理流程": "Korzystanie z zapisanego procesu przetwarzania tekstu", "Sakura大模型": "Duży model Sakura", "Magpie路径": "Ścieżka dla Sraków", @@ -831,5 +829,8 @@ "显示的项目": "Wyświetlane elementy", "首位的": "Pierwsze miejsce", "指定的": "Wyznaczone", - "设为显示的项目": "Ustaw jako wyświetlany projekt" + "设为显示的项目": "Ustaw jako wyświetlany projekt", + "跟随默认": "Postępuj zgodnie z domyślnym", + "删除行": "Usuń wiersze", + "使用": "stosować" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index b5aa03eb..ecaf26de 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -176,7 +176,6 @@ "記号": "знак", "选择文件": "Выбор файла", "缩放时禁用窗口大小调整": "Отключить изменение размера окна при масштабировании", - "删除选中行": "Удалить выделенную запись", "图标": "Значки", "指示詞": "указательное слово", "動詞": "глагол", @@ -626,7 +625,6 @@ "片假名": "Фильм под псевдонимом", "罗马音": "Римские согласные", "日语注音方案": "Японская фонетическая программа", - "保存当前游戏的文本处理流程": "Сохранить процесс обработки текста текущей игры", "使用保存的文本处理流程": "Использовать сохраненный процесс обработки текста", "Sakura大模型": "Большая модель Sakura", "Magpie路径": "Путь Magpie", @@ -831,5 +829,8 @@ "显示的项目": "Показать проект", "首位的": "Первый", "指定的": "Назначено", - "设为显示的项目": "Показать проект" + "设为显示的项目": "Показать проект", + "跟随默认": "Следуйте по умолчанию", + "删除行": "Удалить строку", + "使用": "Использование" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index e55b5e72..e1906279 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -21,7 +21,6 @@ "不支持的键位": "คีย์บอร์ดไม่รองรับ", "英语(CP437)": "ภาษาไทย (CP437)", "工具按钮颜色": "สีปุ่มเครื่องมือ", - "删除选中行": "ลบบรรทัดที่เลือก", "模拟按键Enter": "ปุ่มอะนาล็อก Enter", "去除重复行": "ลบแถวที่ซ้ำกัน", "有道": "วิถี", @@ -626,7 +625,6 @@ "片假名": "คาตาคานะ", "罗马音": "เสียงโรมัน", "日语注音方案": "โปรแกรมบันทึกเสียงภาษาญี่ปุ่น", - "保存当前游戏的文本处理流程": "บันทึกกระบวนการประมวลผลข้อความสำหรับเกมปัจจุบัน", "使用保存的文本处理流程": "ใช้กระบวนการประมวลผลข้อความที่บันทึกไว้", "Sakura大模型": "Sakura ใหญ่ แบบ", "Magpie路径": "เส้นทาง Magpie", @@ -831,5 +829,8 @@ "显示的项目": "รายการที่แสดง", "首位的": "อันดับแรก", "指定的": "ระบุ", - "设为显示的项目": "รายการที่ตั้งเป็นจอแสดงผล" + "设为显示的项目": "รายการที่ตั้งเป็นจอแสดงผล", + "跟随默认": "ติดตามค่าเริ่มต้น", + "删除行": "ลบบรรทัด", + "使用": "การใช้" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index 035f7e3f..80e58805 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -176,7 +176,6 @@ "記号": "Simbol", "选择文件": "Dosya Seç", "缩放时禁用窗口大小调整": "Ulaştırırken pencere ölçüsünü değiştirmeyi etkinleştir", - "删除选中行": "Seçili satır sil", "图标": "İşaretçi", "指示詞": "Deixis", "動詞": "Verbs", @@ -626,7 +625,6 @@ "片假名": "KatakanaKCharselect unicode block name", "罗马音": "Romanik sesi", "日语注音方案": "Japon fonetik taslağı", - "保存当前游戏的文本处理流程": "Mektup işleme sürecini şu oyun için kaydet", "使用保存的文本处理流程": "Kaydedilen metin işleme sürecini kullanılıyor", "Sakura大模型": "Sakura Büyük Modeli", "Magpie路径": "Magpie Yolu", @@ -831,5 +829,8 @@ "显示的项目": "Gösterilen öğeler", "首位的": "İlk yer", "指定的": "Tasarlanmış", - "设为显示的项目": "Gösterilen Proje olarak ayarlayın" + "设为显示的项目": "Gösterilen Proje olarak ayarlayın", + "跟随默认": "Öntanımlı takip et", + "删除行": "Satırları Sil", + "使用": "uygulama" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index 2dd9412c..31c3b56e 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -170,7 +170,6 @@ "記号": "Символ", "选择文件": "Виберіть файл", "缩放时禁用窗口大小调整": "Вимкнути зміну розміру вікна під час масштабу", - "删除选中行": "Вилучити вибрані рядки", "图标": "Піктограма", "指示詞": "Демонстративні слова", "動詞": "Дієслова", @@ -626,7 +625,6 @@ "片假名": "Катаканаzambia_ districts. kgm", "罗马音": "Романський звук", "日语注音方案": "Японська фонетична схема", - "保存当前游戏的文本处理流程": "Зберегти процес обробки тексту для поточної гри", "使用保存的文本处理流程": "Використання збереженого процесу обробки тексту", "Sakura大模型": "Великий модель Sakura", "Magpie路径": "Шлях до Magpie", @@ -831,5 +829,8 @@ "显示的项目": "Показані елементи", "首位的": "Перше місце", "指定的": "Визначено", - "设为显示的项目": "Встановити як показаний проект" + "设为显示的项目": "Встановити як показаний проект", + "跟随默认": "Слідувати типово", + "删除行": "Вилучити рядки", + "使用": "застосовувати" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index f2f19fea..f7421db3 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -176,7 +176,6 @@ "記号": "Đánh dấu", "选择文件": "Chọn tập tin", "缩放时禁用窗口大小调整": "Tắt thay đổi kích cỡ cửa sổ khi phóng to", - "删除选中行": "Xoá dòng đã chọn", "图标": "Biểu tượng", "指示詞": "Từ chỉ dẫn", "動詞": "Động từ", @@ -626,7 +625,6 @@ "片假名": "Katakana", "罗马音": "Tiếng La Mã", "日语注音方案": "Chương trình chú thích tiếng Nhật", - "保存当前游戏的文本处理流程": "Lưu luồng xử lý văn bản của trò chơi hiện tại", "使用保存的文本处理流程": "Sử dụng quy trình xử lý văn bản đã lưu", "Sakura大模型": "Sakura Lớn Mô hình", "Magpie路径": "Đường Magpie", @@ -831,5 +829,8 @@ "显示的项目": "Mục hiển thị", "首位的": "Đầu tiên", "指定的": "Đã xác định", - "设为显示的项目": "Mục được đặt làm Hiển thị" + "设为显示的项目": "Mục được đặt làm Hiển thị", + "跟随默认": "Theo mặc định", + "删除行": "Xoá dòng", + "使用": "Sử dụng" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index e1b65a9a..b2d779af 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -21,7 +21,7 @@ "不支持的键位": "", "英语(CP437)": "", "工具按钮颜色": "", - "删除选中行": "", + "删除行": "", "模拟按键Enter": "", "去除重复行": "", "有道": "", @@ -626,7 +626,6 @@ "片假名": "", "罗马音": "", "日语注音方案": "", - "保存当前游戏的文本处理流程": "", "使用保存的文本处理流程": "", "Sakura大模型": "", "Magpie路径": "", @@ -831,5 +830,7 @@ "显示的项目": "", "首位的": "", "指定的": "", - "设为显示的项目": "" + "设为显示的项目": "", + "跟随默认": "", + "使用": "" } \ No newline at end of file diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 2f88422a..b16de82d 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -28,8 +28,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/version) include(generate_product_version) set(VERSION_MAJOR 3) -set(VERSION_MINOR 5) -set(VERSION_PATCH 1) +set(VERSION_MINOR 6) +set(VERSION_PATCH 0) add_library(pch pch.cpp) target_precompile_headers(pch PUBLIC pch.h)