private void ReportStatus(string status, LaunchItem launchItem)
 {
     if (ReportStatusEvent != null)
     {
         ReportStatusEvent(status, launchItem);
     }
 }
Example #2
0
 private void FireReportLaunchItemStatusEvent(string status, LaunchItem launchItem)
 {
     if (ReportLaunchItemStatusEvent != null)
     {
         ReportLaunchItemStatusEvent(status, launchItem, _serverIndex, _serverTotal);
     }
 }
Example #3
0
        void launchGameFromItem(WorkerArgs args, LaunchItem launchItem, Dictionary <string, DateTime> accountLaunchTimes)
        {
            Logger.WriteDebug("launchGameFromItem on thread {0}: Account={1}, Server={2}, Char={3}",
                              Thread.CurrentThread.ManagedThreadId,
                              launchItem.AccountName, launchItem.ServerName, launchItem.CharacterSelected);
            LaunchManager mgr = new LaunchManager(args.ClientExeLocation, launchItem, accountLaunchTimes);

            mgr.ReportStatusEvent += (status, item) => FireReportLaunchItemStatusEvent(status, item);
            LaunchManager.LaunchManagerResult launchResult;
            GameSession session = null;

            try
            {
                session = _gameSessionMap.StartLaunchingSession(launchItem.ServerName, launchItem.AccountName);
                FireReportAccountStatusEvent(ServerAccountStatusEnum.Starting, launchItem);
                launchResult = mgr.LaunchGameHandlingDelaysAndTitles(_worker);
            }
            finally
            {
                _gameSessionMap.EndLaunchingSession(launchItem.ServerName, launchItem.AccountName);
            }

            if (launchResult.Success)
            {
                ++_serverIndex;
                // Let's just wait for game monitor to check if the character list changed
                // b/c the AccountManager is subscribed for that event
                //CallUiNotifyAvailableCharactersChanged(); // Pick up any characters - experimental 2017-04-10
                // CallUiLoadUserAccounts(); // Pick up any characters - before 2017-04-10
                _gameSessionMap.StartSessionWatcher(session);
                session.WindowHwnd = launchResult.Hwnd;
                // session.ProcessId is already populated
                FireReportLaunchItemStatusEvent(GameStatusNotice.CreateSuccess("Launched"), launchItem);
            }
        }
        void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerArgs args = (e.Argument as WorkerArgs);

            if (args == null)
            {
                return;
            }
            lock (_launchTimingLock)
            {
                _lastLaunchInitiatedUtc = DateTime.UtcNow;
            }
            int serverIndex = 0;

            System.Collections.Concurrent.ConcurrentQueue <LaunchItem> globalQueue = args.ConcurrentLaunchQueue;
            int serverTotal = globalQueue.Count;

            if (serverTotal == 0)
            {
                return;
            }

            LaunchItem launchItem         = null;
            var        accountLaunchTimes = _gameSessionMap.GetLaunchAccountTimes();

            while (globalQueue.TryDequeue(out launchItem))
            {
                LaunchManager mgr = new LaunchManager(_launcherLocation, launchItem, accountLaunchTimes);
                mgr.ReportStatusEvent += (status, item) => HandleLaunchMgrStatus(status, item, serverIndex, serverTotal);
                LaunchManager.LaunchManagerResult launchResult;
                GameSession session = null;
                try
                {
                    session = _gameSessionMap.StartLaunchingSession(launchItem.ServerName, launchItem.AccountName);
                    UpdateAccountStatus(ServerAccountStatusEnum.Starting, launchItem);
                    launchResult = mgr.LaunchGameHandlingDelaysAndTitles(_worker);
                }
                finally
                {
                    _gameSessionMap.EndLaunchingSession(launchItem.ServerName, launchItem.AccountName);
                }

                if (launchResult.Success)
                {
                    ++serverIndex;
                    // Let's just wait for game monitor to check if the character list changed
                    // b/c the AccountManager is subscribed for that event
                    //CallUiNotifyAvailableCharactersChanged(); // Pick up any characters - experimental 2017-04-10
                    // CallUiLoadUserAccounts(); // Pick up any characters - before 2017-04-10
                    _gameSessionMap.StartSessionWatcher(session);
                    workerReportProgress("Launched", launchItem, serverIndex, serverTotal);
                }

                if (_worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
            }
        }
 void OnRequestExecuteSimpleLaunch(LaunchItem launchItem)
 {
     if (LaunchingSimpleGameEvent == null)
     {
         throw new Exception("MainWindowViewModel null LaunchingSimpleGameEvent");
     }
     LaunchingSimpleGameEvent(launchItem);
 }
