public async void StartUninstallWatcher()
        {
            watcherToken = new CancellationTokenSource();
            await Task.Run(async() =>
            {
                var app = BattleNetGames.GetAppDefinition(Game.GameId);

                while (true)
                {
                    if (watcherToken.IsCancellationRequested)
                    {
                        return;
                    }

                    var entry = BattleNetLibrary.GetUninstallEntry(app);
                    if (entry == null)
                    {
                        OnUninstalled(this, new GameControllerEventArgs(this, 0));
                        return;
                    }

                    await Task.Delay(2000);
                }
            });
        }
Пример #2
0
        public BattleNetLibrarySettings(BattleNetLibrary library, IPlayniteAPI api)
        {
            this.library = library;
            this.api     = api;

            var settings = library.LoadPluginSettings <BattleNetLibrarySettings>();

            if (settings != null)
            {
                LoadValues(settings);
            }
        }
        public async void StartInstallWatcher()
        {
            watcherToken = new CancellationTokenSource();
            await Task.Run(async() =>
            {
                var app = BattleNetGames.GetAppDefinition(Game.GameId);

                while (true)
                {
                    if (watcherToken.IsCancellationRequested)
                    {
                        return;
                    }

                    var install = BattleNetLibrary.GetUninstallEntry(app);
                    if (install == null)
                    {
                        await Task.Delay(2000);
                        continue;
                    }
                    else
                    {
                        if (Game.PlayAction == null)
                        {
                            if (app.Type == BNetAppType.Classic)
                            {
                                Game.PlayAction = new GameAction()
                                {
                                    Type       = GameActionType.File,
                                    WorkingDir = @"{InstallDir}",
                                    Path       = app.ClassicExecutable
                                };
                            }
                            else
                            {
                                Game.PlayAction = BattleNetLibrary.GetGamePlayTask(Game.GameId);
                            }
                        }

                        Game.InstallDirectory = install.InstallLocation;
                        OnInstalled(this, new GameControllerEventArgs(this, 0));
                        return;
                    }
                }
            });
        }
        public override void Uninstall()
        {
            ReleaseResources();
            var product = BattleNetGames.GetAppDefinition(Game.GameId);
            var entry   = BattleNetLibrary.GetUninstallEntry(product);

            if (entry != null)
            {
                var args = string.Format("/C \"{0}\"", entry.UninstallString);
                ProcessStarter.StartProcess("cmd", args);
                StartUninstallWatcher();
            }
            else
            {
                OnUninstalled(this, new GameControllerEventArgs(this, 0));
            }
        }
        public async void StartInstallWatcher()
        {
            watcherToken = new CancellationTokenSource();
            var app = BattleNetGames.GetAppDefinition(Game.GameId);

            while (true)
            {
                if (watcherToken.IsCancellationRequested)
                {
                    return;
                }

                var install = BattleNetLibrary.GetUninstallEntry(app);
                if (install == null)
                {
                    await Task.Delay(2000);

                    continue;
                }
                else
                {
                    var installInfo = new GameInfo()
                    {
                        InstallDirectory = install.InstallLocation
                    };

                    if (app.Type == BNetAppType.Classic)
                    {
                        installInfo.PlayAction = new GameAction()
                        {
                            Type       = GameActionType.File,
                            WorkingDir = ExpandableVariables.InstallationDirectory,
                            Path       = app.ClassicExecutable
                        };
                    }
                    else
                    {
                        installInfo.PlayAction = BattleNetLibrary.GetGamePlayTask(Game.GameId);
                    }

                    OnInstalled(this, new GameInstalledEventArgs(installInfo, this, 0));
                    return;
                }
            }
        }