private void ShowResponseDialog(OnlineBeatmap beatmap) { if (RespondingBeatmap != null) { HideResponseDialog(); } if ((GameBase.TournamentManager || (ConfigManager.sAutomaticDownload && (MatchSetup.Match != null || StreamingManager.CurrentlySpectating != null))) && !beatmap.exists && !beatmap.HasAttachedDownload) { beatmap.Download(ConfigManager.sAutomaticDownloadNoVideo); return; } if (GameBase.Tournament) { return; } background.FlashColour(Color.Gray, 500); if (ResponseSprites != null) { ResponseSprites.ForEach(s => { s.FadeOut(100); s.AlwaysDraw = false; }); } if (thumbRequest != null) { thumbRequest.Abort(); } if (previewRequest != null) { previewRequest.Abort(); } RespondingBeatmap = beatmap; ResponseSprites = new List <pSprite>(); float y = 24; pText pt = new pText(beatmap.artist, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.Orchid); pt.Field = Fields.TopRight; pt.TextBold = true; ResponseSprites.Add(pt); y += 12; pt = new pText(beatmap.title, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.White); pt.Field = Fields.TopRight; pt.TextBold = true; ResponseSprites.Add(pt); y += 12; pt = new pText("by " + beatmap.creator, 12, new Vector2(background.Position.X, YPOS + y), 1, true, Color.White); pt.Field = Fields.TopRight; ResponseSprites.Add(pt); y += 14; previewThumbnail = new pSprite(null, Fields.TopRight, Origins.Centre, Clocks.Game, new Vector2(background.Position.X - (WIDTH / 2), YPOS + y + (WIDTH * 0.8f / 2)), 1, true, Color.TransparentWhite); previewThumbnail.IsDisposable = true; previewThumbnail.Scale = 0.7f; y += 100; thumbRequest = new pWebRequest(General.STATIC_WEB_ROOT_BEATMAP + @"/thumb/" + beatmap.setId + @"l.jpg"); thumbRequest.Finished += delegate(pWebRequest r, Exception e) { byte[] data = r.ResponseData; if (e != null || data.Length == 0) { return; } GameBase.Scheduler.Add(delegate { previewThumbnail.Texture = pTexture.FromBytes(data); SkinManager.RegisterUnrecoverableTexture(previewThumbnail.Texture); fadeInThumbnail(); }); }; thumbRequest.Perform(); if (!disallowAudioPreview) { previewRequest = new pWebRequest(string.Format(@"{0}/preview/{1}.mp3", General.STATIC_WEB_ROOT_BEATMAP, beatmap.setId)); previewRequest.Finished += delegate(pWebRequest r, Exception e) { byte[] data = r.ResponseData; if (e != null || data.Length == 0) { return; } GameBase.Scheduler.Add(delegate { if (RespondingBeatmap != beatmap) { return; } WasPlayingAudio = AudioEngine.AudioState == AudioStates.Playing; if (WasPlayingAudio && GameBase.Mode != OsuModes.OnlineSelection && GameBase.Mode != OsuModes.Play) { AudioEngine.AllowRandomSong = false; AudioEngine.TogglePause(); } sampleTrack = AudioEngine.PlaySampleAsTrack(data); sampleTrack.Play(); fadeInThumbnail(); }); }; previewRequest.Perform(); } bool hasMap = BeatmapManager.GetBeatmapBySetId(beatmap.setId) != null; pButton pbut = null; float buttonHeight; if (hasMap && !beatmap.HasAttachedDownload && beatmap.hasVideo) { buttonHeight = 16.25f; } else if (hasMap || (!beatmap.HasAttachedDownload && beatmap.hasVideo)) { buttonHeight = 20f; } else { buttonHeight = 25f; } if (hasMap) { pbut = new pButton("Go to map", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.SkyBlue, delegate { if (MatchSetup.Match != null || Player.Instance != null) { return; } Beatmap b = BeatmapManager.GetBeatmapBySetId(beatmap.setId); BeatmapManager.Current = b; GameBase.ChangeMode(OsuModes.SelectPlay, true); HideResponseDialog(); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); y += buttonHeight + 2; } pbut = new pButton(beatmap.HasAttachedDownload ? "Cancel DL" : "Download", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.Bisque, delegate { beatmap.Download(); HideResponseDialog(); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); y += buttonHeight + 2; if (!beatmap.HasAttachedDownload && beatmap.hasVideo) { pbut = new pButton("DL NoVideo", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.BlueViolet, delegate { beatmap.Download(true); HideResponseDialog(); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); y += buttonHeight + 2; } pbut = new pButton("Cancel", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.Gray, delegate { HideResponseDialog(); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); y += buttonHeight + 2; if (beatmap.postid > 0) { pbut = new pButton("View Post", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.YellowGreen, delegate { GameBase.ProcessStart(String.Format(Urls.FORUM_POST, beatmap.postid)); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); } else { pbut = new pButton("View Thread", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.YellowGreen, delegate { GameBase.ProcessStart(String.Format(Urls.FORUM_TOPIC, beatmap.threadid)); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); } y += buttonHeight + 2; pbut = new pButton("View Listing", new Vector2(background.Position.X, YPOS + y), new Vector2(WIDTH, buttonHeight), 0.92f, Color.OrangeRed, delegate { GameBase.ProcessStart(String.Format(Urls.BEATMAP_SET_LISTING, beatmap.setId)); }, false, true); ResponseSprites.AddRange(pbut.SpriteCollection); //The panel isn't yet visible so we are fine to animate as per-usual. ResponseSprites.ForEach(s => s.FadeInFromZero(100)); ResponseSprites.Add(previewThumbnail); spriteManager.Add(ResponseSprites); }