mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
update
1
This commit is contained in:
parent
e45d650697
commit
77b48845a1
@ -1,4 +1,4 @@
|
||||
import functools, time
|
||||
import functools, time, qtawesome
|
||||
from PyQt5.QtWidgets import (
|
||||
QPushButton,
|
||||
QDialog,
|
||||
@ -32,7 +32,16 @@ from PyQt5.QtWidgets import (
|
||||
QAction,
|
||||
QTabBar,
|
||||
)
|
||||
from PyQt5.QtGui import QIntValidator, QResizeEvent, QPixmap, QPainter
|
||||
from PyQt5.QtGui import (
|
||||
QCloseEvent,
|
||||
QIntValidator,
|
||||
QPaintEvent,
|
||||
QResizeEvent,
|
||||
QPixmap,
|
||||
QPainter,
|
||||
QPen,
|
||||
QColor,
|
||||
)
|
||||
from PyQt5.QtCore import Qt
|
||||
from gui.usefulwidget import (
|
||||
getsimplecombobox,
|
||||
@ -117,11 +126,11 @@ class ItemWidget(QWidget):
|
||||
# margin = (
|
||||
# self.itemw - self.imgw
|
||||
# ) // 2 # globalconfig['dialog_savegame_layout']['margin']
|
||||
margin=globalconfig["dialog_savegame_layout"]["margin"]
|
||||
textH=globalconfig["dialog_savegame_layout"]["textH"]
|
||||
self.imgw = self.itemw-2*margin
|
||||
self.imgh = self.itemh-textH-2*margin
|
||||
#
|
||||
margin = globalconfig["dialog_savegame_layout"]["margin"]
|
||||
textH = globalconfig["dialog_savegame_layout"]["textH"]
|
||||
self.imgw = self.itemw - 2 * margin
|
||||
self.imgh = self.itemh - textH - 2 * margin
|
||||
#
|
||||
self.setFixedSize(QSize(self.itemw, self.itemh))
|
||||
self.setFocusPolicy(Qt.StrongFocus)
|
||||
self.maskshowfileexists = QLabel(self)
|
||||
@ -129,11 +138,11 @@ class ItemWidget(QWidget):
|
||||
layout = QVBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
self._img = IMGWidget(self.imgw, self.imgh, pixmap)
|
||||
_w=QWidget()
|
||||
_w.setStyleSheet('background-color: rgba(255,255,255, 0);')
|
||||
wrap=QVBoxLayout()
|
||||
_w = QWidget()
|
||||
_w.setStyleSheet("background-color: rgba(255,255,255, 0);")
|
||||
wrap = QVBoxLayout()
|
||||
_w.setLayout(wrap)
|
||||
_w.setFixedHeight(self.imgh+2*margin)
|
||||
_w.setFixedHeight(self.imgh + 2 * margin)
|
||||
wrap.setContentsMargins(margin, margin, margin, margin)
|
||||
wrap.addWidget(self._img)
|
||||
layout.addWidget(_w)
|
||||
@ -186,13 +195,14 @@ class IMGWidget(QLabel):
|
||||
pixmap = QPixmap(self.size())
|
||||
pixmap.fill(Qt.transparent)
|
||||
painter = QPainter(pixmap)
|
||||
painter.setRenderHint(QPainter.SmoothPixmapTransform)
|
||||
painter.setRenderHint(QPainter.SmoothPixmapTransform)
|
||||
painter.setRenderHint(QPainter.Antialiasing)
|
||||
painter.drawPixmap(self.getrect(), self.pix)
|
||||
painter.end()
|
||||
|
||||
|
||||
self.setPixmap(pixmap)
|
||||
self.setFixedSize(pixmap.size())
|
||||
|
||||
def getrect(self):
|
||||
size = self.adaptsize(self.pix.size())
|
||||
rect = QRect()
|
||||
@ -525,6 +535,14 @@ class browserdialog(QDialog):
|
||||
self.browser.navigate(link)
|
||||
|
||||
|
||||
def getvndbrealtags(vndbtags_naive):
|
||||
vndbtags = []
|
||||
for tagid in vndbtags_naive:
|
||||
if tagid in globalconfig["vndbcache"]["tagid2name"]:
|
||||
vndbtags.append(globalconfig["vndbcache"]["tagid2name"][tagid])
|
||||
return vndbtags
|
||||
|
||||
|
||||
@Singleton
|
||||
class dialog_setting_game(QDialog):
|
||||
def selectexe(self):
|
||||
@ -611,7 +629,7 @@ class dialog_setting_game(QDialog):
|
||||
vndbid.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
|
||||
|
||||
vndbid.textEdited.connect(functools.partial(vidchangedtask, exepath))
|
||||
|
||||
|
||||
statiswids = [
|
||||
QLabel(_TR("统计信息")),
|
||||
getcolorbutton(
|
||||
@ -630,6 +648,13 @@ class dialog_setting_game(QDialog):
|
||||
icon="fa.book",
|
||||
constcolor="#FF69B4",
|
||||
),
|
||||
getcolorbutton(
|
||||
"",
|
||||
"",
|
||||
lambda: vidchangedtask(exepath, savehook_new_data[exepath]["vid"]),
|
||||
icon="fa.refresh",
|
||||
constcolor="#FF69B4",
|
||||
),
|
||||
]
|
||||
formLayout.addLayout(getboxlayout(statiswids))
|
||||
editpath = QLineEdit(exepath)
|
||||
@ -725,10 +750,65 @@ class dialog_setting_game(QDialog):
|
||||
methodtab.addTab(self.gethooktab(exepath), "HOOK")
|
||||
methodtab.addTab(self.getpretranstab(exepath), _TR("预翻译"))
|
||||
methodtab.addTab(self.getttssetting(exepath), _TR("语音"))
|
||||
methodtab.addTab(self.getlabelsetting(exepath), _TR("标签"))
|
||||
formLayout.addWidget(methodtab)
|
||||
|
||||
self.show()
|
||||
|
||||
def getlabelsetting(self, exepath):
|
||||
_w = QWidget()
|
||||
formLayout = QVBoxLayout()
|
||||
# formLayout.setAlignment(Qt.AlignTop)
|
||||
_w.setLayout(formLayout)
|
||||
formLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.labelflow = ScrollFlow()
|
||||
|
||||
def newitem(text, removeable):
|
||||
qw = tagitem(text, removeable)
|
||||
|
||||
def __(_qw, t):
|
||||
_qw.remove()
|
||||
i = savehook_new_data[exepath]["usertags"].index(t)
|
||||
self.labelflow.removeidx(i)
|
||||
savehook_new_data[exepath]["usertags"].remove(t)
|
||||
|
||||
if removeable:
|
||||
qw.removesignal.connect(functools.partial(__, qw))
|
||||
|
||||
def _lbclick(t):
|
||||
self.parent().tagswidget.addTag(t)
|
||||
|
||||
qw.labelclicked.connect(_lbclick)
|
||||
self.labelflow.addwidget(qw)
|
||||
|
||||
for tag in savehook_new_data[exepath]["usertags"]:
|
||||
newitem(tag, True)
|
||||
for tag in getvndbrealtags(savehook_new_data[exepath]["vndbtags"]):
|
||||
newitem(tag, False)
|
||||
formLayout.addWidget(self.labelflow)
|
||||
_dict = {"new": 0}
|
||||
|
||||
formLayout.addWidget(self.labelflow)
|
||||
button = QPushButton(_TR("添加"))
|
||||
|
||||
def _add(_):
|
||||
tag = globalconfig["labelset"][_dict["new"]]
|
||||
if tag not in savehook_new_data[exepath]["usertags"]:
|
||||
savehook_new_data[exepath]["usertags"].append(tag)
|
||||
newitem(tag, True)
|
||||
|
||||
button.clicked.connect(_add)
|
||||
|
||||
formLayout.addLayout(
|
||||
getboxlayout(
|
||||
[
|
||||
getsimplecombobox(globalconfig["labelset"], _dict, "new"),
|
||||
button,
|
||||
]
|
||||
)
|
||||
)
|
||||
return _w
|
||||
|
||||
def getttssetting(self, exepath):
|
||||
_w = QWidget()
|
||||
formLayout = QVBoxLayout()
|
||||
@ -922,8 +1002,8 @@ class dialog_syssetting(QDialog):
|
||||
("itemh", "高度"),
|
||||
# ("imgw", "图片宽度"),
|
||||
# ("imgh", "图片高度"),
|
||||
('margin','边距'),
|
||||
('textH','文字区高度')
|
||||
("margin", "边距"),
|
||||
("textH", "文字区高度"),
|
||||
]:
|
||||
formLayout.addRow(
|
||||
(_TR(name)),
|
||||
@ -1013,6 +1093,7 @@ class dialog_statistic(QDialog):
|
||||
threading.Thread(target=self.refresh).start()
|
||||
|
||||
|
||||
@threader
|
||||
def startgame(game):
|
||||
try:
|
||||
if os.path.exists(game):
|
||||
@ -1096,6 +1177,199 @@ def startgame(game):
|
||||
print_exc()
|
||||
|
||||
|
||||
@Singleton_close
|
||||
class labelsetedit(QDialog):
|
||||
def __init__(self, p) -> None:
|
||||
super().__init__(p)
|
||||
try:
|
||||
self.setWindowTitle(_TR("标签集"))
|
||||
model = QStandardItemModel()
|
||||
model.setHorizontalHeaderLabels(
|
||||
_TRL(
|
||||
[
|
||||
"删除",
|
||||
"标签",
|
||||
]
|
||||
)
|
||||
)
|
||||
self.hcmodel = model
|
||||
|
||||
table = QTableView()
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
|
||||
table.horizontalHeader().setStretchLastSection(True)
|
||||
# table.setEditTriggers(QAbstractItemView.NoEditTriggers);
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.setSelectionMode((QAbstractItemView.SingleSelection))
|
||||
table.setWordWrap(False)
|
||||
table.setModel(model)
|
||||
self.hctable = table
|
||||
|
||||
for row, k in enumerate(globalconfig["labelset"]): # 2
|
||||
self.newline(row, k)
|
||||
formLayout = QVBoxLayout()
|
||||
formLayout.addWidget(self.hctable)
|
||||
button = QPushButton(_TR("添加行"))
|
||||
button.clicked.connect(lambda _: self.newline(0, ""))
|
||||
formLayout.addWidget(button)
|
||||
self.setLayout(formLayout)
|
||||
self.show()
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
def clicked2(self):
|
||||
try:
|
||||
globalconfig["labelset"].pop(self.hctable.currentIndex().row())
|
||||
self.hcmodel.removeRow(self.hctable.currentIndex().row())
|
||||
except:
|
||||
pass
|
||||
|
||||
def closeEvent(self, a0: QCloseEvent) -> None:
|
||||
rows = self.hcmodel.rowCount()
|
||||
rowoffset = 0
|
||||
dedump = set()
|
||||
globalconfig["labelset"].clear()
|
||||
for row in range(rows):
|
||||
k = self.hcmodel.item(row, 1).text()
|
||||
if k == "" or k in dedump:
|
||||
rowoffset += 1
|
||||
continue
|
||||
globalconfig["labelset"].append(k)
|
||||
dedump.add(k)
|
||||
|
||||
def newline(self, row, k):
|
||||
self.hcmodel.insertRow(row, [QStandardItem(), QStandardItem(k)])
|
||||
self.hctable.setIndexWidget(
|
||||
self.hcmodel.index(row, 0),
|
||||
getcolorbutton(
|
||||
"", "", self.clicked2, icon="fa.times", constcolor="#FF69B4"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class ClickableLabel(QLabel):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setClickable(True)
|
||||
|
||||
def setClickable(self, clickable):
|
||||
self._clickable = clickable
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
if self._clickable and event.button() == Qt.LeftButton:
|
||||
self.clicked.emit()
|
||||
|
||||
clicked = pyqtSignal()
|
||||
|
||||
|
||||
class tagitem(QWidget):
|
||||
|
||||
removesignal = pyqtSignal(str)
|
||||
labelclicked = pyqtSignal(str)
|
||||
|
||||
def remove(self):
|
||||
self.hide()
|
||||
_lay = self.layout()
|
||||
_ws = []
|
||||
for i in range(_lay.count()):
|
||||
witem = _lay.itemAt(i)
|
||||
_ws.append(witem.widget())
|
||||
for w in _ws:
|
||||
_lay.removeWidget(w)
|
||||
|
||||
def paintEvent(self, event):
|
||||
painter = QPainter(self)
|
||||
painter.setRenderHint(QPainter.Antialiasing)
|
||||
|
||||
border_color = Qt.black
|
||||
border_width = 1
|
||||
pen = QPen(border_color)
|
||||
pen.setWidth(border_width)
|
||||
painter.setPen(pen)
|
||||
painter.drawRect(self.rect())
|
||||
|
||||
def __init__(self, tag, removeable=True) -> None:
|
||||
super().__init__()
|
||||
tagLayout = QHBoxLayout()
|
||||
tagLayout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
self.setLayout(tagLayout)
|
||||
|
||||
lb = ClickableLabel(tag)
|
||||
lb.clicked.connect(lambda: self.labelclicked.emit(tag))
|
||||
tagLayout.addWidget(lb)
|
||||
if removeable:
|
||||
button = getcolorbutton(
|
||||
None,
|
||||
None,
|
||||
lambda: self.removesignal.emit(tag), # self.removeTag(tag),
|
||||
qicon=qtawesome.icon(
|
||||
"fa.times",
|
||||
color="#FF69B4",
|
||||
),
|
||||
sizefixed=True,
|
||||
)
|
||||
tagLayout.addWidget(button)
|
||||
|
||||
|
||||
class TagWidget(QWidget):
|
||||
tagschanged = pyqtSignal(tuple)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.tags = []
|
||||
|
||||
layout = QHBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addWidget(QLabel(_TR("标签")))
|
||||
self.setLayout(layout)
|
||||
|
||||
self.lineEdit = QLineEdit()
|
||||
self.lineEdit.returnPressed.connect(lambda: self.addTag(self.lineEdit.text()))
|
||||
layout.addWidget(self.lineEdit)
|
||||
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
|
||||
self.tag2widget = {}
|
||||
layout.addWidget(
|
||||
getcolorbutton(
|
||||
"",
|
||||
"",
|
||||
lambda _: labelsetedit(parent),
|
||||
icon="fa.gear",
|
||||
constcolor="#FF69B4",
|
||||
),
|
||||
)
|
||||
|
||||
def addTag(self, tag):
|
||||
try:
|
||||
|
||||
if not tag:
|
||||
return
|
||||
if tag in self.tag2widget:
|
||||
return
|
||||
self.tags.append(tag)
|
||||
qw = tagitem(tag)
|
||||
qw.removesignal.connect(self.removeTag)
|
||||
|
||||
layout = self.layout()
|
||||
# layout.insertLayout(layout.count() - 1, tagLayout)
|
||||
layout.insertWidget(layout.count() - 2, qw)
|
||||
self.tag2widget[tag] = qw
|
||||
self.lineEdit.clear()
|
||||
self.lineEdit.setFocus()
|
||||
self.tagschanged.emit(tuple(self.tag2widget.keys()))
|
||||
except:
|
||||
print_exc()
|
||||
|
||||
def removeTag(self, tag):
|
||||
_w = self.tag2widget[tag]
|
||||
_w.remove()
|
||||
|
||||
self.layout().removeWidget(_w)
|
||||
self.tag2widget.pop(tag)
|
||||
self.lineEdit.setFocus()
|
||||
self.tagschanged.emit(tuple(self.tag2widget.keys()))
|
||||
|
||||
|
||||
@Singleton_close
|
||||
class dialog_savedgame_new(saveposwindow):
|
||||
def startgame(self, game):
|
||||
@ -1143,6 +1417,35 @@ class dialog_savedgame_new(saveposwindow):
|
||||
if len(savehook_new_list):
|
||||
self.flow.l._item_list[0].widget().setFocus()
|
||||
|
||||
def tagschanged(self, tags):
|
||||
checkexists = _TR("存在") in tags
|
||||
if checkexists:
|
||||
_ = list(tags)
|
||||
_.remove(_TR("存在"))
|
||||
tags = tuple(_)
|
||||
self.formLayout.removeWidget(self.flow)
|
||||
self.idxsave.clear()
|
||||
self.flow = ScrollFlow()
|
||||
self.formLayout.insertWidget(self.formLayout.count() - 1, self.flow)
|
||||
for k in savehook_new_list:
|
||||
if checkexists and os.path.exists(k) == False:
|
||||
continue
|
||||
|
||||
# print(vndbtags)
|
||||
notshow = False
|
||||
for tag in tags:
|
||||
if (
|
||||
tag not in getvndbrealtags(savehook_new_data[k]["vndbtags"])
|
||||
and tag not in savehook_new_data[k]["usertags"]
|
||||
):
|
||||
notshow = True
|
||||
break
|
||||
if notshow:
|
||||
continue
|
||||
self.newline(k)
|
||||
self.idxsave.append(k)
|
||||
QApplication.processEvents()
|
||||
|
||||
def __init__(self, parent) -> None:
|
||||
super().__init__(
|
||||
parent,
|
||||
@ -1153,11 +1456,14 @@ class dialog_savedgame_new(saveposwindow):
|
||||
self.setWindowTitle(_TR("已保存游戏"))
|
||||
if globalconfig["showintab_sub"]:
|
||||
showintab(int(self.winId()), True)
|
||||
formLayout = QVBoxLayout() #
|
||||
formLayout = QVBoxLayout()
|
||||
self.tagswidget = TagWidget(self)
|
||||
self.tagswidget.tagschanged.connect(self.tagschanged)
|
||||
formLayout.addWidget(self.tagswidget)
|
||||
self.flow = ScrollFlow()
|
||||
|
||||
formLayout.addWidget(self.flow)
|
||||
|
||||
self.formLayout = formLayout
|
||||
buttonlayout = QHBoxLayout()
|
||||
self.buttonlayout = buttonlayout
|
||||
self.savebutton = []
|
||||
@ -1178,14 +1484,10 @@ class dialog_savedgame_new(saveposwindow):
|
||||
self.itemfocuschanged(False, None)
|
||||
self.show()
|
||||
self.idxsave = []
|
||||
for i, k in enumerate(savehook_new_list):
|
||||
if globalconfig["hide_not_exists"] and os.path.exists(k) == False:
|
||||
continue
|
||||
self.newline(k)
|
||||
self.idxsave.append(k)
|
||||
if i == 0:
|
||||
self.top1focus()
|
||||
QApplication.processEvents()
|
||||
if globalconfig["hide_not_exists"]:
|
||||
self.tagswidget.addTag(_TR("存在"))
|
||||
else:
|
||||
self.tagschanged(tuple())
|
||||
|
||||
def showsettingdialog(self):
|
||||
idx = self.idxsave.index(self.currentfocuspath)
|
||||
|
@ -141,6 +141,10 @@ def setTabcishu_l(self):
|
||||
("点击单词复制", 5),
|
||||
(getsimpleswitch(globalconfig, "usecopyword"), 1),
|
||||
],
|
||||
[
|
||||
("使用原型查询", 5),
|
||||
(getsimpleswitch(globalconfig, "usewordorigin"), 1),
|
||||
],
|
||||
[],
|
||||
[("辞书", 10)],
|
||||
]
|
||||
|
@ -490,7 +490,7 @@ class Textbrowser:
|
||||
)
|
||||
if callback:
|
||||
self.searchmasklabels_clicked[labeli].callback = (
|
||||
functools.partial(callback, (word["orig"]))
|
||||
functools.partial(callback, (word))
|
||||
)
|
||||
|
||||
self.searchmasklabels_clicked[labeli + 1].setGeometry(
|
||||
@ -503,9 +503,7 @@ class Textbrowser:
|
||||
if callback:
|
||||
self.searchmasklabels_clicked[
|
||||
labeli + 1
|
||||
].callback = functools.partial(
|
||||
callback, (word["orig"])
|
||||
)
|
||||
].callback = functools.partial(callback, (word))
|
||||
|
||||
if globalconfig["show_fenci"]:
|
||||
self.searchmasklabels[labeli].setGeometry(*pos1)
|
||||
@ -540,7 +538,7 @@ class Textbrowser:
|
||||
self.searchmasklabels_clicked[labeli].show()
|
||||
if callback:
|
||||
self.searchmasklabels_clicked[labeli].callback = (
|
||||
functools.partial(callback, (word["orig"]))
|
||||
functools.partial(callback, word)
|
||||
)
|
||||
if globalconfig["show_fenci"]:
|
||||
self.searchmasklabels[labeli].setGeometry(*pos1)
|
||||
|
@ -273,6 +273,11 @@ class QUnFrameWindow(resizableframeless):
|
||||
) and hira:
|
||||
|
||||
def callback(word):
|
||||
if globalconfig["usewordorigin"] == False:
|
||||
word = word["orig"]
|
||||
else:
|
||||
word = word.get("origorig", word["orig"])
|
||||
|
||||
if globalconfig["usecopyword"]:
|
||||
winsharedutils.clipboard_set(word)
|
||||
if globalconfig["usesearchword"]:
|
||||
|
@ -6,6 +6,7 @@ from PyQt5.QtWidgets import (
|
||||
QMessageBox,
|
||||
QDialog,
|
||||
QLabel,
|
||||
QSizePolicy,
|
||||
QHBoxLayout,
|
||||
)
|
||||
from PyQt5.QtGui import QCursor, QCloseEvent, QColor, QTextCursor
|
||||
@ -435,12 +436,16 @@ def getcolorbutton(
|
||||
enable=True,
|
||||
transparent=True,
|
||||
qicon=None,
|
||||
sizefixed=False,
|
||||
):
|
||||
if qicon is None:
|
||||
qicon = qtawesome.icon(icon, color=constcolor if constcolor else d[key])
|
||||
b = QPushButton(qicon, "")
|
||||
b = QPushButton()
|
||||
b.setIcon(qicon)
|
||||
b.setEnabled(enable)
|
||||
b.setIconSize(QSize(20, 20))
|
||||
if sizefixed:
|
||||
b.setFixedSize(QSize(20, 20))
|
||||
if transparent:
|
||||
b.setStyleSheet(
|
||||
"""background-color: rgba(255, 255, 255, 0);
|
||||
@ -449,6 +454,7 @@ def getcolorbutton(
|
||||
font: 100 10pt;"""
|
||||
)
|
||||
b.clicked.connect(callback)
|
||||
b.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
if name:
|
||||
setattr(parent, name, b)
|
||||
return b
|
||||
@ -474,7 +480,7 @@ def getsimpleswitch(
|
||||
|
||||
b = MySwitch(sign=d[key], enable=enable)
|
||||
b.clicked.connect(functools.partial(callbackwrap, d, key, callback))
|
||||
|
||||
b.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
||||
if pair:
|
||||
if pair not in dir(parent):
|
||||
setattr(parent, pair, {})
|
||||
|
@ -20,6 +20,9 @@ class hira:
|
||||
for node, fields in self.kks.parse(
|
||||
text, codec
|
||||
): # self.kks.parseToNodeList(text):
|
||||
kana = ""
|
||||
pos1 = ""
|
||||
origorig = None
|
||||
if len(fields):
|
||||
pos1 = fields[0]
|
||||
if len(fields) > 29:
|
||||
@ -28,26 +31,30 @@ class hira:
|
||||
kana = fields[20]
|
||||
elif 29 > len(fields) >= 26:
|
||||
kana = fields[17]
|
||||
origorig = fields[7]
|
||||
elif len(fields) > 9:
|
||||
kana = fields[9] # 无kana,用lform代替
|
||||
elif len(fields) == 9:
|
||||
kana = fields[8] # 7/8均可,issues/514
|
||||
else:
|
||||
kana = ""
|
||||
else:
|
||||
kana = ""
|
||||
pos1 = ""
|
||||
if len(fields) >= 8:
|
||||
origorig = fields[7] # unsafe
|
||||
l = 0
|
||||
if text[start] == "\n":
|
||||
start += 1
|
||||
while str(node) not in text[start : start + l]:
|
||||
l += 1
|
||||
orig = text[start : start + l]
|
||||
if origorig is None:
|
||||
origorig = orig
|
||||
start += l
|
||||
hira = kana # .translate(self.h2k)
|
||||
|
||||
if hira == "*":
|
||||
hira = ""
|
||||
# print(node.feature)
|
||||
result.append({"orig": orig, "hira": hira, "cixing": pos1})
|
||||
result.append(
|
||||
{"orig": orig, "hira": hira, "cixing": pos1, "origorig": origorig}
|
||||
)
|
||||
return result
|
||||
|
@ -86,6 +86,8 @@ def getdefaultsavehook(gamepath, title=None):
|
||||
"gamejsonfile": "",
|
||||
"gamesqlitefile": "",
|
||||
"gamexmlfile": "",
|
||||
"vndbtags": [],
|
||||
"usertags": [],
|
||||
}
|
||||
if gamepath == "0":
|
||||
default["title"] = "No Game"
|
||||
|
@ -125,9 +125,10 @@ def everymethodsthread():
|
||||
vid = data.get("vid", None)
|
||||
title = data.get("title", None)
|
||||
namemap = data.get("namemap", None)
|
||||
|
||||
vndbtags = data.get("vndbtags", None)
|
||||
if not vid:
|
||||
continue
|
||||
print(data)
|
||||
savehook_new_data[gamepath]["vid"] = int(vid[1:])
|
||||
if saveimg and (not savehook_new_data[gamepath]["isimagepathusersetted"]):
|
||||
savehook_new_data[gamepath]["imagepath"] = saveimg
|
||||
@ -137,7 +138,9 @@ def everymethodsthread():
|
||||
savehook_new_data[gamepath]["infopath"] = saveinfo
|
||||
if namemap:
|
||||
savehook_new_data[gamepath]["namemap"] = namemap
|
||||
print(namemap)
|
||||
if vndbtags:
|
||||
savehook_new_data[gamepath]["vndbtags"] = vndbtags
|
||||
|
||||
succ = True
|
||||
break
|
||||
if succ == False:
|
||||
|
@ -2,6 +2,7 @@ import time, requests, re, os, hashlib
|
||||
from myutils.proxy import getproxy
|
||||
from myutils.config import globalconfig
|
||||
from threading import Thread
|
||||
from traceback import print_exc
|
||||
|
||||
|
||||
def b64string(a):
|
||||
@ -82,6 +83,7 @@ def safegetvndbjson(url, json, getter):
|
||||
try:
|
||||
return getter(_.json())
|
||||
except:
|
||||
# print_exc()
|
||||
print(_.text)
|
||||
return None
|
||||
except:
|
||||
@ -155,23 +157,74 @@ def getcharnamemapbyid(vid):
|
||||
return namemap
|
||||
|
||||
|
||||
def gettagnamebytagid(gid):
|
||||
|
||||
return safegetvndbjson(
|
||||
"https://api.vndb.org/kana/tag",
|
||||
{
|
||||
"filters": [
|
||||
"id",
|
||||
"=",
|
||||
gid,
|
||||
],
|
||||
"fields": "name",
|
||||
},
|
||||
lambda js: js["results"][0]["name"],
|
||||
)
|
||||
|
||||
|
||||
def getvntagsbyid(vid):
|
||||
|
||||
res = safegetvndbjson(
|
||||
"https://api.vndb.org/kana/vn",
|
||||
{
|
||||
"filters": [
|
||||
"id",
|
||||
"=",
|
||||
vid,
|
||||
],
|
||||
"fields": "tags.rating",
|
||||
},
|
||||
lambda js: js["results"][0]["tags"],
|
||||
)
|
||||
if not res:
|
||||
return
|
||||
tags = []
|
||||
try:
|
||||
for r in res:
|
||||
tag = r["id"]
|
||||
if tag not in globalconfig["vndbcache"]["tagid2name"]:
|
||||
name = gettagnamebytagid(tag)
|
||||
if name:
|
||||
globalconfig["vndbcache"]["tagid2name"][tag] = name
|
||||
|
||||
tags.append(r["id"])
|
||||
except:
|
||||
pass
|
||||
return tags
|
||||
|
||||
|
||||
def searchforidimage(titleorid):
|
||||
print(titleorid)
|
||||
if os.path.exists("./cache/vndb") == False:
|
||||
os.mkdir("./cache/vndb")
|
||||
if isinstance(titleorid, str):
|
||||
vid = getvidbytitle(titleorid)
|
||||
if not vid:
|
||||
return {}
|
||||
elif isinstance(titleorid, int):
|
||||
vid = "v{}".format(titleorid)
|
||||
img = getimgbyid(vid)
|
||||
title = gettitlebyid(vid)
|
||||
namemap = getcharnamemapbyid(vid)
|
||||
vndbtags = getvntagsbyid(vid)
|
||||
return {
|
||||
"namemap": namemap,
|
||||
"title": title,
|
||||
"vid": vid,
|
||||
"infopath": vndbdowloadinfo(vid),
|
||||
"imagepath": vndbdownloadimg(img),
|
||||
"vndbtags": vndbtags,
|
||||
}
|
||||
|
||||
|
||||
|
@ -688,6 +688,7 @@
|
||||
"lighttheme":0,
|
||||
"usesearchword": false,
|
||||
"usecopyword":false,
|
||||
"usewordorigin":false,
|
||||
"ttscommon": {
|
||||
"rate": 1.0,
|
||||
"volume": 100.0,
|
||||
@ -1230,5 +1231,9 @@
|
||||
"captureOffsetRight":0,
|
||||
"captureOffsetBottom":0,
|
||||
"multiDisplayMode":false
|
||||
}
|
||||
},
|
||||
"vndbcache":{
|
||||
"tagid2name":{}
|
||||
},
|
||||
"labelset":[]
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version":"v2.43.0",
|
||||
"version":"v2.45.0",
|
||||
"themes":{
|
||||
"dark":[
|
||||
{"file":"dark1.qss","name":"PyQtDarkTheme"},
|
||||
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "امتدت",
|
||||
"居中": "مركز",
|
||||
"边距": "هوامش",
|
||||
"文字区高度": "ارتفاع منطقة النص"
|
||||
"文字区高度": "ارتفاع منطقة النص",
|
||||
"标签": "علامة",
|
||||
"存在": "موجود",
|
||||
"标签集": "تسمية مجموعة",
|
||||
"添加": "إضافة .",
|
||||
"使用原型查询": "باستخدام نموذج الاستعلام"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "拉伸",
|
||||
"居中": "居中",
|
||||
"边距": "邊距",
|
||||
"文字区高度": "文字區高度"
|
||||
"文字区高度": "文字區高度",
|
||||
"标签": "標籤",
|
||||
"存在": "存在",
|
||||
"标签集": "標籤集",
|
||||
"添加": "添加",
|
||||
"使用原型查询": "使用原型査詢"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "stretching",
|
||||
"居中": "Centered",
|
||||
"边距": "Margins",
|
||||
"文字区高度": "Text area height"
|
||||
"文字区高度": "Text area height",
|
||||
"标签": "label",
|
||||
"存在": "existence",
|
||||
"标签集": "Label set",
|
||||
"添加": "Add",
|
||||
"使用原型查询": "Using prototype queries"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "Estiramiento",
|
||||
"居中": "En el Centro",
|
||||
"边距": "Margen",
|
||||
"文字区高度": "Altura del área de texto"
|
||||
"文字区高度": "Altura del área de texto",
|
||||
"标签": "Etiquetas",
|
||||
"存在": "Existencia",
|
||||
"标签集": "Conjunto de etiquetas",
|
||||
"添加": "Añadir",
|
||||
"使用原型查询": "Consulta con prototipo"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "Stretch",
|
||||
"居中": "Centré",
|
||||
"边距": "Les marges",
|
||||
"文字区高度": "Hauteur de la zone de texte"
|
||||
"文字区高度": "Hauteur de la zone de texte",
|
||||
"标签": "Étiquettes",
|
||||
"存在": "Présence",
|
||||
"标签集": "Ensemble d'étiquettes",
|
||||
"添加": "Ajouter",
|
||||
"使用原型查询": "Utiliser une requête prototype"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "stretching",
|
||||
"居中": "Centrato",
|
||||
"边距": "Margini",
|
||||
"文字区高度": "Altezza area testo"
|
||||
"文字区高度": "Altezza area testo",
|
||||
"标签": "etichetta",
|
||||
"存在": "esistenza",
|
||||
"标签集": "Set di etichette",
|
||||
"添加": "Aggiungi",
|
||||
"使用原型查询": "Utilizzo di query prototipali"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "押し出し",
|
||||
"居中": "中央揃え",
|
||||
"边距": "マージン",
|
||||
"文字区高度": "テキスト領域の高さ"
|
||||
"文字区高度": "テキスト領域の高さ",
|
||||
"标签": "タブ",
|
||||
"存在": "存在する",
|
||||
"标签集": "ラベルセット",
|
||||
"添加": "追加",
|
||||
"使用原型查询": "プロトタイプクエリーの使用"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "스트레치",
|
||||
"居中": "가운데",
|
||||
"边距": "여백",
|
||||
"文字区高度": "문자 영역 높이"
|
||||
"文字区高度": "문자 영역 높이",
|
||||
"标签": "레이블",
|
||||
"存在": "존재",
|
||||
"标签集": "태그 세트",
|
||||
"添加": "추가",
|
||||
"使用原型查询": "원형 조회 사용"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "rozciąganie",
|
||||
"居中": "Wyśrodkowane",
|
||||
"边距": "Marginesy",
|
||||
"文字区高度": "Wysokość obszaru tekstu"
|
||||
"文字区高度": "Wysokość obszaru tekstu",
|
||||
"标签": "etykieta",
|
||||
"存在": "istnienie",
|
||||
"标签集": "Zestaw etykiet",
|
||||
"添加": "Dodaj",
|
||||
"使用原型查询": "Korzystanie z prototypowych zapytań"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "Растяжка",
|
||||
"居中": "В центре",
|
||||
"边距": "Границы",
|
||||
"文字区高度": "Высота зоны"
|
||||
"文字区高度": "Высота зоны",
|
||||
"标签": "Метки",
|
||||
"存在": "Наличие",
|
||||
"标签集": "Набор меток",
|
||||
"添加": "Добавить",
|
||||
"使用原型查询": "Использовать запрос прототипа"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "ยืดออก",
|
||||
"居中": "ศูนย์กลาง",
|
||||
"边距": "ขอบ",
|
||||
"文字区高度": "ความสูงของโซนคำ"
|
||||
"文字区高度": "ความสูงของโซนคำ",
|
||||
"标签": "ป้ายกำกับ",
|
||||
"存在": "การปรากฏตัว",
|
||||
"标签集": "ชุดแท็ก",
|
||||
"添加": "เพิ่ม",
|
||||
"使用原型查询": "การใช้แบบสอบถามต้นแบบ"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "stretching",
|
||||
"居中": "Centered",
|
||||
"边距": "Margins",
|
||||
"文字区高度": "Metin alanının yüksekliği"
|
||||
"文字区高度": "Metin alanının yüksekliği",
|
||||
"标签": "etiket",
|
||||
"存在": "varlığı",
|
||||
"标签集": "Etiket seti",
|
||||
"添加": "Ekle",
|
||||
"使用原型查询": "Prototip sorguları kullanılıyor"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "розтягування",
|
||||
"居中": "З центром",
|
||||
"边距": "Марги",
|
||||
"文字区高度": "Висота області тексту"
|
||||
"文字区高度": "Висота області тексту",
|
||||
"标签": "мітка",
|
||||
"存在": "існування",
|
||||
"标签集": "Встановлення мітки",
|
||||
"添加": "Додати",
|
||||
"使用原型查询": "Використання запитів прототипу"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "căng",
|
||||
"居中": "Ở giữa",
|
||||
"边距": "Viền",
|
||||
"文字区高度": "Chiều cao vùng văn bản"
|
||||
"文字区高度": "Chiều cao vùng văn bản",
|
||||
"标签": "Trang chủ",
|
||||
"存在": "Hiện diện",
|
||||
"标签集": "Bộ thẻ",
|
||||
"添加": "Thêm",
|
||||
"使用原型查询": "Truy vấn với Prototype"
|
||||
}
|
@ -752,5 +752,10 @@
|
||||
"拉伸": "",
|
||||
"居中": "",
|
||||
"边距": "",
|
||||
"文字区高度": ""
|
||||
"文字区高度": "",
|
||||
"标签": "",
|
||||
"存在": "",
|
||||
"标签集": "",
|
||||
"添加": "",
|
||||
"使用原型查询": ""
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user