RareGame: Moved some properties and methods to RareGameBase
These properties or methods were moved to RareGameBase * `version`: For RareEosOverlay and maybe RareGameSlim * `is_origin`: For RareGameSlim * `install_path`: A partial Origin-unaware version * `is_mac/is_win32`: For completeness New methods * `is_overlay`: For the download manager Signed-off-by: loathingKernel <142770+loathingKernel@users.noreply.github.com>
This commit is contained in:
parent
a355339016
commit
c56e7ce82c
|
@ -6,6 +6,7 @@ from logging import getLogger
|
|||
from typing import Optional, List, Tuple
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSignal, QRunnable, QThreadPool, QSettings
|
||||
from legendary.lfs import eos
|
||||
from legendary.models.game import SaveGameFile, SaveGameStatus, Game, InstalledGame
|
||||
|
||||
from rare.lgndr.core import LegendaryCore
|
||||
|
@ -115,32 +116,6 @@ class RareGameBase(QObject):
|
|||
def set_installed(self, installed: bool) -> None:
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_mac(self) -> bool:
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_win32(self) -> bool:
|
||||
pass
|
||||
|
||||
|
||||
class RareGameSlim(RareGameBase):
|
||||
|
||||
def __init__(self, legendary_core: LegendaryCore, game: Game):
|
||||
super(RareGameSlim, self).__init__(legendary_core, game)
|
||||
# None if origin or not installed
|
||||
self.igame: Optional[InstalledGame] = self.core.get_installed_game(game.app_name)
|
||||
self.saves: List[RareSaveGame] = []
|
||||
|
||||
@property
|
||||
def is_installed(self) -> bool:
|
||||
return True
|
||||
|
||||
def set_installed(self, installed: bool) -> None:
|
||||
pass
|
||||
|
||||
@property
|
||||
def platforms(self) -> Tuple:
|
||||
"""!
|
||||
|
@ -168,6 +143,60 @@ class RareGameSlim(RareGameBase):
|
|||
"""
|
||||
return "Win32" in self.game.asset_infos.keys()
|
||||
|
||||
@property
|
||||
def is_origin(self) -> bool:
|
||||
"""!
|
||||
@brief Property to report if a Game is an Origin game
|
||||
|
||||
Legendary and by extenstion Rare can't launch Origin games directly,
|
||||
it just launches the Origin client and thus requires a bit of a special
|
||||
handling to let the user know.
|
||||
|
||||
@return bool If the game is an Origin game
|
||||
"""
|
||||
return (
|
||||
self.game.metadata.get("customAttributes", {}).get("ThirdPartyManagedApp", {}).get("value") == "Origin"
|
||||
)
|
||||
|
||||
@property
|
||||
def is_overlay(self):
|
||||
return self.app_name == eos.EOSOverlayApp.app_name
|
||||
|
||||
@property
|
||||
def version(self) -> str:
|
||||
"""!
|
||||
@brief Reports the currently installed version of the Game
|
||||
|
||||
If InstalledGame reports the currently installed version, which might be
|
||||
different from the remote version available from EGS. For not installed Games
|
||||
it reports the already known version.
|
||||
|
||||
@return str The current version of the game
|
||||
"""
|
||||
return self.igame.version if self.igame is not None else self.game.app_version()
|
||||
|
||||
@property
|
||||
def install_path(self) -> Optional[str]:
|
||||
if self.igame:
|
||||
return self.igame.install_path
|
||||
return None
|
||||
|
||||
|
||||
class RareGameSlim(RareGameBase):
|
||||
|
||||
def __init__(self, legendary_core: LegendaryCore, game: Game):
|
||||
super(RareGameSlim, self).__init__(legendary_core, game)
|
||||
# None if origin or not installed
|
||||
self.igame: Optional[InstalledGame] = self.core.get_installed_game(game.app_name)
|
||||
self.saves: List[RareSaveGame] = []
|
||||
|
||||
@property
|
||||
def is_installed(self) -> bool:
|
||||
return True
|
||||
|
||||
def set_installed(self, installed: bool) -> None:
|
||||
pass
|
||||
|
||||
@property
|
||||
def auto_sync_saves(self):
|
||||
return self.supports_cloud_saves and QSettings().value(
|
||||
|
|
|
@ -202,12 +202,10 @@ class RareGame(RareGameSlim):
|
|||
|
||||
@property
|
||||
def install_path(self) -> Optional[str]:
|
||||
if self.igame:
|
||||
return self.igame.install_path
|
||||
elif self.is_origin:
|
||||
if self.is_origin:
|
||||
# TODO Linux is also C:\\...
|
||||
return self.__origin_install_path
|
||||
return None
|
||||
return super(RareGame, self).install_path
|
||||
|
||||
@install_path.setter
|
||||
def install_path(self, path: str) -> None:
|
||||
|
@ -217,19 +215,6 @@ class RareGame(RareGameSlim):
|
|||
elif self.is_origin:
|
||||
self.__origin_install_path = path
|
||||
|
||||
@property
|
||||
def version(self) -> str:
|
||||
"""!
|
||||
@brief Reports the currently installed version of the Game
|
||||
|
||||
If InstalledGame reports the currently installed version, which might be
|
||||
different from the remote version available from EGS. For not installed Games
|
||||
it reports the already known version.
|
||||
|
||||
@return str The current version of the game
|
||||
"""
|
||||
return self.igame.version if self.igame is not None else self.game.app_version()
|
||||
|
||||
@property
|
||||
def remote_version(self) -> str:
|
||||
"""!
|
||||
|
@ -423,21 +408,6 @@ class RareGame(RareGameSlim):
|
|||
# Asset infos are usually None, but there was a bug, that it was an empty GameAsset class
|
||||
return not self.game.asset_infos or not next(iter(self.game.asset_infos.values())).app_name
|
||||
|
||||
@property
|
||||
def is_origin(self) -> bool:
|
||||
"""!
|
||||
@brief Property to report if a Game is an Origin game
|
||||
|
||||
Legendary and by extenstion Rare can't launch Origin games directly,
|
||||
it just launches the Origin client and thus requires a bit of a special
|
||||
handling to let the user know.
|
||||
|
||||
@return bool If the game is an Origin game
|
||||
"""
|
||||
return (
|
||||
self.game.metadata.get("customAttributes", {}).get("ThirdPartyManagedApp", {}).get("value") == "Origin"
|
||||
)
|
||||
|
||||
@property
|
||||
def is_ubisoft(self) -> bool:
|
||||
return (
|
||||
|
@ -612,11 +582,3 @@ class RareEosOverlay(RareGameBase):
|
|||
else:
|
||||
self.igame = None
|
||||
self.signals.game.uninstalled.emit(self.app_name)
|
||||
|
||||
@property
|
||||
def is_mac(self) -> bool:
|
||||
return False
|
||||
|
||||
@property
|
||||
def is_win32(self) -> bool:
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue