mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-13 07:33:53 +08:00
.
This commit is contained in:
parent
14f4bc1dc0
commit
475501b678
@ -1,7 +1,7 @@
|
||||
|
||||
set(VERSION_MAJOR 6)
|
||||
set(VERSION_MINOR 16)
|
||||
set(VERSION_PATCH 1)
|
||||
set(VERSION_PATCH 2)
|
||||
set(VERSION_REVISION 0)
|
||||
set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}")
|
||||
add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)
|
||||
|
@ -9,6 +9,7 @@ from gui.dynalang import LAction
|
||||
from gui.dialog_savedgame_v3 import dialog_savedgame_v3
|
||||
from gui.dialog_savedgame_legacy import dialog_savedgame_legacy
|
||||
from gui.dialog_savedgame_setting import dialog_setting_game, userlabelset
|
||||
from myutils.utils import targetmod
|
||||
from myutils.wrapper import Singleton_close, tryprint
|
||||
from gui.specialwidget import lazyscrollflow
|
||||
from myutils.config import (
|
||||
@ -17,6 +18,7 @@ from myutils.config import (
|
||||
_TR,
|
||||
get_launchpath,
|
||||
globalconfig,
|
||||
extradatas,
|
||||
)
|
||||
from gui.usefulwidget import (
|
||||
saveposwindow,
|
||||
@ -366,24 +368,28 @@ class ItemWidget(QWidget):
|
||||
self._lb.setFixedHeight(globalconfig["dialog_savegame_layout"]["textH"])
|
||||
self._img.switch()
|
||||
|
||||
def __init__(self, gameuid, pixmap, file) -> None:
|
||||
def __init__(self, gameuid) -> None:
|
||||
super().__init__()
|
||||
self.gameuid = gameuid
|
||||
self.file = file
|
||||
self.maskshowfileexists = QLabel(self)
|
||||
self.l = QVBoxLayout(self)
|
||||
self.l.setSpacing(0)
|
||||
self.l.setContentsMargins(
|
||||
*([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)
|
||||
if self._img._pixmap.isNull():
|
||||
self.l.setAlignment(Qt.AlignmentFlag.AlignBottom)
|
||||
else:
|
||||
self._lb.setFixedHeight(globalconfig["dialog_savegame_layout"]["textH"])
|
||||
self.l.addWidget(self._img)
|
||||
self._lb.setText(file)
|
||||
self._lb.setText(savehook_new_data[gameuid]["title"])
|
||||
self._lb.setWordWrap(True)
|
||||
self._lb.setObjectName("savegame_textfont1")
|
||||
self._lb.setAlignment(Qt.AlignmentFlag.AlignHCenter)
|
||||
@ -808,9 +814,7 @@ class dialog_savedgame_new(QWidget):
|
||||
_btn.setEnabled(_able1)
|
||||
|
||||
def getagameitem(self, k, focus):
|
||||
gameitem = ItemWidget(
|
||||
k, functools.partial(getpixfunction, k), savehook_new_data[k]["title"]
|
||||
)
|
||||
gameitem = ItemWidget(k)
|
||||
gameitem.doubleclicked.connect(
|
||||
functools.partial(startgamecheck, self, getreflist(self.reftagid))
|
||||
)
|
||||
|
@ -14,6 +14,7 @@ from myutils.config import (
|
||||
uid2gamepath,
|
||||
get_launchpath,
|
||||
_TR,
|
||||
extradatas,
|
||||
savehook_new_list,
|
||||
globalconfig,
|
||||
)
|
||||
@ -171,6 +172,7 @@ def __scaletosize(_pix: QPixmap, tgt):
|
||||
|
||||
|
||||
def getcachedimage(src, small) -> QPixmap:
|
||||
src = extradatas["localedpath"].get(src, src)
|
||||
if not small:
|
||||
return QPixmap(src)
|
||||
if not os.path.exists(src):
|
||||
|
@ -11,7 +11,12 @@ from myutils.config import (
|
||||
globalconfig,
|
||||
)
|
||||
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 gui.inputdialog import autoinitdialog
|
||||
from gui.specialwidget import stackedlist, shrinkableitem, shownumQPushButton
|
||||
@ -106,6 +111,10 @@ class clickitem(QWidget):
|
||||
self._ = _
|
||||
_.setScaledContents(True)
|
||||
_.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.setDevicePixelRatio(self.devicePixelRatioF())
|
||||
_.setPixmap(icon)
|
||||
@ -293,7 +302,7 @@ class previewimages(QWidget):
|
||||
self.list.takeItem(idx)
|
||||
if delfile:
|
||||
try:
|
||||
os.remove(path)
|
||||
os.remove(extradatas["localedpath"].get(path, path))
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -352,24 +361,12 @@ class viewpixmap_x(QWidget):
|
||||
self.maybehavecomment.clicked.connect(self.viscomment)
|
||||
self.commentedit = QPlainTextEdit(self)
|
||||
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.centerwidgetlayout = QVBoxLayout()
|
||||
audio = QHBoxLayout()
|
||||
self.recordbtn = statusbutton(icons=["fa.microphone", "fa.stop"])
|
||||
self.recordbtn.clicked.connect(self.startorendrecord)
|
||||
self.centerwidget.setLayout(self.centerwidgetlayout)
|
||||
self.centerwidgetlayout.addWidget(self.timenothide)
|
||||
self.centerwidgetlayout.addWidget(self.pathandopen)
|
||||
self.centerwidgetlayout.addWidget(self.commentedit)
|
||||
self.centerwidgetlayout.addLayout(audio)
|
||||
audio.addWidget(self.recordbtn)
|
||||
@ -435,8 +432,6 @@ class viewpixmap_x(QWidget):
|
||||
return
|
||||
tgt = image + os.path.splitext(path)[1]
|
||||
shutil.copy(path, tgt)
|
||||
if "imagerefmp3" not in extradatas:
|
||||
extradatas["imagerefmp3"] = {}
|
||||
extradatas["imagerefmp3"][image] = tgt
|
||||
|
||||
self.btnplay.setEnabled(self.checkplayable())
|
||||
@ -447,8 +442,6 @@ class viewpixmap_x(QWidget):
|
||||
self.recorder = None
|
||||
|
||||
def changecommit(self):
|
||||
if "imagecomment" not in extradatas:
|
||||
extradatas["imagecomment"] = {}
|
||||
extradatas["imagecomment"][self.currentimage] = self.commentedit.toPlainText()
|
||||
|
||||
def viscomment(self):
|
||||
@ -483,21 +476,21 @@ class viewpixmap_x(QWidget):
|
||||
|
||||
self.currentimage = path
|
||||
self.centerwidget.setVisible(False)
|
||||
self.pathandopen.setText(path)
|
||||
self.pathview.setText(path)
|
||||
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:
|
||||
timestamp = None
|
||||
self.infoview.setText(timestamp)
|
||||
self.commentedit.setPlainText(extradatas.get("imagecomment", {}).get(path, ""))
|
||||
self.timenothide.setText(timestamp)
|
||||
if not path:
|
||||
pixmap = QPixmap()
|
||||
else:
|
||||
pixmap = QPixmap.fromImage(QImage(path))
|
||||
if pixmap is None or pixmap.isNull():
|
||||
pixmap = QPixmap()
|
||||
pixmap = QPixmap.fromImage(
|
||||
QImage(extradatas["localedpath"].get(path, path))
|
||||
)
|
||||
self.pixmapviewer.showpixmap(pixmap)
|
||||
self.btnplay.setEnabled(self.checkplayable())
|
||||
|
||||
@ -566,7 +559,7 @@ class pixwrapper(QWidget):
|
||||
deleteimage_x = LAction("删除图片文件")
|
||||
hualang = 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(seticon)
|
||||
menu.addAction(copyimage)
|
||||
@ -580,7 +573,7 @@ class pixwrapper(QWidget):
|
||||
if action == deleteimage:
|
||||
self.removecurrent(False)
|
||||
elif copyimage == action:
|
||||
clipboard_set_image(curr)
|
||||
clipboard_set_image(extradatas["localedpath"].get(curr, curr))
|
||||
elif action == deleteimage_x:
|
||||
self.removecurrent(True)
|
||||
elif action == pos:
|
||||
|
@ -4,7 +4,7 @@ import gobject
|
||||
import os
|
||||
from gui.usefulwidget import WebivewWidget
|
||||
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]
|
||||
|
||||
@ -114,16 +114,34 @@ def everymonths_game_images(everymonth):
|
||||
return months
|
||||
|
||||
|
||||
def getuidimage(uid):
|
||||
def getuidimage_local(uid):
|
||||
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 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)
|
||||
else:
|
||||
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(_)
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ import os, hashlib, queue, gobject
|
||||
from myutils.proxy import getproxy
|
||||
from threading import Thread
|
||||
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 traceback import print_exc
|
||||
from requests import RequestException
|
||||
@ -113,9 +113,9 @@ class common:
|
||||
self.__tasks_downloadimg.put(pair)
|
||||
|
||||
def __do_download_img(self, url, save):
|
||||
print(url, save)
|
||||
if os.path.exists(save):
|
||||
return
|
||||
print(url, save)
|
||||
headers = {
|
||||
"sec-ch-ua": '"Microsoft Edge";v="113", "Chromium";v="113", "Not-A.Brand";v="24"',
|
||||
"Referer": "https://vndb.org/",
|
||||
@ -156,18 +156,16 @@ class common:
|
||||
namemap = data.get("namemap", None)
|
||||
developers = data.get("developers", [])
|
||||
webtags = data.get("webtags", [])
|
||||
imagepath_all = data.get("imagepath_all", [])
|
||||
description=data.get('description',None)
|
||||
normaled = [
|
||||
os.path.abspath(_) for _ in savehook_new_data[gameuid]["imagepath_all"]
|
||||
]
|
||||
for _ in imagepath_all:
|
||||
if _ is None:
|
||||
images = data.get("images", [])
|
||||
description = data.get("description", None)
|
||||
for _ in images:
|
||||
if not _:
|
||||
continue
|
||||
norm = os.path.abspath(_)
|
||||
if norm not in normaled:
|
||||
normaled.append(norm)
|
||||
savehook_new_data[gameuid]["imagepath_all"].append(_)
|
||||
extradatas["localedpath"][_] = self.dispatchdownloadtask(_)
|
||||
extradatas["imagefrom"][_] = self.typename
|
||||
if _ in savehook_new_data[gameuid]["imagepath_all"]:
|
||||
continue
|
||||
savehook_new_data[gameuid]["imagepath_all"].append(_)
|
||||
if title:
|
||||
if not savehook_new_data[gameuid]["istitlesetted"]:
|
||||
savehook_new_data[gameuid]["title"] = title
|
||||
@ -176,8 +174,8 @@ class common:
|
||||
_urls = [_[1] for _ in savehook_new_data[gameuid]["relationlinks"]]
|
||||
if _url not in _urls:
|
||||
savehook_new_data[gameuid]["relationlinks"].append((_vis, _url))
|
||||
if description and not savehook_new_data[gameuid].get('description'):
|
||||
savehook_new_data[gameuid]['description']=description
|
||||
if description and not savehook_new_data[gameuid].get("description"):
|
||||
savehook_new_data[gameuid]["description"] = description
|
||||
if namemap:
|
||||
dedump = set()
|
||||
for _ in savehook_new_data[gameuid]["namemap2"]:
|
||||
|
@ -339,10 +339,6 @@ class searcher(common):
|
||||
response = response.json()
|
||||
except:
|
||||
return {}
|
||||
try:
|
||||
imagepath = self.dispatchdownloadtask(response["images"]["large"])
|
||||
except:
|
||||
imagepath = []
|
||||
|
||||
vndbtags = [_["name"] for _ in response["tags"]]
|
||||
developers = []
|
||||
@ -369,7 +365,7 @@ class searcher(common):
|
||||
return {
|
||||
"namemap": namemaps,
|
||||
"title": response["name"],
|
||||
"imagepath_all": [imagepath],
|
||||
"images": [response["images"]["large"]],
|
||||
"webtags": vndbtags,
|
||||
"developers": developers,
|
||||
"description": response["summary"].replace("\n", "<br>"),
|
||||
|
@ -119,7 +119,7 @@ class searcher(common):
|
||||
print(description)
|
||||
return {
|
||||
"title": title,
|
||||
"imagepath_all": [self.dispatchdownloadtask(_) for _ in imags1 + imags2],
|
||||
"images": imags1 + imags2,
|
||||
"webtags": tags,
|
||||
"developers": [devp],
|
||||
"description": description,
|
||||
|
@ -57,7 +57,9 @@ class searcher(common):
|
||||
}
|
||||
|
||||
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,
|
||||
cookies=cookies,
|
||||
)
|
||||
@ -175,10 +177,8 @@ class searcher(common):
|
||||
)
|
||||
return {
|
||||
"title": title,
|
||||
"imagepath_all": [
|
||||
self.dispatchdownloadtask(_.replace("js-", "jp-")) for _ in imags2
|
||||
],
|
||||
"images": [_.replace("js-", "jp-") for _ in imags2],
|
||||
"webtags": tags,
|
||||
"developers": [devp],
|
||||
'description':description
|
||||
"description": description,
|
||||
}
|
||||
|
@ -88,9 +88,7 @@ class searcher(common):
|
||||
)
|
||||
return {
|
||||
"title": data["name"],
|
||||
"imagepath_all": [
|
||||
self.dispatchdownloadtask(re.sub("\\?t=(\\d+)", "", _)) for _ in images
|
||||
],
|
||||
"images": [re.sub("\\?t=(\\d+)", "", _) for _ in images],
|
||||
"webtags": tagsofficial,
|
||||
"developers": devs,
|
||||
"description": data["detailed_description"],
|
||||
|
@ -358,15 +358,12 @@ class searcher(common):
|
||||
infos = getinfosbyvid(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 {
|
||||
"namemap": namemap,
|
||||
"title": infos["title"],
|
||||
"imagepath_all": img + sc,
|
||||
"images": [infos["img"]]
|
||||
+ self.getreleasecvfromhtml(_vid)
|
||||
+ infos["sc"],
|
||||
"webtags": infos["tags"],
|
||||
"developers": infos["dev"],
|
||||
"description": (
|
||||
|
@ -124,7 +124,14 @@ except:
|
||||
translatorsetting = tryreadconfig("translatorsetting.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):
|
||||
default = {
|
||||
"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))
|
||||
else:
|
||||
# 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):
|
||||
os.remove(fname)
|
||||
shutil.copy(fname + ".tmp", fname)
|
||||
|
Loading…
x
Reference in New Issue
Block a user