private async Task Initialize() { var osuFolderDirectory = _settings.Get <string>(SettingNames.Instance.MainOsuDirectory); if (!Directory.Exists(osuFolderDirectory)) { return; } var zipFileLocation = Path.Combine(_saver.SaveDirectory, "BrowserOverlay.zip"); //Check one of the files included in overlay assets if (File.Exists(Path.Combine(osuFolderDirectory, "chrome_elf.dll"))) { //everything seems to be in place - start watching for osu! process _loaderWatchdog = new LoaderWatchdog(_logger, GetFullDllLocation()) { InjectionProgressReporter = new Progress <string>(s => _logger.Log(s, LogLevel.Debug)) }; _ = _loaderWatchdog.WatchForProcessStart(CancellationToken.None).HandleExceptions(); return; } _overlayDownloadForm = new OverlayDownload(); _overlayDownloadForm.Show(); if (!File.Exists(zipFileLocation)) { var tempFileLocation = $"{zipFileLocation}.tmp"; if (File.Exists(tempFileLocation)) { File.Delete(tempFileLocation); } try { await DownloadOverlay(tempFileLocation); } catch (WebException ex) { _overlayDownloadForm.SetStatus("problem during download - restart SC to try again"); _logger.Log(ex, LogLevel.Error); return; } if (!File.Exists(tempFileLocation)) { _overlayDownloadForm.SetStatus("Failed to download assets - restart SC to try again"); return; } File.Move(tempFileLocation, zipFileLocation); } _overlayDownloadForm.SetStatus("unpacking files..."); ZipFile.ExtractToDirectory(zipFileLocation, osuFolderDirectory, true); _overlayDownloadForm.Close(); _restarter("browser overlay installation/update finished"); }
private void ClientOnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { if (_overlayDownloadForm == null) { return; } _overlayDownloadForm.SetProgress(e.ProgressPercentage); _overlayDownloadForm.SetStatus($"{e.BytesReceived / 1024 / 1024}MB / {e.TotalBytesToReceive / 1024 / 1024}MB"); }