예제 #1
0
        private void ReportGameStatusWaiting(string status)
        {
            if (ReportGameStatusEvent == null)
            {
                return;
            }
            var statusNotice = GameStatusNotice.CreateWaiting(status);

            ReportGameStatusEvent(statusNotice);
        }
예제 #2
0
        public LaunchManagerResult LaunchGameHandlingDelaysAndTitles(BackgroundWorker worker)
        {
            var result = new LaunchManagerResult();

            if (worker.CancellationPending)
            {
                return(result);
            }

            GameLaunchResult gameLaunchResult = null;

            ReportStatus(GameStatusNotice.CreateWaiting("Launching"), _launchItem);
            _accountLaunchTimes[_launchItem.AccountName] = DateTime.UtcNow;

            var launcher = new GameLauncher();

            launcher.ReportGameStatusEvent += (o) => { ReportStatus(o, _launchItem); };
            launcher.StopLaunchEvent       += (o, eventArgs) => { return(worker.CancellationPending); };
            try
            {
                var    finder       = new ThwargUtils.WindowFinder();
                string launcherPath = GetLaunchItemLauncherLocation(_launchItem);
                OverridePreferenceFile(_launchItem.CustomPreferencePath);
                gameLaunchResult = launcher.LaunchGameClient(
                    launcherPath,
                    _launchItem.ServerName,
                    accountName: _launchItem.AccountName,
                    password: _launchItem.Password,
                    ipAddress: _launchItem.IpAndPort,
                    gameApiUrl: _launchItem.GameApiUrl,
                    loginServerUrl: _launchItem.LoginServerUrl,
                    discordurl: _launchItem.DiscordUrl,
                    emu: _launchItem.EMU,
                    desiredCharacter: _launchItem.CharacterSelected,
                    rodatSetting: _launchItem.RodatSetting,
                    secureSetting: _launchItem.SecureSetting,
                    simpleLaunch: _launchItem.IsSimpleLaunch
                    );
                if (!gameLaunchResult.Success)
                {
                    return(result);
                }
                var regex = GetGameWindowCaptionRegex();
                if (regex != null)
                {
                    IntPtr hwnd = finder.FindWindowByCaptionAndProcessId(regex, newWindow: true, processId: gameLaunchResult.ProcessId);
                    if (hwnd != IntPtr.Zero)
                    {
                        result.Hwnd = hwnd;
                        string newGameTitle = GetNewGameTitle(_launchItem);
                        if (!string.IsNullOrEmpty(newGameTitle))
                        {
                            Logger.WriteDebug("Found hwnd: " + newGameTitle);
                            finder.SetWindowTitle(hwnd, newGameTitle);
                        }
                    }
                    else
                    {
                        Logger.WriteDebug("Unable to find hwnd");
                    }
                }
            }
            catch (Exception exc)
            {
                var statusNotice = GameStatusNotice.CreateFailure("Exception launching game launcher: " + exc.Message);
                ReportStatus(statusNotice, _launchItem);
                return(result);
            }
            if (gameLaunchResult != null && gameLaunchResult.Success)
            {
                result.Success   = true;
                result.ProcessId = gameLaunchResult.ProcessId;
            }
            return(result);
        }