1
0
Fork 0
mirror of synced 2024-06-26 10:11:19 +12:00

Auto sync saves on startup if enabled

This commit is contained in:
Dummerle 2021-05-12 09:19:50 +02:00
parent 4378df2791
commit b4d10cc77e
3 changed files with 44 additions and 31 deletions

View file

@ -1,7 +1,7 @@
import os
from logging import getLogger
from PyQt5.QtCore import QThread, pyqtSignal, Qt
from PyQt5.QtCore import QThread, pyqtSignal, Qt, QSettings
from PyQt5.QtWidgets import QVBoxLayout, QPushButton, QHBoxLayout, QLabel, QGroupBox
from custom_legendary.core import LegendaryCore
@ -167,6 +167,11 @@ class SyncWidget(QGroupBox):
self.layout.addStretch(1)
self.setLayout(self.layout)
if self.res == SaveGameStatus.REMOTE_NEWER:
settings = QSettings()
if settings.value(f"{igame.app_name}/auto_sync_cloud", False, bool):
self.download()
def change_path(self):
path = PathInputDialog("Select directory", "Select savepath. Warning: Do not change if you are not sure",
self.igame.save_path).get_path()

View file

@ -830,7 +830,7 @@ Installationsgröße: {} GB</translation>
<context>
<name>MainWindow</name>
<message>
<location filename="../components/main_window.py" line="82"/>
<location filename="../components/main_window.py" line="84"/>
<source>There is a download active. Do you really want to exit app?</source>
<translation>Ein Download läuft noch. Möchtest du die App wirklich beenden?</translation>
</message>
@ -938,85 +938,90 @@ Installationsgröße: {} GB</translation>
<context>
<name>RareSettings</name>
<message>
<location filename="../components/tabs/settings/rare.py" line="25"/>
<location filename="../components/tabs/settings/rare.py" line="27"/>
<source>Rare settings</source>
<translation>Rare Einstellungen</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="48"/>
<location filename="../components/tabs/settings/rare.py" line="51"/>
<source>Save</source>
<translation>Speichern</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="50"/>
<location filename="../components/tabs/settings/rare.py" line="53"/>
<source>Image Directory</source>
<translation>Ordner für Bilder</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="61"/>
<location filename="../components/tabs/settings/rare.py" line="64"/>
<source>Language</source>
<translation>Sprache</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="87"/>
<location filename="../components/tabs/settings/rare.py" line="102"/>
<source>Restart Application to activate changes</source>
<translation>Starte die App neu um die Änderungen zu aktivieren</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="33"/>
<location filename="../components/tabs/settings/rare.py" line="36"/>
<source>Confirm launch of game</source>
<translation>Start des Spiels bestätigen</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="30"/>
<location filename="../components/tabs/settings/rare.py" line="33"/>
<source>Exit to System Tray Icon</source>
<translation>Beim verlassen auf das System Tray Icon minimieren</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="30"/>
<location filename="../components/tabs/settings/rare.py" line="33"/>
<source>Hide to System Tray Icon</source>
<translation>In das System Tray Icon minimieren</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="35"/>
<location filename="../components/tabs/settings/rare.py" line="38"/>
<source>Auto sync with cloud</source>
<translation>Speicherstände automatisch mit der Cloud synchronisieren</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="35"/>
<location filename="../components/tabs/settings/rare.py" line="38"/>
<source>Sync with cloud</source>
<translation>Automatisch Synchronisieren</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="38"/>
<location filename="../components/tabs/settings/rare.py" line="41"/>
<source>Save size</source>
<translation>Größe Speichern</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="38"/>
<location filename="../components/tabs/settings/rare.py" line="41"/>
<source>Save size of window after restart</source>
<translation>Die Fenstergröße nach dem Beenden speichern</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="31"/>
<location filename="../components/tabs/settings/rare.py" line="34"/>
<source>Automatically update Games on startup</source>
<translation>Spiele automatisch updaten</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="31"/>
<location filename="../components/tabs/settings/rare.py" line="34"/>
<source>Auto updates</source>
<translation>Automatische Updates</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="36"/>
<location filename="../components/tabs/settings/rare.py" line="39"/>
<source>Show Notifications after Downloads</source>
<translation>Benachrichtigung nach Abschluss des Downloads anzeigen</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="36"/>
<location filename="../components/tabs/settings/rare.py" line="39"/>
<source>Show notification</source>
<translation>Benachrichtigung anzeigen</translation>
</message>
<message>
<location filename="../components/tabs/settings/rare.py" line="76"/>
<source>Open Log directory</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SyncSaves</name>
@ -1134,22 +1139,22 @@ Installationsgröße: {} GB</translation>
<translation>Pfad ändern</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="181"/>
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="186"/>
<source>Uploading...</source>
<translation>Hochladen...</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="189"/>
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="194"/>
<source>Upload finished</source>
<translation>Hochladen abgeschlossen</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="199"/>
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="204"/>
<source>Downloading...</source>
<translation>Runterladen...</translation>
</message>
<message>
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="205"/>
<location filename="../components/tabs/cloud_saves/sync_widget.py" line="210"/>
<source>Download finished</source>
<translation>Download abgeschlossen</translation>
</message>

