public MainWindow() { Status = LauncherStatus.READY_TO_LAUNCH; DataContext = new Config(); InitializeComponent(); TAModsNews = new News(); ServerStatus = new LoginServerStatus(); AutoInjectTimer = new System.Timers.Timer(); AutoInjectTimer.AutoReset = false; AutoInjectTimer.Elapsed += OnAutoInjectTimerElapsed; string configPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/My Games/Tribes Ascend/TribesGame/config/"; TAModsUpdater = new Updater(((Config)DataContext).UpdateUrl, ".", configPath); // Add event handlers TAModsUpdater.OnUpdateComplete += OnUpdateFinished; TAModsUpdater.OnProgressTick += OnUpdateProgressTick; TALauncher = new InjectorLauncher(); TALauncher.OnTargetProcessLaunched += OnProcessLaunched; TALauncher.OnTargetProcessEnded += OnProcessEnded; TALauncher.OnTargetPollingException += OnProcessPollingException; }
private void LaunchGame() { Config config = (Config)DataContext; string loginServerHost = config.LoginServer.CustomLoginServerHost; if (config.LoginServer.LoginServer == LoginServerMode.HiRez) { loginServerHost = TAModsNews.HirezLoginServerHost; } else if (config.LoginServer.LoginServer == LoginServerMode.Community) { loginServerHost = TAModsNews.CommunityLoginServerHost; } try { lastLaunchedProcessId = InjectorLauncher.LaunchGame(config.GamePath, loginServerHost, config.CustomArguments); } catch (InjectorLauncher.LauncherException ex) { MessageBox.Show("Failed to launch game: " + ex.Message, "Game Launch Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Set up polling for process start if we're doing it by ID if (config.Injection.ProcessDetectionMode == ProcessDetectionMode.ProcessId) { TALauncher.SetTarget(lastLaunchedProcessId, false); } }
private void Inject() { if (Status != LauncherStatus.READY_TO_INJECT && Status != LauncherStatus.WAITING_TO_INJECT) { return; } var config = (Config)DataContext; string dllPath; switch (config.DLL.Channel) { case DLLMode.Release: dllPath = "tamods.dll"; break; case DLLMode.Beta: dllPath = "tamods-beta.dll"; break; case DLLMode.Edge: dllPath = "tamods-edge.dll"; break; default: dllPath = config.DLL.CustomDLLPath; break; } try { InjectorLauncher.Inject(TALauncher.FoundProcess.Id, dllPath); } catch (InjectorLauncher.InjectorException ex) { MessageBox.Show("Failed to inject TAMods: " + ex.Message, "Injection Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } SetStatus(LauncherStatus.INJECTED); System.Media.SoundPlayer s = new System.Media.SoundPlayer(TribesLauncherSharp.Properties.Resources.blueplate); s.Play(); }