1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 13:32:54 +08:00

Shuffle sound samples around and make more conformant

This commit is contained in:
Dean Herbert 2017-06-28 10:19:04 -07:00
parent 28f0da606a
commit ee96d39b93
14 changed files with 84 additions and 49 deletions

View File

@ -3,6 +3,8 @@
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -18,6 +20,9 @@ namespace osu.Game.Graphics.UserInterface
{ {
private Box hover; private Box hover;
private SampleChannel sampleClick;
private SampleChannel sampleHover;
public OsuButton() public OsuButton()
{ {
Height = 40; Height = 40;
@ -34,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface
public override bool HandleInput => Action != null; public override bool HandleInput => Action != null;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours, AudioManager audio)
{ {
if (Action == null) if (Action == null)
Colour = OsuColour.Gray(0.5f); Colour = OsuColour.Gray(0.5f);
@ -60,10 +65,20 @@ namespace osu.Game.Graphics.UserInterface
Alpha = 0, 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) protected override bool OnHover(InputState state)
{ {
sampleHover?.Play();
hover.FadeIn(200); hover.FadeIn(200);
return base.OnHover(state); return base.OnHover(state);
} }

View File

@ -106,8 +106,8 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
sampleChecked = audio.Sample.Get(@"Checkbox/check-on"); sampleChecked = audio.Sample.Get(@"UI/check-on");
sampleUnchecked = audio.Sample.Get(@"Checkbox/check-off"); sampleUnchecked = audio.Sample.Get(@"UI/check-off");
} }
} }
} }

View File

@ -65,8 +65,8 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
sampleHover = audio.Sample.Get(@"Menu/menuclick"); sampleHover = audio.Sample.Get(@"UI/generic-hover");
sampleClick = audio.Sample.Get(@"Menu/menuback"); sampleClick = audio.Sample.Get(@"UI/generic-click");
BackgroundColour = Color4.Transparent; BackgroundColour = Color4.Transparent;
BackgroundColourHover = OsuColour.FromHex(@"172023"); BackgroundColourHover = OsuColour.FromHex(@"172023");

View File

@ -100,7 +100,7 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colours) private void load(AudioManager audio, OsuColour colours)
{ {
sample = audio.Sample.Get(@"Sliderbar/sliderbar"); sample = audio.Sample.Get(@"UI/sliderbar-notch");
AccentColour = colours.Pink; AccentColour = colours.Pink;
} }

View File

@ -12,10 +12,11 @@ using osu.Framework.Input;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.Chat namespace osu.Game.Overlays.Chat
{ {
public class ChannelListItem : ClickableContainer, IFilterable public class ChannelListItem : OsuClickableContainer, IFilterable
{ {
private const float width_padding = 5; private const float width_padding = 5;
private const float channel_width = 150; private const float channel_width = 150;

View File

@ -13,8 +13,6 @@ namespace osu.Game.Overlays.Dialog
private void load(OsuColour colours, AudioManager audio) private void load(OsuColour colours, AudioManager audio)
{ {
ButtonColour = colours.Blue; ButtonColour = colours.Blue;
SampleHover = audio.Sample.Get(@"Menu/menuclick");
SampleClick = audio.Sample.Get(@"Menu/menuback");
} }
} }
} }

View File

@ -10,11 +10,9 @@ namespace osu.Game.Overlays.Dialog
public class PopupDialogOkButton : PopupDialogButton public class PopupDialogOkButton : PopupDialogButton
{ {
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio) private void load(OsuColour colours)
{ {
ButtonColour = colours.Pink; ButtonColour = colours.Pink;
SampleHover = audio.Sample.Get(@"Menu/menuclick");
SampleClick = audio.Sample.Get(@"Menu/menu-play-click");
} }
} }
} }

View File

