Merge pull request #18005 from nekodex/fix-missing-sfx

Fix some missing/incorrect UI SFX
This commit is contained in:
Dean Herbert 2022-04-28 19:45:59 +09:00 committed by GitHub
commit 34457078eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -4,6 +4,8 @@
#nullable enable
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -31,6 +33,9 @@ namespace osu.Game.Graphics.UserInterfaceV2
private Color4 enabledColour;
private Color4 disabledColour;
private Sample? sampleChecked;
private Sample? sampleUnchecked;
public SwitchButton()
{
Size = new Vector2(45, 20);
@ -70,13 +75,16 @@ namespace osu.Game.Graphics.UserInterfaceV2
}
[BackgroundDependencyLoader(true)]
private void load(OverlayColourProvider? colourProvider, OsuColour colours)
private void load(OverlayColourProvider? colourProvider, OsuColour colours, AudioManager audio)
{
enabledColour = colourProvider?.Highlight1 ?? colours.BlueDark;
disabledColour = colourProvider?.Background3 ?? colours.Gray3;
switchContainer.Colour = enabledColour;
fill.Colour = disabledColour;
sampleChecked = audio.Samples.Get(@"UI/check-on");
sampleUnchecked = audio.Samples.Get(@"UI/check-off");
}
protected override void LoadComplete()
@ -107,6 +115,16 @@ namespace osu.Game.Graphics.UserInterfaceV2
base.OnHoverLost(e);
}
protected override void OnUserChange(bool value)
{
base.OnUserChange(value);
if (value)
sampleChecked?.Play();
else
sampleUnchecked?.Play();
}
private void updateBorder()
{
circularContainer.TransformBorderTo((Current.Value ? enabledColour : disabledColour).Lighten(IsHovered ? 0.3f : 0));

View File

@ -72,7 +72,8 @@ namespace osu.Game.Overlays.BeatmapListing
Size = new Vector2(12),
Icon = getIconForCardSize(Value)
}
}
},
new HoverClickSounds(HoverSampleSet.TabSelect)
};
}

View File

@ -149,7 +149,7 @@ namespace osu.Game.Overlays
}
});
AddInternal(new HoverClickSounds());
AddInternal(new HoverClickSounds(HoverSampleSet.TabSelect));
}
protected override void LoadComplete()