1
0
Fork 0
mirror of synced 2024-06-02 02:34:40 +12:00

Auto update Images

This commit is contained in:
Dummerle 2020-12-06 16:54:17 +01:00
parent 1ce098c278
commit 9d40e748e5
4 changed files with 27 additions and 11 deletions

View file

@ -47,8 +47,8 @@ class InstallDialog(QDialog):
class GameSettingsDialog(QDialog):
action: str = None
def __init__(self, game):
super(GameSettingsDialog, self).__init__()
def __init__(self, game, parent):
super(GameSettingsDialog, self).__init__(parent=parent)
self.game = game
self.layout = QVBoxLayout()
self.layout.addWidget(QLabel("Einstellungen"))

View file

@ -118,10 +118,9 @@ class GameWidget(QWidget):
return "gold" # TODO
def settings(self):
settings_dialog = GameSettingsDialog(self.game)
settings_dialog = GameSettingsDialog(self.game, self)
action = settings_dialog.get_settings()
if action == "uninstall":
legendaryUtils.uninstall(self.app_name, self.core)
self.signal.emit(self.app_name)
@ -163,14 +162,18 @@ class UninstalledGameWidget(QWidget):
logger.info("install " + self.title)
dia = InstallDialog(self.game)
data = dia.get_data()
print(data)
if data != 0:
path = data.get("install_path")
logger.info(f"install {self.app_name} in path {path}")
# TODO
self.proc = QProcess()
self.proc.start("legendary", f"-y --base-path {path} {self.app_name}".split(" "))
self.proc.finished.connect(self.download_finished)
self.proc.start("legendary", ["-y", f"--base-path {path}", self.app_name])
# legendaryUtils.install(self.app_name, path=path)
else:
logger.info("Download canceled")
def download_finished(self):
self.setVisible(False)

View file

@ -1,3 +1,4 @@
import json
import os
from logging import getLogger
@ -17,19 +18,31 @@ def download_images(signal: pyqtSignal, core: LegendaryCore):
# Download Images
for i, game in enumerate(sorted(core.get_game_list(), key=lambda x: x.app_title)):
# if game.app_name == "CrabEA":
# print(game.metadata)
if not os.path.isdir(f"{IMAGE_DIR}/" + game.app_name):
os.mkdir(f"{IMAGE_DIR}/" + game.app_name)
if not os.path.isfile(f"{IMAGE_DIR}/{game.app_name}/image.json"):
json_data = {"DieselGameBoxTall": None, "DieselGameBoxLogo": None}
else:
json_data = json.load(open(f"{IMAGE_DIR}/{game.app_name}/image.json", "r"))
for image in game.metadata["keyImages"]:
if image["type"] == "DieselGameBoxTall" or image["type"] == "DieselGameBoxLogo":
if not os.path.isfile(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png"):
if not os.path.isdir(f"{IMAGE_DIR}/" + game.app_name):
os.mkdir(f"{IMAGE_DIR}/" + game.app_name)
if json_data[image["type"]] != image["md5"] or not os.path.isfile(
f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png"):
# Download
json_data[image["type"]] = image["md5"]
# os.remove(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png")
json.dump(json_data, open(f"{IMAGE_DIR}/{game.app_name}/image.json", "w"))
logger.info(f"Download Image for Game: {game.app_title}")
url = image["url"]
with open(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png", "wb") as f:
f.write(requests.get(url).content)
f.close()
else:
logger.info(f"Image for {game.app_title} exists")
if not os.path.isfile(f'{IMAGE_DIR}/' + game.app_name + '/UninstalledArt.png'):

View file

@ -1207,7 +1207,7 @@ QComboBox {
padding-right: 36px;
/* 4 + 16*2 See scrollbar size */
/* Fixes #103, #111 */
min-height: 1.5em;
/* min-height: 1.5em; */
/* padding-top: 2px; removed to fix #132 */
/* padding-bottom: 2px; removed to fix #132 */
/* min-width: 75px; removed to fix #109 */