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

Merge pull request #155 from Dummerle/Add_UE_support

Add Unreal Engine support, to install Unreal Engine for Windows
This commit is contained in:
Dummerle 2022-01-09 21:00:59 +01:00 committed by GitHub
commit 8ce359124e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 98 additions and 46 deletions

View file

@ -103,7 +103,6 @@ class InstallDialog(QDialog, Ui_InstallDialog):
self.download_only_check.stateChanged.connect(
lambda: self.non_reload_option_changed("download_only")
)
self.sdl_list_checks = list()
try:
for key, info in games[self.app_name].items():
@ -120,6 +119,9 @@ class InstallDialog(QDialog, Ui_InstallDialog):
except KeyError:
self.sdl_list_frame.setVisible(False)
self.sdl_list_label.setVisible(False)
except AttributeError:
self.sdl_list_frame.setVisible(False)
self.sdl_list_label.setVisible(False)
self.install_button.setEnabled(False)

View file

@ -1,11 +1,11 @@
from logging import getLogger
from typing import Tuple, Dict
from typing import Tuple, Dict, Union, List
from PyQt5.QtCore import QSettings, QObjectCleanupHandler
from PyQt5.QtWidgets import QStackedWidget, QVBoxLayout, QWidget
import rare.shared as shared
from legendary.models.game import InstalledGame
from legendary.models.game import InstalledGame, Game
from rare.ui.components.tabs.games.games_tab import Ui_GamesTab
from rare.utils.extra_widgets import FlowLayout
from rare.utils.utils import get_pixmap, download_image, get_uninstalled_pixmap
@ -28,7 +28,8 @@ logger = getLogger("GamesTab")
class GamesTab(QStackedWidget, Ui_GamesTab):
widgets: Dict[str, Tuple[InstalledIconWidget, InstalledListWidget]] = dict()
widgets: Dict[str, Tuple[
Union[InstalledIconWidget, IconWidgetUninstalled], Union[InstalledListWidget, ListWidgetUninstalled]]] = dict()
running_games = list()
updates = set()
active_filter = 0
@ -40,7 +41,7 @@ class GamesTab(QStackedWidget, Ui_GamesTab):
self.signals = shared.signals
self.settings = QSettings()
self.game_list = shared.api_results.game_list
self.game_list: List[Game] = shared.api_results.game_list
self.dlcs = shared.api_results.dlcs
self.bit32 = shared.api_results.bit32_games
self.mac_games = shared.api_results.mac_games
@ -79,6 +80,19 @@ class GamesTab(QStackedWidget, Ui_GamesTab):
self.no_asset_names.append(game.app_name)
else:
self.no_assets = []
for i in self.game_list:
if i.app_name.startswith("UE_4"):
pixmap = get_pixmap(i.app_name)
if pixmap.isNull():
continue
self.ue_name = i.app_name
logger.debug(f"Found Unreal AppName {self.ue_name}")
break
else:
logger.warning("No Unreal engine in library found")
self.ue_name = ""
self.installed = self.core.get_installed_list()
self.setup_game_list()
@ -185,11 +199,15 @@ class GamesTab(QStackedWidget, Ui_GamesTab):
def add_installed_widget(self, app_name):
pixmap = get_pixmap(app_name)
if pixmap.isNull():
logger.info(app_name + " has a corrupt image.")
download_image(self.core.get_game(app_name), force=True)
pixmap = get_pixmap(app_name)
try:
if pixmap.isNull():
logger.info(app_name + " has a corrupt image.")
if app_name in self.no_asset_names and self.core.get_asset(app_name).namespace != "ue":
download_image(self.core.get_game(app_name), force=True)
pixmap = get_pixmap(app_name)
elif self.ue_name:
pixmap = get_pixmap(self.ue_name)
icon_widget = InstalledIconWidget(app_name, pixmap, self.game_utils)
list_widget = InstalledListWidget(app_name, pixmap, self.game_utils)
except Exception as e:
@ -207,11 +225,15 @@ class GamesTab(QStackedWidget, Ui_GamesTab):
def add_uninstalled_widget(self, game):
pixmap = get_uninstalled_pixmap(game.app_name)
if pixmap.isNull():
logger.warning(game.app_title + " has a corrupt image. Reloading...")
download_image(game, force=True)
pixmap = get_uninstalled_pixmap(game.app_name)
try:
if pixmap.isNull():
if self.core.get_asset(game.app_name).namespace != "ue":
logger.warning(game.app_title + " has a corrupt image. Reloading...")
download_image(game, force=True)
pixmap = get_uninstalled_pixmap(game.app_name)
elif self.ue_name:
pixmap = get_uninstalled_pixmap(self.ue_name)
icon_widget = IconWidgetUninstalled(game, self.core, pixmap)
list_widget = ListWidgetUninstalled(self.core, game, pixmap)
except Exception as e:
@ -235,31 +257,38 @@ class GamesTab(QStackedWidget, Ui_GamesTab):
filter_name = t
for t in self.widgets.values():
app_name = t[0].game.app_name
# icon and list widget
for w in t:
if filter_name == "installed":
visible = self.core.is_installed(w.game.app_name)
elif filter_name == "offline":
if self.core.is_installed(w.game.app_name):
visible = w.igame.can_run_offline
else:
visible = False
elif filter_name == "32bit" and self.bit32:
visible = w.game.app_name in self.bit32
elif filter_name == "mac" and self.mac_games:
visible = w.game.app_name in self.mac_games
elif filter_name == "installable":
visible = w.game.app_name not in self.no_asset_names
elif filter_name == "all":
# All visible
visible = True
if filter_name == "installed":
visible = self.core.is_installed(app_name)
elif filter_name == "offline":
if self.core.is_installed(app_name):
visible = t[0].igame.can_run_offline
else:
visible = True
if (
search_text.lower() not in w.game.app_name.lower()
and search_text.lower() not in w.game.app_title.lower()
):
visible = False
elif filter_name == "32bit" and self.bit32:
visible = app_name in self.bit32
elif filter_name == "mac" and self.mac_games:
visible = app_name in self.mac_games
elif filter_name == "installable":
visible = app_name not in self.no_asset_names
elif filter_name == "include_ue":
visible = True
elif filter_name == "all":
# All visible except ue
try:
visible = self.core.get_asset(app_name, update=False).namespace != "ue"
except ValueError:
visible = True
else:
visible = True
if (
search_text.lower() not in app_name.lower()
and search_text.lower() not in t[0].game.app_title.lower()
):
visible = False
for w in t:
w.setVisible(visible)
def update_list(self, app_names: list = None):