Example #6
0
 private void ReportStatus(GameStatusNotice statusNotice, LaunchItem launchItem)
 {
     if (ReportStatusEvent == null)
     {
         return;
     }
     ReportStatusEvent(statusNotice, launchItem);
 }
Example #7
0
 private void FireReportLaunchItemStatusEvent(GameStatusNotice statusNotice, LaunchItem launchItem)
 {
     if (ReportLaunchItemStatusEvent == null)
     {
         return;
     }
     ReportLaunchItemStatusEvent(statusNotice, launchItem, _serverIndex, _serverTotal);
 }
 private string GetLaunchItemLauncherLocation(LaunchItem item)
 {
     if (!string.IsNullOrEmpty(item.CustomLaunchPath))
     {
         return(item.CustomLaunchPath);
     }
     else
     {
         return(_launcherLocation);
     }
 }
Example #9
0
 private void LaunchSimpleClient(LaunchItem launchItem)
 {
     if (_worker.IsBusy)
     {
         lblWorkerProgress.Content = "Launcher In Use";
     }
     else
     {
         Properties.Settings.Default.Save();
         _launchConcurrentQueue.Enqueue(launchItem);
         EnableInterface(false);
         btnCancel.IsEnabled = true;
         _launchWorker.LaunchQueue(_launchConcurrentQueue, _clientExeLocation);
     }
 }
Example #10
0
        void workerReportProgress(string verb, LaunchItem launchItem, int index, int total)
        {
            int    pct     = (int)(100.0 * index / total);
            string context = string.Format(
                "{0} {1}:{2}",
                verb, launchItem.AccountName, launchItem.ServerName);
            var progressInfo = new ProgressInfo()
            {
                Index   = index,
                Total   = total,
                Message = context
            };

            _worker.ReportProgress(pct, progressInfo);
        }
 private string GetNewGameTitle(LaunchItem launchItem)
 {
     if (launchItem.CharacterSelected == "None")
     {
         string pattern = ConfigSettings.GetConfigString("NewGameTitleNoChar", "");
         pattern = pattern.Replace("%ACCOUNT%", launchItem.AccountName);
         pattern = pattern.Replace("%SERVER%", launchItem.ServerName);
         return(pattern);
     }
     else
     {
         string pattern = ConfigSettings.GetConfigString("NewGameTitle", "");
         pattern = pattern.Replace("%ACCOUNT%", launchItem.AccountName);
         pattern = pattern.Replace("%SERVER%", launchItem.ServerName);
         pattern = pattern.Replace("%CHARACTER%", launchItem.CharacterSelected);
         return(pattern);
     }
 }
Example #12
0
 private void LaunchSimpleClient(LaunchItem launchItem)
 {
     if (_worker.IsBusy)
     {
         lblWorkerProgress.Content = "Launcher In Use";
     }
     else
     {
         Properties.Settings.Default.Save();
         _launchConcurrentQueue.Enqueue(launchItem);
         EnableInterface(false);
         btnCancel.IsEnabled = true;
         WorkerArgs args = new WorkerArgs()
         {
             ConcurrentLaunchQueue = _launchConcurrentQueue
         };
         _worker.RunWorkerAsync(args);
     }
 }
Example #13
0
        /// <summary>
        /// Get all server/accounts that are checked to be launched
        /// AND that are not already running
        /// </summary>
        /// <param name="accountList"></param>
        /// <returns></returns>
        private LaunchSorter.LaunchList GetLaunchListFromAccountList(IEnumerable <UserAccount> accountList)
        {
            var launchList = new LaunchSorter.LaunchList();

            foreach (var account in accountList)
            {
                if (account.AccountLaunchable)
                {
                    foreach (var server in account.Servers)
                    {
                        if (server.ServerSelected)
                        {
                            var state = _gameSessionMap.GetGameSessionStateByServerAccount(serverName: server.ServerName, accountName: account.Name);
                            if (state != ServerAccountStatusEnum.None)
                            {
                                continue;
                            }
                            var launchItem = new LaunchItem()
                            {
                                Alias                = account.Alias,
                                AccountName          = account.Name,
                                Priority             = account.Priority,
                                Password             = account.Password,
                                ServerName           = server.ServerName,
                                IpAndPort            = server.ServerIpAndPort,
                                GameApiUrl           = server.GameApiUrl,
                                LoginServerUrl       = server.LoginServerUrl,
                                DiscordUrl           = server.DiscordUrl,
                                EMU                  = server.EMU,
                                CharacterSelected    = server.ChosenCharacter,
                                CustomLaunchPath     = account.CustomLaunchPath,
                                CustomPreferencePath = account.CustomPreferencePath,
                                RodatSetting         = server.RodatSetting,
                                SecureSetting        = server.SecureSetting
                            };
                            launchList.Add(launchItem);
                        }
                    }
                }
            }
            return(launchList);
        }
        private void LaunchSimpleGame(string path, ServerModel server, string account, string pwd)
        {
            SaveToSettings();
            var launchItem = new LaunchItem();

            launchItem.CustomLaunchPath = path;
            launchItem.ServerName       = server.ServerName;
            launchItem.AccountName      = account;
            launchItem.Password         = pwd;
            launchItem.IpAndPort        = server.ServerIpAndPort;
            launchItem.EMU = server.EMU;
            launchItem.CharacterSelected = null; // no character choices for SimpleLaunch, b/c that requires MagFilter
            launchItem.RodatSetting      = server.RodatSetting;
            launchItem.IsSimpleLaunch    = true;

            if (LaunchingEvent == null)
            {
                throw new Exception("SimpleLaunchWindowViewModel.LaunchingEvent null");
            }
            LaunchingEvent(launchItem);
        }
