Example #1
0
        public void GetInstalledGamesTest()
        {
            var library = new BattleNetLibrary();
            var games   = library.GetInstalledGames();

            CollectionAssert.IsNotEmpty(games);
        }
        public void UpdateGameWithMetadataTest()
        {
            var library  = new BattleNetLibrary();
            var games    = library.GetInstalledGames();
            var game     = games.First();
            var metadata = library.UpdateGameWithMetadata(game);

            Assert.IsNotNull(metadata.Icon);
        }
Example #3
0
        public void UninstallGame()
        {
            switch (Provider)
            {
            case Provider.Steam:
                Process.Start("steam://uninstall/" + ProviderId);
                RegisterStateMonitor(new SteamGameStateMonitor(ProviderId, new SteamLibrary()), GameStateMonitorType.Uninstall);
                break;

            case Provider.GOG:
                var uninstaller = Path.Combine(InstallDirectory, "unins000.exe");
                if (!File.Exists(uninstaller))
                {
                    throw new FileNotFoundException("Uninstaller not found.");
                }

                Process.Start(uninstaller);
                RegisterStateMonitor(new GogGameStateMonitor(ProviderId, InstallDirectory, new GogLibrary()), GameStateMonitorType.Uninstall);
                break;

            case Provider.Origin:
                Process.Start("appwiz.cpl");
                RegisterStateMonitor(new OriginGameStateMonitor(ProviderId, new OriginLibrary()), GameStateMonitorType.Uninstall);
                break;

            case Provider.Uplay:
                Process.Start("uplay://uninstall/" + ProviderId);
                RegisterStateMonitor(new UplayGameStateMonitor(ProviderId, new UplayLibrary()), GameStateMonitorType.Uninstall);
                break;

            case Provider.BattleNet:
                var product = BattleNetLibrary.GetAppDefinition(ProviderId);
                var entry   = BattleNetLibrary.GetUninstallEntry(product);
                if (entry != null)
                {
                    var args = string.Format("/C \"{0}\"", entry.UninstallString);
                    Process.Start("cmd", args);
                    RegisterStateMonitor(new BattleNetGameStateMonitor(product, new BattleNetLibrary()), GameStateMonitorType.Uninstall);
                }
                else
                {
                    RegisterStateMonitor(new BattleNetGameStateMonitor(product, new BattleNetLibrary()), GameStateMonitorType.Uninstall);
                }
                break;

            case Provider.Custom:
                break;

            default:
                break;
            }
        }
Example #4
0
        public void InstallGame()
        {
            switch (Provider)
            {
            case Provider.Steam:
                Process.Start(@"steam://install/" + ProviderId);
                RegisterStateMonitor(new SteamGameStateMonitor(ProviderId, new SteamLibrary()), GameStateMonitorType.Install);
                break;

            case Provider.GOG:
                Process.Start(@"goggalaxy://openGameView/" + ProviderId);
                RegisterStateMonitor(new GogGameStateMonitor(ProviderId, InstallDirectory, new GogLibrary()), GameStateMonitorType.Install);
                break;

            case Provider.Origin:
                Process.Start(string.Format(@"origin2://game/launch?offerIds={0}&autoDownload=true", ProviderId));
                RegisterStateMonitor(new OriginGameStateMonitor(ProviderId, new OriginLibrary()), GameStateMonitorType.Install);
                break;

            case Provider.Uplay:
                Process.Start("uplay://install/" + ProviderId);
                RegisterStateMonitor(new UplayGameStateMonitor(ProviderId, new UplayLibrary()), GameStateMonitorType.Install);
                break;

            case Provider.BattleNet:
                var product = BattleNetLibrary.GetAppDefinition(ProviderId);
                if (product.Type == BattleNetLibrary.BNetAppType.Classic)
                {
                    Process.Start(@"https://battle.net/account/management/download/");
                }
                else
                {
                    Process.Start(BattleNetSettings.ClientExecPath, $"--game={product.InternalId}");
                }
                RegisterStateMonitor(new BattleNetGameStateMonitor(product, new BattleNetLibrary()), GameStateMonitorType.Install);
                break;

            case Provider.Custom:
                break;

            default:
                break;
            }
        }