View file

@ -138,6 +138,8 @@ class GameInfo(QWidget, Ui_GameInfo):
self.game_title.setText(f"<h2>{self.game.app_title}</h2>")
pixmap = get_pixmap(self.game.app_name)
if pixmap.isNull():
pixmap = get_pixmap(self.parent().parent().parent().ue_name)
w = 200
pixmap = pixmap.scaled(w, int(w * 4 / 3))
self.image.setPixmap(pixmap)
@ -175,13 +177,17 @@ class GameInfo(QWidget, Ui_GameInfo):
self.repair_button.setDisabled(False)
self.game_actions_stack.setCurrentIndex(0)
if platform.system() != "Windows":
is_ue = self.core.get_asset(app_name).namespace == "ue"
self.grade.setVisible(not is_ue)
self.lbl_grade.setVisible(not is_ue)
if platform.system() != "Windows" and not is_ue:
self.grade.setText(self.tr("Loading"))
self.steam_worker.set_app_name(self.game.app_name)
QThreadPool.globalInstance().start(self.steam_worker)
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(
self.game.app_name
self.game.app_name
):
self.verify_widget.setCurrentIndex(0)
elif self.verify_threads.get(self.game.app_name):

View file

@ -90,6 +90,8 @@ class UninstalledInfo(QWidget, Ui_GameInfo):
self.platform.setText(", ".join(available_platforms))
pixmap = get_pixmap(game.app_name)
if pixmap.isNull():
pixmap = get_pixmap(self.parent().parent().parent().ue_name)
w = 200
pixmap = pixmap.scaled(w, int(w * 4 / 3))
self.image.setPixmap(pixmap)
@ -100,7 +102,11 @@ class UninstalledInfo(QWidget, Ui_GameInfo):
self.install_size.setText("N/A")
self.install_path.setText("N/A")
if platform.system() != "Windows":
is_ue = self.core.get_asset(game.app_name).namespace == "ue"
self.grade.setVisible(not is_ue)
self.lbl_grade.setVisible(not is_ue)
if platform.system() != "Windows" and not is_ue:
self.grade.setText(self.tr("Loading"))
self.steam_worker.set_app_name(game.app_name)
QThreadPool.globalInstance().start(self.steam_worker)

