1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-24 07:14:10 +08:00

Add sample playback time restrictions

This commit is contained in:
Cootz
2023-06-10 13:13:34 +03:00
Unverified
parent 9224486ec7
commit 09cd5580e1
3 changed files with 15 additions and 3 deletions
+2 -1
View File
@@ -103,7 +103,8 @@ namespace osu.Game.Overlays.Mods
private readonly BindableBool customisationVisible = new BindableBool();
protected readonly ModSelectOverlayStatics statics = new ModSelectOverlayStatics();
[Cached]
protected readonly ModSelectOverlayStatics Statics = new ModSelectOverlayStatics();
private ModSettingsArea modSettingsArea = null!;
private ColumnScrollContainer columnScroll = null!;
@@ -9,12 +9,12 @@ namespace osu.Game.Overlays.Mods
{
protected override void InitialiseDefaults()
{
SetDefault(Static.LastModSelectPanelSoundPlaybackTime, (double?)null);
SetDefault(Static.LastModSelectPanelSamplePlaybackTime, (double?)null);
}
}
public enum Static
{
LastModSelectPanelSoundPlaybackTime
LastModSelectPanelSamplePlaybackTime
}
}
+11
View File
@@ -44,6 +44,7 @@ namespace osu.Game.Overlays.Mods
public const float CORNER_RADIUS = 7;
public const float HEIGHT = 42;
public double SAMPLE_PLAYBACK_DELAY = 30;
protected virtual float IdleSwitchWidth => 14;
protected virtual float ExpandedSwitchWidth => 30;
@@ -62,6 +63,9 @@ namespace osu.Game.Overlays.Mods
[Resolved]
protected OverlayColourProvider ColourProvider { get; private set; } = null!;
[Resolved]
protected ModSelectOverlayStatics ModOverlayStatics { get; private set; } = null!;
private readonly OsuSpriteText titleText;
private readonly OsuSpriteText descriptionText;
@@ -192,10 +196,17 @@ namespace osu.Game.Overlays.Mods
if (samplePlaybackDisabled.Value)
return;
double? lastPlaybackTime = ModOverlayStatics.Get<double?>(Static.LastModSelectPanelSamplePlaybackTime);
if (lastPlaybackTime is not null && Time.Current - lastPlaybackTime < SAMPLE_PLAYBACK_DELAY)
return;
if (Active.Value)
sampleOn?.Play();
else
sampleOff?.Play();
ModOverlayStatics.SetValue<double?>(Static.LastModSelectPanelSamplePlaybackTime, Time.Current);
}
protected override bool OnHover(HoverEvent e)