Exemplo n.º 1
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("Launched", launchItem);
            }
        }
Exemplo n.º 2
0
 private void FireReportLaunchItemStatusEvent(string status, LaunchItem launchItem)
 {
     if (ReportLaunchItemStatusEvent != null)
     {
         ReportLaunchItemStatusEvent(status, launchItem, _serverIndex, _serverTotal);
     }
 }
Exemplo n.º 3
0
 private void ReportStatus(string status, LaunchItem launchItem)
 {
     if (ReportStatusEvent != null)
     {
         ReportStatusEvent(status, launchItem);
     }
 }
Exemplo n.º 4
0
 void OnRequestExecuteSimpleLaunch(LaunchItem launchItem)
 {
     if (LaunchingSimpleGameEvent == null)
     {
         throw new Exception("MainWindowViewModel null LaunchingSimpleGameEvent");
     }
     LaunchingSimpleGameEvent(launchItem);
 }
Exemplo n.º 5
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();

            if (_gameSessionMap.GetAllGameSessions().Count >= 3)
            {
                return(launchList);
            }

            count_abc = (count_abc + 1) % 10;

            foreach (var account in accountList)
            {
                if (account.AccountLaunchable)
                {
                    foreach (var server in account.Servers)
                    {
                        if (server.ServerSelected)
                        {
                            var account_name = account.Name;
                            if (account.Name.ToLower().Contains("ztiel"))
                            {
                                account_name += count_abc.ToString();
                            }

                            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);
        }
Exemplo n.º 6
0
 private string GetLaunchItemLauncherLocation(LaunchItem item)
 {
     if (!string.IsNullOrEmpty(item.CustomLaunchPath))
     {
         return(item.CustomLaunchPath);
     }
     else
     {
         return(_launcherLocation);
     }
 }
Exemplo n.º 7
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);
     }
 }
Exemplo n.º 8
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;
                }
            }
        }
        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 SteelFilter
            launchItem.RodatSetting      = server.RodatSetting;
            launchItem.SecureSetting     = server.SecureSetting;
            launchItem.IsSimpleLaunch    = true;

            if (LaunchingEvent == null)
            {
                throw new Exception("SimpleLaunchWindowViewModel.LaunchingEvent null");
            }
            LaunchingEvent(launchItem);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
 private void UpdateAccountStatus(ServerAccountStatusEnum status, LaunchItem launchItem)
 {
     _viewModel.UpdateAccountStatus(launchItem.ServerName, launchItem.AccountName, status);
 }
Exemplo n.º 12
0
 private void FireReportAccountStatusEvent(ServerAccountStatusEnum accountStatus, LaunchItem launchItem)
 {
     if (ReportAccountStatusEvent != null)
     {
         ReportAccountStatusEvent(accountStatus, launchItem);
     }
 }
Exemplo n.º 13
0
 public void PushBottom(LaunchItem item)
 {
     Add(item);
 }
Exemplo n.º 14
0
 public void Add(LaunchItem item)
 {
     _launchItems.Add(item);
 }
Exemplo n.º 15
0
 public LaunchManager(string launcherLocation, LaunchItem launchItem, Dictionary <string, DateTime> accountLaunchTimes)
 {
     _launcherLocation   = launcherLocation;
     _launchItem         = launchItem;
     _accountLaunchTimes = accountLaunchTimes;
 }