private void BeginUpdate() { if (Status == LauncherStatus.UPDATE_IN_PROGRESS) { return; } // If the user has ubermenu configured, backup their Ubermenu config so it doesn't get overwritten try { if (TAModsUpdater.ConfigUsesUbermenu()) { TAModsUpdater.BackupUbermenuConfig(); } } catch (Exception ex) { MessageBox.Show("Failed to backup Ubermenu config: " + ex.Message, "Update Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Run the update asynchronously TAModsUpdater.PerformUpdate().FireAndForget((ex) => { MessageBox.Show("Failed to complete update: " + ex.Message, "Update Error", MessageBoxButton.OK, MessageBoxImage.Error); }); SetStatus(LauncherStatus.UPDATE_IN_PROGRESS); }
private void FullReinstallButton_Click(object sender, RoutedEventArgs e) { var doSetUp = MessageBox.Show( "Are you sure you want to perform a full reinstall of TAMods? The process will attempt to preserve Ubermenu configuration.", "Reinstall TAMods", MessageBoxButton.YesNo, MessageBoxImage.Warning); switch (doSetUp) { case MessageBoxResult.Yes: // Delete the version XML TAModsUpdater.DeleteVersionManifest(); SetStatus(LauncherStatus.UPDATE_REQUIRED); break; default: break; } }
private void OnUpdateFinished(object sender, EventArgs e) { UpdateProgressBar.Value = 100; // If necessary, restore the Ubermenu config backup Dispatcher.Invoke(new ThreadStart(() => { try { if (TAModsUpdater.ConfigUsesUbermenu()) { TAModsUpdater.RestoreUbermenuConfig(); } } catch (Exception ex) { MessageBox.Show("Failed to restore Ubermenu config: " + ex.Message, "Update Error", MessageBoxButton.OK, MessageBoxImage.Error); } SetStatus(LauncherStatus.READY_TO_LAUNCH); })); }
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); } }