diff --git a/osu-framework b/osu-framework index 2f7ebfcf63..cd2b351de3 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 2f7ebfcf637cc1928d8d37f6336e5da77f4926a0 +Subproject commit cd2b351de37f17b6d91d1fc062627208a09c3834 diff --git a/osu-resources b/osu-resources index 10fda22522..76656c51f2 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 10fda22522ffadbdbc43fa0f3683a065e536f7d1 +Subproject commit 76656c51f281e7934159e9ed4414378fef24d130 diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 299f64d998..51145b42c8 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -11,6 +11,7 @@ using System.Reflection; using System.Drawing; using System.IO; using System.Threading.Tasks; +using osu.Framework.Graphics.Containers; using osu.Game.Screens.Menu; namespace osu.Desktop @@ -22,18 +23,22 @@ namespace osu.Desktop public OsuGameDesktop(string[] args = null) : base(args) { - versionManager = new VersionManager { Depth = int.MinValue }; + versionManager = new VersionManager + { + Depth = int.MinValue, + State = Visibility.Hidden + }; } protected override void LoadComplete() { base.LoadComplete(); - LoadComponentAsync(versionManager); + LoadComponentAsync(versionManager, Add); ScreenChanged += s => { - if (!versionManager.IsAlive && s is Intro) - Add(versionManager); + if (!versionManager.IsPresent && s is Intro) + versionManager.State = Visibility.Visible; }; } diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index b53c4ab3d4..9182f925e1 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -93,12 +93,6 @@ namespace osu.Desktop.Overlays checkForUpdateAsync(); } - protected override void LoadComplete() - { - base.LoadComplete(); - State = Visibility.Visible; - } - protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index 395e496b61..c6c009e8f2 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { if (!userTriggered && Time.Current >= slider.EndTime) { - var ticksCount = ticks.Children.Count() + 1; + var ticksCount = ticks.Children.Count + 1; var ticksHit = ticks.Children.Count(t => t.Judgement.Result == HitResult.Hit); if (initialCircle.Judgement.Result == HitResult.Hit) ticksHit++; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs index 4857f5c0d2..9a114aa72c 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBall.cs @@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces base.Update(); if (Time.Current < slider.EndTime) - Tracking = canCurrentlyTrack && lastState != null && Contains(lastState.Mouse.NativeState.Position) && lastState.Mouse.HasMainButtonPressed; + Tracking = canCurrentlyTrack && lastState != null && ReceiveMouseInputAt(lastState.Mouse.NativeState.Position) && lastState.Mouse.HasMainButtonPressed; } public void UpdateProgress(double progress, int repeat) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs index 234aa8d055..f3ddf683d2 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs @@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces }; } - public override bool Contains(Vector2 screenSpacePos) => true; + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; private bool tracking; public bool Tracking diff --git a/osu.Game/Graphics/Containers/OsuClickableContainer.cs b/osu.Game/Graphics/Containers/OsuClickableContainer.cs new file mode 100644 index 0000000000..11c049ed3e --- /dev/null +++ b/osu.Game/Graphics/Containers/OsuClickableContainer.cs @@ -0,0 +1,35 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Graphics.Containers; +using osu.Framework.Input; + +namespace osu.Game.Graphics.Containers +{ + public class OsuClickableContainer : ClickableContainer + { + protected SampleChannel SampleClick, SampleHover; + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + SampleHover = audio.Sample.Get(@"UI/generic-hover"); + SampleClick = audio.Sample.Get(@"UI/generic-click"); + } + + protected override bool OnHover(InputState state) + { + SampleHover?.Play(); + return base.OnHover(state); + } + + protected override bool OnClick(InputState state) + { + SampleClick?.Play(); + return base.OnClick(state); + } + } +} diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs new file mode 100644 index 0000000000..0713fa1a52 --- /dev/null +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -0,0 +1,38 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Graphics.Containers +{ + public class OsuFocusedOverlayContainer : FocusedOverlayContainer + { + private SampleChannel samplePopIn; + private SampleChannel samplePopOut; + + [BackgroundDependencyLoader] + private void load(AudioManager audio) + { + samplePopIn = audio.Sample.Get(@"UI/melodic-5"); + samplePopOut = audio.Sample.Get(@"UI/melodic-4"); + + StateChanged += OsuFocusedOverlayContainer_StateChanged; + } + + private void OsuFocusedOverlayContainer_StateChanged(VisibilityContainer arg1, Visibility arg2) + { + switch (arg2) + { + case Visibility.Visible: + samplePopIn?.Play(); + break; + case Visibility.Hidden: + samplePopOut?.Play(); + break; + } + } + } +} diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index bbebc7e1b1..035f6f98b0 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -74,7 +74,7 @@ namespace osu.Game.Graphics.Cursor } } - public override bool Contains(Vector2 screenSpacePos) => true; + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; [BackgroundDependencyLoader] private void load(ShaderManager shaders, TextureStore textures) diff --git a/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs b/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs index 2cc6c3a46a..9162fd6893 100644 --- a/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs @@ -10,9 +10,5 @@ namespace osu.Game.Graphics.Cursor public class OsuContextMenuContainer : ContextMenuContainer { protected override ContextMenu CreateContextMenu() => new OsuContextMenu(); - - public OsuContextMenuContainer(CursorContainer cursor) : base(cursor) - { - } } } \ No newline at end of file diff --git a/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs b/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs index 133caf8040..7608a366dc 100644 --- a/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuTooltipContainer.cs @@ -15,7 +15,7 @@ namespace osu.Game.Graphics.Cursor { public class OsuTooltipContainer : TooltipContainer { - protected override Tooltip CreateTooltip() => new OsuTooltip(); + protected override ITooltip CreateTooltip() => new OsuTooltip(); public OsuTooltipContainer(CursorContainer cursor) : base(cursor) { diff --git a/osu.Game/Graphics/UserInterface/BackButton.cs b/osu.Game/Graphics/UserInterface/BackButton.cs index 2b4b9cdb04..6a3757ec0e 100644 --- a/osu.Game/Graphics/UserInterface/BackButton.cs +++ b/osu.Game/Graphics/UserInterface/BackButton.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Framework.Graphics; namespace osu.Game.Graphics.UserInterface @@ -18,9 +17,8 @@ namespace osu.Game.Graphics.UserInterface } [BackgroundDependencyLoader] - private void load(AudioManager audio, OsuColour colours) + private void load(OsuColour colours) { - ActivationSound = audio.Sample.Get(@"Menu/menuback"); BackgroundColour = colours.Pink; HoverColour = colours.PinkDark; } diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index d0965a1861..e4a471bbba 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -29,7 +29,7 @@ namespace osu.Game.Graphics.UserInterface base.Direction = (direction & BarDirection.Horizontal) > 0 ? FillDirection.Vertical : FillDirection.Horizontal; foreach (var bar in Children) { - bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / Children.Count()) : new Vector2(1.0f / Children.Count(), 1); + bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / Children.Count) : new Vector2(1.0f / Children.Count, 1); bar.Direction = direction; } } diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index c284398240..155b08fde8 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -38,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface public readonly TextAwesome Chevron; //don't allow clicking between transitions and don't make the chevron clickable - public override bool Contains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos); + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceiveMouseInputAt(screenSpacePos); public override bool HandleInput => State == Visibility.Visible; private Visibility state; diff --git a/osu.Game/Graphics/UserInterface/DialogButton.cs b/osu.Game/Graphics/UserInterface/DialogButton.cs index 47f628f96c..3f1b81893d 100644 --- a/osu.Game/Graphics/UserInterface/DialogButton.cs +++ b/osu.Game/Graphics/UserInterface/DialogButton.cs @@ -8,14 +8,14 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Containers; -using osu.Framework.Audio.Sample; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Graphics.Containers; namespace osu.Game.Graphics.UserInterface { - public class DialogButton : ClickableContainer + public class DialogButton : OsuClickableContainer { private const float hover_width = 0.9f; private const float hover_duration = 500; @@ -79,8 +79,6 @@ namespace osu.Game.Graphics.UserInterface } } - public SampleChannel SampleClick, SampleHover; - private readonly Container backgroundContainer; private readonly Container colourContainer; private readonly Container glowContainer; @@ -93,15 +91,13 @@ namespace osu.Game.Graphics.UserInterface private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking - public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceiveMouseInputAt(screenSpacePos); protected override bool OnClick(Framework.Input.InputState state) { didClick = true; colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, EasingTypes.In); flash(); - SampleClick?.Play(); - Action?.Invoke(); Delay(click_duration); Schedule(delegate { @@ -110,7 +106,7 @@ namespace osu.Game.Graphics.UserInterface glowContainer.FadeOut(); }); - return true; + return base.OnClick(state); } protected override bool OnHover(Framework.Input.InputState state) @@ -119,7 +115,7 @@ namespace osu.Game.Graphics.UserInterface colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, EasingTypes.OutElastic); glowContainer.FadeIn(glow_fade_duration, EasingTypes.Out); - SampleHover?.Play(); + base.OnHover(state); return true; } diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 8540b35702..84904c10db 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -9,10 +9,11 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; +using osu.Game.Graphics.Containers; namespace osu.Game.Graphics.UserInterface { - public class IconButton : ClickableContainer + public class IconButton : OsuClickableContainer { private readonly TextAwesome icon; private readonly Box hover; 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 @@ namespace osu.Game.Graphics.UserInterface { private Box hover; + private SampleChannel sampleClick; + private SampleChannel sampleHover; + public OsuButton() { Height = 40; @@ -34,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface 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 @@ namespace osu.Game.Graphics.UserInterface 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 @@ namespace osu.Game.Graphics.UserInterface [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 @@ namespace osu.Game.Graphics.UserInterface [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 @@ namespace osu.Game.Graphics.UserInterface [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/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index c60a937440..df7238a6c6 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -23,8 +23,6 @@ namespace osu.Game.Graphics.UserInterface protected override TabItem CreateTabItem(T value) => new OsuTabItem(value); - public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || Dropdown.Contains(screenSpacePos); - private bool isEnumType => typeof(T).IsEnum; public OsuTabControl() diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index b188e782e2..7f2bbb8f9f 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -18,7 +17,7 @@ using osu.Framework.Graphics.Shapes; namespace osu.Game.Graphics.UserInterface { - public class TwoLayerButton : ClickableContainer + public class TwoLayerButton : OsuClickableContainer { private readonly BouncingIcon bouncingIcon; @@ -32,7 +31,6 @@ namespace osu.Game.Graphics.UserInterface public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50); public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50); - public SampleChannel ActivationSound; private readonly SpriteText text; public Color4 HoverColour; @@ -171,7 +169,7 @@ namespace osu.Game.Graphics.UserInterface } } - public override bool Contains(Vector2 screenSpacePos) => IconLayer.Contains(screenSpacePos) || TextLayer.Contains(screenSpacePos); + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => IconLayer.ReceiveMouseInputAt(screenSpacePos) || TextLayer.ReceiveMouseInputAt(screenSpacePos); protected override bool OnHover(InputState state) { @@ -210,8 +208,6 @@ namespace osu.Game.Graphics.UserInterface flash.FadeOut(500, EasingTypes.OutQuint); flash.Expire(); - ActivationSound.Play(); - return base.OnClick(state); } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 5e73ea55e6..71ac8af08d 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -37,9 +37,9 @@ namespace osu.Game public APIAccess API; - protected override Container Content => ratioContainer; + private Container content; - private RatioAdjust ratioContainer; + protected override Container Content => content; protected MenuCursor Cursor; @@ -146,21 +146,19 @@ namespace osu.Game { base.LoadComplete(); - base.Content.Add(ratioContainer = new RatioAdjust + base.Content.Add(new RatioAdjust { Children = new Drawable[] { - new Container + Cursor = new MenuCursor(), + new OsuTooltipContainer(Cursor) { RelativeSizeAxes = Axes.Both, - Depth = float.MinValue, - Children = new Drawable[] + Child = content = new OsuContextMenuContainer { - Cursor = new MenuCursor(), - new OsuContextMenuContainer(Cursor) { Depth = -2 }, - new OsuTooltipContainer(Cursor) { Depth = -1 }, - } - }, + RelativeSizeAxes = Axes.Both, + }, + } } }); 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.Framework.Input; 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/Chat/ChannelSection.cs b/osu.Game/Overlays/Chat/ChannelSection.cs index f12ec53605..cafb88b6ac 100644 --- a/osu.Game/Overlays/Chat/ChannelSection.cs +++ b/osu.Game/Overlays/Chat/ChannelSection.cs @@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Chat public IEnumerable Channels { - set { ChannelFlow.Children = value.Select(c => new ChannelListItem(c)); } + set { ChannelFlow.ChildrenEnumerable = value.Select(c => new ChannelListItem(c)); } } public ChannelSection() diff --git a/osu.Game/Overlays/Chat/ChannelSelectionOverlay.cs b/osu.Game/Overlays/Chat/ChannelSelectionOverlay.cs index 6ff3cc7be5..9f61d13813 100644 --- a/osu.Game/Overlays/Chat/ChannelSelectionOverlay.cs +++ b/osu.Game/Overlays/Chat/ChannelSelectionOverlay.cs @@ -16,10 +16,11 @@ using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Chat; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Chat { - public class ChannelSelectionOverlay : FocusedOverlayContainer + public class ChannelSelectionOverlay : OsuFocusedOverlayContainer { public static readonly float WIDTH_PADDING = 170; @@ -38,7 +39,7 @@ namespace osu.Game.Overlays.Chat { set { - sectionsFlow.Children = value; + sectionsFlow.ChildrenEnumerable = value; foreach (ChannelSection s in sectionsFlow.Children) { diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 97c7907874..700889ed26 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -22,10 +22,11 @@ using osu.Framework.Input; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Overlays.Chat; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { - public class ChatOverlay : FocusedOverlayContainer, IOnlineComponent + public class ChatOverlay : OsuFocusedOverlayContainer, IOnlineComponent { private const float textbox_height = 60; private const float channel_selection_min_height = 0.3f; @@ -59,7 +60,7 @@ namespace osu.Game.Overlays private readonly Container channelSelectionContainer; private readonly ChannelSelectionOverlay channelSelection; - public override bool Contains(Vector2 screenSpacePos) => chatContainer.Contains(screenSpacePos) || channelSelection.State == Visibility.Visible && channelSelection.Contains(screenSpacePos); + public override bool Contains(Vector2 screenSpacePos) => chatContainer.ReceiveMouseInputAt(screenSpacePos) || channelSelection.State == Visibility.Visible && channelSelection.ReceiveMouseInputAt(screenSpacePos); public ChatOverlay() { @@ -193,7 +194,7 @@ namespace osu.Game.Overlays protected override bool OnDragStart(InputState state) { - if (!channelTabs.Hovering) + if (!channelTabs.IsHovered) return base.OnDragStart(state); startDragChatHeight = chatHeight.Value; diff --git a/osu.Game/Overlays/Dialog/PopupDialog.cs b/osu.Game/Overlays/Dialog/PopupDialog.cs index c8ca50823f..39338ba3e1 100644 --- a/osu.Game/Overlays/Dialog/PopupDialog.cs +++ b/osu.Game/Overlays/Dialog/PopupDialog.cs @@ -15,10 +15,11 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Input; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Dialog { - public class PopupDialog : FocusedOverlayContainer + public class PopupDialog : OsuFocusedOverlayContainer { public static readonly float ENTER_DURATION = 500; public static readonly float EXIT_DURATION = 200; @@ -56,7 +57,7 @@ namespace osu.Game.Overlays.Dialog get { return buttonsContainer.Children; } set { - buttonsContainer.Children = value; + buttonsContainer.ChildrenEnumerable = value; foreach (PopupDialogButton b in value) { var action = b.Action; diff --git a/osu.Game/Overlays/Dialog/PopupDialogCancelButton.cs b/osu.Game/Overlays/Dialog/PopupDialogCancelButton.cs index 1449577b21..a17c4a7bf2 100644 --- a/osu.Game/Overlays/Dialog/PopupDialogCancelButton.cs +++ b/osu.Game/Overlays/Dialog/PopupDialogCancelButton.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Game.Graphics; namespace osu.Game.Overlays.Dialog @@ -10,11 +9,9 @@ namespace osu.Game.Overlays.Dialog public class PopupDialogCancelButton : PopupDialogButton { [BackgroundDependencyLoader] - private void load(OsuColour colours, AudioManager audio) + private void load(OsuColour colours) { 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..3d99987080 100644 --- a/osu.Game/Overlays/Dialog/PopupDialogOkButton.cs +++ b/osu.Game/Overlays/Dialog/PopupDialogOkButton.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Audio; using osu.Game.Graphics; namespace osu.Game.Overlays.Dialog @@ -10,11 +9,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/Overlays/DialogOverlay.cs b/osu.Game/Overlays/DialogOverlay.cs index 757781a4ab..f1a6bc1681 100644 --- a/osu.Game/Overlays/DialogOverlay.cs +++ b/osu.Game/Overlays/DialogOverlay.cs @@ -7,10 +7,11 @@ using osu.Framework.Graphics.Containers; using osu.Game.Overlays.Dialog; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { - public class DialogOverlay : FocusedOverlayContainer + public class DialogOverlay : OsuFocusedOverlayContainer { private readonly Container dialogContainer; private PopupDialog currentDialog; diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 2cede1e574..1e923d79fa 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -16,6 +16,7 @@ using osu.Framework.Graphics.Textures; using System.Linq; using osu.Framework.Input; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Direct { @@ -151,7 +152,7 @@ namespace osu.Game.Overlays.Direct }; } - private class DownloadButton : ClickableContainer + private class DownloadButton : OsuClickableContainer { private readonly TextAwesome icon; diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 8a56cf392e..f8acad1f59 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Direct SetInfo = setInfo; } - protected IEnumerable GetDifficultyIcons() + protected List GetDifficultyIcons() { var icons = new List(); diff --git a/osu.Game/Overlays/Direct/FilterControl.cs b/osu.Game/Overlays/Direct/FilterControl.cs index 455d0ab77b..b898d24c31 100644 --- a/osu.Game/Overlays/Direct/FilterControl.cs +++ b/osu.Game/Overlays/Direct/FilterControl.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Overlays.SearchableList; namespace osu.Game.Overlays.Direct @@ -42,7 +43,7 @@ namespace osu.Game.Overlays.Direct } } - private class RulesetToggleButton : ClickableContainer + private class RulesetToggleButton : OsuClickableContainer { private readonly TextAwesome icon; diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 93c440384b..beb1355f36 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -129,7 +129,7 @@ namespace osu.Game.Overlays private void recreatePanels(PanelDisplayStyle displayStyle) { if (BeatmapSets == null) return; - panels.Children = BeatmapSets.Select(b => displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)new DirectGridPanel(b) { Width = 400 } : new DirectListPanel(b)); + panels.ChildrenEnumerable = BeatmapSets.Select(b => displayStyle == PanelDisplayStyle.Grid ? (DirectPanel)new DirectGridPanel(b) { Width = 400 } : new DirectListPanel(b)); } public class ResultCounts diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index b688bafd4d..790530342f 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -8,10 +8,11 @@ using osu.Game.Graphics; using osu.Game.Overlays.Settings.Sections.General; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { - internal class LoginOverlay : FocusedOverlayContainer + internal class LoginOverlay : OsuFocusedOverlayContainer { private LoginSettings settingsSection; diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 8a04d91cfb..a7e7bb53b5 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -151,8 +151,8 @@ namespace osu.Game.Overlays.Mods [BackgroundDependencyLoader] private void load(AudioManager audio) { - sampleOn = audio.Sample.Get(@"Checkbox/check-on"); - sampleOff = audio.Sample.Get(@"Checkbox/check-off"); + sampleOn = audio.Sample.Get(@"UI/check-on"); + sampleOff = audio.Sample.Get(@"UI/check-off"); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -171,7 +171,7 @@ namespace osu.Game.Overlays.Mods public void SelectNext() { - (++SelectedIndex == -1 ? sampleOff : sampleOn).Play(); + (++SelectedIndex == Mods.Length ? sampleOff : sampleOn).Play(); Action?.Invoke(SelectedMod); } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index e1e920ec0f..61439a26e0 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -24,10 +24,11 @@ using osu.Framework.Threading; using osu.Game.Overlays.Music; using osu.Game.Graphics.UserInterface; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { - public class MusicController : FocusedOverlayContainer + public class MusicController : OsuFocusedOverlayContainer { private const float player_height = 130; diff --git a/osu.Game/Overlays/NotificationManager.cs b/osu.Game/Overlays/NotificationManager.cs index 34690013df..382683cbcc 100644 --- a/osu.Game/Overlays/NotificationManager.cs +++ b/osu.Game/Overlays/NotificationManager.cs @@ -9,10 +9,11 @@ using osu.Framework.Graphics.Containers; using osu.Game.Overlays.Notifications; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { - public class NotificationManager : FocusedOverlayContainer + public class NotificationManager : OsuFocusedOverlayContainer { private const float width = 320; diff --git a/osu.Game/Overlays/Notifications/Notification.cs b/osu.Game/Overlays/Notifications/Notification.cs index 2833ef9f3a..3380c61385 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -13,6 +13,7 @@ using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Notifications { @@ -152,7 +153,7 @@ namespace osu.Game.Overlays.Notifications Expire(); } - private class CloseButton : ClickableContainer + private class CloseButton : OsuClickableContainer { private Color4 hoverColour; diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index b53f8e6b14..b4f35be733 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Notifications { @@ -131,7 +132,7 @@ namespace osu.Game.Overlays.Notifications countText.Text = notifications.Children.Count(c => c.Alpha > 0.99f).ToString(); } - private class ClearAllButton : ClickableContainer + private class ClearAllButton : OsuClickableContainer { private readonly OsuSpriteText text; diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 2887d4355b..4a616a8685 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions; @@ -182,7 +181,7 @@ namespace osu.Game.Overlays textLine2.Origin = optionCount > 0 ? Anchor.BottomCentre : Anchor.Centre; textLine2.Y = optionCount > 0 ? 0 : 5; - if (optionLights.Children.Count() != optionCount) + if (optionLights.Children.Count != optionCount) { optionLights.Clear(); for (int i = 0; i < optionCount; i++) @@ -190,7 +189,7 @@ namespace osu.Game.Overlays } for (int i = 0; i < optionCount; i++) - optionLights.Children.Skip(i).First().Glowing = i == selectedOption; + optionLights.Children[i].Glowing = i == selectedOption; }); } diff --git a/osu.Game/Overlays/SearchableList/DisplayStyleControl.cs b/osu.Game/Overlays/SearchableList/DisplayStyleControl.cs index b37b0db139..7157861632 100644 --- a/osu.Game/Overlays/SearchableList/DisplayStyleControl.cs +++ b/osu.Game/Overlays/SearchableList/DisplayStyleControl.cs @@ -6,6 +6,7 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.SearchableList { @@ -52,7 +53,7 @@ namespace osu.Game.Overlays.SearchableList DisplayStyle.Value = PanelDisplayStyle.Grid; } - private class DisplayStyleToggleButton : ClickableContainer + private class DisplayStyleToggleButton : OsuClickableContainer { private readonly TextAwesome icon; private readonly PanelDisplayStyle style; diff --git a/osu.Game/Overlays/SearchableList/SearchableListFilterControl.cs b/osu.Game/Overlays/SearchableList/SearchableListFilterControl.cs index b5ec70b9e2..8db802ad3d 100644 --- a/osu.Game/Overlays/SearchableList/SearchableListFilterControl.cs +++ b/osu.Game/Overlays/SearchableList/SearchableListFilterControl.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; @@ -29,8 +28,6 @@ namespace osu.Game.Overlays.SearchableList protected abstract T DefaultTab { get; } protected virtual Drawable CreateSupplementaryControls() => null; - public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || DisplayStyleControl.Dropdown.Contains(screenSpacePos); - protected SearchableListFilterControl() { if (!typeof(T).IsEnum) diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 5677bbcad9..fc9dddf121 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -15,7 +15,7 @@ using osu.Game.Overlays.Settings.Sections; namespace osu.Game.Overlays { - public class SettingsOverlay : FocusedOverlayContainer + public class SettingsOverlay : OsuFocusedOverlayContainer { internal const float CONTENT_MARGINS = 10; diff --git a/osu.Game/Overlays/SocialOverlay.cs b/osu.Game/Overlays/SocialOverlay.cs index c6ce20f5cf..1cd2343848 100644 --- a/osu.Game/Overlays/SocialOverlay.cs +++ b/osu.Game/Overlays/SocialOverlay.cs @@ -44,7 +44,7 @@ namespace osu.Game.Overlays panelFlow.Clear(); else { - panelFlow.Children = users.Select(u => + panelFlow.ChildrenEnumerable = users.Select(u => { var p = new UserPanel(u) { Width = 300 }; p.Status.BindTo(u.Status); diff --git a/osu.Game/Overlays/Toolbar/ToolbarButton.cs b/osu.Game/Overlays/Toolbar/ToolbarButton.cs index bb3fc0783f..38fd954fe3 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarButton.cs @@ -1,10 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -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.Containers; @@ -16,10 +12,11 @@ using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.Toolbar { - public class ToolbarButton : Container + public class ToolbarButton : OsuClickableContainer { public const float WIDTH = Toolbar.HEIGHT * 1.4f; @@ -58,7 +55,6 @@ namespace osu.Game.Overlays.Toolbar protected virtual Anchor TooltipAnchor => Anchor.TopLeft; - public Action Action; protected TextAwesome DrawableIcon; protected SpriteText DrawableText; protected Box HoverBackground; @@ -66,7 +62,6 @@ namespace osu.Game.Overlays.Toolbar private readonly SpriteText tooltip1; private readonly SpriteText tooltip2; protected FillFlowContainer Flow; - private SampleChannel sampleClick; public ToolbarButton() { @@ -136,27 +131,19 @@ namespace osu.Game.Overlays.Toolbar }; } - [BackgroundDependencyLoader] - private void load(AudioManager audio) - { - sampleClick = audio.Sample.Get(@"Menu/menuclick"); - } - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; protected override bool OnClick(InputState state) { - Action?.Invoke(); - sampleClick.Play(); HoverBackground.FlashColour(Color4.White.Opacity(100), 500, EasingTypes.OutQuint); - return true; + return base.OnClick(state); } protected override bool OnHover(InputState state) { HoverBackground.FadeIn(200); tooltipContainer.FadeIn(100); - return false; + return base.OnHover(state); } protected override void OnHoverLost(InputState state) diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 59c4ac4a61..95906464ec 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -113,8 +113,11 @@ namespace osu.Game.Overlays.Toolbar { base.UpdateAfterChildren(); - if (!activeMode.EnsureValid()) - activeMode.Refresh(() => modeButtonLine.MoveToX(activeButton.DrawPosition.X, 200, EasingTypes.OutQuint)); + if (!activeMode.IsValid) + { + modeButtonLine.MoveToX(activeButton.DrawPosition.X, 200, EasingTypes.OutQuint); + activeMode.Validate(); + } } } } diff --git a/osu.Game/Overlays/WaveOverlayContainer.cs b/osu.Game/Overlays/WaveOverlayContainer.cs index e744f23a3a..1bb7813d90 100644 --- a/osu.Game/Overlays/WaveOverlayContainer.cs +++ b/osu.Game/Overlays/WaveOverlayContainer.cs @@ -8,10 +8,11 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using System; using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { - public abstract class WaveOverlayContainer : FocusedOverlayContainer + public abstract class WaveOverlayContainer : OsuFocusedOverlayContainer { protected const float APPEAR_DURATION = 800; protected const float DISAPPEAR_DURATION = 500; diff --git a/osu.Game/Rulesets/Timing/DrawableTimingSection.cs b/osu.Game/Rulesets/Timing/DrawableTimingSection.cs index 3ad9f23605..589ee9991d 100644 --- a/osu.Game/Rulesets/Timing/DrawableTimingSection.cs +++ b/osu.Game/Rulesets/Timing/DrawableTimingSection.cs @@ -80,14 +80,9 @@ namespace osu.Game.Rulesets.Timing base.InvalidateFromChild(invalidation); } - private Cached durationBacking = new Cached(); - /// - /// The maximum duration of any one hit object inside this . This is calculated as the maximum - /// end time between all hit objects relative to this 's . - /// - public double Duration => durationBacking.EnsureValid() - ? durationBacking.Value - : durationBacking.Refresh(() => + private Cached durationBacking; + + private double computeDuration() { if (!Children.Any()) return 0; @@ -117,7 +112,13 @@ namespace osu.Game.Rulesets.Timing baseDuration *= 1 + maxAbsoluteSize / ourAbsoluteSize; return baseDuration; - }); + } + + /// + /// The maximum duration of any one hit object inside this . This is calculated as the maximum + /// end time between all hit objects relative to this 's . + /// + public double Duration => durationBacking.IsValid ? durationBacking : (durationBacking.Value = computeDuration()); protected override void Update() { diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index f411f74361..bab267a24a 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -2,16 +2,38 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; +using osu.Framework.Graphics; using osu.Game.Graphics.Backgrounds; namespace osu.Game.Screens.Backgrounds { public class BackgroundScreenDefault : BackgroundScreen { + private int currentDisplay; + private const int background_count = 5; + + private string backgroundName => $@"Menu/menu-background-{currentDisplay % background_count + 1}"; + + private Background current; + [BackgroundDependencyLoader] private void load() { - Add(new Background(@"Backgrounds/bg1")); + display(new Background(backgroundName)); + } + + private void display(Background newBackground) + { + current?.FadeOut(800, EasingTypes.OutQuint); + current?.Expire(); + + Add(current = newBackground); + } + + public void Next() + { + currentDisplay++; + LoadComponentAsync(new Background(backgroundName) { Depth = currentDisplay }, display); } } -} \ No newline at end of file +} diff --git a/osu.Game/Screens/Loader.cs b/osu.Game/Screens/Loader.cs index 30e1538b47..af084e740b 100644 --- a/osu.Game/Screens/Loader.cs +++ b/osu.Game/Screens/Loader.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; -using osu.Framework.Screens; using osu.Game.Screens.Menu; namespace osu.Game.Screens @@ -20,9 +19,9 @@ namespace osu.Game.Screens private void load(OsuGame game) { if (game.IsDeployedBuild) - LoadComponentAsync(new Disclaimer(), d => Push((Screen)d)); + LoadComponentAsync(new Disclaimer(), d => Push(d)); else - LoadComponentAsync(new Intro(), d => Push((Screen)d)); + LoadComponentAsync(new Intro(), d => Push(d)); } } } diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index cdff79c94f..c8739f8894 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -30,16 +30,17 @@ namespace osu.Game.Screens.Menu 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 override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => box.ReceiveMouseInputAt(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 @@ namespace osu.Game.Screens.Menu { 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 @@ namespace osu.Game.Screens.Menu [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 @@ namespace osu.Game.Screens.Menu 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 osu.Game.Overlays.Toolbar; 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 @@ namespace osu.Game.Screens.Menu private readonly List