2019-03-12 16:27:20 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
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;
|
2019-02-21 18:04:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
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;
|
2018-10-02 11:02:47 +08:00
|
|
|
using osu.Framework.Input.Events;
|
2019-01-05 03:13:32 +08:00
|
|
|
using osu.Framework.Logging;
|
2017-03-14 16:29:20 +08:00
|
|
|
using osu.Framework.Screens;
|
2017-04-28 19:44:16 +08:00
|
|
|
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.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-07-03 17:37:21 +08:00
|
|
|
using osu.Game.Input.Bindings;
|
2017-03-14 16:29:20 +08:00
|
|
|
using osu.Game.Overlays;
|
2018-12-06 18:29:18 +08:00
|
|
|
using osu.Game.Overlays.Mods;
|
2018-06-26 15:32:20 +08:00
|
|
|
using osu.Game.Rulesets;
|
2018-07-04 11:40:55 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2017-10-06 23:59:14 +08:00
|
|
|
using osu.Game.Screens.Edit;
|
2017-11-01 19:54:58 +08:00
|
|
|
using osu.Game.Screens.Menu;
|
2017-03-03 09:20:30 +08:00
|
|
|
using osu.Game.Screens.Select.Options;
|
2019-01-05 03:13:32 +08:00
|
|
|
using osuTK;
|
2019-02-04 16:04:52 +08:00
|
|
|
using osuTK.Graphics;
|
2019-01-05 03:13:32 +08:00
|
|
|
using osuTK.Input;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2019-06-10 11:46:21 +08:00
|
|
|
using System.Threading.Tasks;
|
2020-08-05 20:10:38 +08:00
|
|
|
using osu.Framework.Audio.Track;
|
2019-03-27 18:29:27 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2019-06-25 16:17:29 +08:00
|
|
|
using osu.Framework.Input.Bindings;
|
2020-09-11 10:15:50 +08:00
|
|
|
using osu.Game.Collections;
|
2020-04-30 10:51:06 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-11-02 23:45:55 +08:00
|
|
|
using System.Diagnostics;
|
2022-05-05 03:53:04 +08:00
|
|
|
using JetBrains.Annotations;
|
2021-01-04 17:32:23 +08:00
|
|
|
using osu.Game.Screens.Play;
|
2021-05-09 23:12:58 +08:00
|
|
|
using osu.Game.Database;
|
2022-03-07 22:26:27 +08:00
|
|
|
using osu.Game.Skinning;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2016-11-21 03:34:16 +08:00
|
|
|
namespace osu.Game.Screens.Select
|
2016-09-29 19:13:58 +08:00
|
|
|
{
|
2021-01-04 17:24:21 +08:00
|
|
|
public abstract class SongSelect : ScreenWithBeatmapBackground, IKeyBindingHandler<GlobalAction>
|
2016-09-29 19:13:58 +08:00
|
|
|
{
|
2020-01-23 19:03:52 +08:00
|
|
|
public static readonly float WEDGE_HEIGHT = 245;
|
2019-05-12 14:40:58 +08:00
|
|
|
|
2019-03-14 15:09:17 +08:00
|
|
|
protected const float BACKGROUND_BLUR = 20;
|
2017-12-15 11:48:15 +08:00
|
|
|
private const float left_area_padding = 20;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-11-15 17:23:35 +08:00
|
|
|
public FilterControl FilterControl { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-04-22 17:37:40 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this song select instance should take control of the global track,
|
|
|
|
/// applying looping and preview offsets.
|
|
|
|
/// </summary>
|
|
|
|
protected virtual bool ControlGlobalMusic => true;
|
|
|
|
|
2017-03-15 10:10:59 +08:00
|
|
|
protected virtual bool ShowFooter => true;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2021-11-25 16:12:15 +08:00
|
|
|
protected virtual bool DisplayStableImportPrompt => legacyImportManager?.SupportsImportFromStable == true;
|
2021-05-16 21:35:44 +08:00
|
|
|
|
2021-09-16 15:08:09 +08:00
|
|
|
public override bool? AllowTrackAdjustments => true;
|
2021-09-15 18:12:57 +08:00
|
|
|
|
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>
|
2019-11-15 17:20:36 +08:00
|
|
|
protected BeatmapOptionsOverlay BeatmapOptions { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
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>
|
2019-11-15 17:20:36 +08:00
|
|
|
protected Footer Footer { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-03-23 18:32:58 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Contains any panel which is triggered by a footer button.
|
|
|
|
/// Helps keep them located beneath the footer itself.
|
|
|
|
/// </summary>
|
2019-11-15 17:20:36 +08:00
|
|
|
protected Container FooterPanels { get; private set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-01-29 21:20:34 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether entering editor mode should be allowed.
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool AllowEditing => true;
|
|
|
|
|
2021-11-25 20:11:13 +08:00
|
|
|
public bool BeatmapSetsLoaded => IsLoaded && Carousel?.BeatmapSetsLoaded == true;
|
|
|
|
|
2020-01-30 16:37:52 +08:00
|
|
|
[Resolved]
|
|
|
|
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; }
|
|
|
|
|
2019-11-15 17:20:36 +08:00
|
|
|
protected BeatmapCarousel Carousel { get; private set; }
|
2020-04-11 15:58:13 +08:00
|
|
|
|
2021-08-12 17:02:00 +08:00
|
|
|
protected Container LeftArea { get; private set; }
|
|
|
|
|
2019-11-13 17:00:45 +08:00
|
|
|
private BeatmapInfoWedge beatmapInfoWedge;
|
2022-04-18 17:09:14 +08:00
|
|
|
private IDialogOverlay dialogOverlay;
|
2020-01-29 15:51:14 +08:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2021-05-18 21:27:20 +08:00
|
|
|
[Resolved(CanBeNull = true)]
|
2021-11-25 16:12:15 +08:00
|
|
|
private LegacyImportManager legacyImportManager { get; set; }
|
2021-05-18 04:01:05 +08:00
|
|
|
|
2022-05-11 04:29:57 +08:00
|
|
|
protected ModSelectOverlay ModSelect { get; private set; }
|
2019-11-15 17:20:36 +08:00
|
|
|
|
2021-01-19 16:11:40 +08:00
|
|
|
protected Sample SampleConfirm { get; private set; }
|
2018-12-06 18:29:18 +08:00
|
|
|
|
2021-01-19 16:11:40 +08:00
|
|
|
private Sample sampleChangeDifficulty;
|
|
|
|
private Sample sampleChangeBeatmap;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-04-30 10:51:06 +08:00
|
|
|
private Container carouselContainer;
|
|
|
|
|
2019-11-15 17:20:36 +08:00
|
|
|
protected BeatmapDetailArea BeatmapDetails { get; private set; }
|
2018-07-04 11:40:55 +08:00
|
|
|
|
2019-02-01 14:42:15 +08:00
|
|
|
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
2018-07-04 11:40:55 +08:00
|
|
|
|
2021-11-11 18:20:50 +08:00
|
|
|
private double audioFeedbackLastPlaybackTime;
|
|
|
|
|
2022-05-05 03:53:04 +08:00
|
|
|
[CanBeNull]
|
|
|
|
private IDisposable modSelectOverlayRegistration;
|
|
|
|
|
2020-08-11 11:40:58 +08:00
|
|
|
[Resolved]
|
2019-07-10 23:20:01 +08:00
|
|
|
private MusicController music { get; set; }
|
2019-07-09 17:32:49 +08:00
|
|
|
|
2022-05-05 03:53:04 +08:00
|
|
|
[Resolved(CanBeNull = true)]
|
2022-05-05 21:47:10 +08:00
|
|
|
internal IOverlayManager OverlayManager { get; private set; }
|
2022-05-05 03:53:04 +08:00
|
|
|
|
2019-11-13 17:00:45 +08:00
|
|
|
[BackgroundDependencyLoader(true)]
|
2022-04-18 17:09:14 +08:00
|
|
|
private void load(AudioManager audio, IDialogOverlay dialog, OsuColour colours, ManageCollectionsDialog manageCollectionsDialog, DifficultyRecommender recommender)
|
2016-10-12 02:15:22 +08:00
|
|
|
{
|
2019-11-14 07:38:01 +08:00
|
|
|
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
|
2019-11-13 17:00:45 +08:00
|
|
|
transferRulesetValue();
|
|
|
|
|
2020-04-30 10:51:06 +08:00
|
|
|
LoadComponentAsync(Carousel = new BeatmapCarousel
|
|
|
|
{
|
|
|
|
AllowSelection = false, // delay any selection until our bindables are ready to make a good choice.
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
BleedTop = FilterControl.HEIGHT,
|
|
|
|
BleedBottom = Footer.HEIGHT,
|
|
|
|
SelectionChanged = updateSelectedBeatmap,
|
|
|
|
BeatmapSetsChanged = carouselBeatmapsLoaded,
|
2020-12-22 13:36:52 +08:00
|
|
|
GetRecommendedBeatmap = s => recommender?.GetRecommendedBeatmap(s),
|
2020-04-30 10:51:06 +08:00
|
|
|
}, c => carouselContainer.Child = c);
|
|
|
|
|
2020-01-24 14:34:15 +08:00
|
|
|
AddRangeInternal(new Drawable[]
|
2016-10-12 02:15:22 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
new ResetScrollContainer(() => Carousel.ScrollToSelected())
|
2016-10-14 04:55:15 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Width = 250,
|
|
|
|
},
|
|
|
|
new VerticalMaskingContainer
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
2016-10-20 02:02:03 +08:00
|
|
|
{
|
2020-01-24 14:00:10 +08:00
|
|
|
new GridContainer // used for max width implementation
|
2017-12-13 11:46:02 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-01-24 14:00:10 +08:00
|
|
|
ColumnDimensions = new[]
|
|
|
|
{
|
|
|
|
new Dimension(),
|
|
|
|
new Dimension(GridSizeMode.Relative, 0.5f, maxSize: 850),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
new ParallaxContainer
|
2020-01-24 14:00:10 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
ParallaxAmount = 0.005f,
|
2020-01-24 14:00:10 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-01-24 14:34:15 +08:00
|
|
|
Child = new WedgeBackground
|
2020-01-23 19:03:52 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding { Right = -150 },
|
2020-01-23 19:03:52 +08:00
|
|
|
},
|
|
|
|
},
|
2020-04-30 10:51:06 +08:00
|
|
|
carouselContainer = new Container
|
2020-01-23 19:03:52 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
Top = FilterControl.HEIGHT,
|
|
|
|
Bottom = Footer.HEIGHT
|
2020-01-23 19:03:52 +08:00
|
|
|
},
|
2020-04-30 10:51:06 +08:00
|
|
|
Child = new LoadingSpinner(true) { State = { Value = Visibility.Visible } }
|
2020-01-24 14:34:15 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
2020-01-23 19:03:52 +08:00
|
|
|
},
|
2020-01-24 14:34:15 +08:00
|
|
|
FilterControl = new FilterControl
|
2017-12-25 11:57:45 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = FilterControl.HEIGHT,
|
|
|
|
FilterChanged = ApplyFilterToCarousel,
|
|
|
|
},
|
|
|
|
new GridContainer // used for max width implementation
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
ColumnDimensions = new[]
|
2017-12-25 11:57:45 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
new Dimension(GridSizeMode.Relative, 0.5f, maxSize: 650),
|
|
|
|
},
|
|
|
|
Content = new[]
|
|
|
|
{
|
|
|
|
new Drawable[]
|
2019-07-25 14:31:21 +08:00
|
|
|
{
|
2021-08-12 17:02:00 +08:00
|
|
|
LeftArea = new Container
|
2020-01-23 19:03:52 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
Anchor = Anchor.BottomLeft,
|
2020-01-23 19:03:52 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-08-12 17:02:00 +08:00
|
|
|
Padding = new MarginPadding { Top = left_area_padding },
|
2020-01-24 14:34:15 +08:00
|
|
|
Children = new Drawable[]
|
2020-01-23 19:03:52 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
beatmapInfoWedge = new BeatmapInfoWedge
|
|
|
|
{
|
|
|
|
Height = WEDGE_HEIGHT,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Margin = new MarginPadding
|
|
|
|
{
|
|
|
|
Right = left_area_padding,
|
2021-08-13 21:29:22 +08:00
|
|
|
Left = -BeatmapInfoWedge.BORDER_THICKNESS, // Hide the left border
|
2020-01-24 14:34:15 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
new Container
|
2020-01-23 19:03:52 +08:00
|
|
|
{
|
2020-01-24 14:34:15 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding
|
|
|
|
{
|
|
|
|
Bottom = Footer.HEIGHT,
|
2021-08-12 17:02:00 +08:00
|
|
|
Top = WEDGE_HEIGHT,
|
2020-01-24 14:34:15 +08:00
|
|
|
Left = left_area_padding,
|
|
|
|
Right = left_area_padding * 2,
|
|
|
|
},
|
2020-02-12 18:52:47 +08:00
|
|
|
Child = BeatmapDetails = CreateBeatmapDetailArea().With(d =>
|
2020-01-23 19:03:52 +08:00
|
|
|
{
|
2020-02-12 18:52:47 +08:00
|
|
|
d.RelativeSizeAxes = Axes.Both;
|
|
|
|
d.Padding = new MarginPadding { Top = 10, Right = 5 };
|
|
|
|
})
|
2020-01-24 14:34:15 +08:00
|
|
|
},
|
2020-01-23 19:03:52 +08:00
|
|
|
}
|
|
|
|
},
|
2020-01-24 14:34:15 +08:00
|
|
|
},
|
|
|
|
}
|
2017-12-25 11:57:45 +08:00
|
|
|
}
|
2020-01-24 14:34:15 +08:00
|
|
|
}
|
2020-01-23 19:03:52 +08:00
|
|
|
},
|
2022-03-07 22:26:27 +08:00
|
|
|
new SkinnableTargetContainer(SkinnableTarget.SongSelect)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2017-07-29 22:33:20 +08:00
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-03-15 10:10:59 +08:00
|
|
|
if (ShowFooter)
|
2017-03-14 21:51:26 +08:00
|
|
|
{
|
2020-02-02 03:24:29 +08:00
|
|
|
AddRangeInternal(new Drawable[]
|
2017-02-17 04:05:03 +08:00
|
|
|
{
|
2022-05-05 03:49:02 +08:00
|
|
|
FooterPanels = new Container
|
2018-12-06 18:29:18 +08:00
|
|
|
{
|
2022-05-05 03:49:02 +08:00
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
2020-02-02 03:24:29 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-05-05 03:49:02 +08:00
|
|
|
Padding = new MarginPadding { Bottom = Footer.HEIGHT },
|
|
|
|
Children = new Drawable[]
|
2019-06-25 15:55:49 +08:00
|
|
|
{
|
2022-05-05 03:49:02 +08:00
|
|
|
BeatmapOptions = new BeatmapOptionsOverlay(),
|
2019-06-25 15:55:49 +08:00
|
|
|
}
|
|
|
|
},
|
2022-05-05 03:49:02 +08:00
|
|
|
Footer = new Footer(),
|
2018-12-06 18:29:18 +08:00
|
|
|
});
|
2017-03-14 21:51:26 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-05-05 03:53:04 +08:00
|
|
|
// preload the mod select overlay for later use in `LoadComplete()`.
|
|
|
|
// therein it will be registered at the `OsuGame` level to properly function as a blocking overlay.
|
|
|
|
LoadComponent(ModSelect = CreateModSelectOverlay());
|
|
|
|
|
2017-03-14 21:51:26 +08:00
|
|
|
if (Footer != null)
|
|
|
|
{
|
2021-01-27 21:03:51 +08:00
|
|
|
foreach (var (button, overlay) in CreateFooterButtons())
|
|
|
|
Footer.AddButton(button, overlay);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-09-15 02:21:23 +08:00
|
|
|
BeatmapOptions.AddButton(@"Manage", @"collections", FontAwesome.Solid.Book, colours.Green, () => manageCollectionsDialog?.Show());
|
2020-09-15 02:23:41 +08:00
|
|
|
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo));
|
2020-09-15 02:19:18 +08:00
|
|
|
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.Regular.TimesCircle, colours.Purple, null);
|
|
|
|
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.Solid.Eraser, colours.Purple, () => clearScores(Beatmap.Value.BeatmapInfo));
|
2017-03-14 21:51:26 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-03-02 06:41:00 +08:00
|
|
|
dialogOverlay = dialog;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-05-28 16:06:01 +08:00
|
|
|
sampleChangeDifficulty = audio.Samples.Get(@"SongSelect/select-difficulty");
|
|
|
|
sampleChangeBeatmap = audio.Samples.Get(@"SongSelect/select-expand");
|
|
|
|
SampleConfirm = audio.Samples.Get(@"SongSelect/confirm-selection");
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-12-12 12:21:44 +08:00
|
|
|
if (dialogOverlay != null)
|
|
|
|
{
|
|
|
|
Schedule(() =>
|
|
|
|
{
|
2021-05-10 03:29:41 +08:00
|
|
|
// if we have no beatmaps, let's prompt the user to import from over a stable install if he has one.
|
2022-01-12 00:29:40 +08:00
|
|
|
if (beatmaps.QueryBeatmapSet(s => !s.Protected && !s.DeletePending) == null && DisplayStableImportPrompt)
|
2019-11-11 19:53:22 +08:00
|
|
|
{
|
2018-12-12 12:21:44 +08:00
|
|
|
dialogOverlay.Push(new ImportFromStablePopup(() =>
|
|
|
|
{
|
2021-11-25 16:12:15 +08:00
|
|
|
Task.Run(() => legacyImportManager.ImportFromStableAsync(StableContent.All));
|
2018-12-12 12:21:44 +08:00
|
|
|
}));
|
2019-11-11 19:53:22 +08:00
|
|
|
}
|
2018-12-12 12:21:44 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-05 03:53:04 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-05-05 21:47:10 +08:00
|
|
|
modSelectOverlayRegistration = OverlayManager?.RegisterBlockingOverlay(ModSelect);
|
2022-05-05 03:53:04 +08:00
|
|
|
}
|
|
|
|
|
2021-02-01 17:50:32 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Creates the buttons to be displayed in the footer.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>A set of <see cref="FooterButton"/> and an optional <see cref="OverlayContainer"/> which the button opens when pressed.</returns>
|
2021-01-27 21:03:51 +08:00
|
|
|
protected virtual IEnumerable<(FooterButton, OverlayContainer)> CreateFooterButtons() => new (FooterButton, OverlayContainer)[]
|
|
|
|
{
|
|
|
|
(new FooterButtonMods { Current = Mods }, ModSelect),
|
2021-04-07 16:13:25 +08:00
|
|
|
(new FooterButtonRandom
|
|
|
|
{
|
2022-02-04 14:42:52 +08:00
|
|
|
NextRandom = () => Carousel.SelectNextRandom(),
|
|
|
|
PreviousRandom = Carousel.SelectPreviousRandom
|
2021-04-07 16:13:25 +08:00
|
|
|
}, null),
|
2021-01-27 21:03:51 +08:00
|
|
|
(new FooterButtonOptions(), BeatmapOptions)
|
|
|
|
};
|
|
|
|
|
2022-05-11 04:29:57 +08:00
|
|
|
protected virtual ModSelectOverlay CreateModSelectOverlay() => new UserModSelectOverlay();
|
2021-01-18 16:50:32 +08:00
|
|
|
|
2019-11-20 16:24:43 +08:00
|
|
|
protected virtual void ApplyFilterToCarousel(FilterCriteria criteria)
|
|
|
|
{
|
2019-12-10 01:30:23 +08:00
|
|
|
// if not the current screen, we want to get carousel in a good presentation state before displaying (resume or enter).
|
|
|
|
bool shouldDebounce = this.IsCurrentScreen();
|
|
|
|
|
2020-01-29 18:37:54 +08:00
|
|
|
Carousel.Filter(criteria, shouldDebounce);
|
2019-11-20 16:24:43 +08:00
|
|
|
}
|
2019-11-20 14:43:00 +08:00
|
|
|
|
2018-12-12 12:21:44 +08:00
|
|
|
private DependencyContainer dependencies;
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
|
|
{
|
|
|
|
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
2019-04-08 18:16:34 +08:00
|
|
|
|
2018-12-12 12:21:44 +08:00
|
|
|
dependencies.CacheAs(this);
|
2019-02-01 14:42:15 +08:00
|
|
|
dependencies.CacheAs(decoupledRuleset);
|
|
|
|
dependencies.CacheAs<IBindable<RulesetInfo>>(decoupledRuleset);
|
2018-12-12 12:21:44 +08:00
|
|
|
|
|
|
|
return dependencies;
|
|
|
|
}
|
|
|
|
|
2020-02-12 18:52:47 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Creates the beatmap details to be displayed underneath the wedge.
|
|
|
|
/// </summary>
|
|
|
|
protected abstract BeatmapDetailArea CreateBeatmapDetailArea();
|
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
public void Edit(BeatmapInfo beatmapInfo = null)
|
2017-10-06 23:59:14 +08:00
|
|
|
{
|
2020-04-16 11:11:12 +08:00
|
|
|
if (!AllowEditing)
|
|
|
|
throw new InvalidOperationException($"Attempted to edit when {nameof(AllowEditing)} is disabled");
|
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo ?? beatmapInfoNoDebounce);
|
2021-09-05 22:59:28 +08:00
|
|
|
this.Push(new EditorLoader());
|
2017-10-06 23:59:14 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-12-28 20:07:19 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Call to make a selection and perform the default action for this SongSelect.
|
|
|
|
/// </summary>
|
2021-10-02 23:55:29 +08:00
|
|
|
/// <param name="beatmapInfo">An optional beatmap to override the current carousel selection.</param>
|
2020-05-04 13:04:30 +08:00
|
|
|
/// <param name="ruleset">An optional ruleset to override the current carousel selection.</param>
|
|
|
|
/// <param name="customStartAction">An optional custom action to perform instead of <see cref="OnStart"/>.</param>
|
2021-10-02 23:55:29 +08:00
|
|
|
public void FinaliseSelection(BeatmapInfo beatmapInfo = null, RulesetInfo ruleset = null, Action customStartAction = null)
|
2017-03-14 21:51:26 +08:00
|
|
|
{
|
2019-03-21 19:52:34 +08:00
|
|
|
// This is very important as we have not yet bound to screen-level bindables before the carousel load is completed.
|
|
|
|
if (!Carousel.BeatmapSetsLoaded)
|
|
|
|
return;
|
|
|
|
|
2020-05-04 13:04:30 +08:00
|
|
|
if (ruleset != null)
|
|
|
|
Ruleset.Value = ruleset;
|
|
|
|
|
2020-01-29 18:37:54 +08:00
|
|
|
transferRulesetValue();
|
|
|
|
|
|
|
|
// while transferRulesetValue will flush, it only does so if the ruleset changes.
|
|
|
|
// the user could have changed a filter, and we want to ensure we are 100% up-to-date and consistent here.
|
2017-12-24 14:39:25 +08:00
|
|
|
Carousel.FlushPendingFilterOperations();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-08 17:06:46 +08:00
|
|
|
// avoid attempting to continue before a selection has been obtained.
|
|
|
|
// this could happen via a user interaction while the carousel is still in a loading state.
|
2021-10-02 11:44:22 +08:00
|
|
|
if (Carousel.SelectedBeatmapInfo == null) return;
|
2019-01-08 17:06:46 +08:00
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
if (beatmapInfo != null)
|
|
|
|
Carousel.SelectBeatmap(beatmapInfo);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-07-21 04:58:58 +08:00
|
|
|
if (selectionChangedDebounce?.Completed == false)
|
2017-05-19 12:22:53 +08:00
|
|
|
{
|
2017-07-21 04:58:58 +08:00
|
|
|
selectionChangedDebounce.RunTask();
|
2020-11-30 18:36:30 +08:00
|
|
|
selectionChangedDebounce?.Cancel(); // cancel the already scheduled task.
|
2017-07-21 04:58:58 +08:00
|
|
|
selectionChangedDebounce = null;
|
2017-05-19 12:22:53 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-05-04 13:04:30 +08:00
|
|
|
if (customStartAction != null)
|
|
|
|
{
|
|
|
|
customStartAction();
|
|
|
|
Carousel.AllowSelection = false;
|
|
|
|
}
|
|
|
|
else if (OnStart())
|
2020-01-31 16:35:53 +08:00
|
|
|
Carousel.AllowSelection = false;
|
2017-03-14 21:51:26 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-12-15 11:48:15 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Called when a selection is made.
|
|
|
|
/// </summary>
|
2017-12-28 20:07:19 +08:00
|
|
|
/// <returns>If a resultant action occurred that takes the user away from SongSelect.</returns>
|
2018-05-30 14:44:35 +08:00
|
|
|
protected abstract bool OnStart();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-07-19 12:32:16 +08:00
|
|
|
private ScheduledDelegate selectionChangedDebounce;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-02-21 17:56:34 +08:00
|
|
|
private void workingBeatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
2018-03-03 22:24:54 +08:00
|
|
|
{
|
2020-02-10 15:31:52 +08:00
|
|
|
if (e.NewValue is DummyWorkingBeatmap || !this.IsCurrentScreen()) return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2021-10-14 13:07:43 +08:00
|
|
|
Logger.Log($"Song select working beatmap updated to {e.NewValue}");
|
2020-03-12 14:52:03 +08:00
|
|
|
|
2020-02-10 15:31:52 +08:00
|
|
|
if (!Carousel.SelectBeatmap(e.NewValue.BeatmapInfo, false))
|
2019-11-11 19:53:22 +08:00
|
|
|
{
|
2020-02-10 15:31:52 +08:00
|
|
|
// A selection may not have been possible with filters applied.
|
|
|
|
|
|
|
|
// There was possibly a ruleset mismatch. This is a case we can help things along by updating the game-wide ruleset to match.
|
2021-12-16 19:11:45 +08:00
|
|
|
if (!e.NewValue.BeatmapInfo.Ruleset.Equals(decoupledRuleset.Value))
|
2018-03-09 22:09:28 +08:00
|
|
|
{
|
2019-02-21 17:56:34 +08:00
|
|
|
Ruleset.Value = e.NewValue.BeatmapInfo.Ruleset;
|
2020-02-10 15:31:52 +08:00
|
|
|
transferRulesetValue();
|
2018-03-09 22:09:28 +08:00
|
|
|
}
|
2020-02-10 15:31:52 +08:00
|
|
|
|
|
|
|
// Even if a ruleset mismatch was not the cause (ie. a text filter is applied),
|
2020-03-04 19:14:18 +08:00
|
|
|
// we still want to temporarily show the new beatmap, bypassing filters.
|
|
|
|
// This will be undone the next time the user changes the filter.
|
|
|
|
var criteria = FilterControl.CreateCriteria();
|
2020-03-04 21:59:49 +08:00
|
|
|
criteria.SelectedBeatmapSet = e.NewValue.BeatmapInfo.BeatmapSet;
|
2020-03-04 19:14:18 +08:00
|
|
|
Carousel.Filter(criteria);
|
2020-03-05 20:45:19 +08:00
|
|
|
|
|
|
|
Carousel.SelectBeatmap(e.NewValue.BeatmapInfo);
|
2019-11-11 19:53:22 +08:00
|
|
|
}
|
2018-03-03 22:24:54 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-06-29 18:32:42 +08:00
|
|
|
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
|
2021-11-10 16:12:49 +08:00
|
|
|
private BeatmapInfo beatmapInfoPrevious;
|
2021-10-02 23:55:29 +08:00
|
|
|
private BeatmapInfo beatmapInfoNoDebounce;
|
2018-06-29 18:32:42 +08:00
|
|
|
private RulesetInfo rulesetNoDebounce;
|
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
private void updateSelectedBeatmap(BeatmapInfo beatmapInfo)
|
2018-07-19 17:48:40 +08:00
|
|
|
{
|
2021-10-02 23:55:29 +08:00
|
|
|
if (beatmapInfo == null && beatmapInfoNoDebounce == null)
|
2021-01-03 21:43:02 +08:00
|
|
|
return;
|
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
if (beatmapInfo?.Equals(beatmapInfoNoDebounce) == true)
|
2018-07-19 17:48:40 +08:00
|
|
|
return;
|
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
beatmapInfoNoDebounce = beatmapInfo;
|
2018-07-19 17:48:40 +08:00
|
|
|
performUpdateSelected();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateSelectedRuleset(RulesetInfo ruleset)
|
|
|
|
{
|
2021-01-05 19:38:58 +08:00
|
|
|
if (ruleset == null && rulesetNoDebounce == null)
|
|
|
|
return;
|
|
|
|
|
2018-07-19 17:48:40 +08:00
|
|
|
if (ruleset?.Equals(rulesetNoDebounce) == true)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rulesetNoDebounce = ruleset;
|
|
|
|
performUpdateSelected();
|
|
|
|
}
|
|
|
|
|
2017-07-19 12:32:16 +08:00
|
|
|
/// <summary>
|
2020-04-20 13:03:55 +08:00
|
|
|
/// Selection has been changed as the result of a user interaction.
|
2017-07-19 12:32:16 +08:00
|
|
|
/// </summary>
|
2018-07-19 17:48:40 +08:00
|
|
|
private void performUpdateSelected()
|
2017-07-19 12:32:16 +08:00
|
|
|
{
|
2021-10-02 23:55:29 +08:00
|
|
|
var beatmap = beatmapInfoNoDebounce;
|
2018-07-19 17:48:40 +08:00
|
|
|
var ruleset = rulesetNoDebounce;
|
2018-06-29 18:32:42 +08:00
|
|
|
|
2019-03-21 19:51:21 +08:00
|
|
|
selectionChangedDebounce?.Cancel();
|
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
if (beatmapInfoNoDebounce == null)
|
2019-03-21 19:51:21 +08:00
|
|
|
run();
|
|
|
|
else
|
|
|
|
selectionChangedDebounce = Scheduler.AddDelayed(run, 200);
|
|
|
|
|
2022-01-07 15:49:13 +08:00
|
|
|
if (beatmap?.Equals(beatmapInfoPrevious) != true)
|
2021-11-10 16:12:49 +08:00
|
|
|
{
|
2021-11-11 18:20:50 +08:00
|
|
|
if (beatmap != null && beatmapInfoPrevious != null && Time.Current - audioFeedbackLastPlaybackTime >= 50)
|
2021-11-10 16:12:49 +08:00
|
|
|
{
|
2022-02-04 14:42:52 +08:00
|
|
|
if (beatmap.BeatmapSet?.ID == beatmapInfoPrevious.BeatmapSet?.ID)
|
2021-11-10 16:12:49 +08:00
|
|
|
sampleChangeDifficulty.Play();
|
|
|
|
else
|
|
|
|
sampleChangeBeatmap.Play();
|
2021-11-11 18:20:50 +08:00
|
|
|
|
|
|
|
audioFeedbackLastPlaybackTime = Time.Current;
|
2021-11-10 16:12:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
beatmapInfoPrevious = beatmap;
|
|
|
|
}
|
|
|
|
|
2018-07-20 10:32:00 +08:00
|
|
|
void run()
|
2017-07-19 12:32:16 +08:00
|
|
|
{
|
2020-11-30 18:36:30 +08:00
|
|
|
// clear pending task immediately to track any potential nested debounce operation.
|
|
|
|
selectionChangedDebounce = null;
|
|
|
|
|
2022-01-27 14:19:48 +08:00
|
|
|
Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"} ruleset:{ruleset?.ShortName ?? "null"}");
|
2018-07-19 17:51:08 +08:00
|
|
|
|
2020-01-29 18:37:54 +08:00
|
|
|
if (transferRulesetValue())
|
2018-07-17 21:20:19 +08:00
|
|
|
{
|
2019-11-14 12:29:06 +08:00
|
|
|
Mods.Value = Array.Empty<Mod>();
|
2020-03-12 14:52:03 +08:00
|
|
|
|
2020-11-30 18:36:30 +08:00
|
|
|
// transferRulesetValue() may trigger a re-filter. If the current selection does not match the new ruleset, we want to switch away from it.
|
2020-04-20 13:03:55 +08:00
|
|
|
// The default logic on WorkingBeatmap change is to switch to a matching ruleset (see workingBeatmapChanged()), but we don't want that here.
|
|
|
|
// We perform an early selection attempt and clear out the beatmap selection to avoid a second ruleset change (revert).
|
|
|
|
if (beatmap != null && !Carousel.SelectBeatmap(beatmap, false))
|
|
|
|
beatmap = null;
|
2018-07-17 21:20:19 +08:00
|
|
|
}
|
|
|
|
|
2020-11-30 18:36:30 +08:00
|
|
|
if (selectionChangedDebounce != null)
|
|
|
|
{
|
|
|
|
// a new nested operation was started; switch to it for further selection.
|
|
|
|
// this avoids having two separate debounces trigger from the same source.
|
|
|
|
selectionChangedDebounce.RunTask();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-07-20 13:05:42 +08: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.
|
2019-11-14 17:35:02 +08:00
|
|
|
if (!EqualityComparer<BeatmapInfo>.Default.Equals(beatmap, Beatmap.Value.BeatmapInfo))
|
2017-07-20 13:05:42 +08:00
|
|
|
{
|
2018-07-20 10:32:00 +08:00
|
|
|
Logger.Log($"beatmap changed from \"{Beatmap.Value.BeatmapInfo}\" to \"{beatmap}\"");
|
2021-05-31 13:11:57 +08:00
|
|
|
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap);
|
2017-07-20 13:05:42 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-10-08 09:40:52 +08:00
|
|
|
if (this.IsCurrentScreen())
|
|
|
|
ensurePlayingSelected();
|
|
|
|
|
2020-03-12 14:52:03 +08:00
|
|
|
updateComponentFromBeatmap(Beatmap.Value);
|
2018-01-16 02:42:17 +08:00
|
|
|
}
|
2017-07-19 12:32:16 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
public override void OnEntering(ScreenTransitionEvent e)
|
2016-10-28 18:55:48 +08:00
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
base.OnEntering(e);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
this.FadeInFromZero(250);
|
2017-03-16 13:23:48 +08:00
|
|
|
FilterControl.Activate();
|
2020-01-30 16:37:52 +08:00
|
|
|
|
|
|
|
ModSelect.SelectedMods.BindTo(selectedMods);
|
2020-09-13 02:43:17 +08:00
|
|
|
|
2020-11-02 23:45:55 +08:00
|
|
|
beginLooping();
|
2016-10-28 18:55:48 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-11-01 19:54:58 +08:00
|
|
|
private const double logo_transition = 250;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-11-09 16:38:20 +08:00
|
|
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
2017-11-01 19:54:58 +08:00
|
|
|
{
|
2017-11-09 16:38:20 +08:00
|
|
|
base.LogoArriving(logo, resuming);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-11-01 19:54:58 +08:00
|
|
|
Vector2 position = new Vector2(0.95f, 0.96f);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-11-01 19:54:58 +08:00
|
|
|
if (logo.Alpha > 0.8f)
|
|
|
|
{
|
|
|
|
logo.MoveTo(position, 500, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
logo.Hide();
|
|
|
|
logo.ScaleTo(0.2f);
|
|
|
|
logo.MoveTo(position);
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-11-01 19:54:58 +08:00
|
|
|
logo.FadeIn(logo_transition, Easing.OutQuint);
|
|
|
|
logo.ScaleTo(0.4f, logo_transition, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-11-25 22:29:08 +08:00
|
|
|
logo.Action = () =>
|
|
|
|
{
|
2017-12-28 20:07:19 +08:00
|
|
|
FinaliseSelection();
|
2017-11-26 02:30:05 +08:00
|
|
|
return false;
|
2017-11-25 22:29:08 +08:00
|
|
|
};
|
2017-11-01 19:54:58 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-11-09 16:38:20 +08:00
|
|
|
protected override void LogoExiting(OsuLogo logo)
|
2017-11-01 19:54:58 +08:00
|
|
|
{
|
2017-11-09 16:38:20 +08:00
|
|
|
base.LogoExiting(logo);
|
2017-11-10 00:10:40 +08:00
|
|
|
logo.ScaleTo(0.2f, logo_transition / 2, Easing.Out);
|
|
|
|
logo.FadeOut(logo_transition / 2, Easing.Out);
|
2017-11-01 19:54:58 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
public override void OnResuming(ScreenTransitionEvent e)
|
2016-10-28 18:55:48 +08:00
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
base.OnResuming(e);
|
2020-01-30 16:37:52 +08:00
|
|
|
|
|
|
|
// required due to https://github.com/ppy/osu-framework/issues/3218
|
|
|
|
ModSelect.SelectedMods.Disabled = false;
|
|
|
|
ModSelect.SelectedMods.BindTo(selectedMods);
|
|
|
|
|
2020-01-31 16:35:53 +08:00
|
|
|
Carousel.AllowSelection = true;
|
|
|
|
|
2020-02-12 18:52:47 +08:00
|
|
|
BeatmapDetails.Refresh();
|
2018-12-12 12:21:44 +08:00
|
|
|
|
2020-11-02 23:45:55 +08:00
|
|
|
beginLooping();
|
2018-12-12 12:21:44 +08:00
|
|
|
|
2017-07-19 12:32:16 +08:00
|
|
|
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
|
2017-07-19 09:59:13 +08:00
|
|
|
{
|
2020-03-12 14:52:03 +08:00
|
|
|
updateComponentFromBeatmap(Beatmap.Value);
|
2019-10-10 19:12:47 +08:00
|
|
|
|
2022-04-22 17:37:40 +08:00
|
|
|
if (ControlGlobalMusic)
|
|
|
|
{
|
|
|
|
// restart playback on returning to song select, regardless.
|
|
|
|
// not sure this should be a permanent thing (we may want to leave a user pause paused even on returning)
|
|
|
|
music.ResetTrackAdjustments();
|
|
|
|
music.Play(requestedByUser: true);
|
|
|
|
}
|
2017-07-19 09:59:13 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
this.FadeIn(250);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
this.ScaleTo(1, 250, Easing.OutSine);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
FilterControl.Activate();
|
2016-11-20 19:16:54 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
public override void OnSuspending(ScreenTransitionEvent e)
|
2016-11-20 19:16:54 +08:00
|
|
|
{
|
2022-01-29 17:38:45 +08:00
|
|
|
// Handle the case where FinaliseSelection is never called (ie. when a screen is pushed externally).
|
|
|
|
// Without this, it's possible for a transfer to happen while we are not the current screen.
|
|
|
|
transferRulesetValue();
|
|
|
|
|
2020-01-30 16:37:52 +08:00
|
|
|
ModSelect.SelectedMods.UnbindFrom(selectedMods);
|
2018-12-06 18:29:18 +08:00
|
|
|
ModSelect.Hide();
|
|
|
|
|
2019-05-12 12:26:42 +08:00
|
|
|
BeatmapOptions.Hide();
|
|
|
|
|
2020-11-02 23:45:55 +08:00
|
|
|
endLooping();
|
2020-03-25 14:45:33 +08:00
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
this.ScaleTo(1.1f, 250, Easing.InSine);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
this.FadeOut(250);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
FilterControl.Deactivate();
|
2022-04-21 23:52:44 +08:00
|
|
|
base.OnSuspending(e);
|
2016-11-20 19:16:54 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
public override bool OnExiting(ScreenExitEvent e)
|
2016-11-20 19:16:54 +08:00
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
if (base.OnExiting(e))
|
2019-02-25 17:40:19 +08:00
|
|
|
return true;
|
|
|
|
|
2019-06-11 13:28:52 +08:00
|
|
|
beatmapInfoWedge.Hide();
|
2022-05-05 23:27:21 +08:00
|
|
|
ModSelect.Hide();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
this.FadeOut(100);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-03-16 13:23:48 +08:00
|
|
|
FilterControl.Deactivate();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-11-02 23:45:55 +08:00
|
|
|
endLooping();
|
2018-12-12 12:21:44 +08:00
|
|
|
|
2019-02-25 17:40:19 +08:00
|
|
|
return false;
|
2016-10-28 18:55:48 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-11-02 23:45:55 +08:00
|
|
|
private bool isHandlingLooping;
|
|
|
|
|
|
|
|
private void beginLooping()
|
|
|
|
{
|
2022-04-22 17:37:40 +08:00
|
|
|
if (!ControlGlobalMusic)
|
|
|
|
return;
|
|
|
|
|
2020-11-02 23:45:55 +08:00
|
|
|
Debug.Assert(!isHandlingLooping);
|
|
|
|
|
2021-02-18 14:01:11 +08:00
|
|
|
isHandlingLooping = true;
|
2020-11-02 23:45:55 +08:00
|
|
|
|
2021-02-18 14:01:11 +08:00
|
|
|
ensureTrackLooping(Beatmap.Value, TrackChangeDirection.None);
|
2020-11-02 23:45:55 +08:00
|
|
|
music.TrackChanged += ensureTrackLooping;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void endLooping()
|
|
|
|
{
|
2020-11-03 15:49:13 +08:00
|
|
|
// may be called multiple times during screen exit process.
|
|
|
|
if (!isHandlingLooping)
|
|
|
|
return;
|
|
|
|
|
2020-11-02 23:45:55 +08:00
|
|
|
music.CurrentTrack.Looping = isHandlingLooping = false;
|
|
|
|
|
|
|
|
music.TrackChanged -= ensureTrackLooping;
|
|
|
|
}
|
|
|
|
|
2021-11-15 17:46:11 +08:00
|
|
|
private void ensureTrackLooping(IWorkingBeatmap beatmap, TrackChangeDirection changeDirection)
|
2021-02-18 14:01:11 +08:00
|
|
|
=> beatmap.PrepareTrackForPreviewLooping();
|
2020-09-13 02:43:17 +08:00
|
|
|
|
2020-07-14 15:00:10 +08:00
|
|
|
public override bool OnBackButton()
|
|
|
|
{
|
|
|
|
if (ModSelect.State.Value == Visibility.Visible)
|
|
|
|
{
|
|
|
|
ModSelect.Hide();
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-12 12:21:44 +08:00
|
|
|
|
2019-02-25 17:40:19 +08:00
|
|
|
return false;
|
2016-10-28 18:55:48 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2016-10-08 18:12:31 +08:00
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-02-01 14:42:15 +08:00
|
|
|
decoupledRuleset.UnbindAll();
|
2020-09-15 13:34:58 +08:00
|
|
|
|
|
|
|
if (music != null)
|
|
|
|
music.TrackChanged -= ensureTrackLooping;
|
2022-05-05 03:53:04 +08:00
|
|
|
|
|
|
|
modSelectOverlayRegistration?.Dispose();
|
2016-10-06 22:33:28 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-09-01 17:22:38 +08: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>
|
2020-03-12 14:52:03 +08:00
|
|
|
private void updateComponentFromBeatmap(WorkingBeatmap beatmap)
|
2016-10-26 22:52:04 +08:00
|
|
|
{
|
2021-01-04 17:32:23 +08:00
|
|
|
ApplyToBackground(backgroundModeBeatmap =>
|
2016-11-20 00:39:43 +08:00
|
|
|
{
|
|
|
|
backgroundModeBeatmap.Beatmap = beatmap;
|
2019-03-20 13:17:35 +08:00
|
|
|
backgroundModeBeatmap.BlurAmount.Value = BACKGROUND_BLUR;
|
2019-02-04 16:04:52 +08:00
|
|
|
backgroundModeBeatmap.FadeColour(Color4.White, 250);
|
2021-01-04 17:32:23 +08:00
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-06-01 17:03:16 +08:00
|
|
|
beatmapInfoWedge.Beatmap = beatmap;
|
2018-12-12 12:21:44 +08:00
|
|
|
|
|
|
|
BeatmapDetails.Beatmap = beatmap;
|
2016-11-20 17:02:20 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-08-05 20:10:38 +08:00
|
|
|
private readonly WeakReference<ITrack> lastTrack = new WeakReference<ITrack>(null);
|
2019-10-08 14:03:48 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Ensures some music is playing for the current track.
|
|
|
|
/// Will resume playback from a manual user pause if the track has changed.
|
|
|
|
/// </summary>
|
2019-10-10 19:12:47 +08:00
|
|
|
private void ensurePlayingSelected()
|
2016-10-28 18:55:48 +08:00
|
|
|
{
|
2022-04-22 17:37:40 +08:00
|
|
|
if (!ControlGlobalMusic)
|
|
|
|
return;
|
|
|
|
|
2020-08-11 11:40:58 +08:00
|
|
|
ITrack track = music.CurrentTrack;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-10-08 14:03:48 +08:00
|
|
|
bool isNewTrack = !lastTrack.TryGetTarget(out var last) || last != track;
|
|
|
|
|
2020-11-02 15:08:59 +08:00
|
|
|
if (!track.IsRunning && (music.UserPauseRequested != true || isNewTrack))
|
2020-08-11 11:40:58 +08:00
|
|
|
music.Play(true);
|
2019-10-08 14:03:48 +08:00
|
|
|
|
|
|
|
lastTrack.SetTarget(track);
|
2016-10-28 18:55:48 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-12-15 11:48:15 +08:00
|
|
|
private void carouselBeatmapsLoaded()
|
|
|
|
{
|
2019-03-21 19:52:15 +08:00
|
|
|
bindBindables();
|
2018-07-17 21:20:19 +08:00
|
|
|
|
2020-03-20 14:01:26 +08:00
|
|
|
Carousel.AllowSelection = true;
|
|
|
|
|
2019-06-12 15:07:35 +08:00
|
|
|
// If a selection was already obtained, do not attempt to update the selected beatmap.
|
2019-05-28 13:04:33 +08:00
|
|
|
if (Carousel.SelectedBeatmapSet != null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Attempt to select the current beatmap on the carousel, if it is valid to be selected.
|
2020-03-12 14:52:03 +08:00
|
|
|
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false)
|
|
|
|
{
|
|
|
|
if (Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// prefer not changing ruleset at this point, so look for another difficulty in the currently playing beatmap
|
|
|
|
var found = Beatmap.Value.BeatmapSetInfo.Beatmaps.FirstOrDefault(b => b.Ruleset.Equals(decoupledRuleset.Value));
|
|
|
|
|
|
|
|
if (found != null && Carousel.SelectBeatmap(found, false))
|
|
|
|
return;
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-05-28 13:04:33 +08:00
|
|
|
// If the current active beatmap could not be selected, select a new random beatmap.
|
|
|
|
if (!Carousel.SelectNextRandom())
|
2017-12-31 11:55:53 +08:00
|
|
|
{
|
2018-03-09 18:52:59 +08:00
|
|
|
// in the case random selection failed, we want to trigger selectionChanged
|
|
|
|
// to show the dummy beatmap (we have nothing else to display).
|
2018-07-19 17:48:40 +08:00
|
|
|
performUpdateSelected();
|
2017-12-31 11:55:53 +08:00
|
|
|
}
|
2017-12-15 11:48:15 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2019-03-21 19:52:15 +08:00
|
|
|
private bool boundLocalBindables;
|
|
|
|
|
|
|
|
private void bindBindables()
|
2019-03-21 19:52:34 +08:00
|
|
|
{
|
2019-03-21 19:52:15 +08:00
|
|
|
if (boundLocalBindables)
|
|
|
|
return;
|
|
|
|
|
2019-03-21 19:52:34 +08:00
|
|
|
// manual binding to parent ruleset to allow for delayed load in the incoming direction.
|
2019-11-13 17:00:45 +08:00
|
|
|
transferRulesetValue();
|
2020-01-29 18:37:54 +08:00
|
|
|
|
2019-03-21 19:52:34 +08:00
|
|
|
Ruleset.ValueChanged += r => updateSelectedRuleset(r.NewValue);
|
2019-03-21 19:52:15 +08:00
|
|
|
|
2019-03-21 19:52:34 +08:00
|
|
|
decoupledRuleset.ValueChanged += r => Ruleset.Value = r.NewValue;
|
|
|
|
decoupledRuleset.DisabledChanged += r => Ruleset.Disabled = r;
|
2019-03-21 19:52:15 +08:00
|
|
|
|
2019-03-21 19:52:34 +08:00
|
|
|
Beatmap.BindValueChanged(workingBeatmapChanged);
|
2019-03-21 19:52:15 +08:00
|
|
|
|
|
|
|
boundLocalBindables = true;
|
|
|
|
}
|
|
|
|
|
2020-01-29 18:37:54 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Transfer the game-wide ruleset to the local decoupled ruleset.
|
2020-01-30 10:31:34 +08:00
|
|
|
/// Will immediately run filter operations if required.
|
2020-01-29 18:37:54 +08:00
|
|
|
/// </summary>
|
|
|
|
/// <returns>Whether a transfer occurred.</returns>
|
|
|
|
private bool transferRulesetValue()
|
2019-11-13 17:00:45 +08:00
|
|
|
{
|
2020-01-29 18:37:54 +08:00
|
|
|
if (decoupledRuleset.Value?.Equals(Ruleset.Value) == true)
|
|
|
|
return false;
|
|
|
|
|
2020-04-20 13:03:55 +08:00
|
|
|
Logger.Log($"decoupled ruleset transferred (\"{decoupledRuleset.Value}\" -> \"{Ruleset.Value}\")");
|
2019-11-13 17:00:45 +08:00
|
|
|
rulesetNoDebounce = decoupledRuleset.Value = Ruleset.Value;
|
2020-01-29 18:37:54 +08: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?.FlushPendingFilterOperations();
|
|
|
|
return true;
|
2019-11-13 17:00:45 +08:00
|
|
|
}
|
|
|
|
|
2017-12-15 11:48:15 +08:00
|
|
|
private void delete(BeatmapSetInfo beatmap)
|
|
|
|
{
|
2022-01-13 17:38:38 +08:00
|
|
|
if (beatmap == null) return;
|
2019-02-27 20:07:17 +08:00
|
|
|
|
2017-08-30 19:41:41 +08:00
|
|
|
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
2017-03-02 20:40:55 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
private void clearScores(BeatmapInfo beatmapInfo)
|
2019-01-05 03:13:32 +08:00
|
|
|
{
|
2022-01-13 17:38:38 +08:00
|
|
|
if (beatmapInfo == null) return;
|
2019-01-05 03:13:32 +08:00
|
|
|
|
2021-10-02 23:55:29 +08:00
|
|
|
dialogOverlay?.Push(new BeatmapClearScoresDialog(beatmapInfo, () =>
|
2019-03-01 19:52:34 +08:00
|
|
|
// schedule done here rather than inside the dialog as the dialog may fade out and never callback.
|
2020-02-12 18:52:47 +08:00
|
|
|
Schedule(() => BeatmapDetails.Refresh())));
|
2019-01-05 03:13:32 +08:00
|
|
|
}
|
|
|
|
|
2021-09-16 17:26:12 +08:00
|
|
|
public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
2018-07-03 17:37:21 +08:00
|
|
|
{
|
2021-11-18 11:35:47 +08:00
|
|
|
if (e.Repeat)
|
|
|
|
return false;
|
|
|
|
|
2019-01-23 19:52:00 +08:00
|
|
|
if (!this.IsCurrentScreen()) return false;
|
2018-07-03 17:37:21 +08:00
|
|
|
|
2021-09-16 17:26:12 +08:00
|
|
|
switch (e.Action)
|
2018-07-03 17:37:21 +08:00
|
|
|
{
|
|
|
|
case GlobalAction.Select:
|
|
|
|
FinaliseSelection();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-06-25 16:17:29 +08:00
|
|
|
return false;
|
2018-07-03 17:37:21 +08:00
|
|
|
}
|
|
|
|
|
2021-09-16 17:26:12 +08:00
|
|
|
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
2020-01-22 12:22:34 +08:00
|
|
|
{
|
|
|
|
}
|
2019-06-25 16:17:29 +08:00
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
protected override bool OnKeyDown(KeyDownEvent e)
|
2016-12-15 19:55:37 +08:00
|
|
|
{
|
2018-10-02 11:02:47 +08:00
|
|
|
if (e.Repeat) return false;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
switch (e.Key)
|
2016-12-15 19:55:37 +08:00
|
|
|
{
|
2017-03-14 21:51:26 +08:00
|
|
|
case Key.Delete:
|
2018-10-02 11:44:14 +08:00
|
|
|
if (e.ShiftPressed)
|
2017-03-14 21:51:26 +08:00
|
|
|
{
|
2017-08-30 19:41:41 +08:00
|
|
|
if (!Beatmap.IsDefault)
|
2017-12-15 11:48:15 +08:00
|
|
|
delete(Beatmap.Value.BeatmapSetInfo);
|
2017-03-14 21:51:26 +08:00
|
|
|
return true;
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-03-14 21:51:26 +08:00
|
|
|
break;
|
2016-12-15 19:55:37 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
return base.OnKeyDown(e);
|
2016-12-15 19:55:37 +08:00
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-01-24 14:34:15 +08:00
|
|
|
private class VerticalMaskingContainer : Container
|
|
|
|
{
|
|
|
|
private const float panel_overflow = 1.2f;
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content { get; }
|
|
|
|
|
|
|
|
public VerticalMaskingContainer()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Masking = true;
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2020-05-05 09:31:11 +08:00
|
|
|
Width = panel_overflow; // avoid horizontal masking so the panels don't clip when screen stack is pushed.
|
2020-01-24 14:34:15 +08:00
|
|
|
InternalChild = Content = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Width = 1 / panel_overflow,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-31 19:20:12 +08:00
|
|
|
private class ResetScrollContainer : Container
|
2017-07-29 22:33:20 +08:00
|
|
|
{
|
2017-07-31 19:20:12 +08:00
|
|
|
private readonly Action onHoverAction;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2017-07-31 19:20:12 +08:00
|
|
|
public ResetScrollContainer(Action onHoverAction)
|
|
|
|
{
|
|
|
|
this.onHoverAction = onHoverAction;
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
protected override bool OnHover(HoverEvent e)
|
2017-07-29 22:33:20 +08:00
|
|
|
{
|
2017-07-31 19:20:12 +08:00
|
|
|
onHoverAction?.Invoke();
|
2018-10-02 11:02:47 +08:00
|
|
|
return base.OnHover(e);
|
2017-07-29 22:33:20 +08:00
|
|
|
}
|
|
|
|
}
|
2016-09-29 19:13:58 +08:00
|
|
|
}
|
|
|
|
}
|