This commit is contained in:
恍兮惚兮 2024-06-02 15:39:47 +08:00
parent abef0a1e25
commit f3e6f2836b
22 changed files with 435 additions and 144 deletions

View File

@ -464,7 +464,7 @@ class MAINUI:
def selectprocess(self, selectedp): def selectprocess(self, selectedp):
self.textsource = None self.textsource = None
pids, pexe, hwnd = selectedp pids, pexe, hwnd = selectedp
checkifnewgame(pexe, windows.GetWindowText(hwnd)) checkifnewgame(savehook_new_list, pexe, windows.GetWindowText(hwnd))
if globalconfig["sourcestatus2"]["texthook"]["use"]: if globalconfig["sourcestatus2"]["texthook"]["use"]:
self.textsource = texthook(pids, hwnd, pexe) self.textsource = texthook(pids, hwnd, pexe)

View File

@ -1,5 +1,5 @@
from qtsymbols import * from qtsymbols import *
import os, functools import os, functools, uuid
from datetime import datetime, timedelta from datetime import datetime, timedelta
from traceback import print_exc from traceback import print_exc
import windows, gobject, winsharedutils import windows, gobject, winsharedutils
@ -7,6 +7,7 @@ from myutils.vndb import parsehtmlmethod
from myutils.config import ( from myutils.config import (
savehook_new_list, savehook_new_list,
savehook_new_data, savehook_new_data,
savegametaged,
vndbtagdata, vndbtagdata,
_TR, _TR,
_TRL, _TRL,
@ -62,7 +63,7 @@ class ItemWidget(QWidget):
pass pass
ItemWidget.globallashfocus = None ItemWidget.globallashfocus = None
def mousePressEvent(self, ev) -> None: def click(self):
try: try:
self.bottommask.setStyleSheet( self.bottommask.setStyleSheet(
f'background-color: {str2rgba(globalconfig["dialog_savegame_layout"]["onselectcolor"],globalconfig["dialog_savegame_layout"]["transparent"])};' f'background-color: {str2rgba(globalconfig["dialog_savegame_layout"]["onselectcolor"],globalconfig["dialog_savegame_layout"]["transparent"])};'
@ -75,6 +76,9 @@ class ItemWidget(QWidget):
except: except:
print_exc() print_exc()
def mousePressEvent(self, ev) -> None:
self.click()
def focusOut(self): def focusOut(self):
self.bottommask.setStyleSheet("background-color: rgba(255,255,255, 0);") self.bottommask.setStyleSheet("background-color: rgba(255,255,255, 0);")
self.focuschanged.emit(False, self.exe) self.focuschanged.emit(False, self.exe)
@ -583,7 +587,6 @@ class dialog_setting_game_internal(QWidget):
return return
savehook_new_list[savehook_new_list.index(self.exepath)] = res savehook_new_list[savehook_new_list.index(self.exepath)] = res
savehook_new_data[res] = savehook_new_data[self.exepath] savehook_new_data[res] = savehook_new_data[self.exepath]
savehook_new_data.pop(self.exepath)
_icon = getExeIcon(res, cache=True) _icon = getExeIcon(res, cache=True)
self.setWindowIcon(_icon) self.setWindowIcon(_icon)
@ -1453,29 +1456,18 @@ def startgamecheck(self, game):
startgame(game) startgame(game)
def removegame(game): def addgamesingle(callback, targetlist):
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):
f = QFileDialog.getOpenFileName(options=QFileDialog.Option.DontResolveSymlinks) f = QFileDialog.getOpenFileName(options=QFileDialog.Option.DontResolveSymlinks)
res = f[0] res = f[0]
if res == "": if res == "":
return return
res = os.path.normpath(res) res = os.path.normpath(res)
if res not in savehook_new_list: if checkifnewgame(targetlist, res):
checkifnewgame(res)
callback(res) callback(res)
def addgamebatch(callback): def addgamebatch(callback, targetlist):
res = QFileDialog.getExistingDirectory( res = QFileDialog.getExistingDirectory(
options=QFileDialog.Option.DontResolveSymlinks options=QFileDialog.Option.DontResolveSymlinks
) )
@ -1486,8 +1478,7 @@ def addgamebatch(callback):
path = os.path.normpath(os.path.abspath(os.path.join(_dir, _f))) path = os.path.normpath(os.path.abspath(os.path.join(_dir, _f)))
if path.lower().endswith(".exe") == False: if path.lower().endswith(".exe") == False:
continue continue
if path not in savehook_new_list: if checkifnewgame(targetlist, path):
checkifnewgame(path)
callback(path) callback(path)
@ -1497,21 +1488,25 @@ class dialog_savedgame_new(saveposwindow):
try: try:
game = self.currentfocuspath game = self.currentfocuspath
idx2 = savehook_new_list.index(game) idx2 = savehook_new_list.index(game)
removegame(game) savehook_new_list.pop(idx2)
self.flow.removeidx(idx2) self.flow.removeidx(idx2)
self.flow.setfocus(idx2) IMGWidget.clearFocus()
try:
self.flow.widget(idx2).click()
except:
self.flow.widget(0).click()
except: except:
pass print_exc()
def clicked4(self): def clicked4(self):
opendir(self.currentfocuspath) opendir(self.currentfocuspath)
def clicked3_batch(self): def clicked3_batch(self):
addgamebatch(lambda res: self.newline(res, True)) addgamebatch(lambda res: self.newline(res, True), savehook_new_list)
def clicked3(self): def clicked3(self):
addgamesingle(lambda res: self.newline(res, True)) addgamesingle(lambda res: self.newline(res, True), savehook_new_list)
def tagschanged(self, tags): def tagschanged(self, tags):
self.currtags = tags self.currtags = tags
@ -1712,10 +1707,7 @@ class dialog_savedgame_new(saveposwindow):
idx1 = savehook_new_list.index(game) idx1 = savehook_new_list.index(game)
idx2 = (idx1 + dx) % len(savehook_new_list) idx2 = (idx1 + dx) % len(savehook_new_list)
savehook_new_list[idx1], savehook_new_list[idx2] = ( savehook_new_list.insert(idx2, savehook_new_list.pop(idx1))
savehook_new_list[idx2],
savehook_new_list[idx1],
)
self.flow.switchidx(idx1, idx2) self.flow.switchidx(idx1, idx2)
def showsettingdialog(self): def showsettingdialog(self):
@ -1793,7 +1785,9 @@ class dialog_savedgame_lagacy(QDialog):
def clicked2(self): def clicked2(self):
try: 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()) self.model.removeRow(self.table.currentIndex().row())
except: except:
pass pass
@ -1931,6 +1925,7 @@ class clickitem(QWidget):
def resizeEvent(self, a0: QResizeEvent) -> None: def resizeEvent(self, a0: QResizeEvent) -> None:
self.bottommask.resize(a0.size()) self.bottommask.resize(a0.size())
self.maskshowfileexists.resize(a0.size()) self.maskshowfileexists.resize(a0.size())
self.bottomline.resize(a0.size())
def __init__(self, exe): def __init__(self, exe):
super().__init__() super().__init__()
@ -1949,8 +1944,14 @@ class clickitem(QWidget):
self.maskshowfileexists.setStyleSheet(f"background-color:{c};") self.maskshowfileexists.setStyleSheet(f"background-color:{c};")
self.bottommask = QLabel(self) self.bottommask = QLabel(self)
self.bottommask.setStyleSheet("background-color: rgba(255,255,255, 0);") 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() _ = QLabel()
_.setFixedSize(QSize(40, 40)) _.setFixedSize(QSize(size, size))
_.setScaledContents(True) _.setScaledContents(True)
_.setStyleSheet("background-color: rgba(255,255,255, 0);") _.setStyleSheet("background-color: rgba(255,255,255, 0);")
icon = getExeIcon(exe, icon=False, cache=True) icon = getExeIcon(exe, icon=False, cache=True)
@ -1959,12 +1960,10 @@ class clickitem(QWidget):
self.lay.addWidget(_) self.lay.addWidget(_)
_ = QLabel(savehook_new_data[exe]["title"]) _ = QLabel(savehook_new_data[exe]["title"])
_.setWordWrap(True) _.setWordWrap(True)
_.setFixedHeight(40) _.setFixedHeight(size + 1)
self.lay.addWidget(_) self.lay.addWidget(_)
self.setLayout(self.lay) self.setLayout(self.lay)
_.setStyleSheet( _.setStyleSheet("""background-color: rgba(255,255,255, 0);""")
"""background-color: rgba(255,255,255, 0);border-bottom: 1px solid black;"""
)
class pixwrapper(QWidget): class pixwrapper(QWidget):
@ -2010,8 +2009,10 @@ class dialog_savedgame_v3(saveposwindow):
except: except:
print_exc() print_exc()
def itemfocuschanged(self, b, k): def itemfocuschanged(self, reflst, reftagid, b, k):
self.reflst = reflst
self.reftagid = reftagid
if b: if b:
self.currentfocuspath = k self.currentfocuspath = k
else: else:
@ -2027,13 +2028,29 @@ class dialog_savedgame_v3(saveposwindow):
if self.currentfocuspath: if self.currentfocuspath:
self.viewitem(k) self.viewitem(k)
def newline(self, row, k, select): def delayitemcreater(self, k, select, reflst, reftagid):
item = clickitem(k) item = clickitem(k)
item.doubleclicked.connect(functools.partial(startgamecheck, self)) item.doubleclicked.connect(functools.partial(startgamecheck, self))
item.focuschanged.connect(self.itemfocuschanged) item.focuschanged.connect(
functools.partial(self.itemfocuschanged, reflst, reftagid)
)
if select: if select:
item.click() 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): def stack_showmenu(self, p):
if not self.currentfocuspath: if not self.currentfocuspath:
@ -2068,17 +2085,18 @@ class dialog_savedgame_v3(saveposwindow):
globalconfig["gamemanageruseversion"] = 2 globalconfig["gamemanageruseversion"] = 2
self.setWindowTitle(_TR("游戏管理")) self.setWindowTitle(_TR("游戏管理"))
self.currentfocuspath = None self.currentfocuspath = None
self.reftagid = None
self.reflst = None
self.stack = stackedlist() self.stack = stackedlist()
self.stack.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.stack.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.stack.customContextMenuRequested.connect(self.stack_showmenu) self.stack.customContextMenuRequested.connect(self.stack_showmenu)
self.stack.setFixedWidth(300) self.stack.setFixedWidth(300)
self.stack.bgclicked.connect(clickitem.clearfocus)
w = QWidget() w = QWidget()
self.setCentralWidget(w) self.setCentralWidget(w)
lay = QHBoxLayout() lay = QHBoxLayout()
w.setLayout(lay) w.setLayout(lay)
lay.addWidget(self.stack) lay.addWidget(self.stack)
self.group0 = shrinkableitem(QPushButton("GLOBAL"))
self.stack.addw(self.group0)
self.righttop = makesubtab_lazy() self.righttop = makesubtab_lazy()
self.pixview = pixwrapper() self.pixview = pixwrapper()
_w = QWidget() _w = QWidget()
@ -2100,8 +2118,8 @@ class dialog_savedgame_v3(saveposwindow):
self.simplebutton("打开目录", True, self.clicked4, True) self.simplebutton("打开目录", True, self.clicked4, True)
if globalconfig["startgamenototop"]: if globalconfig["startgamenototop"]:
self.simplebutton("Up", True, functools.partial(self.moverank, -1), False) self.simplebutton("上移", 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("添加游戏", False, self.clicked3, 1) self.simplebutton("添加游戏", False, self.clicked3, 1)
self.simplebutton("批量添加", False, self.clicked3_batch, 1) self.simplebutton("批量添加", False, self.clicked3_batch, 1)
self.simplebutton( self.simplebutton(
@ -2109,24 +2127,132 @@ class dialog_savedgame_v3(saveposwindow):
) )
self.show() 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 def taglistrerank(self, tagid, dx):
if globalconfig["hide_not_exists"]: idx1 = self.calculatetagidx(tagid)
if not os.path.exists(k):
continue
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): def moverank(self, dx):
game = self.currentfocuspath game = self.currentfocuspath
idx1 = self.reflst.index(game)
idx1 = savehook_new_list.index(game) idx2 = (idx1 + dx) % len(self.reflst)
idx2 = (idx1 + dx) % len(savehook_new_list) self.reflst.insert(idx2, self.reflst.pop(idx1))
savehook_new_list[idx1], savehook_new_list[idx2] = ( self.stack.w(self.calculatetagidx(self.reftagid)).switchidx(idx1, idx2)
savehook_new_list[idx2],
savehook_new_list[idx1],
)
self.group0.insertw(idx2, self.group0.popw(idx1))
def clicked2(self): def clicked2(self):
if not self.currentfocuspath: if not self.currentfocuspath:
@ -2134,22 +2260,26 @@ class dialog_savedgame_v3(saveposwindow):
try: try:
game = self.currentfocuspath game = self.currentfocuspath
idx2 = savehook_new_list.index(game) idx2 = self.reflst.index(game)
self.group0.popw(idx2).deleteLater() group0 = self.stack.w(self.calculatetagidx(self.reftagid))
removegame(game) group0.popw(idx2)
self.reflst.pop(idx2)
self.currentfocuspath = savehook_new_list[idx2] clickitem.clearfocus()
try:
group0.w(idx2).click()
except:
group0.w(0).click()
except: except:
pass print_exc()
def clicked4(self): def clicked4(self):
opendir(self.currentfocuspath) opendir(self.currentfocuspath)
def clicked3_batch(self): 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): def clicked3(self):
addgamesingle(lambda res: self.newline(0, res, True)) addgamesingle(lambda res: self.newline(0, res, True), self.reflst)
def clicked(self): def clicked(self):
startgamecheck(self, self.currentfocuspath) startgamecheck(self, self.currentfocuspath)