@ -30,16 +30,17 @@ namespace osu.Game.Screens.Menu
private readonly Container box; private readonly Container box;
private readonly Box boxHoverLayer; private readonly Box boxHoverLayer;
private readonly TextAwesome icon; private readonly TextAwesome icon;
private readonly string internalName; private readonly string sampleName;
private readonly Action clickAction; private readonly Action clickAction;
private readonly Key triggerKey; private readonly Key triggerKey;
private SampleChannel sampleClick; private SampleChannel sampleClick;
private SampleChannel sampleHover;
public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); 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.clickAction = clickAction;
this.triggerKey = triggerKey; this.triggerKey = triggerKey;
@ -120,8 +121,7 @@ namespace osu.Game.Screens.Menu
{ {
if (State != ButtonState.Expanded) return true; if (State != ButtonState.Expanded) return true;
//if (OsuGame.Instance.IsActive) sampleHover?.Play();
// Game.Audio.PlaySamplePositional($@"menu-{internalName}-hover", @"menuclick");
box.ScaleTo(new Vector2(1.5f, 1), 500, EasingTypes.OutElastic); box.ScaleTo(new Vector2(1.5f, 1), 500, EasingTypes.OutElastic);
@ -222,7 +222,9 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) 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) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
@ -259,7 +261,7 @@ namespace osu.Game.Screens.Menu
private void trigger() private void trigger()
{ {
sampleClick.Play(); sampleClick?.Play();
clickAction?.Invoke(); clickAction?.Invoke();

View File

@ -15,6 +15,8 @@ using osu.Game.Overlays.Toolbar;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio;
namespace osu.Game.Screens.Menu namespace osu.Game.Screens.Menu
{ {
@ -51,6 +53,8 @@ namespace osu.Game.Screens.Menu
private readonly List<Button> buttonsTopLevel = new List<Button>(); private readonly List<Button> buttonsTopLevel = new List<Button>();
private readonly List<Button> buttonsPlay = new List<Button>(); private readonly List<Button> buttonsPlay = new List<Button>();
private SampleChannel sampleBack;
public ButtonSystem() public ButtonSystem()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -82,8 +86,8 @@ namespace osu.Game.Screens.Menu
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new[] Children = new[]
{ {
settingsButton = new Button(@"settings", @"settings", FontAwesome.fa_gear, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O), settingsButton = new Button(@"settings", string.Empty, FontAwesome.fa_gear, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O),
backButton = new Button(@"back", @"back", FontAwesome.fa_osu_left_o, new Color4(51, 58, 94, 255), onBack, -WEDGE_WIDTH), backButton = new Button(@"back", string.Empty, FontAwesome.fa_osu_left_o, new Color4(51, 58, 94, 255), onBack, -WEDGE_WIDTH),
iconFacade = new Container //need a container to make the osu! icon flow properly. iconFacade = new Container //need a container to make the osu! icon flow properly.
{ {
Size = new Vector2(0, BUTTON_AREA_HEIGHT) Size = new Vector2(0, BUTTON_AREA_HEIGHT)
@ -101,23 +105,24 @@ namespace osu.Game.Screens.Menu
} }
}; };
buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P)); buttonsPlay.Add(new Button(@"solo", @"select-6", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M)); buttonsPlay.Add(new Button(@"multi", @"select-5", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke())); buttonsPlay.Add(new Button(@"chart", @"select-5", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
buttonsTopLevel.Add(new Button(@"play", @"play", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, WEDGE_WIDTH, Key.P)); buttonsTopLevel.Add(new Button(@"play", @"select-1", FontAwesome.fa_osu_logo, new Color4(102, 68, 204, 255), onPlay, WEDGE_WIDTH, Key.P));
buttonsTopLevel.Add(new Button(@"osu!editor", @"edit", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E)); buttonsTopLevel.Add(new Button(@"osu!editor", @"select-5", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
buttonsTopLevel.Add(new Button(@"osu!direct", @"direct", FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D)); buttonsTopLevel.Add(new Button(@"osu!direct", string.Empty, FontAwesome.fa_osu_chevron_down_o, new Color4(165, 204, 0, 255), () => OnDirect?.Invoke(), 0, Key.D));
buttonsTopLevel.Add(new Button(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q)); buttonsTopLevel.Add(new Button(@"exit", string.Empty, FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q));
buttonFlow.Add(buttonsPlay); buttonFlow.Add(buttonsPlay);
buttonFlow.Add(buttonsTopLevel); buttonFlow.Add(buttonsTopLevel);
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(OsuGame game = null) private void load(AudioManager audio, OsuGame game = null)
{ {
toolbar = game?.Toolbar; toolbar = game?.Toolbar;
sampleBack = audio.Sample.Get(@"Menu/select-4");
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -167,6 +172,7 @@ namespace osu.Game.Screens.Menu
private void onBack() private void onBack()
{ {
sampleBack?.Play();
State = MenuState.TopLevel; State = MenuState.TopLevel;
} }
@ -231,6 +237,8 @@ namespace osu.Game.Screens.Menu
osuLogo.RotateTo(20, EXIT_DELAY * 1.5f); osuLogo.RotateTo(20, EXIT_DELAY * 1.5f);
osuLogo.FadeOut(EXIT_DELAY); osuLogo.FadeOut(EXIT_DELAY);
} }
else if (lastState == MenuState.TopLevel)
sampleBack?.Play();
break; break;
case MenuState.TopLevel: case MenuState.TopLevel:
buttonArea.Flush(true); buttonArea.Flush(true);

View File

@ -72,11 +72,11 @@ namespace osu.Game.Screens.Menu
private const float default_size = 480; private const float default_size = 480;
private const double beat_in_time = 60; private const double early_activation = 60;
public OsuLogo() public OsuLogo()
{ {
EarlyActivationMilliseconds = beat_in_time; EarlyActivationMilliseconds = early_activation;
Size = new Vector2(default_size); Size = new Vector2(default_size);
@ -215,8 +215,9 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures, AudioManager audio) private void load(TextureStore textures, AudioManager audio)
{ {
sampleClick = audio.Sample.Get(@"Menu/menuhit"); sampleClick = audio.Sample.Get(@"Menu/select-2");
sampleBeat = audio.Sample.Get(@"Menu/heartbeat"); sampleBeat = audio.Sample.Get(@"Menu/heartbeat");
logo.Texture = textures.Get(@"Menu/logo"); logo.Texture = textures.Get(@"Menu/logo");
ripple.Texture = textures.Get(@"Menu/logo"); ripple.Texture = textures.Get(@"Menu/logo");
} }
@ -236,10 +237,13 @@ namespace osu.Game.Screens.Menu
if (beatIndex < 0) return; if (beatIndex < 0) return;
if (Hovering) if (Hovering)
sampleBeat.Play(); {
using (BeginDelayedSequence(early_activation))
Schedule(() => sampleBeat.Play());
}
logoBeatContainer.ScaleTo(1 - 0.02f * amplitudeAdjust, beat_in_time, EasingTypes.Out); logoBeatContainer.ScaleTo(1 - 0.02f * amplitudeAdjust, early_activation, EasingTypes.Out);
using (logoBeatContainer.BeginDelayedSequence(beat_in_time)) using (logoBeatContainer.BeginDelayedSequence(early_activation))
logoBeatContainer.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint); logoBeatContainer.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint);
ripple.ClearTransforms(); ripple.ClearTransforms();
@ -255,11 +259,11 @@ namespace osu.Game.Screens.Menu
flashLayer.ClearTransforms(); flashLayer.ClearTransforms();
visualizer.ClearTransforms(); visualizer.ClearTransforms();
flashLayer.FadeTo(0.2f * amplitudeAdjust, beat_in_time, EasingTypes.Out); flashLayer.FadeTo(0.2f * amplitudeAdjust, early_activation, EasingTypes.Out);
visualizer.FadeTo(0.9f * amplitudeAdjust, beat_in_time, EasingTypes.Out); visualizer.FadeTo(0.9f * amplitudeAdjust, early_activation, EasingTypes.Out);
using (flashLayer.BeginDelayedSequence(beat_in_time)) using (flashLayer.BeginDelayedSequence(early_activation))
flashLayer.FadeOut(beatLength); flashLayer.FadeOut(beatLength);
using (visualizer.BeginDelayedSequence(beat_in_time)) using (visualizer.BeginDelayedSequence(early_activation))
visualizer.FadeTo(0.5f, beatLength); visualizer.FadeTo(0.5f, beatLength);
} }
} }

View File

@ -8,6 +8,8 @@ using osu.Game.Beatmaps;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using OpenTK; using OpenTK;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio;
namespace osu.Game.Screens namespace osu.Game.Screens
{ {
@ -33,6 +35,8 @@ namespace osu.Game.Screens
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>(); private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private SampleChannel sampleExit;
public WorkingBeatmap Beatmap public WorkingBeatmap Beatmap
{ {
get get
@ -46,7 +50,7 @@ namespace osu.Game.Screens
} }
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuGameBase game, OsuGame osuGame) private void load(OsuGameBase game, OsuGame osuGame, AudioManager audio)
{ {
if (game != null) if (game != null)
{ {
@ -59,6 +63,8 @@ namespace osu.Game.Screens
if (osuGame != null) if (osuGame != null)
ruleset.BindTo(osuGame.Ruleset); ruleset.BindTo(osuGame.Ruleset);
sampleExit = audio.Sample.Get(@"UI/melodic-1");
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -82,6 +88,12 @@ namespace osu.Game.Screens
ruleset.Disabled = !AllowRulesetChange; ruleset.Disabled = !AllowRulesetChange;
} }
protected override void OnResuming(Screen last)
{
base.OnResuming(last);
sampleExit?.Play();
}
protected override void OnEntering(Screen last) protected override void OnEntering(Screen last)
{ {
OsuScreen lastOsu = last as OsuScreen; OsuScreen lastOsu = last as OsuScreen;

View File

@ -18,7 +18,6 @@ namespace osu.Game.Screens.Play
{ {
public Action Action; public Action Action;
private SampleChannel retrySample;
private Box overlay; private Box overlay;
private const int activate_delay = 400; private const int activate_delay = 400;
@ -29,7 +28,6 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
retrySample = audio.Sample.Get(@"Menu/menuback");
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
AlwaysPresent = true; AlwaysPresent = true;
@ -74,7 +72,6 @@ namespace osu.Game.Screens.Play
if (!fired && overlay.Alpha == 1) if (!fired && overlay.Alpha == 1)
{ {
fired = true; fired = true;
retrySample.Play();
Action?.Invoke(); Action?.Invoke();
} }
} }

View File

@ -23,6 +23,7 @@ using osu.Framework.Threading;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Framework.Audio.Sample;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -61,6 +62,8 @@ namespace osu.Game.Screens.Play
private Bindable<bool> mouseWheelDisabled; private Bindable<bool> mouseWheelDisabled;
private Bindable<double> userAudioOffset; private Bindable<double> userAudioOffset;
private SampleChannel sampleRestart;
#endregion #endregion
private HUDOverlay hudOverlay; private HUDOverlay hudOverlay;
@ -72,6 +75,8 @@ namespace osu.Game.Screens.Play
dimLevel = config.GetBindable<double>(OsuSetting.DimLevel); dimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel); mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
sampleRestart = audio.Sample.Get(@"Gameplay/restart");
Ruleset rulesetInstance; Ruleset rulesetInstance;
try try
@ -215,6 +220,7 @@ namespace osu.Game.Screens.Play
public void Restart() public void Restart()
{ {
sampleRestart?.Play();
ValidForResume = false; ValidForResume = false;
RestartRequested?.Invoke(); RestartRequested?.Invoke();
Exit(); Exit();

View File

@ -196,12 +196,6 @@ namespace osu.Game.Screens
Anchor = Anchor.BottomRight; Anchor = Anchor.BottomRight;
Origin = Anchor.BottomRight; Origin = Anchor.BottomRight;
} }
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
ActivationSound = audio.Sample.Get(@"Menu/menuhit");
}
} }
} }
} }