Add checkbox sound effects.

This commit is contained in:
Dean Herbert 2016-12-05 19:45:54 +09:00
parent d4670fc64e
commit 590ca3108c
2 changed files with 15 additions and 1 deletions

@ -1 +1 @@
Subproject commit 6edd5eacdd25cc8c4f4dbca3414678c0b7dc5deb
Subproject commit 8ee9e6736fb3f656894baaef109a06fd25278fe6

View File

@ -1,5 +1,8 @@
using System;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -60,6 +63,8 @@ public MarginPadding LabelPadding
private Light light;
private SpriteText labelSpriteText;
private AudioSample sampleChecked;
private AudioSample sampleUnchecked;
public CheckBoxOption()
{
@ -102,11 +107,19 @@ protected override void OnHoverLost(InputState state)
base.OnHoverLost(state);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleChecked = audio.Sample.Get(@"Checkbox/check-on");
sampleUnchecked = audio.Sample.Get(@"Checkbox/check-off");
}
protected override void OnChecked()
{
if (bindable != null)
bindable.Value = true;
sampleChecked?.Play();
light.State = CheckBoxState.Checked;
}
@ -115,6 +128,7 @@ protected override void OnUnchecked()
if (bindable != null)
bindable.Value = false;
sampleUnchecked?.Play();
light.State = CheckBoxState.Unchecked;
}