private void Btn_Browse_Click(object sender, EventArgs e) { try { var exePath = Assembly.GetEntryAssembly().Location; if (exePath.EndsWith("AOEOnline.exe", StringComparison.OrdinalIgnoreCase)) { throw new Exception("Celeste Fan Project Launcher is already compatible with \"Steam\"."); } var exeFolder = Path.GetDirectoryName(exePath); if (!string.Equals(Program.UserConfig.GameFilesPath, exeFolder, StringComparison.OrdinalIgnoreCase)) { throw new Exception("Celeste Fan Project Launcher need to be installed in the same folder has the game."); } Steam.ConvertToSteam(Program.UserConfig.GameFilesPath); MsgBox.ShowMessage( @"""Celeste Fan Project Launcher"" is now compatible with ""Steam"", it will now re-start.", @"Celeste Fan Project", MessageBoxButtons.OK, MessageBoxIcon.Information); Process.Start(Assembly.GetEntryAssembly().Location.Replace("Celeste_Launcher_Gui.exe", "AOEOnline.exe")); Environment.Exit(0); } catch (Exception ex) { MsgBox.ShowMessage( $"Error: {ex.Message}", @"Celeste Fan Project", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Application_Startup(object sender, StartupEventArgs e) { LegacyBootstrapper.LoadUserConfig(); LegacyBootstrapper.SetUILanguage(); Steam.ConvertToSteam(LegacyBootstrapper.UserConfig.GameFilesPath); var dialog = new GenericMessageDialog(Celeste_Launcher_Gui.Properties.Resources.SteamConverterSuccess, DialogIcon.None, DialogOptions.Ok); dialog.ShowDialog(); Current.Shutdown(); }
private void ConfirmBtnClick(object sender, RoutedEventArgs e) { try { var currentApplicationFullPath = Assembly.GetEntryAssembly().Location; if (currentApplicationFullPath.EndsWith("AOEOnline.exe", StringComparison.OrdinalIgnoreCase)) { GenericMessageDialog.Show(Properties.Resources.SteamConverterAlreadySteamGame, DialogIcon.None, DialogOptions.Ok); Close(); return; } var currentWorkingDirectory = Path.GetDirectoryName(currentApplicationFullPath); if (!File.Exists($"{currentWorkingDirectory}\\Spartan.exe")) { GenericMessageDialog.Show(Properties.Resources.SteamConverterIncorrectInstallationDirectory, DialogIcon.None, DialogOptions.Ok); Close(); return; } LegacyBootstrapper.UserConfig.GameFilesPath = currentWorkingDirectory; LegacyBootstrapper.UserConfig.Save(LegacyBootstrapper.UserConfigFilePath); Steam.ConvertToSteam(LegacyBootstrapper.UserConfig.GameFilesPath); GenericMessageDialog.Show(Properties.Resources.SteamConverterSuccess, DialogIcon.None, DialogOptions.Ok); Process.Start(Assembly.GetEntryAssembly().Location .Replace(Path.GetFileName(currentApplicationFullPath), "AOEOnline.exe")); Environment.Exit(0); } catch (Exception ex) { Logger.Error(ex, ex.Message); GenericMessageDialog.Show(Properties.Resources.GenericUnexpectedErrorMessage, DialogIcon.Error, DialogOptions.Ok); } }
public static async Task DownloadAndInstallUpdate(bool isSteam = false, IProgress <int> progress = null, CancellationToken ct = default(CancellationToken)) { Misc.CleanUpFiles(Directory.GetCurrentDirectory(), "*.old"); var versionService = new LauncherVersionService(); var newVersion = await versionService.GetLatestVersion().ConfigureAwait(false); progress?.Report(3); if (newVersion.Version <= Assembly.GetExecutingAssembly().GetName().Version) { return; } ct.ThrowIfCancellationRequested(); //Download File progress?.Report(5); var tempFileName = Path.GetTempFileName(); try { var downloadFileAsync = new SimpleFileDownloader(newVersion.Url, tempFileName); if (progress != null) { downloadFileAsync.ProgressChanged += (sender, args) => { progress.Report(Convert.ToInt32(Math.Floor(70 * (downloadFileAsync.DownloadProgress / 100)))); } } ; await downloadFileAsync.DownloadAsync(ct); } catch (AggregateException) { if (File.Exists(tempFileName)) { File.Delete(tempFileName); } throw; } //Extract File progress?.Report(65); Progress <double> extractProgress = null; if (progress != null) { extractProgress = new Progress <double>(); extractProgress.ProgressChanged += (o, ea) => { progress.Report(70 + Convert.ToInt32(Math.Floor(20 * (ea / 100)))); }; } var tempDir = Path.Combine(Path.GetTempPath(), $"Celeste_Launcher_v{newVersion.Version}"); if (Directory.Exists(tempDir)) { Misc.CleanUpFiles(tempDir, "*.*"); } try { await ZipUtils.ExtractZipFile(tempFileName, tempDir, extractProgress, ct); } catch (AggregateException) { Misc.CleanUpFiles(tempDir, "*.*"); throw; } finally { if (File.Exists(tempFileName)) { File.Delete(tempFileName); } } //Move File progress?.Report(90); var destinationDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar; try { Misc.MoveFiles(tempDir, destinationDir); } finally { Misc.CleanUpFiles(tempDir, "*.*"); } //isSteam Version if (isSteam) { progress?.Report(95); Steam.ConvertToSteam(destinationDir); } //Clean Old File progress?.Report(97); Misc.CleanUpFiles(Directory.GetCurrentDirectory(), "*.old"); // progress?.Report(100); }
private static async Task DoDownloadAndInstallUpdate(bool isSteam, IProgress <int> progress, CancellationToken ct) { Misc.CleanUpFiles(Directory.GetCurrentDirectory(), "*.old"); var gitVersion = await GetGitHubVersion().ConfigureAwait(false); progress.Report(3); if (gitVersion <= Assembly.GetExecutingAssembly().GetName().Version) { return; } ct.ThrowIfCancellationRequested(); const string zipName = "Celeste_Launcher.zip"; var downloadLink = $"{ReleaseZipUrl}{gitVersion}/{zipName}"; //Download File progress.Report(5); var dowloadProgress = new Progress <DownloadFileProgress>(); dowloadProgress.ProgressChanged += (o, ea) => { progress.Report(5 + Convert.ToInt32(Math.Floor((65 - 5) * ((double)ea.ProgressPercentage / 100)))); }; var tempFileName = Path.GetTempFileName(); var downloadFileAsync = new DownloadFileUtils(new Uri(downloadLink), tempFileName, dowloadProgress); try { await downloadFileAsync.DoDownload(ct); } catch (AggregateException) { if (File.Exists(tempFileName)) { File.Delete(tempFileName); } throw; } //Extract File progress.Report(65); var extractProgress = new Progress <ZipFileProgress>(); extractProgress.ProgressChanged += (o, ea) => { progress.Report( 65 + Convert.ToInt32(Math.Floor((90 - 65) * ((double)ea.ProgressPercentage / 100)))); }; var tempDir = Path.Combine(Path.GetTempPath(), $"Celeste_Launcher_v{gitVersion}"); if (Directory.Exists(tempDir)) { Misc.CleanUpFiles(tempDir, "*.*"); } try { await ZipUtils.DoExtractZipFile(tempFileName, tempDir, extractProgress, ct); } catch (AggregateException) { Misc.CleanUpFiles(tempDir, "*.*"); throw; } finally { if (File.Exists(tempFileName)) { File.Delete(tempFileName); } } //Move File progress.Report(90); var destinationDir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar; try { Misc.MoveFiles(tempDir, destinationDir); } finally { Misc.CleanUpFiles(tempDir, "*.*"); } //isSteam Version if (isSteam) { progress.Report(95); Steam.ConvertToSteam(destinationDir); } //Clean Old File progress.Report(97); Misc.CleanUpFiles(Directory.GetCurrentDirectory(), "*.old"); // progress.Report(100); }