Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        private void OnProcessEnded(object sender, InjectorLauncher.OnProcessStatusEventArgs e)
        {
            Dispatcher.Invoke(new ThreadStart(() =>
            {
                if (((Config)DataContext).Injection.ProcessDetectionMode == ProcessDetectionMode.ProcessId)
                {
                    // Stop polling for the dead process
                    TALauncher.UnsetTarget();
                }

                SetStatus(LauncherStatus.READY_TO_LAUNCH);
            }));
        }
Ejemplo n.º 3
0
        private void MainAppWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (File.Exists("launcherconfig.yaml"))
            {
                try
                {
                    DataContext = Config.Load("launcherconfig.yaml");
                    TAModsUpdater.RemoteBaseUrl = ((Config)DataContext).UpdateUrl;
                } catch (Exception ex)
                {
                    MessageBox.Show("Failed to read launcher configuration: " + ex.Message, "Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            Config config = (Config)DataContext;

            if (config.Injection.Mode == InjectMode.Automatic)
            {
                InjectionModeAutoRadio.IsChecked = true;
            }
            else
            {
                InjectionModeManualRadio.IsChecked = true;
            }
            switch (config.Injection.ProcessDetectionMode)
            {
            case ProcessDetectionMode.ProcessName:
                ProcessDetectionModeProcessNameRadio.IsChecked = true;
                break;

            case ProcessDetectionMode.ProcessId:
                ProcessDetectionModeProcessIdRadio.IsChecked = true;
                break;

            case ProcessDetectionMode.CommandLineString:
                ProcessDetectionModeCommandLineRadio.IsChecked = true;
                break;
            }

            // Setup the info text boxinfo box
            InitInfoRichTextBox();

            // Download news
            try
            {
                TAModsNews.DownloadNews($"{config.UpdateUrl}/news.json");
            } catch (Exception ex)
            {
                MessageBox.Show("Failed to download server information: " + ex.Message, "News Download Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // Set up polling for game process if we're doing it by name
            if (config.Injection.ProcessDetectionMode != ProcessDetectionMode.ProcessId)
            {
                TALauncher.SetTarget(config.Injection.RunningProcessName, config.Injection.ProcessDetectionMode == ProcessDetectionMode.CommandLineString);
            }

            // Prompt to update if need be
            var currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            var newsVersion    = Version.Parse(TAModsNews.LatestLauncherVersion);

            if (newsVersion > currentVersion)
            {
                var doGoToUpdate = MessageBox.Show(
                    $"A launcher update is available. You have version {currentVersion.ToString()}, and version {newsVersion.ToString()} is available. Open update page?",
                    "Launcher Update Available", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                switch (doGoToUpdate)
                {
                case MessageBoxResult.Yes:
                    System.Diagnostics.Process.Start(TAModsNews.LauncherUpdateLink);
                    break;

                default:
                    break;
                }
            }

            // Prompt if the game path doesn't exist
            if (!File.Exists(((Config)DataContext).GamePath))
            {
                MessageBox.Show(
                    "The game path you have selected does not appear to exist. You will not be able to launch the game until this points to the location of TribesAscend.exe",
                    "Game Path Not Found", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            // Prompt to set up Ubermenu if need be
            if (config.PromptForUbermenu && !TAModsUpdater.ConfigUsesUbermenu())
            {
                var doSetUp = MessageBox.Show(
                    "You have not configured Ubermenu, which allows you to configure TAMods in-game by pressing F1. Do you want to set it up now?",
                    "Ubermenu Configuration", MessageBoxButton.YesNo, MessageBoxImage.Question);

                switch (doSetUp)
                {
                case MessageBoxResult.Yes:
                    try
                    {
                        TAModsUpdater.SetupUbermenuPreset();
                    } catch (Exception ex)
                    {
                        MessageBox.Show("Failed to enable Ubermenu: " + ex.Message, "Ubermenu Configuration Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    break;

                default:
                    break;
                }
            }

            // Check for an update
            if (TAModsUpdater.IsUpdateRequired())
            {
                SetStatus(LauncherStatus.UPDATE_REQUIRED);
            }
        }