mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
fix
This commit is contained in:
parent
a63c14c8fd
commit
867faaaca2
@ -560,6 +560,13 @@ class dialog_setting_game(QDialog):
|
|||||||
icon="fa.book",
|
icon="fa.book",
|
||||||
constcolor="#FF69B4",
|
constcolor="#FF69B4",
|
||||||
),
|
),
|
||||||
|
getcolorbutton(
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
lambda: os.startfile('https://vndb.org/v{}'.format(savehook_new_data[exepath]["vid"])),
|
||||||
|
icon="fa.chrome",
|
||||||
|
constcolor="#FF69B4",
|
||||||
|
),
|
||||||
getcolorbutton(
|
getcolorbutton(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@ -812,10 +819,10 @@ class dialog_setting_game(QDialog):
|
|||||||
formLayout.setContentsMargins(0, 0, 0, 0)
|
formLayout.setContentsMargins(0, 0, 0, 0)
|
||||||
self.labelflow = ScrollFlow()
|
self.labelflow = ScrollFlow()
|
||||||
|
|
||||||
def newitem(text, removeable, first=False):
|
def newitem(text, removeable, first=False, _type=tagitem.TYPE_RAND):
|
||||||
qw = tagitem(text, removeable)
|
qw = tagitem(text, removeable, _type)
|
||||||
|
|
||||||
def __(_qw, t):
|
def __(_qw, t, _type):
|
||||||
_qw.remove()
|
_qw.remove()
|
||||||
i = savehook_new_data[exepath]["usertags"].index(t)
|
i = savehook_new_data[exepath]["usertags"].index(t)
|
||||||
self.labelflow.removeidx(i)
|
self.labelflow.removeidx(i)
|
||||||
@ -824,22 +831,24 @@ class dialog_setting_game(QDialog):
|
|||||||
if removeable:
|
if removeable:
|
||||||
qw.removesignal.connect(functools.partial(__, qw))
|
qw.removesignal.connect(functools.partial(__, qw))
|
||||||
|
|
||||||
def _lbclick(t):
|
def _lbclick(tp, t):
|
||||||
try:
|
try:
|
||||||
self.parent().tagswidget.addTag(t)
|
self.parent().tagswidget.addTag(t, tp)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
qw.labelclicked.connect(_lbclick)
|
qw.labelclicked.connect(functools.partial(_lbclick, _type))
|
||||||
if first:
|
if first:
|
||||||
self.labelflow.insertwidget(0, qw)
|
self.labelflow.insertwidget(0, qw)
|
||||||
else:
|
else:
|
||||||
self.labelflow.addwidget(qw)
|
self.labelflow.addwidget(qw)
|
||||||
|
|
||||||
for tag in savehook_new_data[exepath]["usertags"]:
|
for tag in savehook_new_data[exepath]["usertags"]:
|
||||||
newitem(tag, True)
|
newitem(tag, True, _type=tagitem.TYPE_USERTAG)
|
||||||
|
for tag in savehook_new_data[exepath]["developers"]:
|
||||||
|
newitem(tag, False, _type=tagitem.TYPE_DEVELOPER)
|
||||||
for tag in getvndbrealtags(savehook_new_data[exepath]["vndbtags"]):
|
for tag in getvndbrealtags(savehook_new_data[exepath]["vndbtags"]):
|
||||||
newitem(tag, False)
|
newitem(tag, False, _type=tagitem.TYPE_TAG)
|
||||||
formLayout.addWidget(self.labelflow)
|
formLayout.addWidget(self.labelflow)
|
||||||
_dict = {"new": 0}
|
_dict = {"new": 0}
|
||||||
|
|
||||||
@ -856,7 +865,7 @@ class dialog_setting_game(QDialog):
|
|||||||
# tag = globalconfig["labelset"][_dict["new"]]
|
# tag = globalconfig["labelset"][_dict["new"]]
|
||||||
if tag and tag not in savehook_new_data[exepath]["usertags"]:
|
if tag and tag not in savehook_new_data[exepath]["usertags"]:
|
||||||
savehook_new_data[exepath]["usertags"].insert(0, tag)
|
savehook_new_data[exepath]["usertags"].insert(0, tag)
|
||||||
newitem(tag, True, True)
|
newitem(tag, True, True, _type=tagitem.TYPE_USERTAG)
|
||||||
combo.clearEditText()
|
combo.clearEditText()
|
||||||
|
|
||||||
button.clicked.connect(_add)
|
button.clicked.connect(_add)
|
||||||
@ -1250,8 +1259,8 @@ class listediter(QDialog):
|
|||||||
|
|
||||||
|
|
||||||
class ClickableLabel(QLabel):
|
class ClickableLabel(QLabel):
|
||||||
def __init__(self, parent=None):
|
def __init__(self):
|
||||||
super().__init__(parent)
|
super().__init__()
|
||||||
self.setClickable(True)
|
self.setClickable(True)
|
||||||
|
|
||||||
def setClickable(self, clickable):
|
def setClickable(self, clickable):
|
||||||
@ -1265,8 +1274,12 @@ class ClickableLabel(QLabel):
|
|||||||
|
|
||||||
|
|
||||||
class tagitem(QWidget):
|
class tagitem(QWidget):
|
||||||
|
TYPE_RAND = 0
|
||||||
removesignal = pyqtSignal(str)
|
TYPE_DEVELOPER = 1
|
||||||
|
TYPE_TAG = 2
|
||||||
|
TYPE_USERTAG = 3
|
||||||
|
TYPE_EXISTS = 4
|
||||||
|
removesignal = pyqtSignal(str, int)
|
||||||
labelclicked = pyqtSignal(str)
|
labelclicked = pyqtSignal(str)
|
||||||
|
|
||||||
def remove(self):
|
def remove(self):
|
||||||
@ -1282,29 +1295,38 @@ class tagitem(QWidget):
|
|||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
painter = QPainter(self)
|
painter = QPainter(self)
|
||||||
painter.setRenderHint(QPainter.Antialiasing)
|
painter.setRenderHint(QPainter.Antialiasing)
|
||||||
|
if self._type == tagitem.TYPE_RAND:
|
||||||
border_color = Qt.black
|
border_color = Qt.black
|
||||||
|
elif self._type == tagitem.TYPE_DEVELOPER:
|
||||||
|
border_color = Qt.red
|
||||||
|
elif self._type == tagitem.TYPE_TAG:
|
||||||
|
border_color = Qt.green
|
||||||
|
elif self._type == tagitem.TYPE_USERTAG:
|
||||||
|
border_color = Qt.blue
|
||||||
|
elif self._type == tagitem.TYPE_EXISTS:
|
||||||
|
border_color = Qt.yellow
|
||||||
border_width = 1
|
border_width = 1
|
||||||
pen = QPen(border_color)
|
pen = QPen(border_color)
|
||||||
pen.setWidth(border_width)
|
pen.setWidth(border_width)
|
||||||
painter.setPen(pen)
|
painter.setPen(pen)
|
||||||
painter.drawRect(self.rect())
|
painter.drawRect(self.rect())
|
||||||
|
|
||||||
def __init__(self, tag, removeable=True) -> None:
|
def __init__(self, tag, removeable=True, _type=TYPE_RAND) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
tagLayout = QHBoxLayout()
|
tagLayout = QHBoxLayout()
|
||||||
tagLayout.setContentsMargins(0, 0, 0, 0)
|
tagLayout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self._type = _type
|
||||||
self.setLayout(tagLayout)
|
self.setLayout(tagLayout)
|
||||||
|
|
||||||
lb = ClickableLabel(tag)
|
lb = ClickableLabel()
|
||||||
|
lb.setText(tag)
|
||||||
lb.clicked.connect(lambda: self.labelclicked.emit(tag))
|
lb.clicked.connect(lambda: self.labelclicked.emit(tag))
|
||||||
tagLayout.addWidget(lb)
|
tagLayout.addWidget(lb)
|
||||||
if removeable:
|
if removeable:
|
||||||
button = getcolorbutton(
|
button = getcolorbutton(
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
lambda: self.removesignal.emit(tag), # self.removeTag(tag),
|
lambda: self.removesignal.emit(tag, self._type), # self.removeTag(tag),
|
||||||
qicon=qtawesome.icon(
|
qicon=qtawesome.icon(
|
||||||
"fa.times",
|
"fa.times",
|
||||||
color="#FF69B4",
|
color="#FF69B4",
|
||||||
@ -1349,9 +1371,20 @@ class TagWidget(QWidget):
|
|||||||
|
|
||||||
self.lineEdit = QComboBox()
|
self.lineEdit = QComboBox()
|
||||||
self.lineEdit.setLineEdit(QLineEdit())
|
self.lineEdit.setLineEdit(QLineEdit())
|
||||||
self.lineEdit.lineEdit().returnPressed.connect(
|
|
||||||
lambda: self.addTag(self.lineEdit.currentText())
|
def callback():
|
||||||
)
|
t = self.lineEdit.currentText()
|
||||||
|
|
||||||
|
if t in globalconfig["labelset"]:
|
||||||
|
tp = tagitem.TYPE_USERTAG
|
||||||
|
else:
|
||||||
|
tp = tagitem.TYPE_RAND
|
||||||
|
self.addTag(self.lineEdit.currentText(), tp)
|
||||||
|
self.lineEdit.clear()
|
||||||
|
self.lineEdit.addItems(globalconfig["labelset"])
|
||||||
|
self.lineEdit.clearEditText()
|
||||||
|
|
||||||
|
self.lineEdit.lineEdit().returnPressed.connect(callback)
|
||||||
|
|
||||||
self.lineEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
|
self.lineEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
|
||||||
|
|
||||||
@ -1368,33 +1401,32 @@ class TagWidget(QWidget):
|
|||||||
|
|
||||||
refreshcombo()
|
refreshcombo()
|
||||||
|
|
||||||
def addTag(self, tag):
|
def addTag(self, tag, _type):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
if not tag:
|
if not tag:
|
||||||
return
|
return
|
||||||
if tag in self.tag2widget:
|
if (tag, _type) in self.tag2widget:
|
||||||
return
|
return
|
||||||
self.tags.append(tag)
|
self.tags.append(tag)
|
||||||
qw = tagitem(tag)
|
qw = tagitem(tag, _type=_type)
|
||||||
qw.removesignal.connect(self.removeTag)
|
qw.removesignal.connect(self.removeTag)
|
||||||
|
|
||||||
layout = self.layout()
|
layout = self.layout()
|
||||||
# layout.insertLayout(layout.count() - 1, tagLayout)
|
# layout.insertLayout(layout.count() - 1, tagLayout)
|
||||||
layout.insertWidget(layout.count() - 1, qw)
|
layout.insertWidget(layout.count() - 1, qw)
|
||||||
self.tag2widget[tag] = qw
|
self.tag2widget[(tag, _type)] = qw
|
||||||
self.lineEdit.clearEditText()
|
self.lineEdit.clearEditText()
|
||||||
self.lineEdit.setFocus()
|
self.lineEdit.setFocus()
|
||||||
self.tagschanged.emit(tuple(self.tag2widget.keys()))
|
self.tagschanged.emit(tuple(self.tag2widget.keys()))
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
|
|
||||||
def removeTag(self, tag):
|
def removeTag(self, tag, _type):
|
||||||
_w = self.tag2widget[tag]
|
_w = self.tag2widget[(tag, _type)]
|
||||||
_w.remove()
|
_w.remove()
|
||||||
|
|
||||||
self.layout().removeWidget(_w)
|
self.layout().removeWidget(_w)
|
||||||
self.tag2widget.pop(tag)
|
self.tag2widget.pop((tag, _type))
|
||||||
self.lineEdit.setFocus()
|
self.lineEdit.setFocus()
|
||||||
self.tagschanged.emit(tuple(self.tag2widget.keys()))
|
self.tagschanged.emit(tuple(self.tag2widget.keys()))
|
||||||
|
|
||||||
@ -1448,11 +1480,9 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
self.newline(res, True)
|
self.newline(res, True)
|
||||||
|
|
||||||
def tagschanged(self, tags):
|
def tagschanged(self, tags):
|
||||||
checkexists = _TR("存在") in tags
|
self.currtags = tags
|
||||||
if checkexists:
|
newtags = tags
|
||||||
_ = list(tags)
|
print(tags)
|
||||||
_.remove(_TR("存在"))
|
|
||||||
tags = tuple(_)
|
|
||||||
ItemWidget.clearfocus()
|
ItemWidget.clearfocus()
|
||||||
self.formLayout.removeWidget(self.flow)
|
self.formLayout.removeWidget(self.flow)
|
||||||
self.idxsave.clear()
|
self.idxsave.clear()
|
||||||
@ -1460,17 +1490,32 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
self.flow.bgclicked.connect(ItemWidget.clearfocus)
|
self.flow.bgclicked.connect(ItemWidget.clearfocus)
|
||||||
self.formLayout.insertWidget(self.formLayout.count() - 1, self.flow)
|
self.formLayout.insertWidget(self.formLayout.count() - 1, self.flow)
|
||||||
for k in savehook_new_list:
|
for k in savehook_new_list:
|
||||||
if checkexists and os.path.exists(k) == False:
|
if newtags != self.currtags:
|
||||||
continue
|
break
|
||||||
|
|
||||||
# print(vndbtags)
|
|
||||||
notshow = False
|
notshow = False
|
||||||
for tag in tags:
|
for tag, _type in tags:
|
||||||
|
if _type == tagitem.TYPE_EXISTS:
|
||||||
|
if os.path.exists(k) == False:
|
||||||
|
notshow = True
|
||||||
|
break
|
||||||
|
elif _type == tagitem.TYPE_DEVELOPER:
|
||||||
|
if tag not in savehook_new_data[k]["developers"]:
|
||||||
|
notshow = True
|
||||||
|
break
|
||||||
|
elif _type == tagitem.TYPE_TAG:
|
||||||
|
if tag not in getvndbrealtags(savehook_new_data[k]["vndbtags"]):
|
||||||
|
notshow = True
|
||||||
|
break
|
||||||
|
elif _type == tagitem.TYPE_USERTAG:
|
||||||
|
if tag not in savehook_new_data[k]["usertags"]:
|
||||||
|
notshow = True
|
||||||
|
break
|
||||||
|
elif _type == tagitem.TYPE_RAND:
|
||||||
if (
|
if (
|
||||||
tag not in getvndbrealtags(savehook_new_data[k]["vndbtags"])
|
tag not in getvndbrealtags(savehook_new_data[k]["vndbtags"])
|
||||||
and tag not in savehook_new_data[k]["usertags"]
|
and tag not in savehook_new_data[k]["usertags"]
|
||||||
and tag not in savehook_new_data[k]["title"]
|
and tag not in savehook_new_data[k]["title"]
|
||||||
and tag != str(savehook_new_data[k]["vid"])
|
and tag not in savehook_new_data[k]["developers"]
|
||||||
):
|
):
|
||||||
notshow = True
|
notshow = True
|
||||||
break
|
break
|
||||||
@ -1526,6 +1571,7 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
showintab(int(self.winId()), True)
|
showintab(int(self.winId()), True)
|
||||||
formLayout = QVBoxLayout()
|
formLayout = QVBoxLayout()
|
||||||
self.tagswidget = TagWidget(self)
|
self.tagswidget = TagWidget(self)
|
||||||
|
self.currtags = tuple()
|
||||||
self.tagswidget.tagschanged.connect(self.tagschanged)
|
self.tagswidget.tagschanged.connect(self.tagschanged)
|
||||||
formLayout.addWidget(self.tagswidget)
|
formLayout.addWidget(self.tagswidget)
|
||||||
self.flow = ScrollFlow()
|
self.flow = ScrollFlow()
|
||||||
@ -1555,7 +1601,7 @@ class dialog_savedgame_new(saveposwindow):
|
|||||||
self.show()
|
self.show()
|
||||||
self.idxsave = []
|
self.idxsave = []
|
||||||
if globalconfig["hide_not_exists"]:
|
if globalconfig["hide_not_exists"]:
|
||||||
self.tagswidget.addTag(_TR("存在"))
|
self.tagswidget.addTag(_TR("存在"), tagitem.TYPE_EXISTS)
|
||||||
else:
|
else:
|
||||||
self.tagschanged(tuple())
|
self.tagschanged(tuple())
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ ocrsetting = tryreadconfig("ocrsetting.json")
|
|||||||
vndbtagdata = tryreadconfig("vndbtagdata.json")
|
vndbtagdata = tryreadconfig("vndbtagdata.json")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getdefaultsavehook(gamepath, title=None):
|
def getdefaultsavehook(gamepath, title=None):
|
||||||
default = {
|
default = {
|
||||||
"localeswitcher": 0,
|
"localeswitcher": 0,
|
||||||
@ -93,6 +92,7 @@ def getdefaultsavehook(gamepath, title=None):
|
|||||||
"usertags": [],
|
"usertags": [],
|
||||||
"traceplaytime_v2": [], # [[start,end]]
|
"traceplaytime_v2": [], # [[start,end]]
|
||||||
"autosavesavedata": "",
|
"autosavesavedata": "",
|
||||||
|
"developers": [],
|
||||||
}
|
}
|
||||||
if gamepath == "0":
|
if gamepath == "0":
|
||||||
default["title"] = "No Game"
|
default["title"] = "No Game"
|
||||||
|
@ -62,6 +62,7 @@ def checkvid(gamepath):
|
|||||||
checkimage(gamepath)
|
checkimage(gamepath)
|
||||||
or checkinfo(gamepath)
|
or checkinfo(gamepath)
|
||||||
or (len(savehook_new_data[gamepath]["vndbtags"]) == 0)
|
or (len(savehook_new_data[gamepath]["vndbtags"]) == 0)
|
||||||
|
or (len(savehook_new_data[gamepath]["developers"]) == 0)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return (
|
return (
|
||||||
@ -131,6 +132,7 @@ def everymethodsthread():
|
|||||||
vid = data.get("vid", None)
|
vid = data.get("vid", None)
|
||||||
title = data.get("title", None)
|
title = data.get("title", None)
|
||||||
namemap = data.get("namemap", None)
|
namemap = data.get("namemap", None)
|
||||||
|
developers = data.get("developers", None)
|
||||||
vndbtags = data.get("vndbtags", None)
|
vndbtags = data.get("vndbtags", None)
|
||||||
if not vid:
|
if not vid:
|
||||||
continue
|
continue
|
||||||
@ -146,7 +148,8 @@ def everymethodsthread():
|
|||||||
savehook_new_data[gamepath]["namemap"] = namemap
|
savehook_new_data[gamepath]["namemap"] = namemap
|
||||||
if vndbtags:
|
if vndbtags:
|
||||||
savehook_new_data[gamepath]["vndbtags"] = vndbtags
|
savehook_new_data[gamepath]["vndbtags"] = vndbtags
|
||||||
|
if developers:
|
||||||
|
savehook_new_data[gamepath]["developers"] = developers
|
||||||
succ = True
|
succ = True
|
||||||
break
|
break
|
||||||
if succ == False:
|
if succ == False:
|
||||||
|
@ -138,6 +138,20 @@ def getvidbytitle_release(title):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def getdevelopersbyid(vid):
|
||||||
|
def _js(js):
|
||||||
|
_ = []
|
||||||
|
for item in js["results"][0]["developers"]:
|
||||||
|
_.append(item["name"])
|
||||||
|
return _
|
||||||
|
|
||||||
|
return safegetvndbjson(
|
||||||
|
"https://api.vndb.org/kana/vn",
|
||||||
|
{"filters": ["id", "=", vid], "fields": "developers.name"},
|
||||||
|
_js,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def getvidbytitle(title):
|
def getvidbytitle(title):
|
||||||
vid = getvidbytitle_vn(title)
|
vid = getvidbytitle_vn(title)
|
||||||
if vid:
|
if vid:
|
||||||
@ -188,12 +202,13 @@ def safedownload():
|
|||||||
js = json.load(ff)
|
js = json.load(ff)
|
||||||
newjs = {}
|
newjs = {}
|
||||||
for item in js:
|
for item in js:
|
||||||
gid = 'g'+str(item['id'])
|
gid = "g" + str(item["id"])
|
||||||
name = item["name"]
|
name = item["name"]
|
||||||
newjs[gid] = name
|
newjs[gid] = name
|
||||||
return newjs
|
return newjs
|
||||||
except:
|
except:
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
|
|
||||||
print_exc()
|
print_exc()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -243,6 +258,7 @@ def searchforidimage(titleorid):
|
|||||||
title = gettitlebyid(vid)
|
title = gettitlebyid(vid)
|
||||||
namemap = getcharnamemapbyid(vid)
|
namemap = getcharnamemapbyid(vid)
|
||||||
vndbtags = getvntagsbyid(vid)
|
vndbtags = getvntagsbyid(vid)
|
||||||
|
developers = getdevelopersbyid(vid)
|
||||||
return {
|
return {
|
||||||
"namemap": namemap,
|
"namemap": namemap,
|
||||||
"title": title,
|
"title": title,
|
||||||
@ -250,6 +266,7 @@ def searchforidimage(titleorid):
|
|||||||
"infopath": vndbdowloadinfo(vid),
|
"infopath": vndbdowloadinfo(vid),
|
||||||
"imagepath": vndbdownloadimg(img),
|
"imagepath": vndbdownloadimg(img),
|
||||||
"vndbtags": vndbtags,
|
"vndbtags": vndbtags,
|
||||||
|
"developers": developers,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user