View file

@ -45,6 +45,9 @@ class BaseInstalledWidget(QGroupBox):
self.game = self.core.get_game(app_name)
self.igame = self.core.get_installed_game(app_name) # None if origin
if self.game.app_title == "Unreal Engine":
self.game.app_title = f"{self.game.app_title} {self.game.app_name.split('_')[-1]}"
self.image = QLabel()
self.image.setPixmap(
pixmap.scaled(200, int(200 * 4 / 3), transformMode=Qt.SmoothTransformation)

View file

@ -2,8 +2,8 @@ from logging import getLogger
from PyQt5.QtCore import pyqtSignal, Qt
from PyQt5.QtWidgets import QGroupBox, QLabel, QAction
from legendary.models.game import Game
from legendary.models.game import Game
from rare.utils import utils
logger = getLogger("Uninstalled")
@ -15,6 +15,9 @@ class BaseUninstalledWidget(QGroupBox):
def __init__(self, game, core, pixmap):
super(BaseUninstalledWidget, self).__init__()
self.game = game
if self.game.app_title == "Unreal Engine":
self.game.app_title = f"{self.game.app_title} {self.game.app_name.split('_')[-1]}"
self.core = core
self.image = QLabel()
self.image.setPixmap(

View file

@ -30,11 +30,9 @@ class GameListHeadBar(QWidget):
self.tr("All"),
self.tr("Installed only"),
self.tr("Offline Games"),
# ,
#
# self.tr(),
]
)
])
self.layout().addWidget(self.filter)
self.available_filters = [
"all",
"installed",
@ -52,12 +50,14 @@ class GameListHeadBar(QWidget):
self.filter.addItem(self.tr("Exclude Origin"))
self.available_filters.append("installable")
self.layout().addWidget(self.filter)
self.filter.addItem(self.tr("Include Unreal Engine"))
self.available_filters.append("include_ue")
try:
self.filter.setCurrentIndex(self.settings.value("filter", 0, int))
except TypeError:
self.settings.setValue("filter", 0)
self.filter.setCurrentIndex(0)
self.filter.currentIndexChanged.connect(self.filter_changed)
self.layout().addStretch(1)

View file

@ -49,7 +49,7 @@ def download_images(progress: pyqtSignal, results: pyqtSignal, core: LegendaryCo
logger.info("Create Image dir")
# Download Images
games, dlcs = core.get_game_and_dlc_list(True)
games, dlcs = core.get_game_and_dlc_list(True, skip_ue=False)
results.emit((games, dlcs), "gamelist")
dlc_list = []
for i in dlcs.values():
@ -60,6 +60,9 @@ def download_images(progress: pyqtSignal, results: pyqtSignal, core: LegendaryCo
game_list = games + dlc_list + no_assets
for i, game in enumerate(game_list):
if game.app_title == "Unreal Engine":
game.app_title += f" {game.app_name.split('_')[-1]}"
shared.core.lgd.set_game_meta(game.app_name, game)
try:
download_image(game)
except json.decoder.JSONDecodeError: