Add EA Desktop support

Add EA Desktop IDs for Dragon Age: Origins and Dragon Age 2.
This commit is contained in:
Jeroen Ruigrok van der Werven
2022-04-19 10:52:47 +02:00
parent 16939ac6c7
commit 9a8ebf3027
5 changed files with 87 additions and 7 deletions
+22 -2
View File
@@ -205,6 +205,7 @@ class BasicGameMappings:
gogAPPId: BasicGameOptionsMapping[str]
originManifestIds: BasicGameOptionsMapping[str]
originWatcherExecutables: BasicGameMapping[List[str]]
eaDesktopContentId: BasicGameOptionsMapping[str]
@staticmethod
def _default_documents_directory(game):
@@ -316,7 +317,9 @@ class BasicGameMappings:
apply_fn=lambda s: [s] if isinstance(s, str) else s,
default=lambda g: [],
)
self.eaDesktopContentId = BasicGameOptionsMapping(
game, "GameEaDesktopId", "eaDesktopContentId", default=lambda g: "", apply_fn=ids_apply
)
class BasicGame(mobase.IPluginGame):
@@ -328,16 +331,19 @@ class BasicGame(mobase.IPluginGame):
steam_games: Dict[str, Path]
gog_games: Dict[str, Path]
origin_games: Dict[str, Path]
eadesktop_games: Dict[str, Path]
@staticmethod
def setup():
from .gog_utils import find_games as find_gog_games
from .steam_utils import find_games as find_steam_games
from .origin_utils import find_games as find_origin_games
from .eadesktop_utils import find_games as find_eadesktop_games
BasicGame.steam_games = find_steam_games()
BasicGame.gog_games = find_gog_games()
BasicGame.origin_games = find_origin_games()
BasicGame.eadesktop_games = find_eadesktop_games()
# File containing the plugin:
_fromName: str
@@ -372,6 +378,9 @@ class BasicGame(mobase.IPluginGame):
def is_origin(self) -> bool:
return self._mappings.originManifestIds.has_value()
def is_eadesktop(self) -> bool:
return self._mappings.eaDesktopContentId.has_value()
# IPlugin interface:
def init(self, organizer: mobase.IOrganizer) -> bool:
@@ -434,6 +443,11 @@ class BasicGame(mobase.IPluginGame):
self.setGamePath(BasicGame.origin_games[origin_manifest_id])
return
for eadesktop_content_id in self._mappings.eaDesktopContentId.get():
if eadesktop_content_id in BasicGame.eadesktop_games:
self.setGamePath(BasicGame.eadesktop_games[eadesktop_content_id])
return
def gameName(self) -> str:
return self._mappings.gameName.get()
@@ -463,6 +477,9 @@ class BasicGame(mobase.IPluginGame):
def gogAPPId(self) -> str:
return self._mappings.gogAPPId.current()
def eaDesktopContentId(self) -> str:
return self._mappings.eaDesktopContentId.current()
def binaryName(self) -> str:
return self._mappings.binaryName.get()
@@ -560,7 +577,7 @@ class BasicGame(mobase.IPluginGame):
path = Path(path)
# Check if we have a matching steam ID or GOG id and set the index accordingly:
# Check if we have a matching steam, GOG, Origin or EA Desktop id and set the index accordingly:
for steamid, steampath in BasicGame.steam_games.items():
if steampath == path:
self._mappings.steamAPPId.set_value(steamid)
@@ -570,6 +587,9 @@ class BasicGame(mobase.IPluginGame):
for originid, originpath in BasicGame.origin_games.items():
if originpath == path:
self._mappings.originManifestIds.set_value(originid)
for eadesktopid, eadesktoppath in BasicGame.eadesktop_games.items():
if eadesktoppath == path:
self._mappings.eaDesktopContentId.set_value(eadesktopid)
def documentsDirectory(self) -> QDir:
return self._mappings.documentsDirectory.get()