1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:47:24 +08:00
osu-lazer/osu.Game/Overlays/WaveOverlayContainer.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.8 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
2017-02-23 10:16:23 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Game.Graphics.Containers;
2018-04-13 17:19:50 +08:00
2017-02-23 10:16:23 +08:00
namespace osu.Game.Overlays
{
public abstract partial class WaveOverlayContainer : OsuFocusedOverlayContainer
2017-02-23 10:16:23 +08:00
{
protected readonly WaveContainer Waves;
2018-04-13 17:19:50 +08:00
protected override bool BlockNonPositionalInput => true;
protected override Container<Drawable> Content => Waves;
2018-04-13 17:19:50 +08:00
2020-09-03 15:28:14 +08:00
public const float WIDTH_PADDING = 80;
protected override bool StartHidden => true;
// `WaveContainer` plays PopIn/PopOut samples, so we disable the overlay-level one as to not double-up sample playback.
2023-08-25 00:07:07 +08:00
protected override string PopInSampleName => string.Empty;
protected override string PopOutSampleName => string.Empty;
public const float HORIZONTAL_PADDING = 50;
2017-02-23 11:48:24 +08:00
protected WaveOverlayContainer()
2017-02-23 10:16:23 +08:00
{
AddInternal(Waves = new WaveContainer
2017-02-23 10:16:23 +08:00
{
RelativeSizeAxes = Axes.Both,
});
2017-02-23 10:22:01 +08:00
}
2018-04-13 17:19:50 +08:00
2017-02-23 11:42:31 +08:00
protected override void PopIn()
{
Waves.Show();
this.FadeIn(100, Easing.OutQuint);
2017-02-23 11:42:31 +08:00
}
2018-04-13 17:19:50 +08:00
2017-02-23 11:42:31 +08:00
protected override void PopOut()
{
Waves.Hide();
Fix preview tracks playing after their owning overlay has hidden RFC. Closes https://github.com/ppy/osu/issues/27883. The idea here is that `PopOut()` is called _when the hide is requested_, so once an overlay trigger would hide, the overlay would `StopAnyPlaying()`, but because of async load things, the actual track would start playing after that but before the overlay has fully hidden. (That last part is significant because after the overlay has fully hidden, schedules save the day.) Due to the loose coupling between `PreviewTrackManager` and `IPreviewTrackOwner` there's really no easy way to handle this locally to the usages of the preview tracks. Heck, `PreviewTrackManager` doesn't really know which preview track owner is to be considered _present_ at any time, it just kinda works on vibes based on DI until the owner tells all of its preview tracks to stop. This solution causes the preview tracks to stop a little bit later but maybe that's fine? Just trying to not overthink the issue is all. No tests because this is going to suck to test automatically while it is pretty easy to test manually (got it in a few tries on master). The issue also mentions that the track can sometimes resume playing after the overlay is pulled up again, but I don't see that as a problem necessarily, and even if it was, it's not going to be that easy to address due to the aforementioned loose coupling - to fix that, play buttons would have to know who is the current preview track owner and cancel schedules upon determining that their preview track owner has gone away.
2024-04-16 22:07:56 +08:00
this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InQuint)
// base call is responsible for stopping preview tracks.
// delay it until the fade has concluded to ensure that nothing inside the overlay has triggered
// another preview track playback in the meantime, leaving an "orphaned" preview playing.
.OnComplete(_ => base.PopOut());
2017-02-23 10:16:23 +08:00
}
}
}