/// <summary> /// Exits to watch a replay online. /// </summary> private void WatchOnlineReplay() { if (IsFetchingOnlineReplay) { return; } IsFetchingOnlineReplay = true; Logger.Important($"Fetching online replay for score: {Score.Id}", LogType.Network); var dialog = new DownloadingReplayDialog(); DialogManager.Show(dialog); ThreadScheduler.Run(() => { var dir = $"{ConfigManager.DataDirectory}/Downloads"; var path = $"{dir}/{Score.Id}.qr"; Directory.CreateDirectory(dir); try { OnlineManager.Client?.DownloadReplay(Score.Id, path); var replay = new Replay(path); // Load up the .qua file again var qua = MapManager.Selected.Value.LoadQua(); MapManager.Selected.Value.Qua = qua; Exit(() => { if (AudioEngine.Track != null) { lock (AudioEngine.Track) AudioEngine.Track.Fade(10, 300); } return(new GameplayScreen(MapManager.Selected.Value.Qua, MapManager.Selected.Value.Md5Checksum, new List <Score>(), replay)); }); } catch (Exception e) { Logger.Error(e, LogType.Network); NotificationManager.Show(NotificationLevel.Error, "Failed to download online replay"); } finally { DialogManager.Dismiss(dialog); File.Delete(path); IsFetchingOnlineReplay = false; } }); }
/// <summary> /// Exits to watch a replay online. /// </summary> private void WatchOnlineReplay() { if (IsFetchingOnlineReplay) { return; } IsFetchingOnlineReplay = true; Logger.Important($"Fetching online replay for score: {Score.Id}", LogType.Network); var dialog = new DownloadingReplayDialog(); DialogManager.Show(dialog); ThreadScheduler.Run(() => { var dir = $"{ConfigManager.DataDirectory}/Downloads"; var path = $"{dir}/{Score.Id}.qr"; Directory.CreateDirectory(dir); try { OnlineManager.Client?.DownloadReplay(Score.Id, path); var replay = new Replay(path); Exit(() => { if (AudioEngine.Track != null) { lock (AudioEngine.Track) AudioEngine.Track.Fade(10, 300); } GameBase.Game.GlobalUserInterface.Cursor.Alpha = 0; return(new MapLoadingScreen(new List <Score>(), replay)); }); } catch (Exception e) { Logger.Error(e, LogType.Network); NotificationManager.Show(NotificationLevel.Error, "Failed to download online replay"); } finally { DialogManager.Dismiss(dialog); File.Delete(path); IsFetchingOnlineReplay = false; } }); }