From ee96d39b93eaaaade69541de50f09b22a704b9c0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 28 Jun 2017 10:19:04 -0700 Subject: [PATCH] Shuffle sound samples around and make more conformant --- osu.Game/Graphics/UserInterface/OsuButton.cs | 17 ++++++++++- .../Graphics/UserInterface/OsuCheckbox.cs | 4 +-- .../UserInterface/OsuContextMenuItem.cs | 4 +-- .../Graphics/UserInterface/OsuSliderBar.cs | 2 +- osu.Game/Overlays/Chat/ChannelListItem.cs | 3 +- .../Dialog/PopupDialogCancelButton.cs | 2 -- .../Overlays/Dialog/PopupDialogOkButton.cs | 4 +-- osu.Game/Screens/Menu/Button.cs | 16 ++++++----- osu.Game/Screens/Menu/ButtonSystem.cs | 28 ++++++++++++------- osu.Game/Screens/Menu/OsuLogo.cs | 24 +++++++++------- osu.Game/Screens/OsuScreen.cs | 14 +++++++++- osu.Game/Screens/Play/HotkeyRetryOverlay.cs | 3 -- osu.Game/Screens/Play/Player.cs | 6 ++++ osu.Game/Screens/ScreenWhiteBox.cs | 6 ---- 14 files changed, 84 insertions(+), 49 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuButton.cs b/osu.Game/Graphics/UserInterface/OsuButton.cs index 7bd58d38a5..6814308cb4 100644 --- a/osu.Game/Graphics/UserInterface/OsuButton.cs +++ b/osu.Game/Graphics/UserInterface/OsuButton.cs @@ -3,6 +3,8 @@ using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; @@ -18,6 +20,9 @@ public class OsuButton : Button { private Box hover; + private SampleChannel sampleClick; + private SampleChannel sampleHover; + public OsuButton() { Height = 40; @@ -34,7 +39,7 @@ public OsuButton() public override bool HandleInput => Action != null; [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, AudioManager audio) { if (Action == null) Colour = OsuColour.Gray(0.5f); @@ -60,10 +65,20 @@ private void load(OsuColour colours) Alpha = 0, }, }); + + sampleClick = audio.Sample.Get(@"UI/generic-click"); + sampleHover = audio.Sample.Get(@"UI/generic-hover"); + } + + protected override bool OnClick(InputState state) + { + sampleClick?.Play(); + return base.OnClick(state); } protected override bool OnHover(InputState state) { + sampleHover?.Play(); hover.FadeIn(200); return base.OnHover(state); } diff --git a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs index 198a01b5a4..68ff99e593 100644 --- a/osu.Game/Graphics/UserInterface/OsuCheckbox.cs +++ b/osu.Game/Graphics/UserInterface/OsuCheckbox.cs @@ -106,8 +106,8 @@ protected override void OnHoverLost(InputState state) [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleChecked = audio.Sample.Get(@"Checkbox/check-on"); - sampleUnchecked = audio.Sample.Get(@"Checkbox/check-off"); + sampleChecked = audio.Sample.Get(@"UI/check-on"); + sampleUnchecked = audio.Sample.Get(@"UI/check-off"); } } } diff --git a/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs b/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs index 769df18566..5d12dadf5f 100644 --- a/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs +++ b/osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs @@ -65,8 +65,8 @@ public OsuContextMenuItem(string title, MenuItemType type = MenuItemType.Standar [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleHover = audio.Sample.Get(@"Menu/menuclick"); - sampleClick = audio.Sample.Get(@"Menu/menuback"); + sampleHover = audio.Sample.Get(@"UI/generic-hover"); + sampleClick = audio.Sample.Get(@"UI/generic-click"); BackgroundColour = Color4.Transparent; BackgroundColourHover = OsuColour.FromHex(@"172023"); diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index 4f0ac28731..673a23afac 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -100,7 +100,7 @@ public OsuSliderBar() [BackgroundDependencyLoader] private void load(AudioManager audio, OsuColour colours) { - sample = audio.Sample.Get(@"Sliderbar/sliderbar"); + sample = audio.Sample.Get(@"UI/sliderbar-notch"); AccentColour = colours.Pink; } diff --git a/osu.Game/Overlays/Chat/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelListItem.cs index 9aa11cdd4f..aca65bbc17 100644 --- a/osu.Game/Overlays/Chat/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelListItem.cs @@ -12,10 +12,11 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.Chat; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Chat { - public class ChannelListItem : ClickableContainer, IFilterable + public class ChannelListItem : OsuClickableContainer, IFilterable { private const float width_padding = 5; private const float channel_width = 150; diff --git a/osu.Game/Overlays/Dialog/PopupDialogCancelButton.cs b/osu.Game/Overlays/Dialog/PopupDialogCancelButton.cs index 1449577b21..28b6e1b5fb 100644 --- a/osu.Game/Overlays/Dialog/PopupDialogCancelButton.cs +++ b/osu.Game/Overlays/Dialog/PopupDialogCancelButton.cs @@ -13,8 +13,6 @@ public class PopupDialogCancelButton : PopupDialogButton private void load(OsuColour colours, AudioManager audio) { ButtonColour = colours.Blue; - SampleHover = audio.Sample.Get(@"Menu/menuclick"); - SampleClick = audio.Sample.Get(@"Menu/menuback"); } } } diff --git a/osu.Game/Overlays/Dialog/PopupDialogOkButton.cs b/osu.Game/Overlays/Dialog/PopupDialogOkButton.cs index 46bf3debc4..8bc8ad76b9 100644 --- a/osu.Game/Overlays/Dialog/PopupDialogOkButton.cs +++ b/osu.Game/Overlays/Dialog/PopupDialogOkButton.cs @@ -10,11 +10,9 @@ namespace osu.Game.Overlays.Dialog public class PopupDialogOkButton : PopupDialogButton { [BackgroundDependencyLoader] - private void load(OsuColour colours, AudioManager audio) + private void load(OsuColour colours) { ButtonColour = colours.Pink; - SampleHover = audio.Sample.Get(@"Menu/menuclick"); - SampleClick = audio.Sample.Get(@"Menu/menu-play-click"); } } } diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index cdff79c94f..3e9f51ebe9 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -30,16 +30,17 @@ public class Button : Container, IStateful private readonly Container box; private readonly Box boxHoverLayer; private readonly TextAwesome icon; - private readonly string internalName; + private readonly string sampleName; private readonly Action clickAction; private readonly Key triggerKey; private SampleChannel sampleClick; + private SampleChannel sampleHover; public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); - public Button(string text, string internalName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown) + public Button(string text, string sampleName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown) { - this.internalName = internalName; + this.sampleName = sampleName; this.clickAction = clickAction; this.triggerKey = triggerKey; @@ -120,8 +121,7 @@ protected override bool OnHover(InputState state) { if (State != ButtonState.Expanded) return true; - //if (OsuGame.Instance.IsActive) - // Game.Audio.PlaySamplePositional($@"menu-{internalName}-hover", @"menuclick"); + sampleHover?.Play(); box.ScaleTo(new Vector2(1.5f, 1), 500, EasingTypes.OutElastic); @@ -222,7 +222,9 @@ protected override void OnHoverLost(InputState state) [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleClick = audio.Sample.Get($@"Menu/menu-{internalName}-click") ?? audio.Sample.Get(internalName.Contains(@"back") ? @"Menu/menuback" : @"Menu/menuhit"); + sampleHover = audio.Sample.Get(@"Menu/hover"); + if (!string.IsNullOrEmpty(sampleName)) + sampleClick = audio.Sample.Get($@"Menu/{sampleName}"); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -259,7 +261,7 @@ protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) private void trigger() { - sampleClick.Play(); + sampleClick?.Play(); clickAction?.Invoke(); diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 82b7335a9b..9ba16ab1ca 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -15,6 +15,8 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Input; +using osu.Framework.Audio.Sample; +using osu.Framework.Audio; namespace osu.Game.Screens.Menu { @@ -51,6 +53,8 @@ public class ButtonSystem : Container, IStateful private readonly List