private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) { //we might be off-screen when this update comes in. //rather than Scheduling, manually handle this to avoid possible memory contention. pendingBeatmapSwitch = () => { Task.Run(() => { if (beatmap?.Beatmap == null) { title.Text = @"Nothing to play"; artist.Text = @"Nothing to play"; } else { BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; title.Text = unicodeString(metadata.Title, metadata.TitleUnicode); artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode); } }); MusicControllerBackground newBackground; (newBackground = new MusicControllerBackground(beatmap)).LoadAsync(game, delegate { dragContainer.Add(newBackground); switch (direction) { case TransformDirection.Next: newBackground.Position = new Vector2(400, 0); newBackground.MoveToX(0, 500, EasingTypes.OutCubic); backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic); break; case TransformDirection.Prev: newBackground.Position = new Vector2(-400, 0); newBackground.MoveToX(0, 500, EasingTypes.OutCubic); backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic); break; } backgroundSprite.Expire(); backgroundSprite = newBackground; }); }; }
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) { Task.Run(() => { if (beatmap.Beatmap == null) { //todo: we may need to display some default text here (currently in the constructor). return; } BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode); artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode); }); MusicControllerBackground newBackground; (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate { Add(newBackground); switch (direction) { case TransformDirection.Next: newBackground.Position = new Vector2(400, 0); newBackground.MoveToX(0, 500, EasingTypes.OutCubic); backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic); break; case TransformDirection.Prev: newBackground.Position = new Vector2(-400, 0); newBackground.MoveToX(0, 500, EasingTypes.OutCubic); backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic); break; } backgroundSprite.Expire(); backgroundSprite = newBackground; }); }
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) { Task.Run(() => { if (beatmap?.Beatmap == null) //todo: we may need to display some default text here (currently in the constructor). return; BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; title.Text = config.GetUnicodeString(metadata.Title, metadata.TitleUnicode); artist.Text = config.GetUnicodeString(metadata.Artist, metadata.ArtistUnicode); }); MusicControllerBackground newBackground; (newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate { Add(newBackground); switch (direction) { case TransformDirection.Next: newBackground.Position = new Vector2(400, 0); newBackground.MoveToX(0, 500, EasingTypes.OutCubic); backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic); break; case TransformDirection.Prev: newBackground.Position = new Vector2(-400, 0); newBackground.MoveToX(0, 500, EasingTypes.OutCubic); backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic); break; } backgroundSprite.Expire(); backgroundSprite = newBackground; }); }