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 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);
}

View File

@ -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");
}
}
}

View File

@ -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");

View File

@ -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;
}

View File

@ -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;

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -30,16 +30,17 @@ public class Button : Container, IStateful<ButtonState>
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();

View File

@ -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<MenuState>
private readonly List<Button> buttonsTopLevel = new List<Button>();
private readonly List<Button> buttonsPlay = new List<Button>();
private SampleChannel sampleBack;
public ButtonSystem()
{
RelativeSizeAxes = Axes.Both;
@ -82,8 +86,8 @@ public ButtonSystem()
AutoSizeAxes = Axes.Both,
Children = new[]
{
settingsButton = new Button(@"settings", @"settings", 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),
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", 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.
{
Size = new Vector2(0, BUTTON_AREA_HEIGHT)
@ -101,23 +105,24 @@ public ButtonSystem()
}
};
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(@"multi", @"multiplayer", 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(@"solo", @"select-6", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
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", @"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(@"osu!editor", @"edit", 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(@"exit", @"exit", FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q));
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", @"select-5", FontAwesome.fa_osu_edit_o, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
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", string.Empty, FontAwesome.fa_osu_cross_o, new Color4(238, 51, 153, 255), onExit, 0, Key.Q));
buttonFlow.Add(buttonsPlay);
buttonFlow.Add(buttonsTopLevel);
}
[BackgroundDependencyLoader(true)]
private void load(OsuGame game = null)
private void load(AudioManager audio, OsuGame game = null)
{
toolbar = game?.Toolbar;
sampleBack = audio.Sample.Get(@"Menu/select-4");
}
protected override void LoadComplete()
@ -167,6 +172,7 @@ private void onExit()
private void onBack()
{
sampleBack?.Play();
State = MenuState.TopLevel;
}
@ -231,6 +237,8 @@ public MenuState State
osuLogo.RotateTo(20, EXIT_DELAY * 1.5f);
osuLogo.FadeOut(EXIT_DELAY);
}
else if (lastState == MenuState.TopLevel)
sampleBack?.Play();
break;
case MenuState.TopLevel:
buttonArea.Flush(true);

View File

@ -72,11 +72,11 @@ public bool Ripple
private const float default_size = 480;
private const double beat_in_time = 60;
private const double early_activation = 60;
public OsuLogo()
{
EarlyActivationMilliseconds = beat_in_time;
EarlyActivationMilliseconds = early_activation;
Size = new Vector2(default_size);
@ -215,8 +215,9 @@ public OsuLogo()
[BackgroundDependencyLoader]
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");
logo.Texture = textures.Get(@"Menu/logo");
ripple.Texture = textures.Get(@"Menu/logo");
}
@ -236,10 +237,13 @@ protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint,
if (beatIndex < 0) return;
if (Hovering)
sampleBeat.Play();
{
using (BeginDelayedSequence(early_activation))
Schedule(() => sampleBeat.Play());
}
logoBeatContainer.ScaleTo(1 - 0.02f * amplitudeAdjust, beat_in_time, EasingTypes.Out);
using (logoBeatContainer.BeginDelayedSequence(beat_in_time))
logoBeatContainer.ScaleTo(1 - 0.02f * amplitudeAdjust, early_activation, EasingTypes.Out);
using (logoBeatContainer.BeginDelayedSequence(early_activation))
logoBeatContainer.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint);
ripple.ClearTransforms();
@ -255,11 +259,11 @@ protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint,
flashLayer.ClearTransforms();
visualizer.ClearTransforms();
flashLayer.FadeTo(0.2f * amplitudeAdjust, beat_in_time, EasingTypes.Out);
visualizer.FadeTo(0.9f * amplitudeAdjust, beat_in_time, EasingTypes.Out);
using (flashLayer.BeginDelayedSequence(beat_in_time))
flashLayer.FadeTo(0.2f * amplitudeAdjust, early_activation, EasingTypes.Out);
visualizer.FadeTo(0.9f * amplitudeAdjust, early_activation, EasingTypes.Out);
using (flashLayer.BeginDelayedSequence(early_activation))
flashLayer.FadeOut(beatLength);
using (visualizer.BeginDelayedSequence(beat_in_time))
using (visualizer.BeginDelayedSequence(early_activation))
visualizer.FadeTo(0.5f, beatLength);
}
}

View File

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

View File

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

View File

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

View File

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