View File

@ -509,7 +509,7 @@ class hookselect(closeashidewindow):
embedw, hlay = getformlayoutw(cls=QHBoxLayout) embedw, hlay = getformlayoutw(cls=QHBoxLayout)
label = QLabel() label = QLabel()
hlay.addWidget(label) hlay.addWidget(label)
label.setStyleSheet("background-color: rgba(255, 255, 255, 0)") embedw.setStyleSheet("background-color: rgba(255, 255, 255, 0)")
checkbtn = QPushButton() checkbtn = QPushButton()
checkbtn.setSizePolicy( checkbtn.setSizePolicy(
QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Preferred

View File

@ -303,7 +303,7 @@ class FlowLayout(QLayout):
return new_height return new_height
class lazyscrollflow(QWidget): class lazyscrollflow(ScrollArea):
bgclicked = pyqtSignal() bgclicked = pyqtSignal()
def mousePressEvent(self, _2) -> None: def mousePressEvent(self, _2) -> None:
@ -317,13 +317,11 @@ class lazyscrollflow(QWidget):
self._margin = self._spacing # 9 self._margin = self._spacing # 9
self.lock = threading.Lock() self.lock = threading.Lock()
self.internalwid = QWidget(self) self.internalwid = QWidget(self)
self.qscrollarea = ScrollArea(self) self.setWidgetResizable(True)
self.qscrollarea.setWidgetResizable(True) self.setWidget(self.internalwid)
self.qscrollarea.setWidget(self.internalwid) self.scrolled.connect(lambda _: self.doshowlazywidget(True, _))
self.qscrollarea.scrolled.connect(lambda _: self.doshowlazywidget(True, _))
def resizeEvent(self, a0: QResizeEvent) -> None: def resizeEvent(self, a0: QResizeEvent) -> None:
self.qscrollarea.resize(self.size())
self.resizeandshow(False) self.resizeandshow(False)
return super().resizeEvent(a0) return super().resizeEvent(a0)
@ -369,14 +367,8 @@ class lazyscrollflow(QWidget):
@trypass @trypass
def switchidx(self, idx1, idx2): def switchidx(self, idx1, idx2):
with self.lock: with self.lock:
self.widgets[idx1], self.widgets[idx2] = ( self.widgets.insert(idx2, self.widgets.pop(idx1))
self.widgets[idx2], self.fakegeos.insert(idx2, self.fakegeos.pop(idx1))
self.widgets[idx1],
)
self.fakegeos[idx1], self.fakegeos[idx2] = (
self.fakegeos[idx2],
self.fakegeos[idx1],
)
self.resizeandshow() self.resizeandshow()
@trypass @trypass
@ -388,11 +380,6 @@ class lazyscrollflow(QWidget):
idx = len(self.widgets) idx = len(self.widgets)
self.widgets.insert(idx, widfunc) self.widgets.insert(idx, widfunc)
self.fakegeos.insert(idx, QRect()) self.fakegeos.insert(idx, QRect())
if isinstance(widfunc, QWidget):
widfunc.setParent(self.internalwid)
widfunc.adjustSize()
widfunc.setVisible(True)
if refresh: if refresh:
self.resizeandshow() self.resizeandshow()
@ -401,8 +388,9 @@ class lazyscrollflow(QWidget):
with self.lock: with self.lock:
if idx >= 0 and idx < len(self.widgets): if idx >= 0 and idx < len(self.widgets):
w = self.widgets[idx] w = self.widgets[idx]
w.setParent(None) if isinstance(w, QWidget):
w.deleteLater() w.setParent(None)
w.deleteLater()
self.widgets.pop(idx) self.widgets.pop(idx)
self.fakegeos.pop(idx) self.fakegeos.pop(idx)
self.resizeandshow() self.resizeandshow()
@ -423,8 +411,8 @@ class lazyscrollflow(QWidget):
return self._spacing return self._spacing
def fakeresize(self): def fakeresize(self):
if self.qscrollarea.verticalScrollBar().isVisible(): if self.verticalScrollBar().isVisible():
scrollw = self.qscrollarea.verticalScrollBar().width() scrollw = self.verticalScrollBar().width()
else: else:
scrollw = 0 scrollw = 0
with self.lock: with self.lock:
@ -465,32 +453,114 @@ class lazyscrollflow(QWidget):
return new_height 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): def __init__(self):
super().__init__() super().__init__()
self.lay = QVBoxLayout() self.internal_itemH = []
self.lay.setContentsMargins(0, 0, 0, 0) self.internal_widgets = []
self.lay.setSpacing(0) self.lock = threading.Lock()
self.setLayout(self.lay) self.nowvisregion = QRect()
def addw(self, w): def resizeEvent(self, e: QResizeEvent):
self.lay.addWidget(w) 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): def _dovisinternal(self, procevent, region: QRect):
self.lay.insertWidget(i, w) 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): 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): def w(self, i):
return self.lay.itemAt(i).widget() _ = self.internal_widgets[i]
if isinstance(_, QWidget):
return _
return None
def len(self): def len(self):
return self.lay.count() return len(self.internal_widgets)
class shrinkableitem(QWidget): class shrinkableitem(QWidget):
def __init__(self, shrinker: QPushButton): def __init__(self, shrinker: QPushButton, opened):
super().__init__() super().__init__()
self.lay = QVBoxLayout() self.lay = QVBoxLayout()
# self.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Fixed) # self.setSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Fixed)
@ -498,25 +568,24 @@ class shrinkableitem(QWidget):
self.lay.setContentsMargins(0, 0, 0, 0) self.lay.setContentsMargins(0, 0, 0, 0)
self.lay.setSpacing(0) self.lay.setSpacing(0)
self.btn = shrinker self.btn = shrinker
self.items = simplelistw() self.items = delayloadvbox()
self.btn.clicked.connect(self.Revert) self.btn.clicked.connect(self.Revert)
self.lay.addWidget(self.btn) self.lay.addWidget(self.btn)
self.lay.addWidget(self.items) self.lay.addWidget(self.items)
self.items.setVisible(opened)
def _dovisinternal(self, procevent, region: QRect):
self.items._dovisinternal(procevent, region)
def Revert(self): def Revert(self):
self.items.setVisible(not self.items.isVisible()) self.items.setVisible(not self.items.isVisible())
def Show(self): @trypass
self.items.show() def switchidx(self, idx1, idx2):
self.items.switchidx(idx1, idx2)
def Hide(self): def insertw(self, i, wf, height):
self.items.hide() self.items.insertw(i, wf, height)
def addw(self, w):
self.items.addw(w)
def insertw(self, i, w):
self.items.insertw(i, w)
def popw(self, i): def popw(self, i):
return self.items.popw(i) return self.items.popw(i)
@ -528,7 +597,16 @@ class shrinkableitem(QWidget):
return self.items.len() 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): def __init__(self):
super().__init__() super().__init__()
self.setStyleSheet("""QScrollArea{background-color:transparent;border:0px}""") self.setStyleSheet("""QScrollArea{background-color:transparent;border:0px}""")
@ -540,19 +618,31 @@ class stackedlist(QScrollArea):
self.lay.setSpacing(0) self.lay.setSpacing(0)
self.lay.setContentsMargins(0, 0, 0, 0) self.lay.setContentsMargins(0, 0, 0, 0)
internal.setLayout(self.lay) 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.internal = internal
self.scrolled.connect(lambda _: self.doshowlazywidget(True, _))
def addw(self, w): def doshowlazywidget(self, procevent, region: QRect):
self.lay.addWidget(w) 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) self.lay.insertWidget(i, w)
def popw(self, i): def popw(self, i) -> shrinkableitem:
return self.lay.takeAt(i).widget() self.lay.takeAt(i).widget().deleteLater()
def w(self, i): def w(self, i) -> shrinkableitem:
return self.lay.itemAt(i).widget() return self.lay.itemAt(i).widget()
def len(self): def len(self):
return self.lay.count() return self.lay.count()
def switchidx(self, i1, i2):
self.lay.insertItem(i2, self.lay.takeAt(i1))

