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));
        }
Exemple #2
0
 public GameStartedEventArgs(IGame game, GameCommandArguments gameArguments, GameBuildType buildType, Process process)
 {
     Game          = game;
     GameArguments = gameArguments;
     BuildType     = buildType;
     Process       = process;
 }
 internal static void Validate(this GameCommandArguments args)
 {
     if (args.Mods != null && args.Mods.Any(x => x.Type == ModType.Virtual))
     {
         throw new GameArgumentException("The mod list must not contain any virtual mods");
     }
 }
        internal static string ToArgs(this GameCommandArguments args)
        {
            var sb = new StringBuilder();

            sb.Append(CreateModArgs(args.Mods));

            if (args.IgnoreAsserts)
            {
                sb.Append(" IGNOREASSERTS");
            }
            if (args.NoArtProcess)
            {
                sb.Append(" NOARTPROCESS");
            }
            if (args.Windowed)
            {
                sb.Append(" WINDOWED");
            }
            string lang = !string.IsNullOrEmpty(args.Language) ? args.Language ! : "ENGLISH";

            sb.Append($" LANGUAGE={lang}");

            return(sb.ToString().Trim(' '));
        }
Exemple #5
0
 public GameStartingEventArgs(IGame game, GameCommandArguments arguments, GameBuildType buildType)
 {
     Game          = game;
     GameArguments = arguments;
     BuildType     = buildType;
 }