public async void StartBnetRunningWatcher() { if (!BattleNet.IsRunning) { logger.Info("Battle.net is not running, starting it first."); BattleNet.StartClient(); while (BattleNet.RunningProcessesCount < 3) { await Task.Delay(500); } } var task = new GameAction() { Path = BattleNet.ClientExecPath, Arguments = string.Format("--exec=\"launch {0}\"", Game.GameId) }; GameActionActivator.ActivateAction(task); if (Directory.Exists(Game.InstallDirectory)) { procMon.TreeStarted += ProcMon_TreeStarted; procMon.WatchDirectoryProcesses(Game.InstallDirectory, false); } else { OnStopped(this, new GameControllerEventArgs(this, 0)); } }
public override async void Play() { ReleaseResources(); stopWatch = Stopwatch.StartNew(); procMon = new ProcessMonitor(); procMon.TreeDestroyed += Monitor_TreeDestroyed; var app = BattleNetGames.GetAppDefinition(Game.GameId); if (Game.PlayAction.Type == GameActionType.URL && Game.PlayAction.Path.StartsWith("battlenet", StringComparison.OrdinalIgnoreCase)) { if (!BattleNet.IsInstalled) { throw new Exception("Cannot start game, Battle.net launcher is not installed properly."); } var bnetRunning = BattleNet.IsRunning; if (!bnetRunning) { logger.Info("Battle.net is not running, starting it first."); BattleNet.StartClient(); while (BattleNet.RunningProcessesCount < 3) { await Task.Delay(500); } } OnStarting(this, new GameControllerEventArgs(this, 0)); var task = new GameAction() { Path = BattleNet.ClientExecPath, Arguments = string.Format("--exec=\"launch {0}\"", Game.GameId) }; GameActionActivator.ActivateAction(task, Game); procMon.TreeStarted += ProcMon_TreeStarted; procMon.WatchDirectoryProcesses(Game.InstallDirectory, false); } else if (app.Type == BNetAppType.Classic && Game.PlayAction.Path.Contains(app.ClassicExecutable)) { OnStarting(this, new GameControllerEventArgs(this, 0)); var proc = GameActionActivator.ActivateAction(Game.PlayAction, Game); procMon.WatchDirectoryProcesses(Game.InstallDirectory, true); OnStarted(this, new GameControllerEventArgs(this, 0)); } else { throw new Exception("Unknoww Play action configuration"); } }
public override void Open() { BattleNet.StartClient(); }