2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-29 11:13:58 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
2016-11-14 08:23:33 +00:00
|
|
|
|
using System.Linq;
|
2016-11-22 07:13:38 +00:00
|
|
|
|
using System.Threading;
|
2016-11-14 08:23:33 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Track;
|
2016-10-08 10:12:31 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-02-17 09:59:30 +00:00
|
|
|
|
using osu.Framework.Screens;
|
2016-10-11 17:52:16 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-11-14 08:23:33 +00:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2016-10-13 17:49:44 +00:00
|
|
|
|
using osu.Game.Database;
|
2016-11-14 09:03:20 +00:00
|
|
|
|
using osu.Game.Modes;
|
2016-11-14 08:23:33 +00:00
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
2016-10-13 20:55:15 +00:00
|
|
|
|
using OpenTK;
|
2016-11-20 19:34:16 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2016-11-20 19:43:43 +00:00
|
|
|
|
using osu.Framework;
|
2016-12-05 11:09:56 +00:00
|
|
|
|
using osu.Framework.Audio.Sample;
|
2016-12-07 11:47:28 +00:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
2016-11-23 02:59:50 +00:00
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2016-11-23 05:29:20 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-01-26 14:07:49 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2016-12-15 11:55:37 +00:00
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using OpenTK.Input;
|
2017-01-18 00:18:15 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-02-08 11:30:05 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-01-27 02:31:28 +00:00
|
|
|
|
using osu.Framework.Threading;
|
2017-02-18 11:28:22 +00:00
|
|
|
|
using osu.Game.Overlays.Mods;
|
2016-09-29 11:13:58 +00:00
|
|
|
|
|
2016-11-20 19:34:16 +00:00
|
|
|
|
namespace osu.Game.Screens.Select
|
2016-09-29 11:13:58 +00:00
|
|
|
|
{
|
2017-02-17 09:59:30 +00:00
|
|
|
|
public class PlaySongSelect : OsuScreen
|
2016-09-29 11:13:58 +00:00
|
|
|
|
{
|
2016-10-08 10:12:31 +00:00
|
|
|
|
private Bindable<PlayMode> playMode;
|
2016-10-27 08:35:00 +00:00
|
|
|
|
private BeatmapDatabase database;
|
2017-02-17 09:59:30 +00:00
|
|
|
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
2016-11-19 16:39:43 +00:00
|
|
|
|
|
2016-11-23 04:28:49 +00:00
|
|
|
|
private CarouselContainer carousel;
|
2016-10-28 10:55:48 +00:00
|
|
|
|
private TrackManager trackManager;
|
2016-11-20 09:02:20 +00:00
|
|
|
|
|
2016-11-23 04:07:35 +00:00
|
|
|
|
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 225);
|
2016-11-24 04:48:48 +00:00
|
|
|
|
private BeatmapInfoWedge beatmapInfoWedge;
|
2016-10-14 01:40:44 +00:00
|
|
|
|
|
2017-02-18 11:28:22 +00:00
|
|
|
|
private ModSelectOverlay modSelect;
|
2017-02-16 20:05:03 +00:00
|
|
|
|
|
2017-02-07 07:15:45 +00:00
|
|
|
|
private static readonly Vector2 background_blur = new Vector2(20);
|
2016-11-22 07:13:38 +00:00
|
|
|
|
private CancellationTokenSource initialAddSetsTask;
|
2016-11-19 16:39:43 +00:00
|
|
|
|
|
2017-02-18 08:35:04 +00:00
|
|
|
|
private SampleChannel sampleChangeDifficulty;
|
|
|
|
|
private SampleChannel sampleChangeBeatmap;
|
2017-02-08 11:30:05 +00:00
|
|
|
|
|
2017-01-18 00:18:15 +00:00
|
|
|
|
private List<BeatmapGroup> beatmapGroups;
|
2016-12-05 11:09:56 +00:00
|
|
|
|
|
2017-01-26 14:07:49 +00:00
|
|
|
|
private Footer footer;
|
|
|
|
|
|
2017-01-13 04:49:05 +00:00
|
|
|
|
Player player;
|
2017-01-18 00:18:15 +00:00
|
|
|
|
FilterControl filter;
|
2017-01-13 04:49:05 +00:00
|
|
|
|
|
|
|
|
|
private void start()
|
|
|
|
|
{
|
2017-02-02 17:21:34 +00:00
|
|
|
|
if (player != null || Beatmap == null)
|
2017-01-13 04:49:05 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//in the future we may want to move this logic to a PlayerLoader gamemode or similar, so we can rely on the SongSelect transition
|
|
|
|
|
//and provide a better loading experience (at the moment song select is still accepting input during preload).
|
|
|
|
|
player = new Player
|
|
|
|
|
{
|
|
|
|
|
BeatmapInfo = carousel.SelectedGroup.SelectedPanel.Beatmap,
|
|
|
|
|
PreferredPlayMode = playMode.Value
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
player.Preload(Game, delegate
|
|
|
|
|
{
|
|
|
|
|
if (!Push(player))
|
|
|
|
|
{
|
|
|
|
|
player = null;
|
|
|
|
|
//error occured?
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(permitNulls: true)]
|
|
|
|
|
private void load(BeatmapDatabase beatmaps, AudioManager audio, BaseGame game,
|
|
|
|
|
OsuGame osuGame, OsuColour colours)
|
2016-10-11 18:15:22 +00:00
|
|
|
|
{
|
2017-02-07 07:15:45 +00:00
|
|
|
|
const float carousel_width = 640;
|
2017-02-08 11:30:05 +00:00
|
|
|
|
const float filter_height = 100;
|
|
|
|
|
|
2017-01-18 00:18:15 +00:00
|
|
|
|
beatmapGroups = new List<BeatmapGroup>();
|
2016-10-13 20:55:15 +00:00
|
|
|
|
Children = new Drawable[]
|
2016-10-11 18:15:22 +00:00
|
|
|
|
{
|
2016-11-23 05:29:20 +00:00
|
|
|
|
new ParallaxContainer
|
2016-10-13 20:55:15 +00:00
|
|
|
|
{
|
2017-02-08 11:30:05 +00:00
|
|
|
|
Padding = new MarginPadding { Top = filter_height },
|
2016-11-23 05:29:20 +00:00
|
|
|
|
ParallaxAmount = 0.005f,
|
2016-10-13 20:55:15 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-02-08 11:30:05 +00:00
|
|
|
|
Children = new[]
|
2016-10-19 18:02:03 +00:00
|
|
|
|
{
|
2016-11-23 05:29:20 +00:00
|
|
|
|
new WedgeBackground
|
2016-10-19 18:02:03 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-02-08 11:30:05 +00:00
|
|
|
|
Padding = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Right = carousel_width * 0.76f
|
|
|
|
|
},
|
2016-10-19 18:02:03 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
2016-10-13 20:55:15 +00:00
|
|
|
|
},
|
2016-11-23 04:28:49 +00:00
|
|
|
|
carousel = new CarouselContainer
|
2016-10-11 18:15:22 +00:00
|
|
|
|
{
|
2016-10-19 18:02:03 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
2017-02-07 07:15:45 +00:00
|
|
|
|
Size = new Vector2(carousel_width, 1),
|
2016-10-19 18:02:03 +00:00
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
2016-10-21 14:52:52 +00:00
|
|
|
|
},
|
2017-01-18 00:18:15 +00:00
|
|
|
|
filter = new FilterControl
|
2017-01-10 22:51:22 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-02-08 11:30:05 +00:00
|
|
|
|
Height = filter_height,
|
2017-01-18 00:18:15 +00:00
|
|
|
|
FilterChanged = filterChanged,
|
2017-02-02 08:33:39 +00:00
|
|
|
|
Exit = Exit,
|
2017-01-10 22:51:22 +00:00
|
|
|
|
},
|
2016-11-24 04:48:48 +00:00
|
|
|
|
beatmapInfoWedge = new BeatmapInfoWedge
|
2016-11-20 09:02:20 +00:00
|
|
|
|
{
|
2016-11-20 11:16:54 +00:00
|
|
|
|
Alpha = 0,
|
2016-11-20 09:02:20 +00:00
|
|
|
|
Size = wedged_container_size,
|
2016-11-23 04:07:35 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-02-08 11:30:05 +00:00
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Top = 20,
|
|
|
|
|
Right = 20,
|
|
|
|
|
},
|
2016-11-20 09:02:20 +00:00
|
|
|
|
},
|
2017-02-18 11:28:22 +00:00
|
|
|
|
modSelect = new ModSelectOverlay
|
2017-02-16 20:05:03 +00:00
|
|
|
|
{
|
2017-02-18 11:28:22 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-02-16 20:05:03 +00:00
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
2017-02-18 11:28:22 +00:00
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Bottom = 50,
|
|
|
|
|
},
|
2017-02-16 20:05:03 +00:00
|
|
|
|
},
|
2017-01-26 14:07:49 +00:00
|
|
|
|
footer = new Footer()
|
2016-10-21 14:52:52 +00:00
|
|
|
|
{
|
2017-01-26 14:07:49 +00:00
|
|
|
|
OnBack = Exit,
|
|
|
|
|
OnStart = start,
|
2016-10-11 18:15:22 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-01-26 14:07:49 +00:00
|
|
|
|
|
2017-02-16 20:05:03 +00:00
|
|
|
|
footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility);
|
2017-01-26 14:07:49 +00:00
|
|
|
|
footer.AddButton(@"random", colours.Green, carousel.SelectRandom);
|
|
|
|
|
footer.AddButton(@"options", colours.Blue, null);
|
|
|
|
|
|
2016-11-20 19:43:43 +00:00
|
|
|
|
if (osuGame != null)
|
2016-10-13 19:10:00 +00:00
|
|
|
|
{
|
2016-11-20 19:43:43 +00:00
|
|
|
|
playMode = osuGame.PlayMode;
|
2016-10-28 10:55:48 +00:00
|
|
|
|
playMode.ValueChanged += playMode_ValueChanged;
|
2017-02-16 22:32:27 +00:00
|
|
|
|
modSelect.ModMode = playMode;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
modSelect.ModMode = PlayMode.Osu;
|
2016-10-13 19:10:00 +00:00
|
|
|
|
}
|
2016-10-27 03:31:45 +00:00
|
|
|
|
|
2016-10-27 08:35:00 +00:00
|
|
|
|
if (database == null)
|
2016-11-08 23:13:20 +00:00
|
|
|
|
database = beatmaps;
|
2016-10-27 08:35:00 +00:00
|
|
|
|
|
2016-11-22 07:13:38 +00:00
|
|
|
|
database.BeatmapSetAdded += onDatabaseOnBeatmapSetAdded;
|
2016-10-27 08:35:00 +00:00
|
|
|
|
|
2016-11-08 23:13:20 +00:00
|
|
|
|
trackManager = audio.Track;
|
2016-10-28 10:55:48 +00:00
|
|
|
|
|
2016-12-05 11:09:56 +00:00
|
|
|
|
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
|
|
|
|
|
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
|
|
|
|
|
|
2016-11-22 07:13:38 +00:00
|
|
|
|
initialAddSetsTask = new CancellationTokenSource();
|
|
|
|
|
|
|
|
|
|
Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 02:31:28 +00:00
|
|
|
|
private ScheduledDelegate filterTask;
|
|
|
|
|
|
2017-01-18 00:18:15 +00:00
|
|
|
|
private void filterChanged()
|
|
|
|
|
{
|
2017-01-30 14:48:21 +00:00
|
|
|
|
filterTask?.Cancel();
|
2017-01-27 02:31:28 +00:00
|
|
|
|
filterTask = Scheduler.AddDelayed(() =>
|
2017-01-18 00:18:15 +00:00
|
|
|
|
{
|
2017-01-27 02:31:28 +00:00
|
|
|
|
filterTask = null;
|
|
|
|
|
var search = filter.Search;
|
|
|
|
|
BeatmapGroup newSelection = null;
|
|
|
|
|
foreach (var beatmapGroup in carousel)
|
2017-01-18 00:18:15 +00:00
|
|
|
|
{
|
2017-01-27 02:31:28 +00:00
|
|
|
|
var set = beatmapGroup.BeatmapSet;
|
|
|
|
|
bool match = string.IsNullOrEmpty(search)
|
|
|
|
|
|| (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
|
|
|
|
|| (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
|
|
|
|
|| (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
|
|
|
|
|| (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;
|
|
|
|
|
if (match)
|
|
|
|
|
{
|
2017-01-31 03:35:09 +00:00
|
|
|
|
beatmapGroup.State = BeatmapGroupState.Collapsed;
|
2017-01-27 02:31:28 +00:00
|
|
|
|
if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
|
|
|
|
|
newSelection = beatmapGroup;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-01-31 03:35:09 +00:00
|
|
|
|
beatmapGroup.State = BeatmapGroupState.Hidden;
|
2017-01-27 02:31:28 +00:00
|
|
|
|
}
|
2017-01-18 00:18:15 +00:00
|
|
|
|
}
|
2017-01-27 02:31:28 +00:00
|
|
|
|
if (newSelection != null)
|
2017-02-02 08:33:39 +00:00
|
|
|
|
carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false);
|
2017-01-27 02:31:28 +00:00
|
|
|
|
}, 250);
|
2017-01-18 00:18:15 +00:00
|
|
|
|
}
|
2017-02-02 08:33:39 +00:00
|
|
|
|
|
2016-11-22 07:13:38 +00:00
|
|
|
|
private void onDatabaseOnBeatmapSetAdded(BeatmapSetInfo s)
|
|
|
|
|
{
|
2017-01-17 22:05:06 +00:00
|
|
|
|
Schedule(() => addBeatmapSet(s, Game, true));
|
2016-10-08 10:12:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
|
protected override void OnEntering(Screen last)
|
2016-10-28 10:55:48 +00:00
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
ensurePlayingSelected();
|
2016-11-19 16:39:43 +00:00
|
|
|
|
|
2016-11-20 09:02:20 +00:00
|
|
|
|
changeBackground(Beatmap);
|
2016-11-20 11:16:54 +00:00
|
|
|
|
|
|
|
|
|
Content.FadeInFromZero(250);
|
2016-12-07 11:47:28 +00:00
|
|
|
|
|
2017-02-08 10:32:55 +00:00
|
|
|
|
beatmapInfoWedge.MoveToX(-50);
|
|
|
|
|
beatmapInfoWedge.MoveToX(0, 800, EasingTypes.OutQuint);
|
2017-02-08 11:30:05 +00:00
|
|
|
|
|
2017-01-30 18:43:21 +00:00
|
|
|
|
filter.Activate();
|
2016-10-28 10:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
|
protected override void OnResuming(Screen last)
|
2016-10-28 10:55:48 +00:00
|
|
|
|
{
|
2016-12-15 12:18:30 +00:00
|
|
|
|
player = null;
|
|
|
|
|
|
2016-11-20 09:02:20 +00:00
|
|
|
|
changeBackground(Beatmap);
|
2016-10-28 10:55:48 +00:00
|
|
|
|
ensurePlayingSelected();
|
|
|
|
|
base.OnResuming(last);
|
2016-11-20 11:16:54 +00:00
|
|
|
|
|
|
|
|
|
Content.FadeIn(250);
|
2016-12-07 11:47:28 +00:00
|
|
|
|
|
|
|
|
|
Content.ScaleTo(1, 250, EasingTypes.OutSine);
|
2017-01-30 18:43:21 +00:00
|
|
|
|
|
|
|
|
|
filter.Activate();
|
2016-11-20 11:16:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
|
protected override void OnSuspending(Screen next)
|
2016-11-20 11:16:54 +00:00
|
|
|
|
{
|
2016-12-07 11:47:28 +00:00
|
|
|
|
Content.ScaleTo(1.1f, 250, EasingTypes.InSine);
|
|
|
|
|
|
2016-11-20 11:16:54 +00:00
|
|
|
|
Content.FadeOut(250);
|
2017-02-08 11:30:05 +00:00
|
|
|
|
|
2017-01-30 18:43:21 +00:00
|
|
|
|
filter.Deactivate();
|
2016-11-20 11:16:54 +00:00
|
|
|
|
base.OnSuspending(next);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
|
protected override bool OnExiting(Screen next)
|
2016-11-20 11:16:54 +00:00
|
|
|
|
{
|
2017-02-08 10:32:55 +00:00
|
|
|
|
beatmapInfoWedge.MoveToX(-100, 800, EasingTypes.InQuint);
|
2016-12-07 11:47:28 +00:00
|
|
|
|
beatmapInfoWedge.RotateTo(10, 800, EasingTypes.InQuint);
|
|
|
|
|
|
2016-11-20 11:16:54 +00:00
|
|
|
|
Content.FadeOut(100);
|
2017-01-30 18:43:21 +00:00
|
|
|
|
|
2017-02-08 11:30:05 +00:00
|
|
|
|
filter.Deactivate();
|
2016-11-20 11:16:54 +00:00
|
|
|
|
return base.OnExiting(next);
|
2016-10-28 10:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 10:12:31 +00:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
2016-10-14 14:47:44 +00:00
|
|
|
|
if (playMode != null)
|
2016-10-28 10:55:48 +00:00
|
|
|
|
playMode.ValueChanged -= playMode_ValueChanged;
|
2016-11-22 07:13:38 +00:00
|
|
|
|
|
|
|
|
|
database.BeatmapSetAdded -= onDatabaseOnBeatmapSetAdded;
|
|
|
|
|
|
|
|
|
|
initialAddSetsTask.Cancel();
|
2016-10-06 14:33:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 10:55:48 +00:00
|
|
|
|
private void playMode_ValueChanged(object sender, EventArgs e)
|
2016-10-06 14:33:28 +00:00
|
|
|
|
{
|
2017-02-18 11:28:22 +00:00
|
|
|
|
modSelect.ModMode = playMode;
|
2016-10-06 14:33:28 +00:00
|
|
|
|
}
|
2016-10-27 03:31:45 +00:00
|
|
|
|
|
2016-11-20 09:02:20 +00:00
|
|
|
|
private void changeBackground(WorkingBeatmap beatmap)
|
2016-10-26 14:52:04 +00:00
|
|
|
|
{
|
2017-02-17 09:59:30 +00:00
|
|
|
|
var backgroundModeBeatmap = Background as BackgroundScreenBeatmap;
|
2016-11-19 16:39:43 +00:00
|
|
|
|
if (backgroundModeBeatmap != null)
|
|
|
|
|
{
|
|
|
|
|
backgroundModeBeatmap.Beatmap = beatmap;
|
2017-02-07 07:15:45 +00:00
|
|
|
|
backgroundModeBeatmap.BlurTo(background_blur, 1000);
|
2016-11-19 16:39:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-30 14:44:02 +00:00
|
|
|
|
if (beatmap != null)
|
|
|
|
|
beatmapInfoWedge.UpdateBeatmap(beatmap);
|
2016-11-20 09:02:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The global Beatmap was changed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
base.OnBeatmapChanged(beatmap);
|
|
|
|
|
|
2016-11-22 13:07:15 +00:00
|
|
|
|
//todo: change background in selectionChanged instead; support per-difficulty backgrounds.
|
2016-11-20 09:02:20 +00:00
|
|
|
|
changeBackground(beatmap);
|
2017-02-02 08:33:39 +00:00
|
|
|
|
carousel.SelectBeatmap(beatmap.BeatmapInfo);
|
2016-10-28 10:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// selection has been changed as the result of interaction with the carousel.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void selectionChanged(BeatmapGroup group, BeatmapInfo beatmap)
|
|
|
|
|
{
|
2016-12-15 23:11:48 +00:00
|
|
|
|
bool beatmapSetChange = false;
|
2016-12-15 23:28:22 +00:00
|
|
|
|
|
2016-10-28 12:08:32 +00:00
|
|
|
|
if (!beatmap.Equals(Beatmap?.BeatmapInfo))
|
2016-12-05 11:09:56 +00:00
|
|
|
|
{
|
2016-12-21 06:47:56 +00:00
|
|
|
|
if (beatmap.BeatmapSetInfoID == Beatmap?.BeatmapInfo.BeatmapSetInfoID)
|
2016-12-05 11:09:56 +00:00
|
|
|
|
sampleChangeDifficulty.Play();
|
|
|
|
|
else
|
2016-12-15 23:11:48 +00:00
|
|
|
|
{
|
2016-12-05 11:09:56 +00:00
|
|
|
|
sampleChangeBeatmap.Play();
|
2016-12-15 23:11:48 +00:00
|
|
|
|
beatmapSetChange = true;
|
|
|
|
|
}
|
2016-10-28 11:24:14 +00:00
|
|
|
|
Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap);
|
2016-12-05 11:09:56 +00:00
|
|
|
|
}
|
2016-12-15 23:11:48 +00:00
|
|
|
|
ensurePlayingSelected(beatmapSetChange);
|
2016-10-26 14:52:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-18 14:19:41 +00:00
|
|
|
|
private void ensurePlayingSelected(bool preview = false)
|
2016-10-28 10:55:48 +00:00
|
|
|
|
{
|
2017-02-18 08:35:04 +00:00
|
|
|
|
Track track = Beatmap?.Track;
|
2016-10-28 10:55:48 +00:00
|
|
|
|
|
2016-12-18 14:19:41 +00:00
|
|
|
|
if (track != null)
|
2016-10-28 10:55:48 +00:00
|
|
|
|
{
|
2016-12-18 14:19:41 +00:00
|
|
|
|
trackManager.SetExclusive(track);
|
|
|
|
|
if (preview)
|
|
|
|
|
track.Seek(Beatmap.Beatmap.Metadata.PreviewTime);
|
|
|
|
|
track.Start();
|
|
|
|
|
}
|
2016-10-28 10:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-17 22:05:06 +00:00
|
|
|
|
private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game, bool select = false)
|
2016-10-26 14:52:04 +00:00
|
|
|
|
{
|
2016-12-20 15:56:49 +00:00
|
|
|
|
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.ID);
|
2016-12-15 13:48:35 +00:00
|
|
|
|
beatmapSet.Beatmaps.ForEach(b =>
|
|
|
|
|
{
|
|
|
|
|
database.GetChildren(b);
|
|
|
|
|
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
|
|
|
|
|
});
|
|
|
|
|
|
2017-02-19 16:41:51 +00:00
|
|
|
|
foreach (var b in beatmapSet.Beatmaps)
|
|
|
|
|
b.ComputeDifficulty(database);
|
2017-01-30 06:26:28 +00:00
|
|
|
|
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.StarDifficulty).ToList();
|
2016-11-05 11:00:14 +00:00
|
|
|
|
|
2016-12-15 13:48:35 +00:00
|
|
|
|
var beatmap = new WorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault(), beatmapSet, database);
|
2016-11-05 11:00:14 +00:00
|
|
|
|
|
2017-02-19 16:41:51 +00:00
|
|
|
|
var group = new BeatmapGroup(beatmap)
|
2016-12-18 07:59:13 +00:00
|
|
|
|
{
|
|
|
|
|
SelectionChanged = selectionChanged,
|
|
|
|
|
StartRequested = b => start()
|
|
|
|
|
};
|
2016-11-01 14:24:14 +00:00
|
|
|
|
|
2016-11-20 19:34:16 +00:00
|
|
|
|
//for the time being, let's completely load the difficulty panels in the background.
|
|
|
|
|
//this likely won't scale so well, but allows us to completely async the loading flow.
|
|
|
|
|
Task.WhenAll(group.BeatmapPanels.Select(panel => panel.Preload(game))).ContinueWith(task => Schedule(delegate
|
2016-10-26 14:52:04 +00:00
|
|
|
|
{
|
2017-01-18 00:18:15 +00:00
|
|
|
|
beatmapGroups.Add(group);
|
|
|
|
|
|
2016-11-23 04:28:49 +00:00
|
|
|
|
carousel.AddGroup(group);
|
2016-11-01 14:24:14 +00:00
|
|
|
|
|
2017-01-17 22:05:06 +00:00
|
|
|
|
if (Beatmap == null || select)
|
2016-11-23 04:28:49 +00:00
|
|
|
|
carousel.SelectBeatmap(beatmapSet.Beatmaps.First());
|
2016-10-28 14:27:59 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2016-11-20 19:34:16 +00:00
|
|
|
|
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(Beatmap.BeatmapInfo));
|
|
|
|
|
if (panel != null)
|
2016-11-23 04:28:49 +00:00
|
|
|
|
carousel.SelectGroup(group, panel);
|
2016-10-28 14:27:59 +00:00
|
|
|
|
}
|
2016-11-20 19:34:16 +00:00
|
|
|
|
}));
|
2016-10-26 14:52:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 07:13:38 +00:00
|
|
|
|
private void addBeatmapSets(BaseGame game, CancellationToken token)
|
2016-10-26 14:52:04 +00:00
|
|
|
|
{
|
2016-10-27 08:35:00 +00:00
|
|
|
|
foreach (var beatmapSet in database.Query<BeatmapSetInfo>())
|
2016-11-22 07:13:38 +00:00
|
|
|
|
{
|
|
|
|
|
if (token.IsCancellationRequested) return;
|
2016-11-20 19:34:16 +00:00
|
|
|
|
addBeatmapSet(beatmapSet, game);
|
2016-11-22 07:13:38 +00:00
|
|
|
|
}
|
2016-10-26 14:52:04 +00:00
|
|
|
|
}
|
2016-12-15 11:55:37 +00:00
|
|
|
|
|
|
|
|
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
switch (args.Key)
|
|
|
|
|
{
|
|
|
|
|
case Key.Enter:
|
|
|
|
|
start();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.OnKeyDown(state, args);
|
|
|
|
|
}
|
2016-09-29 11:13:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|