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
|
|
|
|
|
2017-07-19 04:32:16 +00:00
|
|
|
|
using System;
|
2016-11-22 07:13:38 +00:00
|
|
|
|
using System.Threading;
|
2017-03-14 08:29:20 +00:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Input;
|
2016-11-14 08:23:33 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
2017-03-14 08:29:20 +00:00
|
|
|
|
using osu.Framework.Audio.Sample;
|
2016-11-14 08:23:33 +00:00
|
|
|
|
using osu.Framework.Audio.Track;
|
2016-10-11 17:52:16 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-03-14 08:29:20 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Framework.Screens;
|
2017-04-28 11:44:16 +00:00
|
|
|
|
using osu.Framework.Threading;
|
2016-11-14 08:23:33 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-03-14 08:29:20 +00:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays;
|
2016-11-14 08:23:33 +00:00
|
|
|
|
using osu.Game.Screens.Backgrounds;
|
2017-10-06 15:59:14 +00:00
|
|
|
|
using osu.Game.Screens.Edit;
|
2017-03-03 01:20:30 +00:00
|
|
|
|
using osu.Game.Screens.Select.Options;
|
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-03-14 08:58:34 +00:00
|
|
|
|
public abstract class SongSelect : OsuScreen
|
2016-09-29 11:13:58 +00:00
|
|
|
|
{
|
2017-07-27 07:56:41 +00:00
|
|
|
|
private BeatmapManager manager;
|
2017-07-19 04:33:00 +00:00
|
|
|
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
2016-11-19 16:39:43 +00:00
|
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly BeatmapCarousel carousel;
|
2017-02-28 06:09:36 +00:00
|
|
|
|
private DialogOverlay dialogOverlay;
|
2016-11-20 09:02:20 +00:00
|
|
|
|
|
2017-03-15 05:34:19 +00:00
|
|
|
|
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
|
|
|
|
|
|
|
|
|
private const float left_area_padding = 20;
|
|
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
2016-10-14 01:40:44 +00:00
|
|
|
|
|
2017-03-15 05:34:19 +00:00
|
|
|
|
protected Container LeftContent;
|
|
|
|
|
|
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-03-15 02:10:59 +00:00
|
|
|
|
protected virtual bool ShowFooter => true;
|
|
|
|
|
|
2017-03-14 13:51:26 +00:00
|
|
|
|
/// <summary>
|
2017-03-16 05:08:37 +00:00
|
|
|
|
/// Can be null if <see cref="ShowFooter"/> is false.
|
2017-03-14 13:51:26 +00:00
|
|
|
|
/// </summary>
|
2017-03-15 02:10:59 +00:00
|
|
|
|
protected readonly BeatmapOptionsOverlay BeatmapOptions;
|
|
|
|
|
|
2017-03-14 13:51:26 +00:00
|
|
|
|
/// <summary>
|
2017-03-16 05:08:37 +00:00
|
|
|
|
/// Can be null if <see cref="ShowFooter"/> is false.
|
2017-03-14 13:51:26 +00:00
|
|
|
|
/// </summary>
|
2017-03-15 02:10:59 +00:00
|
|
|
|
protected readonly Footer Footer;
|
2017-01-26 14:07:49 +00:00
|
|
|
|
|
2017-03-23 10:32:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Contains any panel which is triggered by a footer button.
|
|
|
|
|
/// Helps keep them located beneath the footer itself.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected readonly Container FooterPanels;
|
|
|
|
|
|
2017-03-16 05:23:48 +00:00
|
|
|
|
public readonly FilterControl FilterControl;
|
2017-01-13 04:49:05 +00:00
|
|
|
|
|
2017-03-15 02:10:59 +00:00
|
|
|
|
protected SongSelect()
|
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-03-14 13:51:26 +00:00
|
|
|
|
Add(new ParallaxContainer
|
2016-10-11 18:15:22 +00:00
|
|
|
|
{
|
2017-03-14 13:51:26 +00:00
|
|
|
|
Padding = new MarginPadding { Top = filter_height },
|
|
|
|
|
ParallaxAmount = 0.005f,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Children = new[]
|
2016-10-13 20:55:15 +00:00
|
|
|
|
{
|
2017-03-14 13:51:26 +00:00
|
|
|
|
new WedgeBackground
|
2016-10-19 18:02:03 +00:00
|
|
|
|
{
|
2017-03-14 13:51:26 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Right = carousel_width * 0.76f },
|
2016-10-19 18:02:03 +00:00
|
|
|
|
}
|
2017-03-14 13:51:26 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2017-03-15 05:34:19 +00:00
|
|
|
|
Add(LeftContent = new Container
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Size = new Vector2(wedged_container_size.X, 1),
|
|
|
|
|
Padding = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Bottom = 50,
|
|
|
|
|
Top = wedged_container_size.Y + left_area_padding,
|
|
|
|
|
Left = left_area_padding,
|
|
|
|
|
Right = left_area_padding * 2,
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-03-17 10:12:54 +00:00
|
|
|
|
Add(carousel = new BeatmapCarousel
|
2017-03-14 13:51:26 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Size = new Vector2(carousel_width, 1),
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
2017-07-19 04:32:16 +00:00
|
|
|
|
SelectionChanged = carouselSelectionChanged,
|
|
|
|
|
BeatmapsChanged = carouselBeatmapsLoaded,
|
2017-09-14 03:58:32 +00:00
|
|
|
|
DeleteRequested = promptDelete,
|
2017-08-31 06:49:56 +00:00
|
|
|
|
RestoreRequested = s => { foreach (var b in s.Beatmaps) manager.Restore(b); },
|
2017-10-06 15:59:14 +00:00
|
|
|
|
EditRequested = editRequested,
|
2017-09-03 22:59:32 +00:00
|
|
|
|
HideDifficultyRequested = b => manager.Hide(b),
|
2017-08-03 16:09:41 +00:00
|
|
|
|
StartRequested = () => carouselRaisedStart(),
|
2017-03-14 13:51:26 +00:00
|
|
|
|
});
|
2017-03-16 07:35:44 +00:00
|
|
|
|
Add(FilterControl = new FilterControl
|
2017-03-14 13:51:26 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = filter_height,
|
2017-03-17 10:54:51 +00:00
|
|
|
|
FilterChanged = criteria => filterChanged(criteria),
|
2017-03-14 13:51:26 +00:00
|
|
|
|
Exit = Exit,
|
|
|
|
|
});
|
|
|
|
|
Add(beatmapInfoWedge = new BeatmapInfoWedge
|
|
|
|
|
{
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Size = wedged_container_size,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Margin = new MarginPadding
|
2016-11-20 09:02:20 +00:00
|
|
|
|
{
|
2017-03-15 05:34:19 +00:00
|
|
|
|
Top = left_area_padding,
|
|
|
|
|
Right = left_area_padding,
|
2016-11-20 09:02:20 +00:00
|
|
|
|
},
|
2017-03-14 13:51:26 +00:00
|
|
|
|
});
|
2017-07-31 11:20:12 +00:00
|
|
|
|
Add(new ResetScrollContainer(() => carousel.ScrollToSelected())
|
2017-07-29 14:33:20 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = 250,
|
|
|
|
|
});
|
2017-03-15 02:10:59 +00:00
|
|
|
|
|
|
|
|
|
if (ShowFooter)
|
2017-03-14 13:51:26 +00:00
|
|
|
|
{
|
2017-03-23 10:32:58 +00:00
|
|
|
|
Add(FooterPanels = new Container
|
2017-02-16 20:05:03 +00:00
|
|
|
|
{
|
2017-03-23 10:32:58 +00:00
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-02-18 11:28:22 +00:00
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
2017-03-23 10:32:58 +00:00
|
|
|
|
Bottom = Footer.HEIGHT,
|
2017-02-18 11:28:22 +00:00
|
|
|
|
},
|
2017-03-14 13:51:26 +00:00
|
|
|
|
});
|
|
|
|
|
Add(Footer = new Footer
|
2016-10-21 14:52:52 +00:00
|
|
|
|
{
|
2017-01-26 14:07:49 +00:00
|
|
|
|
OnBack = Exit,
|
2017-08-03 16:09:41 +00:00
|
|
|
|
OnStart = () => carouselRaisedStart(),
|
2017-03-14 13:51:26 +00:00
|
|
|
|
});
|
2017-03-23 10:32:58 +00:00
|
|
|
|
|
|
|
|
|
FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay());
|
2017-03-14 13:51:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-26 14:07:49 +00:00
|
|
|
|
|
2017-03-14 13:51:26 +00:00
|
|
|
|
[BackgroundDependencyLoader(permitNulls: true)]
|
2017-08-15 05:30:50 +00:00
|
|
|
|
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours)
|
2017-03-14 13:51:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (Footer != null)
|
|
|
|
|
{
|
2017-08-15 05:30:50 +00:00
|
|
|
|
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
|
2017-09-20 05:31:17 +00:00
|
|
|
|
Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3);
|
2017-03-14 12:18:14 +00:00
|
|
|
|
|
2017-08-30 12:12:46 +00:00
|
|
|
|
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
|
2017-03-14 13:51:26 +00:00
|
|
|
|
}
|
2017-03-14 12:18:14 +00:00
|
|
|
|
|
2017-07-27 07:56:41 +00:00
|
|
|
|
if (manager == null)
|
|
|
|
|
manager = beatmaps;
|
2016-10-27 08:35:00 +00:00
|
|
|
|
|
2017-04-14 20:22:41 +00:00
|
|
|
|
if (osu != null)
|
2017-07-18 07:55:21 +00:00
|
|
|
|
Ruleset.BindTo(osu.Ruleset);
|
2017-04-05 01:15:39 +00:00
|
|
|
|
|
2017-07-27 07:56:41 +00:00
|
|
|
|
manager.BeatmapSetAdded += onBeatmapSetAdded;
|
|
|
|
|
manager.BeatmapSetRemoved += onBeatmapSetRemoved;
|
2017-08-31 06:49:56 +00:00
|
|
|
|
manager.BeatmapHidden += onBeatmapHidden;
|
|
|
|
|
manager.BeatmapRestored += onBeatmapRestored;
|
2016-10-27 08:35:00 +00:00
|
|
|
|
|
2017-03-01 22:41:00 +00:00
|
|
|
|
dialogOverlay = dialog;
|
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();
|
|
|
|
|
|
2017-07-27 07:56:41 +00:00
|
|
|
|
carousel.Beatmaps = manager.GetAllUsableBeatmapSets();
|
2017-07-19 04:32:16 +00:00
|
|
|
|
|
|
|
|
|
Beatmap.ValueChanged += beatmap_ValueChanged;
|
2017-07-20 02:50:31 +00:00
|
|
|
|
|
|
|
|
|
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled;
|
|
|
|
|
carousel.AllowSelection = !Beatmap.Disabled;
|
2017-03-17 10:12:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-06 15:59:14 +00:00
|
|
|
|
private void editRequested(BeatmapInfo beatmap)
|
|
|
|
|
{
|
|
|
|
|
Beatmap.Value = manager.GetWorkingBeatmap(beatmap, Beatmap);
|
|
|
|
|
Push(new Editor());
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 06:49:56 +00:00
|
|
|
|
private void onBeatmapRestored(BeatmapInfo b) => carousel.UpdateBeatmap(b);
|
|
|
|
|
private void onBeatmapHidden(BeatmapInfo b) => carousel.UpdateBeatmap(b);
|
|
|
|
|
|
2017-07-19 04:32:16 +00:00
|
|
|
|
private void carouselBeatmapsLoaded()
|
2017-03-17 10:12:15 +00:00
|
|
|
|
{
|
2017-07-20 21:15:44 +00:00
|
|
|
|
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
2017-07-19 04:32:16 +00:00
|
|
|
|
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false);
|
2017-03-17 10:12:15 +00:00
|
|
|
|
else
|
|
|
|
|
carousel.SelectNext();
|
2016-11-22 07:13:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-03 16:09:41 +00:00
|
|
|
|
private void carouselRaisedStart(InputState state = null)
|
2017-03-14 13:51:26 +00:00
|
|
|
|
{
|
2017-07-21 08:20:52 +00:00
|
|
|
|
// if we have a pending filter operation, we want to run it now.
|
|
|
|
|
// it could change selection (ie. if the ruleset has been changed).
|
|
|
|
|
carousel.FlushPendingFilters();
|
2017-04-29 11:12:09 +00:00
|
|
|
|
|
2017-07-20 20:58:58 +00:00
|
|
|
|
if (selectionChangedDebounce?.Completed == false)
|
2017-05-19 04:22:53 +00:00
|
|
|
|
{
|
2017-07-20 20:58:58 +00:00
|
|
|
|
selectionChangedDebounce.RunTask();
|
|
|
|
|
selectionChangedDebounce.Cancel(); // cancel the already scheduled task.
|
|
|
|
|
selectionChangedDebounce = null;
|
2017-05-19 04:22:53 +00:00
|
|
|
|
}
|
2017-04-29 11:12:09 +00:00
|
|
|
|
|
2017-08-03 16:09:41 +00:00
|
|
|
|
OnSelected(state);
|
2017-03-14 13:51:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-19 04:32:16 +00:00
|
|
|
|
private ScheduledDelegate selectionChangedDebounce;
|
|
|
|
|
|
|
|
|
|
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
|
|
|
|
|
private BeatmapInfo beatmapNoDebounce;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// selection has been changed as the result of interaction with the carousel.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void carouselSelectionChanged(BeatmapInfo beatmap)
|
|
|
|
|
{
|
|
|
|
|
Action performLoad = delegate
|
|
|
|
|
{
|
2017-07-20 05:05:42 +00:00
|
|
|
|
// We may be arriving here due to another component changing the bindable Beatmap.
|
|
|
|
|
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
|
2017-07-20 06:16:07 +00:00
|
|
|
|
if (beatmap?.Equals(Beatmap.Value.BeatmapInfo) != true)
|
2017-07-20 05:05:42 +00:00
|
|
|
|
{
|
2017-10-04 19:52:12 +00:00
|
|
|
|
bool preview = beatmap?.BeatmapSetInfoId != Beatmap.Value.BeatmapInfo.BeatmapSetInfoId;
|
2017-07-19 08:56:43 +00:00
|
|
|
|
|
2017-07-27 07:56:41 +00:00
|
|
|
|
Beatmap.Value = manager.GetWorkingBeatmap(beatmap, Beatmap);
|
2017-07-20 05:05:42 +00:00
|
|
|
|
ensurePlayingSelected(preview);
|
|
|
|
|
}
|
2017-07-19 08:56:43 +00:00
|
|
|
|
|
2017-09-01 09:22:38 +00:00
|
|
|
|
UpdateBeatmap(Beatmap.Value);
|
2017-07-19 04:32:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-07-20 06:12:20 +00:00
|
|
|
|
selectionChangedDebounce?.Cancel();
|
|
|
|
|
|
|
|
|
|
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
beatmapNoDebounce = beatmap;
|
|
|
|
|
|
2017-07-19 08:56:43 +00:00
|
|
|
|
if (beatmap == null)
|
|
|
|
|
{
|
2017-08-30 11:53:33 +00:00
|
|
|
|
if (!Beatmap.IsDefault)
|
|
|
|
|
performLoad();
|
2017-07-19 08:56:43 +00:00
|
|
|
|
}
|
2017-07-19 04:32:16 +00:00
|
|
|
|
else
|
2017-07-19 08:56:43 +00:00
|
|
|
|
{
|
2017-10-04 19:52:12 +00:00
|
|
|
|
if (beatmap.BeatmapSetInfoId == beatmapNoDebounce?.BeatmapSetInfoId)
|
2017-07-19 08:56:43 +00:00
|
|
|
|
sampleChangeDifficulty.Play();
|
|
|
|
|
else
|
|
|
|
|
sampleChangeBeatmap.Play();
|
|
|
|
|
|
|
|
|
|
if (beatmap == Beatmap.Value.BeatmapInfo)
|
|
|
|
|
performLoad();
|
|
|
|
|
else
|
|
|
|
|
selectionChangedDebounce = Scheduler.AddDelayed(performLoad, 100);
|
|
|
|
|
}
|
2017-07-19 04:32:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 05:30:50 +00:00
|
|
|
|
private void triggerRandom()
|
2017-06-05 09:24:28 +00:00
|
|
|
|
{
|
2017-08-15 05:30:50 +00:00
|
|
|
|
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
|
2017-06-05 09:24:28 +00:00
|
|
|
|
carousel.SelectPreviousRandom();
|
|
|
|
|
else
|
|
|
|
|
carousel.SelectNextRandom();
|
|
|
|
|
}
|
2017-03-14 08:58:34 +00:00
|
|
|
|
|
2017-08-03 16:09:41 +00:00
|
|
|
|
protected abstract void OnSelected(InputState state);
|
2017-01-27 02:31:28 +00:00
|
|
|
|
|
2017-03-17 10:54:51 +00:00
|
|
|
|
private void filterChanged(FilterCriteria criteria, bool debounce = true)
|
2017-01-18 00:18:15 +00:00
|
|
|
|
{
|
2017-03-17 10:54:51 +00:00
|
|
|
|
carousel.Filter(criteria, debounce);
|
2017-01-18 00:18:15 +00:00
|
|
|
|
}
|
2017-02-02 08:33:39 +00:00
|
|
|
|
|
2017-07-28 05:22:14 +00:00
|
|
|
|
private void onBeatmapSetAdded(BeatmapSetInfo s) => Schedule(() => addBeatmapSet(s));
|
2016-10-08 10:12:31 +00:00
|
|
|
|
|
2017-02-24 08:21:14 +00:00
|
|
|
|
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Schedule(() => removeBeatmapSet(s));
|
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);
|
2017-05-20 17:53:18 +00:00
|
|
|
|
|
2016-11-20 11:16:54 +00:00
|
|
|
|
Content.FadeInFromZero(250);
|
2016-12-07 11:47:28 +00:00
|
|
|
|
|
2017-03-16 05:23:48 +00:00
|
|
|
|
FilterControl.Activate();
|
2016-10-28 10:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-19 04:32:16 +00:00
|
|
|
|
private void beatmap_ValueChanged(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
if (!IsCurrentScreen) return;
|
|
|
|
|
|
|
|
|
|
carousel.SelectBeatmap(beatmap?.BeatmapInfo);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-17 09:59:30 +00:00
|
|
|
|
protected override void OnResuming(Screen last)
|
2016-10-28 10:55:48 +00:00
|
|
|
|
{
|
2017-07-19 04:32:16 +00:00
|
|
|
|
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
|
2017-07-19 01:59:13 +00:00
|
|
|
|
{
|
2017-09-01 09:22:38 +00:00
|
|
|
|
UpdateBeatmap(Beatmap);
|
2017-07-19 01:59:13 +00:00
|
|
|
|
ensurePlayingSelected();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 10:55:48 +00:00
|
|
|
|
base.OnResuming(last);
|
2016-11-20 11:16:54 +00:00
|
|
|
|
|
|
|
|
|
Content.FadeIn(250);
|
2016-12-07 11:47:28 +00:00
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
Content.ScaleTo(1, 250, Easing.OutSine);
|
2017-01-30 18:43:21 +00:00
|
|
|
|
|
2017-03-16 05:23:48 +00:00
|
|
|
|
FilterControl.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
|
|
|
|
{
|
2017-07-22 18:50:25 +00:00
|
|
|
|
Content.ScaleTo(1.1f, 250, Easing.InSine);
|
2016-12-07 11:47:28 +00:00
|
|
|
|
|
2016-11-20 11:16:54 +00:00
|
|
|
|
Content.FadeOut(250);
|
2017-02-08 11:30:05 +00:00
|
|
|
|
|
2017-03-16 05:23:48 +00:00
|
|
|
|
FilterControl.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-03-14 08:29:20 +00:00
|
|
|
|
beatmapInfoWedge.State = Visibility.Hidden;
|
2016-12-07 11:47:28 +00:00
|
|
|
|
|
2016-11-20 11:16:54 +00:00
|
|
|
|
Content.FadeOut(100);
|
2017-01-30 18:43:21 +00:00
|
|
|
|
|
2017-03-16 05:23:48 +00:00
|
|
|
|
FilterControl.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-11-22 07:13:38 +00:00
|
|
|
|
|
2017-07-27 07:56:41 +00:00
|
|
|
|
if (manager != null)
|
2017-07-07 12:05:55 +00:00
|
|
|
|
{
|
2017-07-27 07:56:41 +00:00
|
|
|
|
manager.BeatmapSetAdded -= onBeatmapSetAdded;
|
|
|
|
|
manager.BeatmapSetRemoved -= onBeatmapSetRemoved;
|
2017-09-03 23:21:07 +00:00
|
|
|
|
manager.BeatmapHidden -= onBeatmapHidden;
|
|
|
|
|
manager.BeatmapRestored -= onBeatmapRestored;
|
2017-07-07 12:05:55 +00:00
|
|
|
|
}
|
2016-11-22 07:13:38 +00:00
|
|
|
|
|
2017-07-07 12:05:55 +00:00
|
|
|
|
initialAddSetsTask?.Cancel();
|
2016-10-06 14:33:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-01 09:22:38 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Allow components in SongSelect to update their loaded beatmap details.
|
|
|
|
|
/// This is a debounced call (unlike directly binding to WorkingBeatmap.ValueChanged).
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="beatmap">The working beatmap.</param>
|
|
|
|
|
protected virtual void UpdateBeatmap(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);
|
2017-02-22 12:43:29 +00:00
|
|
|
|
backgroundModeBeatmap.FadeTo(1, 250);
|
2016-11-19 16:39:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-19 01:59:13 +00:00
|
|
|
|
beatmapInfoWedge.State = Visibility.Visible;
|
2017-03-13 20:59:44 +00:00
|
|
|
|
beatmapInfoWedge.UpdateBeatmap(beatmap);
|
2016-11-20 09:02:20 +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-07-19 06:45:23 +00:00
|
|
|
|
Track track = Beatmap.Value.Track;
|
2016-10-28 10:55:48 +00:00
|
|
|
|
|
2017-07-20 08:46:23 +00:00
|
|
|
|
if (!track.IsRunning)
|
2016-10-28 10:55:48 +00:00
|
|
|
|
{
|
2017-08-18 08:31:18 +00:00
|
|
|
|
// Ensure the track is added to the TrackManager, since it is removed after the player finishes the map.
|
|
|
|
|
// Using AddItemToList rather than AddItem so that it doesn't attempt to register adjustment dependencies more than once.
|
2017-08-11 07:56:30 +00:00
|
|
|
|
Game.Audio.Track.AddItemToList(track);
|
2017-07-20 08:46:23 +00:00
|
|
|
|
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
|
2016-12-18 14:19:41 +00:00
|
|
|
|
track.Start();
|
|
|
|
|
}
|
2016-10-28 10:55:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 06:49:56 +00:00
|
|
|
|
private void addBeatmapSet(BeatmapSetInfo beatmapSet) => carousel.AddBeatmap(beatmapSet);
|
2017-07-28 05:22:14 +00:00
|
|
|
|
|
2017-02-24 05:37:54 +00:00
|
|
|
|
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)
|
|
|
|
|
{
|
2017-03-17 10:12:15 +00:00
|
|
|
|
carousel.RemoveBeatmap(beatmapSet);
|
|
|
|
|
if (carousel.SelectedBeatmap == null)
|
2017-07-19 04:32:16 +00:00
|
|
|
|
Beatmap.SetDefault();
|
2017-02-24 05:37:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-30 11:53:33 +00:00
|
|
|
|
private void promptDelete(BeatmapSetInfo beatmap)
|
2017-03-02 12:40:55 +00:00
|
|
|
|
{
|
2017-08-30 11:41:41 +00:00
|
|
|
|
if (beatmap == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
2017-03-02 12:40:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-15 11:55:37 +00:00
|
|
|
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
|
|
|
|
{
|
2017-03-14 13:51:26 +00:00
|
|
|
|
if (args.Repeat) return false;
|
|
|
|
|
|
|
|
|
|
switch (args.Key)
|
2016-12-15 11:55:37 +00:00
|
|
|
|
{
|
2017-06-15 21:06:28 +00:00
|
|
|
|
case Key.KeypadEnter:
|
2017-03-14 13:51:26 +00:00
|
|
|
|
case Key.Enter:
|
2017-08-03 16:09:41 +00:00
|
|
|
|
carouselRaisedStart(state);
|
2017-03-14 13:51:26 +00:00
|
|
|
|
return true;
|
|
|
|
|
case Key.Delete:
|
|
|
|
|
if (state.Keyboard.ShiftPressed)
|
|
|
|
|
{
|
2017-08-30 11:41:41 +00:00
|
|
|
|
if (!Beatmap.IsDefault)
|
2017-08-30 11:53:33 +00:00
|
|
|
|
promptDelete(Beatmap.Value.BeatmapSetInfo);
|
2017-03-14 13:51:26 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2016-12-15 11:55:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.OnKeyDown(state, args);
|
|
|
|
|
}
|
2017-07-29 14:33:20 +00:00
|
|
|
|
|
2017-07-31 11:20:12 +00:00
|
|
|
|
private class ResetScrollContainer : Container
|
2017-07-29 14:33:20 +00:00
|
|
|
|
{
|
2017-07-31 11:20:12 +00:00
|
|
|
|
private readonly Action onHoverAction;
|
|
|
|
|
|
|
|
|
|
public ResetScrollContainer(Action onHoverAction)
|
|
|
|
|
{
|
|
|
|
|
this.onHoverAction = onHoverAction;
|
|
|
|
|
}
|
2017-07-29 14:33:20 +00:00
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
2017-07-31 11:20:12 +00:00
|
|
|
|
onHoverAction?.Invoke();
|
2017-07-29 14:33:20 +00:00
|
|
|
|
return base.OnHover(state);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-29 11:13:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|