Beispiel #1
0
        private void DoLaunchGame()
        {
            var username               = IsMF ? _ConfigManager.MFUsername : Environment.UserName;
            var originalAppDataPath    = PathHelper.GetOriginalAppDataPathByUsername(username);
            var originalAppScreensPath = PathHelper.GetOriginalAppScreensPathByUsername(username);
            var gameAppDataPath        = PathHelper.GetGameAppDataPathByGamePath(GamePath);
            var gameAppScreensPath     = PathHelper.GetGameAppScreensPathByGamePath(GamePath);

            if (_ConfigManager.IsRunningMF || _ConfigManager.IsRunningGF)
            {
                if (!GameStateHelper.KillMutant())
                {
                    UtilHelper.ShowAlertDialog(new AlertDialogInterfaceModel {
                        Content = "KillMutant失败"
                    });
                    return;
                }
            }

            Directory.CreateDirectory(gameAppDataPath);
            Directory.CreateDirectory(gameAppScreensPath);

            if (!UtilHelper.RemoveAndCreateDirectoryLink(originalAppDataPath, gameAppDataPath))
            {
                UtilHelper.ShowAlertDialog(new AlertDialogInterfaceModel {
                    Content = "创建配置文件夹链接失败"
                });
                return;
            }

            if (!UtilHelper.RemoveAndCreateDirectoryLink(originalAppScreensPath, gameAppScreensPath))
            {
                UtilHelper.ShowAlertDialog(new AlertDialogInterfaceModel {
                    Content = "创建截图文件夹链接失败"
                });
                return;
            }

            if (IsMF)
            {
                Process.Start(new ProcessStartInfo()
                {
                    UserName        = _ConfigManager.MFUsername,
                    Password        = UtilHelper.ConvertStringToSecureString(_ConfigManager.MFPassword),
                    FileName        = _ConfigManager.MFPath,
                    Arguments       = string.Join(" ", _ConfigManager.MFStartupArgumentList.Where(item => item.Enable).Select(item => item.Command)),
                    UseShellExecute = false,
                    LoadUserProfile = true,
                });
            }
            else
            {
                Process.Start(new ProcessStartInfo()
                {
                    FileName        = _ConfigManager.GFPath,
                    Arguments       = string.Join(" ", _ConfigManager.GFStartupArgumentList.Where(item => item.Enable).Select(item => item.Command)),
                    UseShellExecute = false,
                });
            }

            if (_ConfigManager.ExitOnStartup)
            {
                Environment.Exit(0);
                return;
            }

            CheckGameRunningState();
        }