1
0
Fork 0
mirror of synced 2024-06-02 02:34:40 +12:00
install (Todo)
This commit is contained in:
Dummerle 2020-11-03 21:23:54 +01:00
parent e2e713840e
commit d2f5b3c745
5 changed files with 66 additions and 32 deletions

View file

@ -8,9 +8,10 @@ from Rare.utils import legendaryUtils
class GameWidget(QWidget):
proc: subprocess.Popen
def __init__(self, game):
super(GameWidget, self).__init__()
self.proc: subprocess.Popen = None
self.title = game.title
self.app_name = game.app_name
self.version = game.version
@ -21,7 +22,7 @@ class GameWidget(QWidget):
self.layout = QHBoxLayout()
pixmap = QPixmap(f"../images/{game.app_name}/FinalArt.png")
pixmap = pixmap.scaled(240, 320)
pixmap = pixmap.scaled(180, 240)
self.image = QLabel()
self.image.setPixmap(pixmap)
self.layout.addWidget(self.image)
@ -70,21 +71,27 @@ class UninstalledGameWidget(QWidget):
def __init__(self, game):
super(UninstalledGameWidget, self).__init__()
self.title = game.app_title
self.app_name = game.app_name
self.version = game.app_version
self.layout = QHBoxLayout()
self.game = game
pixmap = QPixmap(f"../images/{game.app_name}/UninstalledArt.png")
pixmap = pixmap.scaled(240, 320)
pixmap = pixmap.scaled(120, 160)
self.image = QLabel()
self.image.setPixmap(pixmap)
self.child_layout = QVBoxLayout()
self.title_label = QLabel(f"<h2>{self.title}</h2>")
self.app_name_label = QLabel(f"App Name: {self.app_name}")
self.version_label = QLabel(f"Version: {self.version}")
self.install_button = QPushButton("Install")
self.install_button.clicked.connect(self.install)
self.child_layout.addWidget(self.title_label)
self.child_layout.addWidget(self.app_name_label)
self.child_layout.addWidget(self.version_label)
self.child_layout.addWidget(self.install_button)
self.child_layout.addStretch(1)
self.layout.addWidget(self.image)
@ -99,5 +106,6 @@ class UninstalledGameWidget(QWidget):
data = dia.get_data()
if data != 0:
path = data.get("install_path")
print(path)
# TODO
print(f"install {self.app_name} in path {path}")
legendaryUtils.install(self.app_name)

View file

@ -8,15 +8,15 @@ from PyQt5.QtWidgets import QTabWidget, QMainWindow, QWidget, QApplication
from Rare.Dialogs import LoginDialog
from Rare.TabWidgets import Settings, GameListInstalled, BrowserTab, GameListUninstalled, UpdateList
from Rare.config import IMAGE_DIR, LOGLEVEL
from Rare.config import IMAGE_DIR
from Rare.utils import legendaryUtils
logging.basicConfig(
format='[%(name)s] %(levelname)s: %(message)s',
level=LOGLEVEL
)
logger = logging.getLogger("Rare")
class MainWindow(QMainWindow):
def __init__(self):
@ -65,6 +65,7 @@ def main():
def download_images():
if not os.path.isdir(IMAGE_DIR):
os.mkdir(IMAGE_DIR)
logger.info("Create Image dir")
# Download Images
for game in legendaryUtils.get_games():
@ -113,7 +114,7 @@ def download_images():
uninstalledArt = finalArt.convert('L')
uninstalledArt.save(f'{IMAGE_DIR}/{game.app_name}/UninstalledArt.png')
else:
logger.error(f"File {IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png dowsn't exist")
logger.warning(f"File {IMAGE_DIR}/{game.app_name}/DieselGameBoxTall.png dowsn't exist")
if __name__ == '__main__':

View file

@ -1,9 +1,9 @@
from PyQt5.QtCore import QUrl, Qt
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QScrollArea, QLineEdit
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QScrollArea, QLineEdit, QPushButton
from Rare.GameWidget import GameWidget, UninstalledGameWidget
from Rare.utils.legendaryUtils import get_installed, get_not_installed
from Rare.utils.legendaryUtils import get_installed, get_not_installed, logout
class BrowserTab(QWebEngineView):
@ -17,12 +17,18 @@ class Settings(QWidget):
def __init__(self, parent):
super(Settings, self).__init__(parent=parent)
self.layout = QVBoxLayout()
label = QLabel()
self.layout.addWidget(QLabel("<h1>Settings</h1>"))
self.layout.addWidget(QLabel("Coming soon"))
self.layout.addWidget(QLabel("<h1>Rare Settings</h1>"))
self.logout_button = QPushButton("Logout")
self.logout_button.clicked.connect(self.logout)
self.layout.addWidget(self.logout_button)
self.layout.addStretch(1)
self.setLayout(self.layout)
def logout(self):
logout()
exit(0)
class GameListInstalled(QScrollArea):
def __init__(self, parent):

View file

@ -1,4 +1,27 @@
import configparser
import logging
IMAGE_DIR = "../images"
import os
LOGLEVEL = logging.ERROR
config_path = os.path.expanduser("~") + "/.config/Rare"
cfg = configparser.ConfigParser()
cfg.read(os.path.expanduser("~") + "/.config/Rare")
logger = logging.getLogger("Config")
if not os.path.exists(config_path):
os.mkdir(config_path)
logger.info("Create Config dir")
if not cfg.sections():
cfg["Rare"] = {
"IMAGE_DIR": "../images",
"LOGLEVEL": logging.INFO
}
with open(config_path + '/Rare.ini', 'w') as configfile:
cfg.write(configfile)
IMAGE_DIR = cfg["Rare"]["IMAGE_DIR"]
LOGLEVEL = cfg["Rare"]["LOGLEVEL"]

View file

@ -1,10 +1,11 @@
import logging
import os
import subprocess
from getpass import getuser
from legendary.core import LegendaryCore
core = LegendaryCore()
from getpass import getuser
def get_installed():
@ -12,10 +13,7 @@ def get_installed():
def get_installed_names():
names = []
for i in core.get_installed_list():
names.append(i.app_name)
return names
return [i.app_name for i in core.get_installed_list()]
def get_not_installed():
@ -32,19 +30,9 @@ def get_games_and_dlcs():
if not core.login():
print("Login Failed")
exit(1)
return core.get_game_and_dlc_list()
def get_games_by_name():
if not core.login():
print("Login Failed")
exit(1)
game = []
for i in core.get_game_list():
game.append(i.app_name)
def get_game_by_name(name: str):
return core.get_game(name)
@ -53,7 +41,13 @@ def get_games():
if not core.login():
print("Login Failed")
exit(1)
return core.get_game_list()
return sorted(core.get_game_list(), key=lambda x: x.app_title)
def get_games_sorted():
if not core.login():
logging.error("No login")
def launch_game(app_name: str, offline: bool = False, skip_version_check: bool = False, username_override=None,
@ -146,5 +140,7 @@ def logout():
core.lgd.invalidate_userdata()
def install(app_name: str, path: str):
pass
def install(app_name: str, path: str = None):
subprocess.Popen(f"legendary -y install {app_name}".split(" "))
# TODO