diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index cc1750d5..7bbe6e36 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -464,7 +464,7 @@ class MAINUI: def selectprocess(self, selectedp): self.textsource = None pids, pexe, hwnd = selectedp - checkifnewgame(pexe, windows.GetWindowText(hwnd)) + checkifnewgame(savehook_new_list, pexe, windows.GetWindowText(hwnd)) if globalconfig["sourcestatus2"]["texthook"]["use"]: self.textsource = texthook(pids, hwnd, pexe) diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index acfeef84..9910b9c2 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -1,5 +1,5 @@ from qtsymbols import * -import os, functools +import os, functools, uuid from datetime import datetime, timedelta from traceback import print_exc import windows, gobject, winsharedutils @@ -7,6 +7,7 @@ from myutils.vndb import parsehtmlmethod from myutils.config import ( savehook_new_list, savehook_new_data, + savegametaged, vndbtagdata, _TR, _TRL, @@ -62,7 +63,7 @@ class ItemWidget(QWidget): pass ItemWidget.globallashfocus = None - def mousePressEvent(self, ev) -> None: + def click(self): try: self.bottommask.setStyleSheet( f'background-color: {str2rgba(globalconfig["dialog_savegame_layout"]["onselectcolor"],globalconfig["dialog_savegame_layout"]["transparent"])};' @@ -75,6 +76,9 @@ class ItemWidget(QWidget): except: print_exc() + def mousePressEvent(self, ev) -> None: + self.click() + def focusOut(self): self.bottommask.setStyleSheet("background-color: rgba(255,255,255, 0);") self.focuschanged.emit(False, self.exe) @@ -583,7 +587,6 @@ class dialog_setting_game_internal(QWidget): return savehook_new_list[savehook_new_list.index(self.exepath)] = res savehook_new_data[res] = savehook_new_data[self.exepath] - savehook_new_data.pop(self.exepath) _icon = getExeIcon(res, cache=True) self.setWindowIcon(_icon) @@ -1453,29 +1456,18 @@ def startgamecheck(self, game): startgame(game) -def removegame(game): - try: - idx = savehook_new_list.index(game) - savehook_new_list.pop(idx) - if game in savehook_new_data: - savehook_new_data.pop(game) - except: - print_exc() - - -def addgamesingle(callback): +def addgamesingle(callback, targetlist): f = QFileDialog.getOpenFileName(options=QFileDialog.Option.DontResolveSymlinks) res = f[0] if res == "": return res = os.path.normpath(res) - if res not in savehook_new_list: - checkifnewgame(res) + if checkifnewgame(targetlist, res): callback(res) -def addgamebatch(callback): +def addgamebatch(callback, targetlist): res = QFileDialog.getExistingDirectory( options=QFileDialog.Option.DontResolveSymlinks ) @@ -1486,8 +1478,7 @@ def addgamebatch(callback): path = os.path.normpath(os.path.abspath(os.path.join(_dir, _f))) if path.lower().endswith(".exe") == False: continue - if path not in savehook_new_list: - checkifnewgame(path) + if checkifnewgame(targetlist, path): callback(path) @@ -1497,21 +1488,25 @@ class dialog_savedgame_new(saveposwindow): try: game = self.currentfocuspath idx2 = savehook_new_list.index(game) - removegame(game) - + savehook_new_list.pop(idx2) self.flow.removeidx(idx2) - self.flow.setfocus(idx2) + IMGWidget.clearFocus() + try: + self.flow.widget(idx2).click() + except: + self.flow.widget(0).click() + except: - pass + print_exc() def clicked4(self): opendir(self.currentfocuspath) def clicked3_batch(self): - addgamebatch(lambda res: self.newline(res, True)) + addgamebatch(lambda res: self.newline(res, True), savehook_new_list) def clicked3(self): - addgamesingle(lambda res: self.newline(res, True)) + addgamesingle(lambda res: self.newline(res, True), savehook_new_list) def tagschanged(self, tags): self.currtags = tags @@ -1712,10 +1707,7 @@ class dialog_savedgame_new(saveposwindow): idx1 = savehook_new_list.index(game) idx2 = (idx1 + dx) % len(savehook_new_list) - savehook_new_list[idx1], savehook_new_list[idx2] = ( - savehook_new_list[idx2], - savehook_new_list[idx1], - ) + savehook_new_list.insert(idx2, savehook_new_list.pop(idx1)) self.flow.switchidx(idx1, idx2) def showsettingdialog(self): @@ -1793,7 +1785,9 @@ class dialog_savedgame_lagacy(QDialog): def clicked2(self): try: - removegame(savehook_new_list[self.table.currentIndex().row()]) + + idx = self.table.currentIndex().row() + savehook_new_list.pop(idx) self.model.removeRow(self.table.currentIndex().row()) except: pass @@ -1931,6 +1925,7 @@ class clickitem(QWidget): def resizeEvent(self, a0: QResizeEvent) -> None: self.bottommask.resize(a0.size()) self.maskshowfileexists.resize(a0.size()) + self.bottomline.resize(a0.size()) def __init__(self, exe): super().__init__() @@ -1949,8 +1944,14 @@ class clickitem(QWidget): self.maskshowfileexists.setStyleSheet(f"background-color:{c};") self.bottommask = QLabel(self) self.bottommask.setStyleSheet("background-color: rgba(255,255,255, 0);") + _ = QLabel(self) + _.setStyleSheet( + """background-color: rgba(255,255,255, 0);border-bottom: 1px solid black;""" + ) + self.bottomline = _ + size = 40 _ = QLabel() - _.setFixedSize(QSize(40, 40)) + _.setFixedSize(QSize(size, size)) _.setScaledContents(True) _.setStyleSheet("background-color: rgba(255,255,255, 0);") icon = getExeIcon(exe, icon=False, cache=True) @@ -1959,12 +1960,10 @@ class clickitem(QWidget): self.lay.addWidget(_) _ = QLabel(savehook_new_data[exe]["title"]) _.setWordWrap(True) - _.setFixedHeight(40) + _.setFixedHeight(size + 1) self.lay.addWidget(_) self.setLayout(self.lay) - _.setStyleSheet( - """background-color: rgba(255,255,255, 0);border-bottom: 1px solid black;""" - ) + _.setStyleSheet("""background-color: rgba(255,255,255, 0);""") class pixwrapper(QWidget): @@ -2010,8 +2009,10 @@ class dialog_savedgame_v3(saveposwindow): except: print_exc() - def itemfocuschanged(self, b, k): + def itemfocuschanged(self, reflst, reftagid, b, k): + self.reflst = reflst + self.reftagid = reftagid if b: self.currentfocuspath = k else: @@ -2027,13 +2028,29 @@ class dialog_savedgame_v3(saveposwindow): if self.currentfocuspath: self.viewitem(k) - def newline(self, row, k, select): + def delayitemcreater(self, k, select, reflst, reftagid): + item = clickitem(k) item.doubleclicked.connect(functools.partial(startgamecheck, self)) - item.focuschanged.connect(self.itemfocuschanged) + item.focuschanged.connect( + functools.partial(self.itemfocuschanged, reflst, reftagid) + ) if select: item.click() - self.group0.insertw(row, item) + return item + + def newline(self, row, k, select): + self.stack.w(self.calculatetagidx(self.reftagid)).insertw( + row, + functools.partial( + self.delayitemcreater, + k, + select, + self.reflst, + self.reftagid, + ), + 41, + ) def stack_showmenu(self, p): if not self.currentfocuspath: @@ -2068,17 +2085,18 @@ class dialog_savedgame_v3(saveposwindow): globalconfig["gamemanageruseversion"] = 2 self.setWindowTitle(_TR("游戏管理")) self.currentfocuspath = None + self.reftagid = None + self.reflst = None self.stack = stackedlist() self.stack.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.stack.customContextMenuRequested.connect(self.stack_showmenu) self.stack.setFixedWidth(300) + self.stack.bgclicked.connect(clickitem.clearfocus) w = QWidget() self.setCentralWidget(w) lay = QHBoxLayout() w.setLayout(lay) lay.addWidget(self.stack) - self.group0 = shrinkableitem(QPushButton("GLOBAL")) - self.stack.addw(self.group0) self.righttop = makesubtab_lazy() self.pixview = pixwrapper() _w = QWidget() @@ -2100,8 +2118,8 @@ class dialog_savedgame_v3(saveposwindow): self.simplebutton("打开目录", True, self.clicked4, True) if globalconfig["startgamenototop"]: - self.simplebutton("Up", True, functools.partial(self.moverank, -1), False) - self.simplebutton("Down", True, functools.partial(self.moverank, 1), False) + self.simplebutton("上移", True, functools.partial(self.moverank, -1), False) + self.simplebutton("下移", True, functools.partial(self.moverank, 1), False) self.simplebutton("添加游戏", False, self.clicked3, 1) self.simplebutton("批量添加", False, self.clicked3_batch, 1) self.simplebutton( @@ -2109,24 +2127,132 @@ class dialog_savedgame_v3(saveposwindow): ) self.show() + for i, tag in enumerate(savegametaged): + # None + # { + # "title":xxx + # "games":[] + # } + if tag is None: + title = "GLOBAL" + lst = savehook_new_list + tagid = None + opened = True + else: + lst = tag["games"] + title = tag["title"] + tagid = tag["uid"] + opened = tag.get("opened", True) + group0 = self.createtaglist(title, tagid, opened) + self.stack.insertw(i, group0) + for row, k in enumerate(lst): + if globalconfig["hide_not_exists"]: + if not os.path.exists(k): + continue + group0.insertw( + row, + functools.partial( + self.delayitemcreater, k, i == 0 and row == 0, lst, tagid + ), + 41, + ) - for row, k in enumerate(savehook_new_list): # 2 - if globalconfig["hide_not_exists"]: - if not os.path.exists(k): - continue + def taglistrerank(self, tagid, dx): + idx1 = self.calculatetagidx(tagid) - self.newline(row, k, row == 0) + idx2 = (idx1 + dx) % len(savegametaged) + savegametaged.insert(idx2, savegametaged.pop(idx1)) + self.stack.switchidx(idx1, idx2) + + def calculatetagidx(self, tagid): + i = 0 + for save in savegametaged: + if save is None and tagid is None: + break + elif save and tagid and save["uid"] == tagid: + break + i += 1 + + return i + + def tagbuttonmenu(self, tagid): + self.currentfocuspath = None + self.reftagid = tagid + if tagid is None: + self.reflst = savehook_new_list + else: + self.reflst = savegametaged[self.calculatetagidx(tagid)]["games"] + menu = QMenu(self) + addlist = QAction(_TR("添加列表")) + dellist = QAction(_TR("删除列表")) + Upaction = QAction(_TR("上移")) + Downaction = QAction(_TR("下移")) + addgame = QAction(_TR("添加游戏")) + batchadd = QAction(_TR("批量添加")) + + menu.addAction(Upaction) + menu.addAction(Downaction) + menu.addAction(addlist) + if tagid: + menu.addAction(dellist) + menu.addAction(addgame) + menu.addAction(batchadd) + action = menu.exec(QCursor.pos()) + if action == addgame: + self.clicked3() + elif action == batchadd: + self.clicked3_batch() + elif action == Upaction: + self.taglistrerank(tagid, -1) + elif action == Downaction: + self.taglistrerank(tagid, 1) + elif action == addlist: + _dia = Prompt_dialog( + self, + _TR("添加列表"), + "", + [ + [_TR("名称"), ""], + ], + ) + + if _dia.exec(): + + title = _dia.text[0].text() + if title != "": + i = self.calculatetagidx(tagid) + + tag = { + "title": title, + "games": [], + "uid": str(uuid.uuid4()), + "opened": True, + } + savegametaged.insert(i, tag) + group0 = self.createtaglist(title, tag["uid"], True) + + self.stack.insertw(i, group0) + elif action == dellist: + i = self.calculatetagidx(tagid) + savegametaged.pop(i) + self.stack.popw(i) + + def createtaglist(self, title, tagid, opened): + _btn = QPushButton(title) + _btn.customContextMenuRequested + _btn.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) + + _btn.customContextMenuRequested.connect( + functools.partial(self.tagbuttonmenu, tagid) + ) + return shrinkableitem(_btn, opened) def moverank(self, dx): game = self.currentfocuspath - - idx1 = savehook_new_list.index(game) - idx2 = (idx1 + dx) % len(savehook_new_list) - savehook_new_list[idx1], savehook_new_list[idx2] = ( - savehook_new_list[idx2], - savehook_new_list[idx1], - ) - self.group0.insertw(idx2, self.group0.popw(idx1)) + idx1 = self.reflst.index(game) + idx2 = (idx1 + dx) % len(self.reflst) + self.reflst.insert(idx2, self.reflst.pop(idx1)) + self.stack.w(self.calculatetagidx(self.reftagid)).switchidx(idx1, idx2) def clicked2(self): if not self.currentfocuspath: @@ -2134,22 +2260,26 @@ class dialog_savedgame_v3(saveposwindow): try: game = self.currentfocuspath - idx2 = savehook_new_list.index(game) - self.group0.popw(idx2).deleteLater() - removegame(game) - - self.currentfocuspath = savehook_new_list[idx2] + idx2 = self.reflst.index(game) + group0 = self.stack.w(self.calculatetagidx(self.reftagid)) + group0.popw(idx2) + self.reflst.pop(idx2) + clickitem.clearfocus() + try: + group0.w(idx2).click() + except: + group0.w(0).click() except: - pass + print_exc() def clicked4(self): opendir(self.currentfocuspath) def clicked3_batch(self): - addgamebatch(lambda res: self.newline(res, True, False)) + addgamebatch(lambda res: self.newline(res, True, False), self.reflst) def clicked3(self): - addgamesingle(lambda res: self.newline(0, res, True)) + addgamesingle(lambda res: self.newline(0, res, True), self.reflst) def clicked(self): startgamecheck(self, self.currentfocuspath) diff --git a/LunaTranslator/LunaTranslator/gui/selecthook.py b/LunaTranslator/LunaTranslator/gui/selecthook.py index 465aca8d..92d87265 100644 --- a/LunaTranslator/LunaTranslator/gui/selecthook.py +++ b/LunaTranslator/LunaTranslator/gui/selecthook.py @@ -509,7 +509,7 @@ class hookselect(closeashidewindow): embedw, hlay = getformlayoutw(cls=QHBoxLayout) label = QLabel() hlay.addWidget(label) - label.setStyleSheet("background-color: rgba(255, 255, 255, 0)") + embedw.setStyleSheet("background-color: rgba(255, 255, 255, 0)") checkbtn = QPushButton() checkbtn.setSizePolicy( QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred diff --git a/LunaTranslator/LunaTranslator/gui/specialwidget.py b/LunaTranslator/LunaTranslator/gui/specialwidget.py index 2fd2dec2..d1d44992 100644 --- a/LunaTranslator/LunaTranslator/gui/specialwidget.py +++ b/LunaTranslator/LunaTranslator/gui/specialwidget.py @@ -303,7 +303,7 @@ class FlowLayout(QLayout): return new_height -class lazyscrollflow(QWidget): +class lazyscrollflow(ScrollArea): bgclicked = pyqtSignal() def mousePressEvent(self, _2) -> None: @@ -317,13 +317,11 @@ class lazyscrollflow(QWidget): self._margin = self._spacing # 9 self.lock = threading.Lock() self.internalwid = QWidget(self) - self.qscrollarea = ScrollArea(self) - self.qscrollarea.setWidgetResizable(True) - self.qscrollarea.setWidget(self.internalwid) - self.qscrollarea.scrolled.connect(lambda _: self.doshowlazywidget(True, _)) + self.setWidgetResizable(True) + self.setWidget(self.internalwid) + self.scrolled.connect(lambda _: self.doshowlazywidget(True, _)) def resizeEvent(self, a0: QResizeEvent) -> None: - self.qscrollarea.resize(self.size()) self.resizeandshow(False) return super().resizeEvent(a0) @@ -369,14 +367,8 @@ class lazyscrollflow(QWidget): @trypass def switchidx(self, idx1, idx2): with self.lock: - self.widgets[idx1], self.widgets[idx2] = ( - self.widgets[idx2], - self.widgets[idx1], - ) - self.fakegeos[idx1], self.fakegeos[idx2] = ( - self.fakegeos[idx2], - self.fakegeos[idx1], - ) + self.widgets.insert(idx2, self.widgets.pop(idx1)) + self.fakegeos.insert(idx2, self.fakegeos.pop(idx1)) self.resizeandshow() @trypass @@ -388,11 +380,6 @@ class lazyscrollflow(QWidget): idx = len(self.widgets) self.widgets.insert(idx, widfunc) self.fakegeos.insert(idx, QRect()) - - if isinstance(widfunc, QWidget): - widfunc.setParent(self.internalwid) - widfunc.adjustSize() - widfunc.setVisible(True) if refresh: self.resizeandshow() @@ -401,8 +388,9 @@ class lazyscrollflow(QWidget): with self.lock: if idx >= 0 and idx < len(self.widgets): w = self.widgets[idx] - w.setParent(None) - w.deleteLater() + if isinstance(w, QWidget): + w.setParent(None) + w.deleteLater() self.widgets.pop(idx) self.fakegeos.pop(idx) self.resizeandshow() @@ -423,8 +411,8 @@ class lazyscrollflow(QWidget): return self._spacing def fakeresize(self): - if self.qscrollarea.verticalScrollBar().isVisible(): - scrollw = self.qscrollarea.verticalScrollBar().width() + if self.verticalScrollBar().isVisible(): + scrollw = self.verticalScrollBar().width() else: scrollw = 0 with self.lock: @@ -465,32 +453,114 @@ class lazyscrollflow(QWidget): return new_height -class simplelistw(QWidget): +def has_intersection(range1, range2): + A1, B1 = range1 + C1, D1 = range2 + + return A1 <= C1 <= B1 or A1 <= D1 <= B1 or C1 <= A1 <= D1 or C1 <= B1 <= D1 + + +class delayloadvbox(QWidget): def __init__(self): super().__init__() - self.lay = QVBoxLayout() - self.lay.setContentsMargins(0, 0, 0, 0) - self.lay.setSpacing(0) - self.setLayout(self.lay) + self.internal_itemH = [] + self.internal_widgets = [] + self.lock = threading.Lock() + self.nowvisregion = QRect() - def addw(self, w): - self.lay.addWidget(w) + def resizeEvent(self, e: QResizeEvent): + if e.oldSize().width() != e.size().width(): + with self.lock: + for w in self.internal_widgets: + if isinstance(w, QWidget): + w.resize(self.width(), w.height()) - def insertw(self, i, w): - self.lay.insertWidget(i, w) + def _dovisinternal(self, procevent, region: QRect): + if region.isEmpty(): + return + visrange = (region.y(), region.y() + region.height()) + ylastend = self.y() + ydiff = self.y() + needdos = [] + with self.lock: + for i, h in enumerate(self.internal_itemH): + ystart = ylastend + yend = ystart + h + ylastend = yend + if isinstance(self.internal_widgets[i], QWidget): + self.internal_widgets[i].move(0, ystart - ydiff) + continue + + if not has_intersection((ystart, yend), visrange): + continue + + widfunc = self.internal_widgets[i] + if not widfunc: + continue + self.internal_widgets[i] = None + needdos.append((i, widfunc, ystart - ydiff, h)) + for i, widfunc, ystart, h in needdos: + try: + with self.lock: + widfunc = widfunc() + widfunc.setParent(self) + widfunc.setVisible(True) + widfunc.move(0, ystart) + widfunc.resize(self.width(), h) + self.internal_widgets[i] = widfunc + if procevent: + QApplication.processEvents() + except: + print_exc() + + self.nowvisregion = region + + @trypass + def switchidx(self, idx1, idx2): + with self.lock: + self.internal_widgets.insert(idx2, self.internal_widgets.pop(idx1)) + self.internal_itemH.insert(idx2, self.internal_itemH.pop(idx1)) + self._dovisinternal(False, self.nowvisregion) def popw(self, i): - return self.lay.takeAt(i).widget() + with self.lock: + if i >= 0 and i < self.len(): + w = self.internal_widgets[i] + if isinstance(w, QWidget): + w.setParent(None) + w.deleteLater() + self.internal_widgets.pop(i) + self.internal_itemH.pop(i) + self.setFixedHeight(sum(self.internal_itemH)) + + self._dovisinternal(False, self.nowvisregion) + + def insertw(self, i, wf, height): + refresh = True + with self.lock: + if i == -1: + refresh = False + i = self.len() + self.internal_itemH.insert(i, height) + self.internal_widgets.insert(i, wf) + + self.setFixedHeight(sum(self.internal_itemH)) + + if refresh: + self._dovisinternal(False, self.nowvisregion) def w(self, i): - return self.lay.itemAt(i).widget() + _ = self.internal_widgets[i] + if isinstance(_, QWidget): + return _ + return None def len(self): - return self.lay.count() + return len(self.internal_widgets) class shrinkableitem(QWidget): - def __init__(self, shrinker: QPushButton): + def __init__(self, shrinker: QPushButton, opened): super().__init__() self.lay = QVBoxLayout() # self.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Fixed) @@ -498,25 +568,24 @@ class shrinkableitem(QWidget): self.lay.setContentsMargins(0, 0, 0, 0) self.lay.setSpacing(0) self.btn = shrinker - self.items = simplelistw() + self.items = delayloadvbox() self.btn.clicked.connect(self.Revert) self.lay.addWidget(self.btn) self.lay.addWidget(self.items) + self.items.setVisible(opened) + + def _dovisinternal(self, procevent, region: QRect): + self.items._dovisinternal(procevent, region) def Revert(self): self.items.setVisible(not self.items.isVisible()) - def Show(self): - self.items.show() + @trypass + def switchidx(self, idx1, idx2): + self.items.switchidx(idx1, idx2) - def Hide(self): - self.items.hide() - - def addw(self, w): - self.items.addw(w) - - def insertw(self, i, w): - self.items.insertw(i, w) + def insertw(self, i, wf, height): + self.items.insertw(i, wf, height) def popw(self, i): return self.items.popw(i) @@ -528,7 +597,16 @@ class shrinkableitem(QWidget): return self.items.len() -class stackedlist(QScrollArea): +class stackedlist(ScrollArea): + bgclicked = pyqtSignal() + + def mousePressEvent(self, _2) -> None: + self.bgclicked.emit() + + @trypass + def resizeEvent(self, e: QResizeEvent): + self.doshowlazywidget(False, self.internal.visibleRegion().rects()[0]) + def __init__(self): super().__init__() self.setStyleSheet("""QScrollArea{background-color:transparent;border:0px}""") @@ -540,19 +618,31 @@ class stackedlist(QScrollArea): self.lay.setSpacing(0) self.lay.setContentsMargins(0, 0, 0, 0) internal.setLayout(self.lay) + self.widgets = [] + self.fakegeos = [] + self._spacing = 6 + self._margin = self._spacing # 9 + self.lock = threading.Lock() + self.setWidgetResizable(True) + self.setWidget(internal) self.internal = internal + self.scrolled.connect(lambda _: self.doshowlazywidget(True, _)) - def addw(self, w): - self.lay.addWidget(w) + def doshowlazywidget(self, procevent, region: QRect): + for i in range(self.len()): + self.w(i)._dovisinternal(procevent, region) - def insertw(self, i, w): + def insertw(self, i, w: shrinkableitem): self.lay.insertWidget(i, w) - def popw(self, i): - return self.lay.takeAt(i).widget() + def popw(self, i) -> shrinkableitem: + self.lay.takeAt(i).widget().deleteLater() - def w(self, i): + def w(self, i) -> shrinkableitem: return self.lay.itemAt(i).widget() def len(self): return self.lay.count() + + def switchidx(self, i1, i2): + self.lay.insertItem(i2, self.lay.takeAt(i1)) diff --git a/LunaTranslator/LunaTranslator/hiraparse/mecab.py b/LunaTranslator/LunaTranslator/hiraparse/mecab.py index d7cb657e..8e275a94 100644 --- a/LunaTranslator/LunaTranslator/hiraparse/mecab.py +++ b/LunaTranslator/LunaTranslator/hiraparse/mecab.py @@ -38,6 +38,7 @@ class mecab(basehira): for node, fields in self.kks.parse( text, codec ): # self.kks.parseToNodeList(text): + print(fields) kana = "" origorig = "" pos1 = fields[0] @@ -53,9 +54,10 @@ class mecab(basehira): elif len(fields) == 9: kana = fields[8] origorig = fields[7] - + elif len(fields) == 6: # 英文 + kana = origorig = node l = 0 - + while str(node) not in text[start : start + l]: l += 1 orig = text[start : start + l] @@ -77,9 +79,10 @@ class mecab(basehira): result.append( {"orig": orig, "hira": hira, "cixing": pos1, "origorig": origorig} ) - extras=text[start :] + extras = text[start:] if len(extras): result.append( - {"orig": extras, "hira": extras, "cixing": '', "origorig": extras} + {"orig": extras, "hira": extras, "cixing": "", "origorig": extras} ) + print(result) return result diff --git a/LunaTranslator/LunaTranslator/myutils/config.py b/LunaTranslator/LunaTranslator/myutils/config.py index 786cc931..6648ecc1 100644 --- a/LunaTranslator/LunaTranslator/myutils/config.py +++ b/LunaTranslator/LunaTranslator/myutils/config.py @@ -49,6 +49,11 @@ except: savehook_new_list = [] savehook_new_data = {} +try: + savegametaged = _savehook[2] +except: + savegametaged = [None] + translatorsetting = tryreadconfig("translatorsetting.json") ocrsetting = tryreadconfig("ocrsetting.json") @@ -338,7 +343,8 @@ def saveallconfig(): safesave("./userconfig/ocrsetting.json", ocrsetting) safesave("./userconfig/vndbtagdata.json", vndbtagdata) safesave( - "./userconfig/savehook_new_1.39.4.json", [savehook_new_list, savehook_new_data] + "./userconfig/savehook_new_1.39.4.json", + [savehook_new_list, savehook_new_data, savegametaged], ) safesave( "./files/lang/{}.json".format(getlanguse()), diff --git a/LunaTranslator/LunaTranslator/myutils/utils.py b/LunaTranslator/LunaTranslator/myutils/utils.py index 4e8ecd0c..ac20c6e4 100644 --- a/LunaTranslator/LunaTranslator/myutils/utils.py +++ b/LunaTranslator/LunaTranslator/myutils/utils.py @@ -196,13 +196,15 @@ def imgchangedtask(gamepath, res): savehook_new_data[gamepath]["isimagepathusersetted"] = True -def checkifnewgame(gamepath, title=None): - if gamepath not in savehook_new_list: - savehook_new_list.insert(0, gamepath) +def checkifnewgame(targetlist, gamepath, title=None): + if gamepath in targetlist: + return False + targetlist.insert(0, gamepath) + if gamepath not in savehook_new_data: savehook_new_data[gamepath] = getdefaultsavehook(gamepath, title) searchvndbqueue.put((2, gamepath, None)) - + return True kanjichs2ja = str.maketrans(static_data["kanjichs2ja"]) diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index 18ce6597..62c7efa4 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -810,5 +810,9 @@ "不显示时间": "لا وقت العرض", "过滤历史重复": "تصفية التاريخ تكرار", "缓存条数": "عدد شرائط التخزين المؤقت", - "腾讯OCR": "تينسنت التعرف الضوئي على الحروف" + "腾讯OCR": "تينسنت التعرف الضوئي على الحروف", + "添加列表": "إضافة قائمة", + "删除列表": "حذف قائمة", + "上移": "رفع", + "下移": "نزولا" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index 99882428..90adcb80 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -810,5 +810,9 @@ "不显示时间": "不顯示時間", "过滤历史重复": "過濾歷史重複", "缓存条数": "緩存條數", - "腾讯OCR": "騰訊OCR" + "腾讯OCR": "騰訊OCR", + "添加列表": "添加清單", + "删除列表": "删除清單", + "上移": "上移", + "下移": "下移" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 61fac263..a352a52b 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -810,5 +810,9 @@ "不显示时间": "Do not display time", "过滤历史重复": "Filter historical duplicates", "缓存条数": "Number of cache entries", - "腾讯OCR": "Tencent OCR" + "腾讯OCR": "Tencent OCR", + "添加列表": "Add List", + "删除列表": "Delete List", + "上移": "Move Up", + "下移": "Move Down" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index af514181..e19901c7 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -810,5 +810,9 @@ "不显示时间": "No muestra el tiempo", "过滤历史重复": "Filtrar repetición histórica", "缓存条数": "Número de barras de caché", - "腾讯OCR": "Tencent OCR" + "腾讯OCR": "Tencent OCR", + "添加列表": "Añadir lista", + "删除列表": "Eliminar lista", + "上移": "Subir", + "下移": "Bajar" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index e844230b..71972a36 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -810,5 +810,9 @@ "不显示时间": "Ne pas afficher l'heure", "过滤历史重复": "Filtrer historique répétition", "缓存条数": "Nombre de barres de cache", - "腾讯OCR": "OCR Tencent" + "腾讯OCR": "OCR Tencent", + "添加列表": "Ajouter une liste", + "删除列表": "Supprimer une liste", + "上移": "Déplacement vers le Haut", + "下移": "Descendre" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index c47433c5..86053b37 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -810,5 +810,9 @@ "不显示时间": "Non visualizzare l'ora", "过滤历史重复": "Filtra duplicati storici", "缓存条数": "Numero di voci della cache", - "腾讯OCR": "Tencent OCR" + "腾讯OCR": "Tencent OCR", + "添加列表": "Aggiungi elenco", + "删除列表": "Elimina elenco", + "上移": "Sposta su", + "下移": "Sposta giù" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index 27cf5931..3201194a 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -810,5 +810,9 @@ "不显示时间": "時間を表示しない", "过滤历史重复": "フィルタ履歴の繰り返し", "缓存条数": "キャッシュ・エントリ数", - "腾讯OCR": "テンセントOCR" + "腾讯OCR": "テンセントOCR", + "添加列表": "リストの追加", + "删除列表": "リストの削除", + "上移": "上へ移動", + "下移": "下へ移動" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index 9dc5d284..4c4c7df4 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -810,5 +810,9 @@ "不显示时间": "시간 표시 안 함", "过滤历史重复": "반복된 기록 필터링", "缓存条数": "캐시 바 수", - "腾讯OCR": "텐센트 OCR" + "腾讯OCR": "텐센트 OCR", + "添加列表": "목록 추가", + "删除列表": "목록 삭제", + "上移": "위로 이동", + "下移": "아래로 이동" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index 17d526da..f76e6a46 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -810,5 +810,9 @@ "不显示时间": "Nie wyświetlaj czasu", "过滤历史重复": "Filtruj duplikaty historyczne", "缓存条数": "Liczba wpisów pamięci podręcznej", - "腾讯OCR": "Dziesięć OCR" + "腾讯OCR": "Dziesięć OCR", + "添加列表": "Dodaj listę", + "删除列表": "Usuń listę", + "上移": "Przesuń się w górę", + "下移": "Przesuń w dół" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index c411ab15..b4cdc039 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -810,5 +810,9 @@ "不显示时间": "Не показывать время", "过滤历史重复": "Фильтровать повторение истории", "缓存条数": "Количество кэшированных записей", - "腾讯OCR": "Скачать OCR" + "腾讯OCR": "Скачать OCR", + "添加列表": "Добавить список", + "删除列表": "Удалить список", + "上移": "Переместить вверх", + "下移": "Переместить вниз" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index 1d634299..2a55c024 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -810,5 +810,9 @@ "不显示时间": "ไม่แสดงเวลา", "过滤历史重复": "ประวัติการกรอง ทำซ้ำ", "缓存条数": "จำนวนแถบแคช", - "腾讯OCR": "Tencent โอซีอาร์" + "腾讯OCR": "Tencent โอซีอาร์", + "添加列表": "เพิ่มรายการ", + "删除列表": "ลบรายการ", + "上移": "เลื่อนขึ้น", + "下移": "เลื่อนลง" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index f8577ec3..c012c257 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -810,5 +810,9 @@ "不显示时间": "Zamanı gösterme", "过滤历史重复": "Tarihi çizgileri sil", "缓存条数": "Cache girişlerinin sayısı", - "腾讯OCR": "Tencent OCR" + "腾讯OCR": "Tencent OCR", + "添加列表": "Liste Ekle", + "删除列表": "Listeyi sil", + "上移": "Yukarı Taşı", + "下移": "Aşağı taşın" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index c7c8b233..c9bc0357 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -810,5 +810,9 @@ "不显示时间": "Не показувати час", "过滤历史重复": "Фільтрувати історичні дублікати", "缓存条数": "Кількість записів кешу", - "腾讯OCR": "Похильний OCR" + "腾讯OCR": "Похильний OCR", + "添加列表": "Додати список", + "删除列表": "Вилучити список", + "上移": "Пересунути вгору", + "下移": "Пересунути вниз" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index 715d8385..6237a86b 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -810,5 +810,9 @@ "不显示时间": "Không hiển thị thời gian", "过滤历史重复": "Lọc lịch sử lặp lại", "缓存条数": "Số thanh bộ nhớ cache", - "腾讯OCR": "Thông tin OCR" + "腾讯OCR": "Thông tin OCR", + "添加列表": "Thêm danh sách", + "删除列表": "Xoá danh sách", + "上移": "Di chuyển lên", + "下移": "Di chuyển xuống" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index a925496d..861c6e0b 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -810,5 +810,9 @@ "不显示时间": "", "过滤历史重复": "", "缓存条数": "", - "腾讯OCR": "" + "腾讯OCR": "", + "添加列表": "", + "删除列表": "", + "上移": "", + "下移": "" } \ No newline at end of file