1
0
Fork 0
mirror of synced 2024-07-01 04:30:20 +12:00
Rare/rare/components/tabs/settings/legendary.py

246 lines
10 KiB
Python
Raw Normal View History

FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
import platform as pf
2021-09-14 05:46:50 +12:00
import re
2021-02-20 06:09:00 +13:00
from logging import getLogger
from typing import Tuple, Set
2021-02-20 06:09:00 +13:00
from PyQt5.QtCore import QObject, pyqtSignal, QThreadPool, QSettings
from PyQt5.QtGui import QShowEvent, QHideEvent
2021-12-14 08:53:21 +13:00
from PyQt5.QtWidgets import QSizePolicy, QWidget, QFileDialog, QMessageBox
2021-02-20 06:09:00 +13:00
from rare.models.options import options
from rare.shared import LegendaryCoreSingleton
from rare.shared.workers.worker import Worker
from rare.ui.components.tabs.settings.legendary import Ui_LegendarySettings
from rare.utils.misc import format_size
from rare.widgets.indicator_edit import PathEdit, IndicatorLineEdit, IndicatorReasonsCommon
2021-02-20 06:09:00 +13:00
logger = getLogger("LegendarySettings")
2021-02-20 00:57:55 +13:00
class RefreshGameMetaWorker(Worker):
class Signals(QObject):
finished = pyqtSignal()
2021-12-28 04:33:56 +13:00
def __init__(self, platforms: Set[str], include_unreal: bool):
2021-12-28 04:33:56 +13:00
super(RefreshGameMetaWorker, self).__init__()
self.signals = RefreshGameMetaWorker.Signals()
self.core = LegendaryCoreSingleton()
self.platforms = platforms if platforms else {"Windows"}
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
self.skip_ue = not include_unreal
2021-12-28 04:33:56 +13:00
def run_real(self) -> None:
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
for platform in self.platforms:
self.core.get_game_and_dlc_list(
True, platform=platform, force_refresh=True, skip_ue=self.skip_ue
)
2021-12-28 04:33:56 +13:00
self.signals.finished.emit()
class LegendarySettings(QWidget, Ui_LegendarySettings):
def __init__(self, parent=None):
super(LegendarySettings, self).__init__(parent=parent)
self.setupUi(self)
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
self.settings = QSettings(self)
self.core = LegendaryCoreSingleton()
2021-04-08 21:09:17 +12:00
# Platform specific installation directory for macOS games
if pf.system() == "Darwin":
self.mac_install_dir = PathEdit(
self.core.get_default_install_dir("Mac"),
placeholder=self.tr("Default installation folder for macOS games"),
file_mode=QFileDialog.DirectoryOnly,
save_func=self.__mac_path_save,
)
self.install_dir_layout.addWidget(self.mac_install_dir)
# Platform-independent installation directory
2021-12-24 22:09:50 +13:00
self.install_dir = PathEdit(
self.core.get_default_install_dir(),
placeholder=self.tr("Default installation folder for Windows games"),
file_mode=QFileDialog.DirectoryOnly,
save_func=self.__win_path_save,
2021-12-24 22:09:50 +13:00
)
self.install_dir_layout.addWidget(self.install_dir)
2021-02-20 06:09:00 +13:00
# Max Workers
2021-12-24 22:09:50 +13:00
max_workers = self.core.lgd.config["Legendary"].getint(
"max_workers", fallback=0
)
self.max_worker_spin.setValue(max_workers)
self.max_worker_spin.valueChanged.connect(self.max_worker_save)
# Max memory
2021-12-24 22:09:50 +13:00
max_memory = self.core.lgd.config["Legendary"].getint("max_memory", fallback=0)
self.max_memory_spin.setValue(max_memory)
self.max_memory_spin.valueChanged.connect(self.max_memory_save)
# Preferred CDN
2021-12-24 22:09:50 +13:00
preferred_cdn = self.core.lgd.config["Legendary"].get(
"preferred_cdn", fallback=""
)
self.preferred_cdn_line.setText(preferred_cdn)
self.preferred_cdn_line.textChanged.connect(self.preferred_cdn_save)
# Disable HTTPS
2021-12-24 22:09:50 +13:00
disable_https = self.core.lgd.config["Legendary"].getboolean(
"disable_https", fallback=False
)
self.disable_https_check.setChecked(disable_https)
self.disable_https_check.stateChanged.connect(self.disable_https_save)
2021-04-06 02:13:27 +12:00
# Cleanup
2021-12-24 22:09:50 +13:00
self.clean_button.clicked.connect(lambda: self.cleanup(False))
self.clean_keep_manifests_button.clicked.connect(lambda: self.cleanup(True))
2021-05-19 23:33:16 +12:00
self.locale_edit = IndicatorLineEdit(
f"{self.core.language_code}-{self.core.country_code}",
edit_func=self.locale_edit_cb,
save_func=self.locale_save_cb,
horiz_policy=QSizePolicy.Minimum,
2021-12-24 22:09:50 +13:00
parent=self,
)
self.locale_layout.addWidget(self.locale_edit)
self.fetch_win32_check.setChecked(self.settings.value(*options.win32_meta))
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
self.fetch_win32_check.stateChanged.connect(
lambda: self.settings.setValue(options.win32_meta.key, self.fetch_win32_check.isChecked())
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
)
self.fetch_macos_check.setChecked(self.settings.value(*options.macos_meta))
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
self.fetch_macos_check.stateChanged.connect(
lambda: self.settings.setValue(options.macos_meta.key, self.fetch_macos_check.isChecked())
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
)
self.fetch_macos_check.setDisabled(pf.system() == "Darwin")
self.fetch_unreal_check.setChecked(self.settings.value(*options.unreal_meta))
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
self.fetch_unreal_check.stateChanged.connect(
lambda: self.settings.setValue(options.unreal_meta.key, self.fetch_unreal_check.isChecked())
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
)
2021-12-28 04:33:56 +13:00
self.exclude_non_asset_check.setChecked(self.settings.value(*options.exclude_non_asset))
self.exclude_non_asset_check.stateChanged.connect(
lambda: self.settings.setValue(options.exclude_non_asset.key, self.exclude_non_asset_check.isChecked())
)
self.exclude_entitlements_check.setChecked(self.settings.value(*options.exclude_entitlements))
self.exclude_entitlements_check.stateChanged.connect(
lambda: self.settings.setValue(options.exclude_entitlements.key, self.exclude_entitlements_check.isChecked())
)
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
self.refresh_metadata_button.clicked.connect(self.refresh_metadata)
# FIXME: Disable the button for now because it interferes with RareCore
self.refresh_metadata_button.setEnabled(False)
self.refresh_metadata_button.setVisible(False)
def showEvent(self, a0: QShowEvent):
if a0.spontaneous():
return super().showEvent(a0)
return super().showEvent(a0)
def hideEvent(self, a0: QHideEvent):
if a0.spontaneous():
return super().hideEvent(a0)
self.core.lgd.save_config()
return super().hideEvent(a0)
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
def refresh_metadata(self):
self.refresh_metadata_button.setDisabled(True)
platforms = set()
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
if self.fetch_win32_check.isChecked():
platforms.add("Win32")
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
if self.fetch_macos_check.isChecked():
platforms.add("Mac")
FetchWorker: Fix issue with missing MacOS assets on MacOS Using `LegendaryCore.get_game_and_dlc_list` with platform `Windows` updated the assets only for the `Windows` builds of the games missing `Win32` and `MacOS` assets on clean installs. This caused Rare to not include MacOS install options on MacOS (duh!). This might also have been the cause that users were unable to launch games, since they where only offered the `Windows` build of the games (big duh!). To fix this, fetch the assets for `Win32` and `MacOS` games before getting the final list of games and dlcs based on the `Windows` platform. In this regard, also re-use the existing options for getting metadata to give the option to the user to include them when updating assets. Also add an option to include Unreal engine assets which until now were fetched unconditionally. * Include Unreal: When the user option is `true` or debugging. Defaults to `false` * Update Win32: When the user option is `true` or debugging. Defaults to `false` * Update MacOS: Force on MacOS, when the option is `true` or debugging on other platforms. Defaults to `true` on MacOS and is disabled, `false` on others Furthermore, respect legendary's `default_platform` config option and set it in the config on new configurations. The new method in our LegendaryCore monkey allows us to use that option in RareGame when doing version checks on not installed games, and not defaulting to `Windows`. Finally, set `install_platform_fallback` to false in a new config to avoid unwanted side-effects.
2023-12-16 03:57:32 +13:00
worker = RefreshGameMetaWorker(platforms, self.fetch_unreal_check.isChecked())
worker.signals.finished.connect(lambda: self.refresh_metadata_button.setDisabled(False))
2021-12-28 04:33:56 +13:00
QThreadPool.globalInstance().start(worker)
@staticmethod
def locale_edit_cb(text: str) -> Tuple[bool, str, int]:
if text:
2021-10-11 21:41:01 +13:00
if re.match("^[a-zA-Z]{2,3}[-_][a-zA-Z]{2,3}$", text):
2024-01-25 05:00:19 +13:00
language, country = text.split("-" if "-" in text else "_")
text = "-".join([language.lower(), country.upper()])
if bool(re.match("^[a-z]{2,3}-[A-Z]{2,3}$", text)):
return True, text, IndicatorReasonsCommon.VALID
else:
return False, text, IndicatorReasonsCommon.WRONG_FORMAT
2021-05-19 23:33:16 +12:00
else:
return True, text, IndicatorReasonsCommon.VALID
2021-05-19 23:33:16 +12:00
def locale_save_cb(self, text: str):
if text:
self.core.egs.language_code, self.core.egs.country_code = text.split("-")
2021-09-14 05:46:50 +12:00
self.core.lgd.config.set("Legendary", "locale", text)
elif self.core.lgd.config.has_option("Legendary", "locale"):
self.core.lgd.config.remove_option("Legendary", "locale")
2021-05-20 07:09:14 +12:00
def __mac_path_save(self, text: str) -> None:
self.__path_save(text, "mac_install_dir")
def __win_path_save(self, text: str) -> None:
self.__path_save(text, "install_dir")
if pf.system() != "Darwin":
self.__mac_path_save(text)
def __path_save(self, text: str, option: str = "Windows"):
self.core.lgd.config["Legendary"][option] = text
if not text and option in self.core.lgd.config["Legendary"].keys():
self.core.lgd.config["Legendary"].pop(option)
2021-02-20 06:09:00 +13:00
else:
logger.debug("Set %s option in config to %s", option, text)
2021-02-20 06:09:00 +13:00
def max_worker_save(self, workers: str):
if workers := int(workers):
self.core.lgd.config.set("Legendary", "max_workers", str(workers))
else:
self.core.lgd.config.remove_option("Legendary", "max_workers")
def max_memory_save(self, memory: str):
if memory := int(memory):
self.core.lgd.config.set("Legendary", "max_memory", str(memory))
else:
self.core.lgd.config.remove_option("Legendary", "max_memory")
def preferred_cdn_save(self, cdn: str):
if cdn:
self.core.lgd.config.set("Legendary", "preferred_cdn", cdn.strip())
else:
self.core.lgd.config.remove_option("Legendary", "preferred_cdn")
def disable_https_save(self, checked: int):
2021-12-24 22:09:50 +13:00
self.core.lgd.config.set(
"Legendary", "disable_https", str(bool(checked)).lower()
)
2021-04-06 02:13:27 +12:00
2021-12-14 08:53:21 +13:00
def cleanup(self, keep_manifests: bool):
2021-04-06 02:13:27 +12:00
before = self.core.lgd.get_dir_size()
2021-12-24 22:09:50 +13:00
logger.debug("Removing app metadata...")
app_names = {g.app_name for g in self.core.get_assets(update_assets=False)}
2021-04-06 02:13:27 +12:00
self.core.lgd.clean_metadata(app_names)
if not keep_manifests:
2021-12-24 22:09:50 +13:00
logger.debug("Removing manifests...")
installed = [
(ig.app_name, ig.version, ig.platform) for ig in self.core.get_installed_list()
2021-12-24 22:09:50 +13:00
]
installed.extend(
(ig.app_name, ig.version, ig.platform) for ig in self.core.get_installed_dlc_list()
2021-12-24 22:09:50 +13:00
)
2021-04-06 02:13:27 +12:00
self.core.lgd.clean_manifests(installed)
2021-12-24 22:09:50 +13:00
logger.debug("Removing tmp data")
2021-04-06 02:13:27 +12:00
self.core.lgd.clean_tmp_data()
after = self.core.lgd.get_dir_size()
2021-12-24 22:09:50 +13:00
logger.info(
f"Cleanup complete! Removed {(before - after) / 1024 / 1024:.02f} MiB."
)
2021-04-23 00:34:06 +12:00
if (before - after) > 0:
2021-12-24 22:09:50 +13:00
QMessageBox.information(
self,
"Cleanup",
self.tr("Cleanup complete! Successfully removed {}").format(
format_size(before - after)
2021-12-24 22:09:50 +13:00
),
)
2021-04-06 02:13:27 +12:00
else:
QMessageBox.information(self, "Cleanup", "Nothing to clean")