This commit is contained in:
恍兮惚兮 2024-12-28 19:00:59 +08:00
parent 14f4bc1dc0
commit 475501b678
12 changed files with 89 additions and 76 deletions

View File

@ -1,7 +1,7 @@
set(VERSION_MAJOR 6) set(VERSION_MAJOR 6)
set(VERSION_MINOR 16) set(VERSION_MINOR 16)
set(VERSION_PATCH 1) set(VERSION_PATCH 2)
set(VERSION_REVISION 0) set(VERSION_REVISION 0)
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}") set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp) add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)

View File

@ -9,6 +9,7 @@ from gui.dynalang import LAction
from gui.dialog_savedgame_v3 import dialog_savedgame_v3 from gui.dialog_savedgame_v3 import dialog_savedgame_v3
from gui.dialog_savedgame_legacy import dialog_savedgame_legacy from gui.dialog_savedgame_legacy import dialog_savedgame_legacy
from gui.dialog_savedgame_setting import dialog_setting_game, userlabelset from gui.dialog_savedgame_setting import dialog_setting_game, userlabelset
from myutils.utils import targetmod
from myutils.wrapper import Singleton_close, tryprint from myutils.wrapper import Singleton_close, tryprint
from gui.specialwidget import lazyscrollflow from gui.specialwidget import lazyscrollflow
from myutils.config import ( from myutils.config import (
@ -17,6 +18,7 @@ from myutils.config import (
_TR, _TR,
get_launchpath, get_launchpath,
globalconfig, globalconfig,
extradatas,
) )
from gui.usefulwidget import ( from gui.usefulwidget import (
saveposwindow, saveposwindow,
@ -366,24 +368,28 @@ class ItemWidget(QWidget):
self._lb.setFixedHeight(globalconfig["dialog_savegame_layout"]["textH"]) self._lb.setFixedHeight(globalconfig["dialog_savegame_layout"]["textH"])
self._img.switch() self._img.switch()
def __init__(self, gameuid, pixmap, file) -> None: def __init__(self, gameuid) -> None:
super().__init__() super().__init__()
self.gameuid = gameuid self.gameuid = gameuid
self.file = file
self.maskshowfileexists = QLabel(self) self.maskshowfileexists = QLabel(self)
self.l = QVBoxLayout(self) self.l = QVBoxLayout(self)
self.l.setSpacing(0) self.l.setSpacing(0)
self.l.setContentsMargins( self.l.setContentsMargins(
*([globalconfig["dialog_savegame_layout"]["margin2"]] * 4) *([globalconfig["dialog_savegame_layout"]["margin2"]] * 4)
) )
self._img = IMGWidget(self, pixmap) for image in savehook_new_data[gameuid]["imagepath_all"]:
fr = extradatas["imagefrom"].get(image)
if fr:
targetmod.get(fr).dispatchdownloadtask(image)
self._img = IMGWidget(self, getpixfunction(gameuid))
self._lb = QLabel(self) self._lb = QLabel(self)
if self._img._pixmap.isNull(): if self._img._pixmap.isNull():
self.l.setAlignment(Qt.AlignmentFlag.AlignBottom) self.l.setAlignment(Qt.AlignmentFlag.AlignBottom)
else: else:
self._lb.setFixedHeight(globalconfig["dialog_savegame_layout"]["textH"]) self._lb.setFixedHeight(globalconfig["dialog_savegame_layout"]["textH"])
self.l.addWidget(self._img) self.l.addWidget(self._img)
self._lb.setText(file) self._lb.setText(savehook_new_data[gameuid]["title"])
self._lb.setWordWrap(True) self._lb.setWordWrap(True)
self._lb.setObjectName("savegame_textfont1") self._lb.setObjectName("savegame_textfont1")
self._lb.setAlignment(Qt.AlignmentFlag.AlignHCenter) self._lb.setAlignment(Qt.AlignmentFlag.AlignHCenter)
@ -808,9 +814,7 @@ class dialog_savedgame_new(QWidget):
_btn.setEnabled(_able1) _btn.setEnabled(_able1)
def getagameitem(self, k, focus): def getagameitem(self, k, focus):
gameitem = ItemWidget( gameitem = ItemWidget(k)
k, functools.partial(getpixfunction, k), savehook_new_data[k]["title"]
)
gameitem.doubleclicked.connect( gameitem.doubleclicked.connect(
functools.partial(startgamecheck, self, getreflist(self.reftagid)) functools.partial(startgamecheck, self, getreflist(self.reftagid))
) )

View File

@ -14,6 +14,7 @@ from myutils.config import (
uid2gamepath, uid2gamepath,
get_launchpath, get_launchpath,
_TR, _TR,
extradatas,
savehook_new_list, savehook_new_list,
globalconfig, globalconfig,
) )
@ -171,6 +172,7 @@ def __scaletosize(_pix: QPixmap, tgt):
def getcachedimage(src, small) -> QPixmap: def getcachedimage(src, small) -> QPixmap:
src = extradatas["localedpath"].get(src, src)
if not small: if not small:
return QPixmap(src) return QPixmap(src)
if not os.path.exists(src): if not os.path.exists(src):

View File

@ -11,7 +11,12 @@ from myutils.config import (
globalconfig, globalconfig,
) )
from myutils.hwnd import clipboard_set_image from myutils.hwnd import clipboard_set_image
from myutils.utils import get_time_stamp, loopbackrecorder, getimagefilefilter from myutils.utils import (
get_time_stamp,
loopbackrecorder,
getimagefilefilter,
targetmod,
)
from myutils.audioplayer import playonce from myutils.audioplayer import playonce
from gui.inputdialog import autoinitdialog from gui.inputdialog import autoinitdialog
from gui.specialwidget import stackedlist, shrinkableitem, shownumQPushButton from gui.specialwidget import stackedlist, shrinkableitem, shownumQPushButton
@ -106,6 +111,10 @@ class clickitem(QWidget):
self._ = _ self._ = _
_.setScaledContents(True) _.setScaledContents(True)
_.setStyleSheet("background:transparent") _.setStyleSheet("background:transparent")
for image in savehook_new_data[uid]["imagepath_all"]:
fr = extradatas["imagefrom"].get(image)
if fr:
targetmod.get(fr).dispatchdownloadtask(image)
icon = getpixfunction(uid, small=True, iconfirst=True) icon = getpixfunction(uid, small=True, iconfirst=True)
icon.setDevicePixelRatio(self.devicePixelRatioF()) icon.setDevicePixelRatio(self.devicePixelRatioF())
_.setPixmap(icon) _.setPixmap(icon)
@ -293,7 +302,7 @@ class previewimages(QWidget):
self.list.takeItem(idx) self.list.takeItem(idx)
if delfile: if delfile:
try: try:
os.remove(path) os.remove(extradatas["localedpath"].get(path, path))
except: except:
pass pass
@ -352,24 +361,12 @@ class viewpixmap_x(QWidget):
self.maybehavecomment.clicked.connect(self.viscomment) self.maybehavecomment.clicked.connect(self.viscomment)
self.commentedit = QPlainTextEdit(self) self.commentedit = QPlainTextEdit(self)
self.commentedit.textChanged.connect(self.changecommit) self.commentedit.textChanged.connect(self.changecommit)
self.timenothide = QLabel(self)
self.timenothide.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.pathandopen = QPushButton(self)
self.pathandopen.clicked.connect(
lambda: (
os.startfile(os.path.abspath(self.currentimage))
if self.currentimage
else ""
)
)
self.centerwidget = QWidget(self) self.centerwidget = QWidget(self)
self.centerwidgetlayout = QVBoxLayout() self.centerwidgetlayout = QVBoxLayout()
audio = QHBoxLayout() audio = QHBoxLayout()
self.recordbtn = statusbutton(icons=["fa.microphone", "fa.stop"]) self.recordbtn = statusbutton(icons=["fa.microphone", "fa.stop"])
self.recordbtn.clicked.connect(self.startorendrecord) self.recordbtn.clicked.connect(self.startorendrecord)
self.centerwidget.setLayout(self.centerwidgetlayout) self.centerwidget.setLayout(self.centerwidgetlayout)
self.centerwidgetlayout.addWidget(self.timenothide)
self.centerwidgetlayout.addWidget(self.pathandopen)
self.centerwidgetlayout.addWidget(self.commentedit) self.centerwidgetlayout.addWidget(self.commentedit)
self.centerwidgetlayout.addLayout(audio) self.centerwidgetlayout.addLayout(audio)
audio.addWidget(self.recordbtn) audio.addWidget(self.recordbtn)
@ -435,8 +432,6 @@ class viewpixmap_x(QWidget):
return return
tgt = image + os.path.splitext(path)[1] tgt = image + os.path.splitext(path)[1]
shutil.copy(path, tgt) shutil.copy(path, tgt)
if "imagerefmp3" not in extradatas:
extradatas["imagerefmp3"] = {}
extradatas["imagerefmp3"][image] = tgt extradatas["imagerefmp3"][image] = tgt
self.btnplay.setEnabled(self.checkplayable()) self.btnplay.setEnabled(self.checkplayable())
@ -447,8 +442,6 @@ class viewpixmap_x(QWidget):
self.recorder = None self.recorder = None
def changecommit(self): def changecommit(self):
if "imagecomment" not in extradatas:
extradatas["imagecomment"] = {}
extradatas["imagecomment"][self.currentimage] = self.commentedit.toPlainText() extradatas["imagecomment"][self.currentimage] = self.commentedit.toPlainText()
def viscomment(self): def viscomment(self):
@ -483,21 +476,21 @@ class viewpixmap_x(QWidget):
self.currentimage = path self.currentimage = path
self.centerwidget.setVisible(False) self.centerwidget.setVisible(False)
self.pathandopen.setText(path)
self.pathview.setText(path) self.pathview.setText(path)
try: try:
timestamp = get_time_stamp(ct=os.path.getctime(path), ms=False) timestamp = get_time_stamp(
ct=os.path.getctime(extradatas["localedpath"].get(path, path)), ms=False
)
except: except:
timestamp = None timestamp = None
self.infoview.setText(timestamp) self.infoview.setText(timestamp)
self.commentedit.setPlainText(extradatas.get("imagecomment", {}).get(path, "")) self.commentedit.setPlainText(extradatas.get("imagecomment", {}).get(path, ""))
self.timenothide.setText(timestamp)
if not path: if not path:
pixmap = QPixmap() pixmap = QPixmap()
else: else:
pixmap = QPixmap.fromImage(QImage(path)) pixmap = QPixmap.fromImage(
if pixmap is None or pixmap.isNull(): QImage(extradatas["localedpath"].get(path, path))
pixmap = QPixmap() )
self.pixmapviewer.showpixmap(pixmap) self.pixmapviewer.showpixmap(pixmap)
self.btnplay.setEnabled(self.checkplayable()) self.btnplay.setEnabled(self.checkplayable())
@ -566,7 +559,7 @@ class pixwrapper(QWidget):
deleteimage_x = LAction("删除图片文件") deleteimage_x = LAction("删除图片文件")
hualang = LAction("画廊") hualang = LAction("画廊")
pos = LAction("位置") pos = LAction("位置")
if curr and os.path.exists(curr): if curr and os.path.exists(extradatas["localedpath"].get(curr, curr)):
menu.addAction(setimage) menu.addAction(setimage)
menu.addAction(seticon) menu.addAction(seticon)
menu.addAction(copyimage) menu.addAction(copyimage)
@ -580,7 +573,7 @@ class pixwrapper(QWidget):
if action == deleteimage: if action == deleteimage:
self.removecurrent(False) self.removecurrent(False)
elif copyimage == action: elif copyimage == action:
clipboard_set_image(curr) clipboard_set_image(extradatas["localedpath"].get(curr, curr))
elif action == deleteimage_x: elif action == deleteimage_x:
self.removecurrent(True) self.removecurrent(True)
elif action == pos: elif action == pos:

View File

@ -4,7 +4,7 @@ import gobject
import os import os
from gui.usefulwidget import WebivewWidget from gui.usefulwidget import WebivewWidget
from datetime import datetime, timedelta from datetime import datetime, timedelta
from myutils.config import savehook_new_data, globalconfig from myutils.config import savehook_new_data, globalconfig, extradatas
timestamps = [1609459200, 1672531200, 1704067200, 1720032000] timestamps = [1609459200, 1672531200, 1704067200, 1720032000]
@ -114,16 +114,34 @@ def everymonths_game_images(everymonth):
return months return months
def getuidimage(uid): def getuidimage_local(uid):
data = savehook_new_data.get(uid) data = savehook_new_data.get(uid)
if not data: if not data:
return return
main = savehook_new_data[uid].get("currentmainimage") main = savehook_new_data[uid].get("currentmainimage")
if (main in savehook_new_data[uid]["imagepath_all"]) and os.path.exists(main): if (main in savehook_new_data[uid]["imagepath_all"]) and os.path.exists(
extradatas["localedpath"].get(main, main)
):
return os.path.abspath(main) return os.path.abspath(main)
else: else:
for _ in savehook_new_data[uid]["imagepath_all"]: for _ in savehook_new_data[uid]["imagepath_all"]:
if os.path.exists(_): if os.path.exists(extradatas["localedpath"].get(_, _)):
return os.path.abspath(_)
def getuidimage(uid):
l = getuidimage_local(uid)
if l:
return l
data = savehook_new_data.get(uid)
if not data:
return
main = savehook_new_data[uid].get("currentmainimage")
if (main in savehook_new_data[uid]["imagepath_all"]) and main.startswith("http"):
return main
else:
for _ in savehook_new_data[uid]["imagepath_all"]:
if _.startswith("http"):
return os.path.abspath(_) return os.path.abspath(_)

View File

@ -2,7 +2,7 @@ import os, hashlib, queue, gobject
from myutils.proxy import getproxy from myutils.proxy import getproxy
from threading import Thread from threading import Thread
from myutils.commonbase import proxysession from myutils.commonbase import proxysession
from myutils.config import globalconfig, savehook_new_data, namemapcast from myutils.config import globalconfig, savehook_new_data, namemapcast, extradatas
from myutils.utils import getlangtgt from myutils.utils import getlangtgt
from traceback import print_exc from traceback import print_exc
from requests import RequestException from requests import RequestException
@ -113,9 +113,9 @@ class common:
self.__tasks_downloadimg.put(pair) self.__tasks_downloadimg.put(pair)
def __do_download_img(self, url, save): def __do_download_img(self, url, save):
print(url, save)
if os.path.exists(save): if os.path.exists(save):
return return
print(url, save)
headers = { headers = {
"sec-ch-ua": '"Microsoft Edge";v="113", "Chromium";v="113", "Not-A.Brand";v="24"', "sec-ch-ua": '"Microsoft Edge";v="113", "Chromium";v="113", "Not-A.Brand";v="24"',
"Referer": "https://vndb.org/", "Referer": "https://vndb.org/",
@ -156,17 +156,15 @@ class common:
namemap = data.get("namemap", None) namemap = data.get("namemap", None)
developers = data.get("developers", []) developers = data.get("developers", [])
webtags = data.get("webtags", []) webtags = data.get("webtags", [])
imagepath_all = data.get("imagepath_all", []) images = data.get("images", [])
description=data.get('description',None) description = data.get("description", None)
normaled = [ for _ in images:
os.path.abspath(_) for _ in savehook_new_data[gameuid]["imagepath_all"] if not _:
] continue
for _ in imagepath_all: extradatas["localedpath"][_] = self.dispatchdownloadtask(_)
if _ is None: extradatas["imagefrom"][_] = self.typename
if _ in savehook_new_data[gameuid]["imagepath_all"]:
continue continue
norm = os.path.abspath(_)
if norm not in normaled:
normaled.append(norm)
savehook_new_data[gameuid]["imagepath_all"].append(_) savehook_new_data[gameuid]["imagepath_all"].append(_)
if title: if title:
if not savehook_new_data[gameuid]["istitlesetted"]: if not savehook_new_data[gameuid]["istitlesetted"]:
@ -176,8 +174,8 @@ class common:
_urls = [_[1] for _ in savehook_new_data[gameuid]["relationlinks"]] _urls = [_[1] for _ in savehook_new_data[gameuid]["relationlinks"]]
if _url not in _urls: if _url not in _urls:
savehook_new_data[gameuid]["relationlinks"].append((_vis, _url)) savehook_new_data[gameuid]["relationlinks"].append((_vis, _url))
if description and not savehook_new_data[gameuid].get('description'): if description and not savehook_new_data[gameuid].get("description"):
savehook_new_data[gameuid]['description']=description savehook_new_data[gameuid]["description"] = description
if namemap: if namemap:
dedump = set() dedump = set()
for _ in savehook_new_data[gameuid]["namemap2"]: for _ in savehook_new_data[gameuid]["namemap2"]:

View File

@ -339,10 +339,6 @@ class searcher(common):
response = response.json() response = response.json()
except: except:
return {} return {}
try:
imagepath = self.dispatchdownloadtask(response["images"]["large"])
except:
imagepath = []
vndbtags = [_["name"] for _ in response["tags"]] vndbtags = [_["name"] for _ in response["tags"]]
developers = [] developers = []
@ -369,7 +365,7 @@ class searcher(common):
return { return {
"namemap": namemaps, "namemap": namemaps,
"title": response["name"], "title": response["name"],
"imagepath_all": [imagepath], "images": [response["images"]["large"]],
"webtags": vndbtags, "webtags": vndbtags,
"developers": developers, "developers": developers,
"description": response["summary"].replace("\n", "<br>"), "description": response["summary"].replace("\n", "<br>"),

View File

@ -119,7 +119,7 @@ class searcher(common):
print(description) print(description)
return { return {
"title": title, "title": title,
"imagepath_all": [self.dispatchdownloadtask(_) for _ in imags1 + imags2], "images": imags1 + imags2,
"webtags": tags, "webtags": tags,
"developers": [devp], "developers": [devp],
"description": description, "description": description,

View File

@ -57,7 +57,9 @@ class searcher(common):
} }
response = self.proxysession.get( response = self.proxysession.get(
"https://dlsoft.dmm.co.jp/search/?floor=digital_pcgame&searchstr={}&service=pcgame".format(title), "https://dlsoft.dmm.co.jp/search/?floor=digital_pcgame&searchstr={}&service=pcgame".format(
title
),
headers=headers, headers=headers,
cookies=cookies, cookies=cookies,
) )
@ -175,10 +177,8 @@ class searcher(common):
) )
return { return {
"title": title, "title": title,
"imagepath_all": [ "images": [_.replace("js-", "jp-") for _ in imags2],
self.dispatchdownloadtask(_.replace("js-", "jp-")) for _ in imags2
],
"webtags": tags, "webtags": tags,
"developers": [devp], "developers": [devp],
'description':description "description": description,
} }

View File

@ -88,9 +88,7 @@ class searcher(common):
) )
return { return {
"title": data["name"], "title": data["name"],
"imagepath_all": [ "images": [re.sub("\\?t=(\\d+)", "", _) for _ in images],
self.dispatchdownloadtask(re.sub("\\?t=(\\d+)", "", _)) for _ in images
],
"webtags": tagsofficial, "webtags": tagsofficial,
"developers": devs, "developers": devs,
"description": data["detailed_description"], "description": data["detailed_description"],

View File

@ -358,15 +358,12 @@ class searcher(common):
infos = getinfosbyvid(self.proxy, vid) infos = getinfosbyvid(self.proxy, vid)
namemap = getcharnamemapbyid(self.proxy, vid) namemap = getcharnamemapbyid(self.proxy, vid)
img = [
self.dispatchdownloadtask(_)
for _ in ([infos["img"]] + self.getreleasecvfromhtml(_vid))
]
sc = [self.dispatchdownloadtask(_) for _ in infos["sc"]]
return { return {
"namemap": namemap, "namemap": namemap,
"title": infos["title"], "title": infos["title"],
"imagepath_all": img + sc, "images": [infos["img"]]
+ self.getreleasecvfromhtml(_vid)
+ infos["sc"],
"webtags": infos["tags"], "webtags": infos["tags"],
"developers": infos["dev"], "developers": infos["dev"],
"description": ( "description": (

View File

@ -124,7 +124,14 @@ except:
translatorsetting = tryreadconfig("translatorsetting.json") translatorsetting = tryreadconfig("translatorsetting.json")
ocrsetting = tryreadconfig("ocrsetting.json") ocrsetting = tryreadconfig("ocrsetting.json")
if "imagerefmp3" not in extradatas:
extradatas["imagerefmp3"] = {}
if "imagecomment" not in extradatas:
extradatas["imagecomment"] = {}
if "localedpath" not in extradatas:
extradatas["localedpath"] = {}
if "imagefrom" not in extradatas:
extradatas["imagefrom"] = {}
def getdefaultsavehook(title=None): def getdefaultsavehook(title=None):
default = { default = {
"gamepath": "", # 不要直接访问要通过uid2gamepath来间接访问 "gamepath": "", # 不要直接访问要通过uid2gamepath来间接访问
@ -694,7 +701,7 @@ def safesave(fname, js, beatiful=True):
ff.write(json.dumps(js, ensure_ascii=False, sort_keys=False, indent=4)) ff.write(json.dumps(js, ensure_ascii=False, sort_keys=False, indent=4))
else: else:
# savegamedata 1w条时indent=4要2秒不indent 0.37秒不ensure_ascii 0.27秒,用不着数据库了 # savegamedata 1w条时indent=4要2秒不indent 0.37秒不ensure_ascii 0.27秒,用不着数据库了
ff.write(json.dumps(js, sort_keys=False)) ff.write(json.dumps(js, ensure_ascii=False, sort_keys=False))
if os.path.exists(fname): if os.path.exists(fname):
os.remove(fname) os.remove(fname)
shutil.copy(fname + ".tmp", fname) shutil.copy(fname + ".tmp", fname)