launch games works
This commit is contained in:
parent
431a5598b9
commit
7dc9aa53ec
23
Rare/Dialogs.py
Normal file
23
Rare/Dialogs.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QLabel
|
||||||
|
|
||||||
|
|
||||||
|
class InstallDialog(QDialog):
|
||||||
|
def __init__(self, game):
|
||||||
|
super(InstallDialog, self).__init__()
|
||||||
|
self.setWindowTitle("Install Game")
|
||||||
|
self.layout = QVBoxLayout()
|
||||||
|
|
||||||
|
|
||||||
|
self.options = QLabel("Verschiedene Optionene")
|
||||||
|
self.layout.addWidget(self.options)
|
||||||
|
|
||||||
|
self.layout.addStretch(1)
|
||||||
|
self.yes_button = QPushButton("Install")
|
||||||
|
self.cancel_button = QPushButton("cancel")
|
||||||
|
|
||||||
|
self.button_layout = QHBoxLayout()
|
||||||
|
self.button_layout.addWidget(self.yes_button)
|
||||||
|
self.button_layout.addWidget(self.cancel_button)
|
||||||
|
self.cancel_button.clicked.connect(self.exit)
|
||||||
|
self.layout.addLayout(self.button_layout)
|
||||||
|
self.setLayout(self.layout)
|
|
@ -1,16 +1,20 @@
|
||||||
import qtawesome as qta
|
|
||||||
from PyQt5.QtGui import QPixmap
|
from PyQt5.QtGui import QPixmap
|
||||||
from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QVBoxLayout, QPushButton
|
from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QVBoxLayout, QPushButton, QStyle
|
||||||
|
|
||||||
|
from Rare.Dialogs import InstallDialog
|
||||||
|
from Rare.utils import legendaryUtils
|
||||||
|
|
||||||
|
|
||||||
class GameWidget(QWidget):
|
class GameWidget(QWidget):
|
||||||
def __init__(self, game):
|
def __init__(self, game):
|
||||||
super(GameWidget, self).__init__()
|
super(GameWidget, self).__init__()
|
||||||
# self.setStyleSheet("border:1px solid rgb(0, 0, 0)")
|
|
||||||
|
|
||||||
self.title = game.title
|
self.title = game.title
|
||||||
|
self.app_name = game.app_name
|
||||||
self.version = game.version
|
self.version = game.version
|
||||||
self.size = game.install_size
|
self.size = game.install_size
|
||||||
|
self.launch_params = game.launch_parameters
|
||||||
|
#self.dev =
|
||||||
|
|
||||||
self.layout = QHBoxLayout()
|
self.layout = QHBoxLayout()
|
||||||
|
|
||||||
|
@ -23,16 +27,17 @@ class GameWidget(QWidget):
|
||||||
##Layout on the right
|
##Layout on the right
|
||||||
self.childLayout = QVBoxLayout()
|
self.childLayout = QVBoxLayout()
|
||||||
|
|
||||||
self.childLayout.addWidget(QLabel(f"<h1>{self.title}</h1>"))
|
play_icon = self.style().standardIcon(getattr(QStyle, 'SP_MediaPlay'))
|
||||||
play_icon = qta.icon('fa5s.play')
|
settings_icon = self.style().standardIcon(getattr(QStyle, 'SP_DirIcon'))
|
||||||
|
self.title_widget = QLabel(f"<h1>{self.title}</h1>")
|
||||||
self.launch_button = QPushButton(play_icon, "Launch")
|
self.launch_button = QPushButton(play_icon, "Launch")
|
||||||
self.launch_button.clicked.connect(self.launch)
|
self.launch_button.clicked.connect(self.launch)
|
||||||
self.wine_rating = QLabel("Wine Rating: " + self.get_rating())
|
self.wine_rating = QLabel("Wine Rating: " + self.get_rating())
|
||||||
self.version_label = QLabel("Version: " + str(self.version))
|
self.version_label = QLabel("Version: " + str(self.version))
|
||||||
self.size_label = QLabel(f"Installed size: {round(self.size / (1024 ** 3), 2)} GB")
|
self.size_label = QLabel(f"Installed size: {round(self.size / (1024 ** 3), 2)} GB")
|
||||||
self.settings = QPushButton(qta.icon("fa5s.cogs"), " Settings")
|
self.settings = QPushButton(settings_icon, " Settings (Icon TODO)")
|
||||||
|
|
||||||
|
self.childLayout.addWidget(self.title_widget)
|
||||||
self.childLayout.addWidget(self.launch_button)
|
self.childLayout.addWidget(self.launch_button)
|
||||||
self.childLayout.addWidget(self.wine_rating)
|
self.childLayout.addWidget(self.wine_rating)
|
||||||
self.childLayout.addWidget(self.version_label)
|
self.childLayout.addWidget(self.version_label)
|
||||||
|
@ -46,7 +51,9 @@ class GameWidget(QWidget):
|
||||||
|
|
||||||
def launch(self):
|
def launch(self):
|
||||||
print(f"launch {self.title}")
|
print(f"launch {self.title}")
|
||||||
# TODO
|
self.launch_button.setText("Running")
|
||||||
|
self.launch_button.setDisabled(True)
|
||||||
|
legendaryUtils.start(self.app_name) # adding launch params #TODO
|
||||||
|
|
||||||
def get_rating(self) -> str:
|
def get_rating(self) -> str:
|
||||||
return "gold" # TODO
|
return "gold" # TODO
|
||||||
|
@ -57,12 +64,30 @@ class UninstalledGameWidget(QWidget):
|
||||||
super(UninstalledGameWidget, self).__init__()
|
super(UninstalledGameWidget, self).__init__()
|
||||||
self.title = game.app_title
|
self.title = game.app_title
|
||||||
self.layout = QHBoxLayout()
|
self.layout = QHBoxLayout()
|
||||||
|
self.game = game
|
||||||
|
|
||||||
|
self.visible = True
|
||||||
pixmap = QPixmap(f"../images/{game.app_name}/UninstalledArt.png")
|
pixmap = QPixmap(f"../images/{game.app_name}/UninstalledArt.png")
|
||||||
pixmap = pixmap.scaled(240, 320)
|
pixmap = pixmap.scaled(240, 320)
|
||||||
self.image = QLabel()
|
self.image = QLabel()
|
||||||
self.image.setPixmap(pixmap)
|
self.image.setPixmap(pixmap)
|
||||||
self.layout.addWidget(self.image)
|
|
||||||
|
|
||||||
self.layout.addWidget(QLabel(f"<h1>{self.title}</h1>"))
|
self.child_layout = QVBoxLayout()
|
||||||
self.setLayout(self.layout)
|
|
||||||
|
self.title_label = QLabel(f"<h2>{self.title}</h2>")
|
||||||
|
self.install_button = QPushButton("Install")
|
||||||
|
self.install_button.clicked.connect(self.install)
|
||||||
|
|
||||||
|
self.child_layout.addWidget(self.title_label)
|
||||||
|
self.child_layout.addWidget(self.install_button)
|
||||||
|
self.child_layout.addStretch(1)
|
||||||
|
self.layout.addWidget(self.image)
|
||||||
|
self.layout.addLayout(self.child_layout)
|
||||||
|
|
||||||
|
self.layout.addStretch(1)
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
def install(self):
|
||||||
|
print("install " + self.title)
|
||||||
|
#TODO
|
||||||
|
# dialog = InstallDialog(self.game)
|
||||||
|
|
26
Rare/Main.py
26
Rare/Main.py
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QTabWidget, QMainWindow, QWidget, QApplication
|
from PyQt5.QtWidgets import QTabWidget, QMainWindow, QWidget, QApplication
|
||||||
|
@ -36,11 +37,36 @@ class TabWidget(QTabWidget):
|
||||||
self.addTab(self.settings, "Settings")
|
self.addTab(self.settings, "Settings")
|
||||||
|
|
||||||
|
|
||||||
|
class LoginWindow(QMainWindow):
|
||||||
|
def __init__(self):
|
||||||
|
super(LoginWindow, self).__init__()
|
||||||
|
self.setWindowTitle("Rare - Login")
|
||||||
|
self.setGeometry(0, 0, 200, 150)
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# Check if Legendary is installed
|
||||||
|
|
||||||
|
if os.path.isfile(os.path.expanduser("~") + '/.config/legendary/user.json'):
|
||||||
|
startMainProcess()
|
||||||
|
else:
|
||||||
|
notLoggedIn()
|
||||||
|
|
||||||
|
|
||||||
|
def startMainProcess():
|
||||||
|
# TODO Download Images
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
ex = MainWindow()
|
ex = MainWindow()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
||||||
|
def notLoggedIn():
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
window = LoginWindow()
|
||||||
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
from PyQt5.QtCore import QUrl, Qt
|
from PyQt5.QtCore import QUrl, Qt
|
||||||
from PyQt5.QtWebEngineWidgets import QWebEngineView
|
from PyQt5.QtWebEngineWidgets import QWebEngineView
|
||||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QScrollArea
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QScrollArea, QLineEdit
|
||||||
|
|
||||||
from Rare.utils.legendaryUtils import get_installed, get_not_installed
|
|
||||||
from Rare.GameWidget import GameWidget, UninstalledGameWidget
|
from Rare.GameWidget import GameWidget, UninstalledGameWidget
|
||||||
|
from Rare.utils.legendaryUtils import get_installed, get_not_installed
|
||||||
|
|
||||||
|
|
||||||
class BrowserTab(QWebEngineView):
|
class BrowserTab(QWebEngineView):
|
||||||
|
@ -18,7 +18,6 @@ class Settings(QWidget):
|
||||||
super(Settings, self).__init__(parent=parent)
|
super(Settings, self).__init__(parent=parent)
|
||||||
self.layout = QVBoxLayout()
|
self.layout = QVBoxLayout()
|
||||||
label = QLabel()
|
label = QLabel()
|
||||||
print(label.fontInfo().pixelSize())
|
|
||||||
self.layout.addWidget(QLabel("<h1>Settings</h1>"))
|
self.layout.addWidget(QLabel("<h1>Settings</h1>"))
|
||||||
self.layout.addWidget(QLabel("Coming soon"))
|
self.layout.addWidget(QLabel("Coming soon"))
|
||||||
self.layout.addStretch(1)
|
self.layout.addStretch(1)
|
||||||
|
@ -35,9 +34,8 @@ class GameListInstalled(QScrollArea):
|
||||||
self.layout = QVBoxLayout()
|
self.layout = QVBoxLayout()
|
||||||
for i in get_installed():
|
for i in get_installed():
|
||||||
widget = GameWidget(i)
|
widget = GameWidget(i)
|
||||||
#print(i.)
|
|
||||||
self.layout.addWidget(widget)
|
|
||||||
|
|
||||||
|
self.layout.addWidget(widget)
|
||||||
self.widget.setLayout(self.layout)
|
self.widget.setLayout(self.layout)
|
||||||
self.setWidget(self.widget)
|
self.setWidget(self.widget)
|
||||||
|
|
||||||
|
@ -51,8 +49,15 @@ class GameListUninstalled(QScrollArea):
|
||||||
|
|
||||||
self.layout = QVBoxLayout()
|
self.layout = QVBoxLayout()
|
||||||
|
|
||||||
|
self.filter = QLineEdit()
|
||||||
|
self.filter.setPlaceholderText("Search game TODO")
|
||||||
|
self.layout.addWidget(self.filter)
|
||||||
|
|
||||||
|
self.widgets = []
|
||||||
for game in get_not_installed():
|
for game in get_not_installed():
|
||||||
self.layout.addWidget(UninstalledGameWidget(game))
|
game_widget = UninstalledGameWidget(game)
|
||||||
|
self.layout.addWidget(game_widget)
|
||||||
|
self.widgets.append(game_widget)
|
||||||
self.widget.setLayout(self.layout)
|
self.widget.setLayout(self.layout)
|
||||||
self.setWidget(self.widget)
|
self.setWidget(self.widget)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import subprocess
|
import os
|
||||||
|
from argparse import Namespace
|
||||||
|
from distutils.util import strtobool
|
||||||
|
|
||||||
from legendary.cli import LegendaryCLI
|
from legendary.cli import LegendaryCLI
|
||||||
from legendary.core import LegendaryCore
|
from legendary.core import LegendaryCore
|
||||||
|
|
||||||
|
|
||||||
core = LegendaryCore()
|
core = LegendaryCore()
|
||||||
cli = LegendaryCLI
|
cli = LegendaryCLI()
|
||||||
|
|
||||||
|
|
||||||
def get_installed():
|
def get_installed():
|
||||||
|
@ -17,6 +20,7 @@ def get_installed_names():
|
||||||
names.append(i.app_name)
|
names.append(i.app_name)
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
||||||
def get_not_installed():
|
def get_not_installed():
|
||||||
games = []
|
games = []
|
||||||
installed = get_installed_names()
|
installed = get_installed_names()
|
||||||
|
@ -25,6 +29,7 @@ def get_not_installed():
|
||||||
games.append(game)
|
games.append(game)
|
||||||
return games
|
return games
|
||||||
|
|
||||||
|
|
||||||
# return (games, dlcs)
|
# return (games, dlcs)
|
||||||
def get_games_and_dlcs():
|
def get_games_and_dlcs():
|
||||||
if not core.login():
|
if not core.login():
|
||||||
|
@ -33,6 +38,7 @@ def get_games_and_dlcs():
|
||||||
|
|
||||||
return core.get_game_and_dlc_list()
|
return core.get_game_and_dlc_list()
|
||||||
|
|
||||||
|
|
||||||
def get_games_by_name():
|
def get_games_by_name():
|
||||||
if not core.login():
|
if not core.login():
|
||||||
print("Login Failed")
|
print("Login Failed")
|
||||||
|
@ -41,9 +47,11 @@ def get_games_by_name():
|
||||||
for i in core.get_game_list():
|
for i in core.get_game_list():
|
||||||
game.append(i.app_name)
|
game.append(i.app_name)
|
||||||
|
|
||||||
|
|
||||||
def get_game_by_name(name: str):
|
def get_game_by_name(name: str):
|
||||||
return core.get_game(name)
|
return core.get_game(name)
|
||||||
|
|
||||||
|
|
||||||
def get_games():
|
def get_games():
|
||||||
if not core.login():
|
if not core.login():
|
||||||
print("Login Failed")
|
print("Login Failed")
|
||||||
|
@ -51,6 +59,34 @@ def get_games():
|
||||||
return core.get_game_list()
|
return core.get_game_list()
|
||||||
|
|
||||||
|
|
||||||
def start(game_name: str, args):
|
def start(game_name,
|
||||||
subprocess.run(["legendary", "launch", game_name])
|
offline=False,
|
||||||
|
skip_version_check=False,
|
||||||
|
reset_defaults=None,
|
||||||
|
set_defaults=None,
|
||||||
|
wine_bin=os.environ.get('LGDRY_WINE_BINARY', None),
|
||||||
|
wine_pfx=os.environ.get('LGDRY_WINE_PREFIX', None),
|
||||||
|
no_wine=strtobool(os.environ.get('LGDRY_NO_WINE', 'False')),
|
||||||
|
debug=False,
|
||||||
|
dry_run=False,
|
||||||
|
user_name_override=None,
|
||||||
|
language=None
|
||||||
|
):
|
||||||
|
cli.launch_game(Namespace(app_name=game_name,
|
||||||
|
offline=offline,
|
||||||
|
wrapper=os.environ.get('LGDRY_WRAPPER', None),
|
||||||
|
skip_version_check=skip_version_check,
|
||||||
|
reset_defaults=reset_defaults,
|
||||||
|
set_defaults=set_defaults,
|
||||||
|
wine_bin=wine_bin,
|
||||||
|
wine_pfx=wine_pfx,
|
||||||
|
no_wine=no_wine,
|
||||||
|
debug=debug,
|
||||||
|
dry_run=dry_run,
|
||||||
|
user_name_override=user_name_override,
|
||||||
|
language=language
|
||||||
|
),
|
||||||
|
[] # Extra
|
||||||
|
)
|
||||||
|
|
||||||
|
# start("Sugar")
|
||||||
|
|
Loading…
Reference in a new issue