2017-02-07 12:59:30 +08: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 19:13:58 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using System.Linq;
|
2016-11-22 15:13:38 +08:00
|
|
|
|
using System.Threading;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Input;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Framework.Audio.Sample;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Framework.Audio.Track;
|
2016-10-08 18:12:31 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2016-10-12 01:52:16 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Framework.Threading;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2016-10-14 01:49:44 +08:00
|
|
|
|
using osu.Game.Database;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
2016-11-14 17:03:20 +08:00
|
|
|
|
using osu.Game.Modes;
|
2017-03-14 16:29:20 +08:00
|
|
|
|
using osu.Game.Overlays;
|
2016-11-14 16:23:33 +08:00
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
2017-03-03 09:20:30 +08:00
|
|
|
|
using osu.Game.Screens.Select.Options;
|
2016-09-29 19:13:58 +08:00
|
|
|
|
|
2016-11-21 03:34:16 +08:00
|
|
|
|
namespace osu.Game.Screens.Select
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2017-03-14 16:58:34 +08:00
|
|
|
|
public abstract class SongSelect : OsuScreen
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2017-03-02 21:02:29 +08:00
|
|
|
|
private Bindable<PlayMode> playMode = new Bindable<PlayMode>();
|
2016-10-27 16:35:00 +08:00
|
|
|
|
private BeatmapDatabase database;
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
2016-11-20 00:39:43 +08:00
|
|
|
|
|
2016-11-23 12:28:49 +08:00
|
|
|
|
private CarouselContainer carousel;
|
2016-10-28 18:55:48 +08:00
|
|
|
|
private TrackManager trackManager;
|
2017-02-28 14:09:36 +08:00
|
|
|
|
private DialogOverlay dialogOverlay;
|
2016-11-20 17:02:20 +08:00
|
|
|
|
|
2016-11-23 12:07:35 +08:00
|
|
|
|
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 225);
|
2016-11-24 12:48:48 +08:00
|
|
|
|
private BeatmapInfoWedge beatmapInfoWedge;
|
2016-10-14 09:40:44 +08:00
|
|
|
|
|
2017-02-07 15:15:45 +08:00
|
|
|
|
private static readonly Vector2 background_blur = new Vector2(20);
|
2016-11-22 15:13:38 +08:00
|
|
|
|
private CancellationTokenSource initialAddSetsTask;
|
2016-11-20 00:39:43 +08:00
|
|
|
|
|
2017-02-18 16:35:04 +08:00
|
|
|
|
private SampleChannel sampleChangeDifficulty;
|
|
|
|
|
private SampleChannel sampleChangeBeatmap;
|
2017-02-08 19:30:05 +08:00
|
|
|
|
|
2017-03-15 10:10:59 +08:00
|
|
|
|
protected virtual bool ShowFooter => true;
|
|
|
|
|
|
2017-03-14 21:51:26 +08:00
|
|
|
|
/// <summary>
|
2017-03-16 13:08:37 +08:00
|
|
|
|
/// Can be null if <see cref="ShowFooter"/> is false.
|
2017-03-14 21:51:26 +08:00
|
|
|
|
/// </summary>
|
2017-03-15 10:10:59 +08:00
|
|
|
|
protected readonly BeatmapOptionsOverlay BeatmapOptions;
|
|
|
|
|
|
2017-03-14 21:51:26 +08:00
|
|
|
|
/// <summary>
|
2017-03-16 13:08:37 +08:00
|
|
|
|
/// Can be null if <see cref="ShowFooter"/> is false.
|
2017-03-14 21:51:26 +08:00
|
|
|
|
/// </summary>
|
2017-03-15 10:10:59 +08:00
|
|
|
|
protected readonly Footer Footer;
|
2017-01-26 22:07:49 +08:00
|
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
|
public readonly FilterControl FilterControl;
|
2017-01-13 12:49:05 +08:00
|
|
|
|
|
2017-03-15 10:10:59 +08:00
|
|
|
|
protected SongSelect()
|
2016-10-12 02:15:22 +08:00
|
|
|
|
{
|
2017-02-07 15:15:45 +08:00
|
|
|
|
const float carousel_width = 640;
|
2017-02-08 19:30:05 +08:00
|
|
|
|
const float filter_height = 100;
|
|
|
|
|
|
2017-03-14 21:51:26 +08:00
|
|
|
|
Add(new ParallaxContainer
|
2016-10-12 02:15:22 +08:00
|
|
|
|
{
|
2017-03-14 21:51:26 +08:00
|
|
|
|
Padding = new MarginPadding { Top = filter_height },
|
|
|
|
|
ParallaxAmount = 0.005f,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
2016-10-14 04:55:15 +08:00
|
|
|
|
{
|
2017-03-14 21:51:26 +08:00
|
|
|
|
new WedgeBackground
|
2016-10-20 02:02:03 +08:00
|
|
|
|
{
|
2017-03-14 21:51:26 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Right = carousel_width * 0.76f },
|
2016-10-20 02:02:03 +08:00
|
|
|
|
}
|
2017-03-14 21:51:26 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Add(carousel = new CarouselContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Size = new Vector2(carousel_width, 1),
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
2017-03-17 18:12:15 +08:00
|
|
|
|
SelectionChanged = selectionChanged,
|
|
|
|
|
StartRequested = raiseSelect
|
2017-03-14 21:51:26 +08:00
|
|
|
|
});
|
2017-03-16 15:35:44 +08:00
|
|
|
|
Add(FilterControl = new FilterControl
|
2017-03-14 21:51:26 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-03-16 15:35:44 +08:00
|
|
|
|
Height = filter_height,
|
2017-03-14 21:51:26 +08:00
|
|
|
|
FilterChanged = () => filterChanged(),
|
|
|
|
|
Exit = Exit,
|
|
|
|
|
});
|
|
|
|
|
Add(beatmapInfoWedge = new BeatmapInfoWedge
|
|
|
|
|
{
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Size = wedged_container_size,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Margin = new MarginPadding
|
2016-11-20 17:02:20 +08:00
|
|
|
|
{
|
2017-03-14 21:51:26 +08:00
|
|
|
|
Top = 20,
|
|
|
|
|
Right = 20,
|
2016-11-20 17:02:20 +08:00
|
|
|
|
},
|
2017-03-14 21:51:26 +08:00
|
|
|
|
X = -50,
|
|
|
|
|
});
|
2017-03-15 10:10:59 +08:00
|
|
|
|
|
|
|
|
|
if (ShowFooter)
|
2017-03-14 21:51:26 +08:00
|
|
|
|
{
|
|
|
|
|
Add(BeatmapOptions = new BeatmapOptionsOverlay
|
2017-02-17 04:05:03 +08:00
|
|
|
|
{
|
2017-02-18 19:28:22 +08:00
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Bottom = 50,
|
|
|
|
|
},
|
2017-03-14 21:51:26 +08:00
|
|
|
|
});
|
|
|
|
|
Add(Footer = new Footer
|
2016-10-21 22:52:52 +08:00
|
|
|
|
{
|
2017-01-26 22:07:49 +08:00
|
|
|
|
OnBack = Exit,
|
2017-03-14 21:51:26 +08:00
|
|
|
|
OnStart = raiseSelect,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-26 22:07:49 +08:00
|
|
|
|
|
2017-03-14 21:51:26 +08:00
|
|
|
|
[BackgroundDependencyLoader(permitNulls: true)]
|
2017-03-17 18:12:15 +08:00
|
|
|
|
private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours)
|
2017-03-14 21:51:26 +08:00
|
|
|
|
{
|
|
|
|
|
if (Footer != null)
|
|
|
|
|
{
|
|
|
|
|
Footer.AddButton(@"random", colours.Green, SelectRandom, Key.F2);
|
|
|
|
|
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
|
2017-03-14 20:18:14 +08:00
|
|
|
|
|
2017-03-14 21:51:26 +08:00
|
|
|
|
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue);
|
|
|
|
|
}
|
2017-03-14 20:18:14 +08:00
|
|
|
|
|
2017-03-02 21:02:29 +08:00
|
|
|
|
if (osu != null)
|
|
|
|
|
playMode.BindTo(osu.PlayMode);
|
|
|
|
|
playMode.ValueChanged += playMode_ValueChanged;
|
2016-10-27 11:31:45 +08:00
|
|
|
|
|
2016-10-27 16:35:00 +08:00
|
|
|
|
if (database == null)
|
2016-11-09 07:13:20 +08:00
|
|
|
|
database = beatmaps;
|
2016-10-27 16:35:00 +08:00
|
|
|
|
|
2017-02-24 16:21:14 +08:00
|
|
|
|
database.BeatmapSetAdded += onBeatmapSetAdded;
|
|
|
|
|
database.BeatmapSetRemoved += onBeatmapSetRemoved;
|
2016-10-27 16:35:00 +08:00
|
|
|
|
|
2016-11-09 07:13:20 +08:00
|
|
|
|
trackManager = audio.Track;
|
2017-03-02 06:41:00 +08:00
|
|
|
|
dialogOverlay = dialog;
|
2016-10-28 18:55:48 +08:00
|
|
|
|
|
2016-12-05 19:09:56 +08:00
|
|
|
|
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
|
|
|
|
|
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
|
|
|
|
|
|
2016-11-22 15:13:38 +08:00
|
|
|
|
initialAddSetsTask = new CancellationTokenSource();
|
|
|
|
|
|
2017-03-17 18:12:15 +08:00
|
|
|
|
carousel.BeatmapsChanged = beatmapsLoaded;
|
|
|
|
|
carousel.Beatmaps = database.Query<BeatmapSetInfo>().Where(b => !b.DeletePending);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void beatmapsLoaded()
|
|
|
|
|
{
|
|
|
|
|
if (Beatmap != null)
|
|
|
|
|
carousel.SelectBeatmap(Beatmap.BeatmapInfo, false);
|
|
|
|
|
else
|
|
|
|
|
carousel.SelectNext();
|
2016-11-22 15:13:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 21:51:26 +08:00
|
|
|
|
private void raiseSelect()
|
|
|
|
|
{
|
|
|
|
|
if (Beatmap == null) return;
|
|
|
|
|
|
|
|
|
|
Beatmap.PreferredPlayMode = playMode.Value;
|
2017-03-14 22:22:23 +08:00
|
|
|
|
OnSelected();
|
2017-03-14 21:51:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 18:38:06 +08:00
|
|
|
|
public void SelectRandom() => carousel.SelectRandom();
|
2017-03-17 18:12:15 +08:00
|
|
|
|
|
2017-03-14 22:22:23 +08:00
|
|
|
|
protected abstract void OnSelected();
|
2017-03-14 16:58:34 +08:00
|
|
|
|
|
2017-01-27 10:31:28 +08:00
|
|
|
|
private ScheduledDelegate filterTask;
|
|
|
|
|
|
2017-03-02 21:02:29 +08:00
|
|
|
|
private void filterChanged(bool debounce = true, bool eagerSelection = true)
|
2017-01-18 08:18:15 +08:00
|
|
|
|
{
|
2017-03-17 18:12:15 +08:00
|
|
|
|
if (!carousel.IsLoaded) return;
|
|
|
|
|
|
|
|
|
|
if (Beatmap == null) return;
|
|
|
|
|
|
2017-01-30 22:48:21 +08:00
|
|
|
|
filterTask?.Cancel();
|
2017-01-27 10:31:28 +08:00
|
|
|
|
filterTask = Scheduler.AddDelayed(() =>
|
2017-01-18 08:18:15 +08:00
|
|
|
|
{
|
2017-01-27 10:31:28 +08:00
|
|
|
|
filterTask = null;
|
2017-03-16 13:23:48 +08:00
|
|
|
|
var search = FilterControl.Search;
|
2017-01-27 10:31:28 +08:00
|
|
|
|
BeatmapGroup newSelection = null;
|
2017-03-17 18:12:15 +08:00
|
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
|
carousel.Sort(FilterControl.Sort);
|
2017-01-27 10:31:28 +08:00
|
|
|
|
foreach (var beatmapGroup in carousel)
|
2017-01-18 08:18:15 +08:00
|
|
|
|
{
|
2017-01-27 10:31:28 +08:00
|
|
|
|
var set = beatmapGroup.BeatmapSet;
|
2017-03-02 21:02:29 +08:00
|
|
|
|
|
|
|
|
|
bool hasCurrentMode = set.Beatmaps.Any(bm => bm.Mode == playMode);
|
|
|
|
|
|
|
|
|
|
bool match = hasCurrentMode;
|
|
|
|
|
|
|
|
|
|
match &= string.IsNullOrEmpty(search)
|
2017-01-27 10:31:28 +08:00
|
|
|
|
|| (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;
|
2017-03-02 21:02:29 +08:00
|
|
|
|
|
2017-01-27 10:31:28 +08:00
|
|
|
|
if (match)
|
|
|
|
|
{
|
|
|
|
|
if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
|
2017-03-02 21:02:29 +08:00
|
|
|
|
{
|
|
|
|
|
if (newSelection != null)
|
|
|
|
|
newSelection.State = BeatmapGroupState.Collapsed;
|
2017-01-27 10:31:28 +08:00
|
|
|
|
newSelection = beatmapGroup;
|
2017-03-02 21:02:29 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
beatmapGroup.State = BeatmapGroupState.Collapsed;
|
2017-01-27 10:31:28 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-01-31 11:35:09 +08:00
|
|
|
|
beatmapGroup.State = BeatmapGroupState.Hidden;
|
2017-01-27 10:31:28 +08:00
|
|
|
|
}
|
2017-01-18 08:18:15 +08:00
|
|
|
|
}
|
2017-03-02 21:02:29 +08:00
|
|
|
|
|
2017-01-27 10:31:28 +08:00
|
|
|
|
if (newSelection != null)
|
2017-03-02 21:02:29 +08:00
|
|
|
|
{
|
|
|
|
|
if (newSelection.BeatmapPanels.Any(b => b.Beatmap.ID == Beatmap.BeatmapInfo.ID))
|
|
|
|
|
carousel.SelectBeatmap(Beatmap.BeatmapInfo, false);
|
|
|
|
|
else if (eagerSelection)
|
|
|
|
|
carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false);
|
|
|
|
|
}
|
|
|
|
|
}, debounce ? 250 : 0);
|
2017-01-18 08:18:15 +08:00
|
|
|
|
}
|
2017-02-02 16:33:39 +08:00
|
|
|
|
|
2017-03-17 18:12:15 +08:00
|
|
|
|
private void onBeatmapSetAdded(BeatmapSetInfo s) => carousel.AddBeatmap(s);
|
2016-10-08 18:12:31 +08:00
|
|
|
|
|
2017-02-24 16:21:14 +08:00
|
|
|
|
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Schedule(() => removeBeatmapSet(s));
|
2016-10-08 18:12:31 +08:00
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnEntering(Screen last)
|
2016-10-28 18:55:48 +08:00
|
|
|
|
{
|
|
|
|
|
base.OnEntering(last);
|
|
|
|
|
ensurePlayingSelected();
|
2016-11-20 00:39:43 +08:00
|
|
|
|
|
2016-11-20 17:02:20 +08:00
|
|
|
|
changeBackground(Beatmap);
|
2016-11-20 19:16:54 +08:00
|
|
|
|
|
|
|
|
|
Content.FadeInFromZero(250);
|
2016-12-07 19:47:28 +08:00
|
|
|
|
|
2017-03-14 16:29:20 +08:00
|
|
|
|
beatmapInfoWedge.State = Visibility.Visible;
|
2017-02-08 19:30:05 +08:00
|
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
|
FilterControl.Activate();
|
2016-10-28 18:55:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnResuming(Screen last)
|
2016-10-28 18:55:48 +08:00
|
|
|
|
{
|
2016-11-20 17:02:20 +08:00
|
|
|
|
changeBackground(Beatmap);
|
2016-10-28 18:55:48 +08:00
|
|
|
|
ensurePlayingSelected();
|
|
|
|
|
base.OnResuming(last);
|
2016-11-20 19:16:54 +08:00
|
|
|
|
|
|
|
|
|
Content.FadeIn(250);
|
2016-12-07 19:47:28 +08:00
|
|
|
|
|
|
|
|
|
Content.ScaleTo(1, 250, EasingTypes.OutSine);
|
2017-01-31 02:43:21 +08:00
|
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
|
FilterControl.Activate();
|
2016-11-20 19:16:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override void OnSuspending(Screen next)
|
2016-11-20 19:16:54 +08:00
|
|
|
|
{
|
2016-12-07 19:47:28 +08:00
|
|
|
|
Content.ScaleTo(1.1f, 250, EasingTypes.InSine);
|
|
|
|
|
|
2016-11-20 19:16:54 +08:00
|
|
|
|
Content.FadeOut(250);
|
2017-02-08 19:30:05 +08:00
|
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
|
FilterControl.Deactivate();
|
2016-11-20 19:16:54 +08:00
|
|
|
|
base.OnSuspending(next);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 17:59:30 +08:00
|
|
|
|
protected override bool OnExiting(Screen next)
|
2016-11-20 19:16:54 +08:00
|
|
|
|
{
|
2017-03-14 16:29:20 +08:00
|
|
|
|
beatmapInfoWedge.State = Visibility.Hidden;
|
2016-12-07 19:47:28 +08:00
|
|
|
|
|
2016-11-20 19:16:54 +08:00
|
|
|
|
Content.FadeOut(100);
|
2017-01-31 02:43:21 +08:00
|
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
|
FilterControl.Deactivate();
|
2016-11-20 19:16:54 +08:00
|
|
|
|
return base.OnExiting(next);
|
2016-10-28 18:55:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-08 18:12:31 +08:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
2016-11-22 15:13:38 +08:00
|
|
|
|
|
2017-02-24 16:21:14 +08:00
|
|
|
|
database.BeatmapSetAdded -= onBeatmapSetAdded;
|
|
|
|
|
database.BeatmapSetRemoved -= onBeatmapSetRemoved;
|
2016-11-22 15:13:38 +08:00
|
|
|
|
|
|
|
|
|
initialAddSetsTask.Cancel();
|
2016-10-06 22:33:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 18:55:48 +08:00
|
|
|
|
private void playMode_ValueChanged(object sender, EventArgs e)
|
2016-10-06 22:33:28 +08:00
|
|
|
|
{
|
2017-03-02 21:02:29 +08:00
|
|
|
|
filterChanged(false);
|
2016-10-06 22:33:28 +08:00
|
|
|
|
}
|
2016-10-27 11:31:45 +08:00
|
|
|
|
|
2016-11-20 17:02:20 +08:00
|
|
|
|
private void changeBackground(WorkingBeatmap beatmap)
|
2016-10-26 22:52:04 +08:00
|
|
|
|
{
|
2017-02-17 17:59:30 +08:00
|
|
|
|
var backgroundModeBeatmap = Background as BackgroundScreenBeatmap;
|
2016-11-20 00:39:43 +08:00
|
|
|
|
if (backgroundModeBeatmap != null)
|
|
|
|
|
{
|
|
|
|
|
backgroundModeBeatmap.Beatmap = beatmap;
|
2017-02-07 15:15:45 +08:00
|
|
|
|
backgroundModeBeatmap.BlurTo(background_blur, 1000);
|
2017-02-22 20:43:29 +08:00
|
|
|
|
backgroundModeBeatmap.FadeTo(1, 250);
|
2016-11-20 00:39:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 04:59:44 +08:00
|
|
|
|
beatmapInfoWedge.UpdateBeatmap(beatmap);
|
2016-11-20 17:02:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The global Beatmap was changed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
base.OnBeatmapChanged(beatmap);
|
|
|
|
|
|
2016-11-22 21:07:15 +08:00
|
|
|
|
//todo: change background in selectionChanged instead; support per-difficulty backgrounds.
|
2016-11-20 17:02:20 +08:00
|
|
|
|
changeBackground(beatmap);
|
2017-03-14 04:59:44 +08:00
|
|
|
|
carousel.SelectBeatmap(beatmap?.BeatmapInfo);
|
2016-10-28 18:55:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// selection has been changed as the result of interaction with the carousel.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void selectionChanged(BeatmapGroup group, BeatmapInfo beatmap)
|
|
|
|
|
{
|
2016-12-16 07:11:48 +08:00
|
|
|
|
bool beatmapSetChange = false;
|
2016-12-16 07:28:22 +08:00
|
|
|
|
|
2016-10-28 20:08:32 +08:00
|
|
|
|
if (!beatmap.Equals(Beatmap?.BeatmapInfo))
|
2016-12-05 19:09:56 +08:00
|
|
|
|
{
|
2016-12-21 14:47:56 +08:00
|
|
|
|
if (beatmap.BeatmapSetInfoID == Beatmap?.BeatmapInfo.BeatmapSetInfoID)
|
2016-12-05 19:09:56 +08:00
|
|
|
|
sampleChangeDifficulty.Play();
|
|
|
|
|
else
|
2016-12-16 07:11:48 +08:00
|
|
|
|
{
|
2016-12-05 19:09:56 +08:00
|
|
|
|
sampleChangeBeatmap.Play();
|
2016-12-16 07:11:48 +08:00
|
|
|
|
beatmapSetChange = true;
|
|
|
|
|
}
|
2016-10-28 19:24:14 +08:00
|
|
|
|
Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap);
|
2016-12-05 19:09:56 +08:00
|
|
|
|
}
|
2016-12-16 07:11:48 +08:00
|
|
|
|
ensurePlayingSelected(beatmapSetChange);
|
2016-10-26 22:52:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-18 22:19:41 +08:00
|
|
|
|
private void ensurePlayingSelected(bool preview = false)
|
2016-10-28 18:55:48 +08:00
|
|
|
|
{
|
2017-02-18 16:35:04 +08:00
|
|
|
|
Track track = Beatmap?.Track;
|
2016-10-28 18:55:48 +08:00
|
|
|
|
|
2016-12-18 22:19:41 +08:00
|
|
|
|
if (track != null)
|
2016-10-28 18:55:48 +08:00
|
|
|
|
{
|
2016-12-18 22:19:41 +08:00
|
|
|
|
trackManager.SetExclusive(track);
|
|
|
|
|
if (preview)
|
|
|
|
|
track.Seek(Beatmap.Beatmap.Metadata.PreviewTime);
|
|
|
|
|
track.Start();
|
|
|
|
|
}
|
2016-10-28 18:55:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-17 01:08:42 +08:00
|
|
|
|
private void selectBeatmap(BeatmapSetInfo beatmapSet = null)
|
|
|
|
|
{
|
2017-03-17 18:12:15 +08:00
|
|
|
|
carousel.SelectBeatmap(beatmapSet != null ? beatmapSet.Beatmaps.First() : Beatmap?.BeatmapInfo);
|
2017-03-17 01:08:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-24 13:37:54 +08:00
|
|
|
|
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)
|
|
|
|
|
{
|
2017-03-17 18:12:15 +08:00
|
|
|
|
carousel.RemoveBeatmap(beatmapSet);
|
|
|
|
|
if (carousel.SelectedBeatmap == null)
|
2017-02-24 13:37:54 +08:00
|
|
|
|
Beatmap = null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 20:18:14 +08:00
|
|
|
|
private void promptDelete()
|
2017-03-02 20:40:55 +08:00
|
|
|
|
{
|
|
|
|
|
if (Beatmap != null)
|
|
|
|
|
dialogOverlay?.Push(new BeatmapDeleteDialog(Beatmap));
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-15 19:55:37 +08:00
|
|
|
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
|
|
|
{
|
2017-03-14 21:51:26 +08:00
|
|
|
|
if (args.Repeat) return false;
|
|
|
|
|
|
|
|
|
|
switch (args.Key)
|
2016-12-15 19:55:37 +08:00
|
|
|
|
{
|
2017-03-14 21:51:26 +08:00
|
|
|
|
case Key.Enter:
|
|
|
|
|
raiseSelect();
|
|
|
|
|
return true;
|
|
|
|
|
case Key.Delete:
|
|
|
|
|
if (state.Keyboard.ShiftPressed)
|
|
|
|
|
{
|
|
|
|
|
promptDelete();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2016-12-15 19:55:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.OnKeyDown(state, args);
|
|
|
|
|
}
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|