public async void StartInstallWatcher() { watcherToken = new CancellationTokenSource(); var manifest = origin.GetLocalManifest(Game.GameId); if (manifest?.publishing == null) { logger.Error($"No publishing manifest found for Origin game {Game.GameId}, stopping installation check."); OnUninstalled(this, new GameControllerEventArgs(this, 0)); return; } var platform = manifest.publishing.softwareList.software.FirstOrDefault(a => a.softwarePlatform == "PCWIN"); while (true) { if (watcherToken.IsCancellationRequested) { return; } var executablePath = origin.GetPathFromPlatformPath(platform.fulfillmentAttributes.installCheckOverride); if (!executablePath?.CompletePath.IsNullOrEmpty() != null) { if (File.Exists(executablePath.CompletePath)) { var installInfo = new GameInfo() { PlayAction = new GameAction { Type = GameActionType.URL, Path = Origin.GetLaunchString(Game.GameId), IsHandledByPlugin = true }, InstallDirectory = origin.GetInstallDirectory(manifest) }; OnInstalled(this, new GameInstalledEventArgs(installInfo, this, 0)); return; } } await Task.Delay(2000); } }
public override void Play() { ReleaseResources(); OnStarting(this, new GameControllerEventArgs(this, 0)); if (Directory.Exists(Game.InstallDirectory)) { stopWatch = Stopwatch.StartNew(); procMon = new ProcessMonitor(); procMon.TreeDestroyed += ProcMon_TreeDestroyed; procMon.TreeStarted += ProcMon_TreeStarted; ProcessStarter.StartUrl(Origin.GetLaunchString(Game.GameId)); StartRunningWatcher(); } else { OnStopped(this, new GameControllerEventArgs(this, 0)); } }
public Dictionary <string, GameInfo> GetInstalledGames() { var contentPath = Path.Combine(Origin.DataPath, "LocalContent"); var games = new Dictionary <string, GameInfo>(); if (Directory.Exists(contentPath)) { var packages = Directory.GetFiles(contentPath, "*.mfst", SearchOption.AllDirectories); foreach (var package in packages) { try { var gameId = Path.GetFileNameWithoutExtension(package); if (!gameId.StartsWith("Origin")) { // Get game id by fixing file via adding : before integer part of the name // for example OFB-EAST52017 converts to OFB-EAST:52017 var match = Regex.Match(gameId, @"^(.*?)(\d+)$"); if (!match.Success) { logger.Warn("Failed to get game id from file " + package); continue; } gameId = match.Groups[1].Value + ":" + match.Groups[2].Value; } var newGame = new GameInfo() { Source = "Origin", GameId = gameId, IsInstalled = true, Platform = "PC" }; GameLocalDataResponse localData = null; try { localData = GetLocalManifest(gameId); } catch (Exception e) when(!Environment.IsDebugBuild) { logger.Error(e, $"Failed to get Origin manifest for a {gameId}, {package}"); continue; } if (localData == null) { continue; } if (localData.offerType != "Base Game" && localData.offerType != "DEMO") { continue; } newGame.Name = StringExtensions.NormalizeGameName(localData.localizableAttributes.displayName); var installDir = GetInstallDirectory(localData); if (installDir.IsNullOrEmpty()) { continue; } newGame.InstallDirectory = installDir; newGame.PlayAction = new GameAction { IsHandledByPlugin = true, Type = GameActionType.URL, Path = Origin.GetLaunchString(gameId) }; games.Add(newGame.GameId, newGame); } catch (Exception e) when(!Environment.IsDebugBuild) { logger.Error(e, $"Failed to import installed Origin game {package}."); } } } return(games); }
public Dictionary <string, GameInfo> GetInstalledGames() { var games = new Dictionary <string, GameInfo>(); foreach (var package in GetInstallPackages()) { try { var newGame = new GameInfo() { Source = "Origin", GameId = package.ConvertedId, IsInstalled = true, Platform = "PC" }; GameLocalDataResponse localData = null; try { localData = GetLocalManifest(package.ConvertedId); } catch (Exception e) when(!Environment.IsDebugBuild) { logger.Error(e, $"Failed to get Origin manifest for a {package.ConvertedId}, {package}"); continue; } if (localData == null) { continue; } if (localData.offerType != "Base Game" && localData.offerType != "DEMO") { continue; } newGame.Name = StringExtensions.NormalizeGameName(localData.localizableAttributes.displayName); var installDir = GetInstallDirectory(localData); if (installDir.IsNullOrEmpty()) { continue; } newGame.InstallDirectory = installDir; newGame.PlayAction = new GameAction { IsHandledByPlugin = true, Type = GameActionType.URL, Path = Origin.GetLaunchString(package.ConvertedId + package.Source) }; games.Add(newGame.GameId, newGame); } catch (Exception e) when(!Environment.IsDebugBuild) { logger.Error(e, $"Failed to import installed Origin game {package}."); } } return(games); }