protected void StartGame(GameCommandArguments gameArgs, GameStartInfo gameStartInfo, string?iconFile = null)
        {
            if (!Exists())
            {
                throw new Exception("Game was not found");
            }
            var startingArguments = new GameStartingEventArgs(this, gameArgs, gameStartInfo.BuildType);

            OnGameStarting(startingArguments);
            if (startingArguments.Cancel)
            {
                return;
            }

            gameArgs.Validate();
            var processStartInfo = CreateGameProcess(gameArgs.ToArgs(), gameStartInfo.Executable);

            Process process;

            try
            {
                process = StartGameProcess(processStartInfo, iconFile);
            }
            catch (Exception e)
            {
                throw new GameStartException(e.Message, e);
            }

            OnGameStarted(new GameStartedEventArgs(this, gameArgs, gameStartInfo.BuildType, process));
        }
 protected override void OnGameStarting(GameStartingEventArgs args)
 {
     if (!SteamClient.Instance.IsRunning)
     {
         ThreadHelper.JoinableTaskFactory.Run(async() =>
         {
             var data    = new WaitDialogProgressData("Waiting for Steam...", isCancelable: true);
             using var s = WaitDialogFactory.Instance.StartWaitDialog("FoC Launcher", data, TimeSpan.FromSeconds(2));
             SteamClient.Instance.StartSteam();
             try
             {
                 await SteamClient.Instance.WaitSteamRunningAndLoggedInAsync(s.UserCancellationToken);
             }
             catch (OperationCanceledException)
             {
                 args.Cancel = true;
             }
         });
     }
     base.OnGameStarting(args);
 }
 protected virtual void OnGameStarting(GameStartingEventArgs args)
 {
     GameStarting?.Invoke(this, args);
 }
示例#4
0
 protected override void OnGameStarting(GameStartingEventArgs args)
 {
     if (args.GameArguments.Mods is null || args.GameArguments.Mods.Any())
         return;
     base.OnGameStarting(args);
 }