mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:03:22 +08:00
Merge branch 'osd-toggle-sounds' into update-resources
This commit is contained in:
commit
4ffb7fb753
@ -3,6 +3,8 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Configuration.Tracking;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -19,6 +21,13 @@ namespace osu.Game.Overlays.OSD
|
||||
{
|
||||
private const int lights_bottom_margin = 40;
|
||||
|
||||
private readonly int optionCount;
|
||||
private readonly int selectedOption = -1;
|
||||
|
||||
private SampleChannel sampleOn;
|
||||
private SampleChannel sampleOff;
|
||||
private SampleChannel sampleChange;
|
||||
|
||||
public TrackedSettingToast(SettingDescription description)
|
||||
: base(description.Name, description.Value, description.Shortcut)
|
||||
{
|
||||
@ -46,9 +55,6 @@ namespace osu.Game.Overlays.OSD
|
||||
}
|
||||
};
|
||||
|
||||
int optionCount = 0;
|
||||
int selectedOption = -1;
|
||||
|
||||
switch (description.RawValue)
|
||||
{
|
||||
case bool val:
|
||||
@ -69,6 +75,34 @@ namespace osu.Game.Overlays.OSD
|
||||
optionLights.Add(new OptionLight { Glowing = i == selectedOption });
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (optionCount == 1)
|
||||
{
|
||||
if (selectedOption == 0)
|
||||
sampleOn?.Play();
|
||||
else
|
||||
sampleOff?.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sampleChange == null) return;
|
||||
|
||||
sampleChange.Frequency.Value = 1 + (double)selectedOption / (optionCount - 1) * 0.25f;
|
||||
sampleChange.Play();
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleOn = audio.Samples.Get("UI/osd-on");
|
||||
sampleOff = audio.Samples.Get("UI/osd-off");
|
||||
sampleChange = audio.Samples.Get("UI/osd-change");
|
||||
}
|
||||
|
||||
private class OptionLight : Container
|
||||
{
|
||||
private Color4 glowingColour, idleColour;
|
||||
|
Loading…
Reference in New Issue
Block a user