mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 00:47:20 +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();
|
private readonly BindableBool customisationVisible = new BindableBool();
|
||||||
|
|
||||||
protected readonly ModSelectOverlayStatics statics = new ModSelectOverlayStatics();
|
[Cached]
|
||||||
|
protected readonly ModSelectOverlayStatics Statics = new ModSelectOverlayStatics();
|
||||||
|
|
||||||
private ModSettingsArea modSettingsArea = null!;
|
private ModSettingsArea modSettingsArea = null!;
|
||||||
private ColumnScrollContainer columnScroll = null!;
|
private ColumnScrollContainer columnScroll = null!;
|
||||||
|
@ -9,12 +9,12 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
protected override void InitialiseDefaults()
|
protected override void InitialiseDefaults()
|
||||||
{
|
{
|
||||||
SetDefault(Static.LastModSelectPanelSoundPlaybackTime, (double?)null);
|
SetDefault(Static.LastModSelectPanelSamplePlaybackTime, (double?)null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Static
|
public enum Static
|
||||||
{
|
{
|
||||||
LastModSelectPanelSoundPlaybackTime
|
LastModSelectPanelSamplePlaybackTime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
|
|
||||||
public const float CORNER_RADIUS = 7;
|
public const float CORNER_RADIUS = 7;
|
||||||
public const float HEIGHT = 42;
|
public const float HEIGHT = 42;
|
||||||
|
public double SAMPLE_PLAYBACK_DELAY = 30;
|
||||||
|
|
||||||
protected virtual float IdleSwitchWidth => 14;
|
protected virtual float IdleSwitchWidth => 14;
|
||||||
protected virtual float ExpandedSwitchWidth => 30;
|
protected virtual float ExpandedSwitchWidth => 30;
|
||||||
@ -62,6 +63,9 @@ namespace osu.Game.Overlays.Mods
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
protected OverlayColourProvider ColourProvider { get; private set; } = null!;
|
protected OverlayColourProvider ColourProvider { get; private set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected ModSelectOverlayStatics ModOverlayStatics { get; private set; } = null!;
|
||||||
|
|
||||||
private readonly OsuSpriteText titleText;
|
private readonly OsuSpriteText titleText;
|
||||||
private readonly OsuSpriteText descriptionText;
|
private readonly OsuSpriteText descriptionText;
|
||||||
|
|
||||||
@ -192,10 +196,17 @@ namespace osu.Game.Overlays.Mods
|
|||||||
if (samplePlaybackDisabled.Value)
|
if (samplePlaybackDisabled.Value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
double? lastPlaybackTime = ModOverlayStatics.Get<double?>(Static.LastModSelectPanelSamplePlaybackTime);
|
||||||
|
|
||||||
|
if (lastPlaybackTime is not null && Time.Current - lastPlaybackTime < SAMPLE_PLAYBACK_DELAY)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Active.Value)
|
if (Active.Value)
|
||||||
sampleOn?.Play();
|
sampleOn?.Play();
|
||||||
else
|
else
|
||||||
sampleOff?.Play();
|
sampleOff?.Play();
|
||||||
|
|
||||||
|
ModOverlayStatics.SetValue<double?>(Static.LastModSelectPanelSamplePlaybackTime, Time.Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user