Add hover+select sounds to some components that are missing them

This commit is contained in:
Jamie Taylor
2021-07-30 21:32:08 +09:00
parent 7dc1de7423
commit 9b7bb37244
6 changed files with 70 additions and 34 deletions

View File

@ -3,6 +3,9 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -13,6 +16,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Chat;
using osuTK;
using osuTK.Graphics;
@ -39,6 +43,8 @@ namespace osu.Game.Overlays.Chat.Tabs
protected override Container<Drawable> Content => content;
private Sample sampleTabSwitched;
public ChannelTabItem(Channel value)
: base(value)
{
@ -112,6 +118,7 @@ namespace osu.Game.Overlays.Chat.Tabs
},
},
},
new HoverSounds()
};
}
@ -152,11 +159,12 @@ namespace osu.Game.Overlays.Chat.Tabs
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OsuColour colours, AudioManager audio)
{
BackgroundActive = colours.ChatBlue;
BackgroundInactive = colours.Gray4;
backgroundHover = colours.Gray7;
sampleTabSwitched = audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select");
highlightBox.Colour = colours.Yellow;
}
@ -217,7 +225,14 @@ namespace osu.Game.Overlays.Chat.Tabs
Text.Font = Text.Font.With(weight: FontWeight.Medium);
}
protected override void OnActivated() => updateState();
protected override void OnActivated()
{
if (IsLoaded)
sampleTabSwitched?.Play();
updateState();
}
protected override void OnDeactivated() => updateState();
}
}