View File

@ -38,6 +38,7 @@ class mecab(basehira):
for node, fields in self.kks.parse( for node, fields in self.kks.parse(
text, codec text, codec
): # self.kks.parseToNodeList(text): ): # self.kks.parseToNodeList(text):
print(fields)
kana = "" kana = ""
origorig = "" origorig = ""
pos1 = fields[0] pos1 = fields[0]
@ -53,9 +54,10 @@ class mecab(basehira):
elif len(fields) == 9: elif len(fields) == 9:
kana = fields[8] kana = fields[8]
origorig = fields[7] origorig = fields[7]
elif len(fields) == 6: # 英文
kana = origorig = node
l = 0 l = 0
while str(node) not in text[start : start + l]: while str(node) not in text[start : start + l]:
l += 1 l += 1
orig = text[start : start + l] orig = text[start : start + l]
@ -77,9 +79,10 @@ class mecab(basehira):
result.append( result.append(
{"orig": orig, "hira": hira, "cixing": pos1, "origorig": origorig} {"orig": orig, "hira": hira, "cixing": pos1, "origorig": origorig}
) )
extras=text[start :] extras = text[start:]
if len(extras): if len(extras):
result.append( result.append(
{"orig": extras, "hira": extras, "cixing": '', "origorig": extras} {"orig": extras, "hira": extras, "cixing": "", "origorig": extras}
) )
print(result)
return result return result

View File

@ -49,6 +49,11 @@ except:
savehook_new_list = [] savehook_new_list = []
savehook_new_data = {} savehook_new_data = {}
try:
savegametaged = _savehook[2]
except:
savegametaged = [None]
translatorsetting = tryreadconfig("translatorsetting.json") translatorsetting = tryreadconfig("translatorsetting.json")
ocrsetting = tryreadconfig("ocrsetting.json") ocrsetting = tryreadconfig("ocrsetting.json")
@ -338,7 +343,8 @@ def saveallconfig():
safesave("./userconfig/ocrsetting.json", ocrsetting) safesave("./userconfig/ocrsetting.json", ocrsetting)
safesave("./userconfig/vndbtagdata.json", vndbtagdata) safesave("./userconfig/vndbtagdata.json", vndbtagdata)
safesave( 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( safesave(
"./files/lang/{}.json".format(getlanguse()), "./files/lang/{}.json".format(getlanguse()),

View File

@ -196,13 +196,15 @@ def imgchangedtask(gamepath, res):
savehook_new_data[gamepath]["isimagepathusersetted"] = True savehook_new_data[gamepath]["isimagepathusersetted"] = True
def checkifnewgame(gamepath, title=None): def checkifnewgame(targetlist, gamepath, title=None):
if gamepath not in savehook_new_list: if gamepath in targetlist:
savehook_new_list.insert(0, gamepath) return False
targetlist.insert(0, gamepath)
if gamepath not in savehook_new_data: if gamepath not in savehook_new_data:
savehook_new_data[gamepath] = getdefaultsavehook(gamepath, title) savehook_new_data[gamepath] = getdefaultsavehook(gamepath, title)
searchvndbqueue.put((2, gamepath, None)) searchvndbqueue.put((2, gamepath, None))
return True
kanjichs2ja = str.maketrans(static_data["kanjichs2ja"]) kanjichs2ja = str.maketrans(static_data["kanjichs2ja"])

View File

@ -810,5 +810,9 @@
"不显示时间": "لا وقت العرض", "不显示时间": "لا وقت العرض",
"过滤历史重复": "تصفية التاريخ تكرار", "过滤历史重复": "تصفية التاريخ تكرار",
"缓存条数": "عدد شرائط التخزين المؤقت", "缓存条数": "عدد شرائط التخزين المؤقت",
"腾讯OCR": "تينسنت التعرف الضوئي على الحروف" "腾讯OCR": "تينسنت التعرف الضوئي على الحروف",
"添加列表": "إضافة قائمة",
"删除列表": "حذف قائمة",
"上移": "رفع",
"下移": "نزولا"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "不顯示時間", "不显示时间": "不顯示時間",
"过滤历史重复": "過濾歷史重複", "过滤历史重复": "過濾歷史重複",
"缓存条数": "緩存條數", "缓存条数": "緩存條數",
"腾讯OCR": "騰訊OCR" "腾讯OCR": "騰訊OCR",
"添加列表": "添加清單",
"删除列表": "删除清單",
"上移": "上移",
"下移": "下移"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "Do not display time", "不显示时间": "Do not display time",
"过滤历史重复": "Filter historical duplicates", "过滤历史重复": "Filter historical duplicates",
"缓存条数": "Number of cache entries", "缓存条数": "Number of cache entries",
"腾讯OCR": "Tencent OCR" "腾讯OCR": "Tencent OCR",
"添加列表": "Add List",
"删除列表": "Delete List",
"上移": "Move Up",
"下移": "Move Down"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "No muestra el tiempo", "不显示时间": "No muestra el tiempo",
"过滤历史重复": "Filtrar repetición histórica", "过滤历史重复": "Filtrar repetición histórica",
"缓存条数": "Número de barras de caché", "缓存条数": "Número de barras de caché",
"腾讯OCR": "Tencent OCR" "腾讯OCR": "Tencent OCR",
"添加列表": "Añadir lista",
"删除列表": "Eliminar lista",
"上移": "Subir",
"下移": "Bajar"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "Ne pas afficher l'heure", "不显示时间": "Ne pas afficher l'heure",
"过滤历史重复": "Filtrer historique répétition", "过滤历史重复": "Filtrer historique répétition",
"缓存条数": "Nombre de barres de cache", "缓存条数": "Nombre de barres de cache",
"腾讯OCR": "OCR Tencent" "腾讯OCR": "OCR Tencent",
"添加列表": "Ajouter une liste",
"删除列表": "Supprimer une liste",
"上移": "Déplacement vers le Haut",
"下移": "Descendre"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "Non visualizzare l'ora", "不显示时间": "Non visualizzare l'ora",
"过滤历史重复": "Filtra duplicati storici", "过滤历史重复": "Filtra duplicati storici",
"缓存条数": "Numero di voci della cache", "缓存条数": "Numero di voci della cache",
"腾讯OCR": "Tencent OCR" "腾讯OCR": "Tencent OCR",
"添加列表": "Aggiungi elenco",
"删除列表": "Elimina elenco",
"上移": "Sposta su",
"下移": "Sposta giù"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "時間を表示しない", "不显示时间": "時間を表示しない",
"过滤历史重复": "フィルタ履歴の繰り返し", "过滤历史重复": "フィルタ履歴の繰り返し",
"缓存条数": "キャッシュ・エントリ数", "缓存条数": "キャッシュ・エントリ数",
"腾讯OCR": "テンセントOCR" "腾讯OCR": "テンセントOCR",
"添加列表": "リストの追加",
"删除列表": "リストの削除",
"上移": "上へ移動",
"下移": "下へ移動"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "시간 표시 안 함", "不显示时间": "시간 표시 안 함",
"过滤历史重复": "반복된 기록 필터링", "过滤历史重复": "반복된 기록 필터링",
"缓存条数": "캐시 바 수", "缓存条数": "캐시 바 수",
"腾讯OCR": "텐센트 OCR" "腾讯OCR": "텐센트 OCR",
"添加列表": "목록 추가",
"删除列表": "목록 삭제",
"上移": "위로 이동",
"下移": "아래로 이동"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "Nie wyświetlaj czasu", "不显示时间": "Nie wyświetlaj czasu",
"过滤历史重复": "Filtruj duplikaty historyczne", "过滤历史重复": "Filtruj duplikaty historyczne",
"缓存条数": "Liczba wpisów pamięci podręcznej", "缓存条数": "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ół"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "Не показывать время", "不显示时间": "Не показывать время",
"过滤历史重复": "Фильтровать повторение истории", "过滤历史重复": "Фильтровать повторение истории",
"缓存条数": "Количество кэшированных записей", "缓存条数": "Количество кэшированных записей",
"腾讯OCR": "Скачать OCR" "腾讯OCR": "Скачать OCR",
"添加列表": "Добавить список",
"删除列表": "Удалить список",
"上移": "Переместить вверх",
"下移": "Переместить вниз"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "ไม่แสดงเวลา", "不显示时间": "ไม่แสดงเวลา",
"过滤历史重复": "ประวัติการกรอง ทำซ้ำ", "过滤历史重复": "ประวัติการกรอง ทำซ้ำ",
"缓存条数": "จำนวนแถบแคช", "缓存条数": "จำนวนแถบแคช",
"腾讯OCR": "Tencent โอซีอาร์" "腾讯OCR": "Tencent โอซีอาร์",
"添加列表": "เพิ่มรายการ",
"删除列表": "ลบรายการ",
"上移": "เลื่อนขึ้น",
"下移": "เลื่อนลง"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "Zamanı gösterme", "不显示时间": "Zamanı gösterme",
"过滤历史重复": "Tarihi çizgileri sil", "过滤历史重复": "Tarihi çizgileri sil",
"缓存条数": "Cache girişlerinin sayısı", "缓存条数": "Cache girişlerinin sayısı",
"腾讯OCR": "Tencent OCR" "腾讯OCR": "Tencent OCR",
"添加列表": "Liste Ekle",
"删除列表": "Listeyi sil",
"上移": "Yukarı Taşı",
"下移": "Aşağı taşın"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "Не показувати час", "不显示时间": "Не показувати час",
"过滤历史重复": "Фільтрувати історичні дублікати", "过滤历史重复": "Фільтрувати історичні дублікати",
"缓存条数": "Кількість записів кешу", "缓存条数": "Кількість записів кешу",
"腾讯OCR": "Похильний OCR" "腾讯OCR": "Похильний OCR",
"添加列表": "Додати список",
"删除列表": "Вилучити список",
"上移": "Пересунути вгору",
"下移": "Пересунути вниз"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "Không hiển thị thời gian", "不显示时间": "Không hiển thị thời gian",
"过滤历史重复": "Lọc lịch sử lặp lại", "过滤历史重复": "Lọc lịch sử lặp lại",
"缓存条数": "Số thanh bộ nhớ cache", "缓存条数": "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"
} }

View File

@ -810,5 +810,9 @@
"不显示时间": "", "不显示时间": "",
"过滤历史重复": "", "过滤历史重复": "",
"缓存条数": "", "缓存条数": "",
"腾讯OCR": "" "腾讯OCR": "",
"添加列表": "",
"删除列表": "",
"上移": "",
"下移": ""
} }