mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:20:04 +08:00
Add sample playback time restrictions
This commit is contained in:
parent
9224486ec7
commit
09cd5580e1
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user