View file

@ -11,14 +11,15 @@ from PyQt5.QtCore import pyqtSignal, QLocale, QSettings
# Windows
if os.name == "nt":
from win32com.client import Dispatch
# Mac not supported
from rare import lang_path, __version__, style_path
from rare import lang_path
from custom_legendary.core import LegendaryCore
logger = getLogger("Utils")
s = QSettings("Rare", "Rare")
IMAGE_DIR = s.value("img_dir", os.path.expanduser("~/.cache/rare/images"), type=str)
logger.info("IMAGE DIRECTORY: " + IMAGE_DIR)
def download_images(signal: pyqtSignal, core: LegendaryCore):
@ -38,7 +39,7 @@ def download_images(signal: pyqtSignal, core: LegendaryCore):
except json.decoder.JSONDecodeError:
shutil.rmtree(f"{IMAGE_DIR}/{game.app_name}")
download_image(game)
signal.emit(i/len(game_list)*100)
signal.emit(i / len(game_list) * 100)
def download_image(game, force=False):
@ -69,7 +70,7 @@ def download_image(game, force=False):
f.write(requests.get(url).content)
try:
img = Image.open(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png")
img = img.resize((200, int(200*4/3)))
img = img.resize((200, int(200 * 4 / 3)))
img.save(f"{IMAGE_DIR}/{game.app_name}/{image['type']}.png")
except UnidentifiedImageError as e:
logger.warning(e)
@ -84,7 +85,7 @@ def download_image(game, force=False):
bg = Image.open(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png")
uninstalledArt = bg.convert('L')
uninstalledArt = uninstalledArt.resize((200, int(200*4/3)))
uninstalledArt = uninstalledArt.resize((200, int(200 * 4 / 3)))
uninstalledArt.save(f'{IMAGE_DIR}/{game.app_name}/UninstalledArt.png')
elif os.path.isfile(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png"):
bg: Image.Image = Image.open(f"{IMAGE_DIR}/{game.app_name}/DieselGameBoxLogo.png")
@ -202,9 +203,11 @@ def create_desktop_link(app_name, core: LegendaryCore, type_of_link="desktop"):
shortcut.WorkingDirectory = os.getcwd()
# Icon
if not os.path.exists(icon+".ico"):
img = Image.open(icon+".png")
img.save(icon+".ico")
if not os.path.exists(icon + ".ico"):
img = Image.open(icon + ".png")
img.save(icon + ".ico")
logger.info("Create Icon")
shortcut.IconLocation = os.path.join(icon+ ".ico")
shortcut.IconLocation = os.path.join(icon + ".ico")
# Save shortcut
shortcut.save()