Example #15
0
        void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerArgs args = (e.Argument as WorkerArgs);

            if (args == null)
            {
                return;
            }
            lock (_launchTimingLock)
            {
                _lastLaunchInitiatedUtc = DateTime.UtcNow;
            }
            _serverIndex = 0;
            System.Collections.Concurrent.ConcurrentQueue <LaunchItem> globalQueue = args.ConcurrentLaunchQueue;
            _serverTotal = globalQueue.Count;
            if (_serverTotal == 0)
            {
                return;
            }

            LaunchItem launchItem         = null;
            var        accountLaunchTimes = _gameSessionMap.GetLaunchAccountTimes();

            while (globalQueue.TryDequeue(out launchItem))
            {
                int threadDelayMs = ConfigSettings.GetConfigInt("ThreadGameLaunchDelayMs", 100);
                Thread.Sleep(threadDelayMs);
                new Thread((x) =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    launchGameFromItem(args, (LaunchItem)x, accountLaunchTimes);
                }).Start(launchItem);

                if (_worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
            }
        }
Example #16
0
        private string GetNewGameTitle(LaunchItem launchItem)
        {
            string pattern = ConfigSettings.GetConfigString("NewGameTitle", "");

            if (launchItem.CharacterSelected == "None")
            {
                pattern = ConfigSettings.GetConfigString("NewGameTitleNoChar", "");
            }
            string alias = launchItem.Alias;

            if (string.IsNullOrEmpty(alias))
            {
                alias = launchItem.AccountName;
            }                                                                    // fall back to account if no alias
            pattern = pattern.Replace("%ALIAS%", alias);
            pattern = pattern.Replace("%ACCOUNT%", launchItem.AccountName);
            pattern = pattern.Replace("%SERVER%", launchItem.ServerName);
            if (launchItem.CharacterSelected != "None")
            {
                pattern = pattern.Replace("%CHARACTER%", launchItem.CharacterSelected);
            }
            return(pattern);
        }
 public LaunchManager(string launcherLocation, LaunchItem launchItem, Dictionary <string, DateTime> accountLaunchTimes)
 {
     _launcherLocation   = launcherLocation;
     _launchItem         = launchItem;
     _accountLaunchTimes = accountLaunchTimes;
 }
Example #18
0
 private void FireReportAccountStatusEvent(ServerAccountStatusEnum accountStatus, LaunchItem launchItem)
 {
     if (ReportAccountStatusEvent != null)
     {
         ReportAccountStatusEvent(accountStatus, launchItem);
     }
 }
Example #19
0
 private void UpdateAccountStatus(ServerAccountStatusEnum status, LaunchItem launchItem)
 {
     _viewModel.UpdateAccountStatus(launchItem.ServerName, launchItem.AccountName, status);
 }
Example #20
0
 private void LauncherReportingLaunchItemStatusEvent(GameStatusNotice statusNotice, LaunchItem launchItem, int serverIndex, int serverTotal)
 {
     if (statusNotice.IsWrongServer)
     {
         // TODO - 2020-08-12, Need to test this
         MessageBox.Show(statusNotice.StatusText, "Wrong Server");
     }
 }
Example #21
0
 public void PushBottom(LaunchItem item)
 {
     Add(item);
 }
Example #22
0
 public void Add(LaunchItem item)
 {
     _launchItems.Add(item);
 }
Example #23
0
 private void HandleLaunchMgrStatus(string status, LaunchItem launchItem, int serverIndex, int serverTotal)
 {
     workerReportProgress(status, launchItem, serverIndex, serverTotal);
 }