diff --git a/osu-framework b/osu-framework index 97ff3376d1..768a775b68 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 97ff3376d1bdac3703d442e62f5ee6a36eb3b73f +Subproject commit 768a775b688d7a008d8933275b48ed0d2d491f12 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.VisualTests/Tests/TestCaseBeatSyncedContainer.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatSyncedContainer.cs new file mode 100644 index 0000000000..01d7d4ff01 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatSyncedContainer.cs @@ -0,0 +1,206 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Framework.Graphics; +using osu.Framework.Timing; +using osu.Game.Overlays; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Containers; +using osu.Framework.Audio.Track; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.Graphics.Shapes; +using OpenTK.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Framework.Lists; +using System; +using osu.Framework.Extensions.Color4Extensions; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseBeatSyncedContainer : TestCase + { + public override string Description => @"Tests beat synced containers."; + + private readonly MusicController mc; + + public TestCaseBeatSyncedContainer() + { + Clock = new FramedClock(); + Clock.ProcessFrame(); + + Add(new BeatContainer + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + }); + + Add(mc = new MusicController + { + Origin = Anchor.TopRight, + Anchor = Anchor.TopRight, + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + mc.ToggleVisibility(); + } + + private class BeatContainer : BeatSyncedContainer + { + private const int flash_layer_heigth = 150; + + private readonly InfoString timingPointCount; + private readonly InfoString currentTimingPoint; + private readonly InfoString beatCount; + private readonly InfoString currentBeat; + private readonly InfoString beatsPerMinute; + private readonly InfoString adjustedBeatLength; + private readonly InfoString timeUntilNextBeat; + private readonly InfoString timeSinceLastBeat; + + private readonly Box flashLayer; + + public BeatContainer() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + new Container + { + Name = @"Info Layer", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Bottom = flash_layer_heigth }, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(150), + }, + new FillFlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + timingPointCount = new InfoString(@"Timing points amount"), + currentTimingPoint = new InfoString(@"Current timing point"), + beatCount = new InfoString(@"Beats amount (in the current timing point)"), + currentBeat = new InfoString(@"Current beat"), + beatsPerMinute = new InfoString(@"BPM"), + adjustedBeatLength = new InfoString(@"Adjusted beat length"), + timeUntilNextBeat = new InfoString(@"Time until next beat"), + timeSinceLastBeat = new InfoString(@"Time since last beat"), + } + } + } + }, + new Container + { + Name = @"Color indicator", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = flash_layer_heigth, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + flashLayer = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + Alpha = 0, + } + } + } + }; + + Beatmap.ValueChanged += delegate + { + timingPointCount.Value = 0; + currentTimingPoint.Value = 0; + beatCount.Value = 0; + currentBeat.Value = 0; + beatsPerMinute.Value = 0; + adjustedBeatLength.Value = 0; + timeUntilNextBeat.Value = 0; + timeSinceLastBeat.Value = 0; + }; + } + + private SortedList timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints; + private TimingControlPoint getNextTimingPoint(TimingControlPoint current) + { + if (timingPoints[timingPoints.Count - 1] == current) + return current; + + return timingPoints[timingPoints.IndexOf(current) + 1]; + } + + private int calculateBeatCount(TimingControlPoint current) + { + if (timingPoints[timingPoints.Count - 1] == current) + return (int)Math.Ceiling((Beatmap.Value.Track.Length - current.Time) / current.BeatLength); + + return (int)Math.Ceiling((getNextTimingPoint(current).Time - current.Time) / current.BeatLength); + } + + protected override void Update() + { + base.Update(); + timeUntilNextBeat.Value = TimeUntilNextBeat; + timeSinceLastBeat.Value = TimeSinceLastBeat; + } + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + + timingPointCount.Value = timingPoints.Count; + currentTimingPoint.Value = timingPoints.IndexOf(timingPoint); + beatCount.Value = calculateBeatCount(timingPoint); + currentBeat.Value = beatIndex; + beatsPerMinute.Value = 60000 / timingPoint.BeatLength; + adjustedBeatLength.Value = timingPoint.BeatLength; + + flashLayer.ClearTransforms(); + flashLayer.FadeTo(1); + flashLayer.FadeTo(0, timingPoint.BeatLength); + } + } + + private class InfoString : FillFlowContainer + { + private const int text_size = 20; + private const int margin = 7; + + private readonly OsuSpriteText valueText; + + public double Value + { + set { valueText.Text = $"{value:G}"; } + } + + public InfoString(string header) + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + Add(new OsuSpriteText { Text = header + @": ", TextSize = text_size }); + Add(valueText = new OsuSpriteText() { TextSize = text_size }); + Margin = new MarginPadding(margin); + } + } + } +} diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs index e755924a15..e0a503bc76 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs @@ -12,10 +12,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Beatmap details in song select"; - public override void Reset() + public TestCaseBeatmapDetailArea() { - base.Reset(); - Add(new BeatmapDetailArea { Anchor = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index df80ffdf53..9335938265 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -13,12 +13,10 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "BeatmapDetails tab of BeatmapDetailArea"; - private BeatmapDetails details; + private readonly BeatmapDetails details; - public override void Reset() + public TestCaseBeatmapDetails() { - base.Reset(); - Add(details = new BeatmapDetails { RelativeSizeAxes = Axes.Both, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapOptionsOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapOptionsOverlay.cs index 7c211227c6..c9c1740856 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapOptionsOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapOptionsOverlay.cs @@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Beatmap options in song select"; - public override void Reset() + public TestCaseBeatmapOptionsOverlay() { - base.Reset(); - var overlay = new BeatmapOptionsOverlay(); overlay.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, Color4.Purple, null, Key.Number1); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs index 658d2f92b1..f2dd454d65 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs @@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"breadcrumb > control"; - public override void Reset() + public TestCaseBreadcrumbs() { - base.Reset(); - BreadcrumbControl c; Add(c = new BreadcrumbControl { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 2663c952cf..751b979bad 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Testing chat api and overlay"; - public override void Reset() + public TestCaseChatDisplay() { - base.Reset(); - Add(new ChatOverlay { State = Visibility.Visible diff --git a/osu.Desktop.VisualTests/Tests/TestCaseContextMenu.cs b/osu.Desktop.VisualTests/Tests/TestCaseContextMenu.cs index 808e9b5d19..f9dc424153 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseContextMenu.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseContextMenu.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Transforms; using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; using osu.Game.Graphics.UserInterface; @@ -21,12 +20,10 @@ namespace osu.Desktop.VisualTests.Tests private const int start_time = 0; private const int duration = 1000; - private MyContextMenuContainer container; + private readonly Container container; - public override void Reset() + public TestCaseContextMenu() { - base.Reset(); - Add(container = new MyContextMenuContainer { Size = new Vector2(200), @@ -56,43 +53,26 @@ namespace osu.Desktop.VisualTests.Tests } } }); + } - container.Transforms.Add(new TransformPosition + protected override void LoadComplete() + { + base.LoadComplete(); + + using (container.BeginLoopedSequence()) { - StartValue = Vector2.Zero, - EndValue = new Vector2(0, 100), - StartTime = start_time, - EndTime = start_time + duration, - LoopCount = -1, - LoopDelay = duration * 3 - }); - container.Transforms.Add(new TransformPosition - { - StartValue = new Vector2(0, 100), - EndValue = new Vector2(100, 100), - StartTime = start_time + duration, - EndTime = start_time + duration * 2, - LoopCount = -1, - LoopDelay = duration * 3 - }); - container.Transforms.Add(new TransformPosition - { - StartValue = new Vector2(100, 100), - EndValue = new Vector2(100, 0), - StartTime = start_time + duration * 2, - EndTime = start_time + duration * 3, - LoopCount = -1, - LoopDelay = duration * 3 - }); - container.Transforms.Add(new TransformPosition - { - StartValue = new Vector2(100, 0), - EndValue = Vector2.Zero, - StartTime = start_time + duration * 3, - EndTime = start_time + duration * 4, - LoopCount = -1, - LoopDelay = duration * 3 - }); + container.MoveTo(new Vector2(0, 100), duration); + using (container.BeginDelayedSequence(duration)) + { + container.MoveTo(new Vector2(100, 100), duration); + using (container.BeginDelayedSequence(duration)) + { + container.MoveTo(new Vector2(100, 0), duration); + using (container.BeginDelayedSequence(duration)) + container.MoveTo(Vector2.Zero, duration); + } + } + } } private class MyContextMenuContainer : Container, IHasContextMenu diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs index 90e214c3c9..6924817827 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs @@ -12,11 +12,9 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Display dialogs"; - private DialogOverlay overlay; - - public override void Reset() + public TestCaseDialogOverlay() { - base.Reset(); + DialogOverlay overlay; Add(overlay = new DialogOverlay()); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 4cda14559f..6b68ffa260 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -16,9 +16,9 @@ namespace osu.Desktop.VisualTests.Tests private DirectOverlay direct; private RulesetDatabase rulesets; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); Add(direct = new DirectOverlay()); newBeatmaps(); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs index 43a8069720..ddda4119bf 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs @@ -15,9 +15,9 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Select your favourite room"; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); DrawableRoom first; DrawableRoom second; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs index ebc9930f93..63ec06963c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs @@ -12,10 +12,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "Tournament drawings"; - public override void Reset() + public TestCaseDrawings() { - base.Reset(); - Add(new Drawings { TeamList = new TestTeamList(), diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index e2cd2bf67b..00d7e8b5c8 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -34,9 +34,9 @@ namespace osu.Desktop.VisualTests.Tests this.rulesets = rulesets; } - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); List objects = new List(); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs b/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs index f653e2b9b4..d969decaa5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs @@ -13,11 +13,9 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "graph"; - private BarGraph graph; - - public override void Reset() + public TestCaseGraph() { - base.Reset(); + BarGraph graph; Children = new[] { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 8c913ae95e..33841cae90 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -29,15 +29,58 @@ namespace osu.Desktop.VisualTests.Tests var rateAdjustClock = new StopwatchClock(true); framedClock = new FramedClock(rateAdjustClock); playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; }; + + playbackSpeed.TriggerChange(); + + AddStep(@"circles", () => loadHitobjects(HitObjectType.Circle)); + AddStep(@"slider", () => loadHitobjects(HitObjectType.Slider)); + AddStep(@"spinner", () => loadHitobjects(HitObjectType.Spinner)); + + AddToggleStep(@"auto", state => { auto = state; loadHitobjects(mode); }); + + BasicSliderBar sliderBar; + Add(new Container + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new SpriteText { Text = "Playback Speed" }, + sliderBar = new BasicSliderBar + { + Width = 150, + Height = 10, + SelectionColor = Color4.Orange, + } + } + }); + + sliderBar.Current.BindTo(playbackSpeed); + + framedClock.ProcessFrame(); + + var clockAdjustContainer = new Container + { + RelativeSizeAxes = Axes.Both, + Clock = framedClock, + Children = new[] + { + playfieldContainer = new Container { RelativeSizeAxes = Axes.Both }, + approachContainer = new Container { RelativeSizeAxes = Axes.Both } + } + }; + + Add(clockAdjustContainer); } private HitObjectType mode = HitObjectType.Slider; private readonly BindableNumber playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 }; - private Container playfieldContainer; - private Container approachContainer; + private readonly Container playfieldContainer; + private readonly Container approachContainer; - private void load(HitObjectType mode) + private void loadHitobjects(HitObjectType mode) { this.mode = mode; @@ -83,54 +126,6 @@ namespace osu.Desktop.VisualTests.Tests } } - public override void Reset() - { - base.Reset(); - - playbackSpeed.TriggerChange(); - - AddStep(@"circles", () => load(HitObjectType.Circle)); - AddStep(@"slider", () => load(HitObjectType.Slider)); - AddStep(@"spinner", () => load(HitObjectType.Spinner)); - - AddToggleStep(@"auto", state => { auto = state; load(mode); }); - - BasicSliderBar sliderBar; - Add(new Container - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new SpriteText { Text = "Playback Speed" }, - sliderBar = new BasicSliderBar - { - Width = 150, - Height = 10, - SelectionColor = Color4.Orange, - } - } - }); - - sliderBar.Current.BindTo(playbackSpeed); - - framedClock.ProcessFrame(); - - var clockAdjustContainer = new Container - { - RelativeSizeAxes = Axes.Both, - Clock = framedClock, - Children = new[] - { - playfieldContainer = new Container { RelativeSizeAxes = Axes.Both }, - approachContainer = new Container { RelativeSizeAxes = Axes.Both } - } - }; - - Add(clockAdjustContainer); - } - private int depth; private void add(DrawableOsuHitObject h) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs index a28176b512..87a40a76ca 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs @@ -20,10 +20,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests key counter"; - public override void Reset() + public TestCaseKeyCounter() { - base.Reset(); - KeyCounterCollection kc = new KeyCounterCollection { Origin = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs b/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs index 39010baf91..12d01ecc79 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs @@ -16,7 +16,7 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"From song select"; - private Leaderboard leaderboard; + private readonly Leaderboard leaderboard; private void newScores() { @@ -207,10 +207,8 @@ namespace osu.Desktop.VisualTests.Tests leaderboard.Scores = scores; } - public override void Reset() + public TestCaseLeaderboard() { - base.Reset(); - Add(leaderboard = new Leaderboard { Origin = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index c66b0b4db4..30346e90c9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCaseManiaHitObjects : TestCase { - public override void Reset() + public TestCaseManiaHitObjects() { - base.Reset(); - Add(new FillFlowContainer { Anchor = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 352b6cdc81..adaae91815 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -25,10 +25,8 @@ namespace osu.Desktop.VisualTests.Tests protected override double TimePerAction => 200; - public override void Reset() + public TestCaseManiaPlayfield() { - base.Reset(); - Action createPlayfield = (cols, pos) => { Clear(); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs b/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs index 0caa518a0b..bab471ed6a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs @@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Main menu button system"; - public override void Reset() + public TestCaseMenuButtonSystem() { - base.Reset(); - Add(new Box { ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke), diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs b/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs index 4de8b297eb..0187c0e629 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs @@ -12,15 +12,12 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests pause and fail overlays"; - private PauseContainer.PauseOverlay pauseOverlay; - private FailOverlay failOverlay; - private int retryCount; - - public override void Reset() + public TestCaseMenuOverlays() { - base.Reset(); + FailOverlay failOverlay; + PauseContainer.PauseOverlay pauseOverlay; - retryCount = 0; + var retryCount = 0; Add(pauseOverlay = new PauseContainer.PauseOverlay { @@ -34,14 +31,16 @@ namespace osu.Desktop.VisualTests.Tests OnQuit = () => Logger.Log(@"Quit"), }); - AddStep(@"Pause", delegate { + AddStep(@"Pause", delegate + { if (failOverlay.State == Visibility.Visible) { failOverlay.Hide(); } pauseOverlay.Show(); }); - AddStep("Fail", delegate { + AddStep("Fail", delegate + { if (pauseOverlay.State == Visibility.Visible) { pauseOverlay.Hide(); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMods.cs b/osu.Desktop.VisualTests/Tests/TestCaseMods.cs index 3f3a9d82f5..e626a70e5f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMods.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMods.cs @@ -27,9 +27,9 @@ namespace osu.Desktop.VisualTests.Tests this.rulesets = rulesets; } - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); Add(modSelect = new ModSelectOverlay { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index 5665bf859a..cbb2775234 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs @@ -13,18 +13,11 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests music controller ui."; - private MusicController mc; - public TestCaseMusicController() { Clock = new FramedClock(); - } - public override void Reset() - { - base.Reset(); - Clock.ProcessFrame(); - mc = new MusicController + var mc = new MusicController { Origin = Anchor.Centre, Anchor = Anchor.Centre diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs index 8972040b06..4ba50c8220 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -16,12 +16,10 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"I handle notifications"; - private NotificationManager manager; + private readonly NotificationManager manager; - public override void Reset() + public TestCaseNotificationManager() { - base.Reset(); - progressingNotifications.Clear(); Content.Add(manager = new NotificationManager diff --git a/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs index 3cefb8a3d2..f2b4ed7918 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs @@ -15,9 +15,9 @@ namespace osu.Desktop.VisualTests.Tests public override string Description => @"Make it easier to see setting changes"; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); Add(new OnScreenDisplay()); diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 35eb6d0ff9..83a1436357 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -13,20 +13,19 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCasePlaySongSelect : TestCase { - private BeatmapDatabase db; - private TestStorage storage; - private PlaySongSelect songSelect; + private readonly BeatmapDatabase db; public override string Description => @"with fake data"; - private RulesetDatabase rulesets; + private readonly RulesetDatabase rulesets; - public override void Reset() + public TestCasePlaySongSelect() { - base.Reset(); + PlaySongSelect songSelect; + if (db == null) { - storage = new TestStorage(@"TestCasePlaySongSelect"); + var storage = new TestStorage(@"TestCasePlaySongSelect"); var backingDatabase = storage.GetDatabase(@"client"); diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index d922f3bb4b..954d24fcc1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Beatmaps; @@ -21,65 +20,54 @@ namespace osu.Desktop.VisualTests.Tests internal class TestCasePlayer : TestCase { protected Player Player; - private BeatmapDatabase db; private RulesetDatabase rulesets; public override string Description => @"Showing everything to play the game."; [BackgroundDependencyLoader] - private void load(BeatmapDatabase db, RulesetDatabase rulesets) + private void load(RulesetDatabase rulesets) { this.rulesets = rulesets; - this.db = db; } - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); - WorkingBeatmap beatmap = null; + var objects = new List(); - var beatmapInfo = db.Query().FirstOrDefault(b => b.RulesetID == 0); - if (beatmapInfo != null) - beatmap = db.GetWorkingBeatmap(beatmapInfo); - - if (beatmap?.Track == null) + int time = 1500; + for (int i = 0; i < 50; i++) { - var objects = new List(); - - int time = 1500; - for (int i = 0; i < 50; i++) + objects.Add(new HitCircle { - objects.Add(new HitCircle - { - StartTime = time, - Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : OsuPlayfield.BASE_SIZE.X, - i % 4 < 2 ? 0 : OsuPlayfield.BASE_SIZE.Y), - NewCombo = i % 4 == 0 - }); + StartTime = time, + Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : OsuPlayfield.BASE_SIZE.X, + i % 4 < 2 ? 0 : OsuPlayfield.BASE_SIZE.Y), + NewCombo = i % 4 == 0 + }); - time += 500; - } - - Beatmap b = new Beatmap - { - HitObjects = objects, - BeatmapInfo = new BeatmapInfo - { - Difficulty = new BeatmapDifficulty(), - Ruleset = rulesets.Query().First(), - Metadata = new BeatmapMetadata - { - Artist = @"Unknown", - Title = @"Sample Beatmap", - Author = @"peppy", - } - } - }; - - beatmap = new TestWorkingBeatmap(b); + time += 500; } + Beatmap b = new Beatmap + { + HitObjects = objects, + BeatmapInfo = new BeatmapInfo + { + Difficulty = new BeatmapDifficulty(), + Ruleset = rulesets.Query().First(), + Metadata = new BeatmapMetadata + { + Artist = @"Unknown", + Title = @"Sample Beatmap", + Author = @"peppy", + } + } + }; + + WorkingBeatmap beatmap = new TestWorkingBeatmap(b); + Add(new Box { RelativeSizeAxes = Framework.Graphics.Axes.Both, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs index b2c211b7f0..00a9774067 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs @@ -13,13 +13,11 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Settings visible in replay/auto"; - private ExampleContainer container; - - public override void Reset() + public TestCaseReplaySettingsOverlay() { - base.Reset(); + ExampleContainer container; - Add(new ReplaySettingsOverlay() + Add(new ReplaySettingsOverlay { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseResults.cs b/osu.Desktop.VisualTests/Tests/TestCaseResults.cs index f8c93e9a73..1cfc2fc664 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseResults.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseResults.cs @@ -28,9 +28,9 @@ namespace osu.Desktop.VisualTests.Tests private WorkingBeatmap beatmap; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); if (beatmap == null) { @@ -39,8 +39,6 @@ namespace osu.Desktop.VisualTests.Tests beatmap = db.GetWorkingBeatmap(beatmapInfo); } - base.Reset(); - Add(new Results(new Score { TotalScore = 2845370, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs index beb664e7ff..00702f7ad0 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs @@ -17,9 +17,9 @@ namespace osu.Desktop.VisualTests.Tests private RulesetDatabase rulesets; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); var room = new Room { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 45ae82109f..e8fc2956b4 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -15,10 +15,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests multiple counters"; - public override void Reset() + public TestCaseScoreCounter() { - base.Reset(); - int numerator = 0, denominator = 0; ScoreCounter score = new ScoreCounter(7) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScrollingHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseScrollingHitObjects.cs index 4ddc35eb84..9f439fe193 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScrollingHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScrollingHitObjects.cs @@ -21,16 +21,15 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "SpeedAdjustmentContainer/DrawableTimingSection"; - private SpeedAdjustmentCollection adjustmentCollection; + private readonly BindableDouble timeRangeBindable; + private readonly OsuSpriteText bottomLabel; + private readonly SpriteText topTime; + private readonly SpriteText bottomTime; - private BindableDouble timeRangeBindable; - private OsuSpriteText timeRangeText; - private OsuSpriteText bottomLabel; - private SpriteText topTime, bottomTime; - - public override void Reset() + public TestCaseScrollingHitObjects() { - base.Reset(); + OsuSpriteText timeRangeText; + SpeedAdjustmentCollection adjustmentCollection; timeRangeBindable = new BindableDouble(2000) { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs b/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs index 660085e558..3d21f0e3b1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs @@ -10,13 +10,16 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests the settings overlay"; - private SettingsOverlay settings; + private readonly SettingsOverlay settings; - public override void Reset() + public TestCaseSettings() { - base.Reset(); - Children = new[] { settings = new SettingsOverlay() }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); settings.ToggleVisibility(); } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSkipButton.cs b/osu.Desktop.VisualTests/Tests/TestCaseSkipButton.cs index fb5be719c1..1f81226a8e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSkipButton.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSkipButton.cs @@ -10,9 +10,10 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Skip skip skippediskip"; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); + Add(new SkipButton(Clock.CurrentTime + 5000)); } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSocial.cs b/osu.Desktop.VisualTests/Tests/TestCaseSocial.cs index eb7df96355..34209119bd 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSocial.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSocial.cs @@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"social browser overlay"; - public override void Reset() + public TestCaseSocial() { - base.Reset(); - SocialOverlay s = new SocialOverlay { Users = new[] diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index e3c343f5f8..3368224be1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -15,15 +15,13 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"With fake data"; - private SongProgress progress; - private SongProgressGraph graph; + private readonly SongProgress progress; + private readonly SongProgressGraph graph; - private StopwatchClock clock; + private readonly StopwatchClock clock; - public override void Reset() + public TestCaseSongProgress() { - base.Reset(); - clock = new StopwatchClock(true); Add(progress = new SongProgress diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index 96933a15e7..c0c01a6daa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -14,10 +14,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Filter for song select"; - public override void Reset() + public TestCaseTabControl() { - base.Reset(); - OsuSpriteText text; OsuTabControl filter; Add(filter = new OsuTabControl diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs index d769071bd9..d98e39ae7b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs @@ -16,10 +16,8 @@ namespace osu.Desktop.VisualTests.Tests private bool kiai; - public override void Reset() + public TestCaseTaikoHitObjects() { - base.Reset(); - AddToggleStep("Kiai", b => { kiai = !kiai; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index 259d0267db..00929c06c2 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -26,13 +26,11 @@ namespace osu.Desktop.VisualTests.Tests protected override double TimePerAction => default_duration * 2; private readonly Random rng = new Random(1337); - private TaikoPlayfield playfield; - private Container playfieldContainer; + private readonly TaikoPlayfield playfield; + private readonly Container playfieldContainer; - public override void Reset() + public TestCaseTaikoPlayfield() { - base.Reset(); - AddStep("Hit!", addHitJudgement); AddStep("Miss :(", addMissJudgement); AddStep("DrumRoll", () => addDrumRoll(false)); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs b/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs index 7182ee7c06..2824c0416f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs @@ -16,10 +16,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests display of icons"; - public override void Reset() + public TestCaseTextAwesome() { - base.Reset(); - FillFlowContainer flow; Add(flow = new FillFlowContainer diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs b/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs index 2decb4c469..0c35a4b8aa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs @@ -10,10 +10,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Mostly back button"; - public override void Reset() + public TestCaseTwoLayerButton() { - base.Reset(); - Add(new BackButton()); } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index 92d58c10c9..22cdf42f7d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Panels for displaying a user's status"; - public override void Reset() + public TestCaseUserPanel() { - base.Reset(); - UserPanel flyte; UserPanel peppy; Add(new FillFlowContainer diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index e31eb316c9..b65bab0d17 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -187,6 +187,7 @@ + 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.Catch/Objects/Drawable/DrawableFruit.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs index ae6585bdb2..3e7d9bd6d7 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableFruit.cs @@ -5,18 +5,17 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Graphics.Transforms; using OpenTK; namespace osu.Game.Rulesets.Catch.Objects.Drawable { internal class DrawableFruit : Sprite { - private readonly CatchBaseHit h; + //private readonly CatchBaseHit h; public DrawableFruit(CatchBaseHit h) { - this.h = h; + //this.h = h; Origin = Anchor.Centre; Scale = new Vector2(0.1f); @@ -29,10 +28,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { Texture = textures.Get(@"Menu/logo"); - const double duration = 0; - - Transforms.Add(new TransformPosition { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) }); - Transforms.Add(new TransformAlpha { StartTime = h.StartTime + duration + 200, EndTime = h.StartTime + duration + 400, StartValue = 1, EndValue = 0 }); + //Transforms.Add(new TransformPosition { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) }); + //Transforms.Add(new TransformAlpha { StartTime = h.StartTime + duration + 200, EndTime = h.StartTime + duration + 400, StartValue = 1, EndValue = 0 }); Expire(true); } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index a0c683143c..3feb448752 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -235,7 +235,7 @@ namespace osu.Game.Rulesets.Mania.UI private void transformVisibleTimeRangeTo(double newTimeRange, double duration = 0, EasingTypes easing = EasingTypes.None) { - TransformTo(() => visibleTimeRange.Value, newTimeRange, duration, easing, new TransformTimeSpan()); + TransformTo(newTimeRange, duration, easing, new TransformTimeSpan()); } protected override void Update() @@ -247,7 +247,7 @@ namespace osu.Game.Rulesets.Mania.UI private class TransformTimeSpan : Transform { - public override double CurrentValue + public double CurrentValue { get { @@ -259,13 +259,8 @@ namespace osu.Game.Rulesets.Mania.UI } } - public override void Apply(Drawable d) - { - base.Apply(d); - - var p = (ManiaPlayfield)d; - p.visibleTimeRange.Value = (float)CurrentValue; - } + public override void Apply(Drawable d) => ((ManiaPlayfield)d).visibleTimeRange.Value = (float)CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((ManiaPlayfield)d).visibleTimeRange.Value; } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 09bfffeefe..75b2dc0a32 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -89,11 +89,15 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { base.UpdateInitialState(); - //sane defaults - ring.Alpha = circle.Alpha = number.Alpha = glow.Alpha = 1; - ApproachCircle.Alpha = 0; - ApproachCircle.Scale = new Vector2(4); - explode.Alpha = 0; + // sane defaults + ring.Show(); + circle.Show(); + number.Show(); + glow.Show(); + + ApproachCircle.Hide(); + ApproachCircle.ScaleTo(new Vector2(4)); + explode.Hide(); } protected override void UpdatePreemptState() @@ -106,43 +110,45 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void UpdateCurrentState(ArmedState state) { - ApproachCircle.FadeOut(); + double duration = ((HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime) - HitObject.StartTime; - double endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; - double duration = endTime - HitObject.StartTime; - - glow.Delay(duration); - glow.FadeOut(400); + using (glow.BeginDelayedSequence(duration)) + glow.FadeOut(400); switch (state) { case ArmedState.Idle: - Delay(duration + TIME_PREEMPT); - FadeOut(TIME_FADEOUT); + using (BeginDelayedSequence(duration + TIME_PREEMPT)) + FadeOut(TIME_FADEOUT); Expire(true); break; case ArmedState.Miss: + ApproachCircle.FadeOut(50); FadeOut(TIME_FADEOUT / 5); Expire(); break; case ArmedState.Hit: + ApproachCircle.FadeOut(50); + const double flash_in = 40; flash.FadeTo(0.8f, flash_in); - flash.Delay(flash_in); - flash.FadeOut(100); + using (flash.BeginDelayedSequence(flash_in)) + flash.FadeOut(100); explode.FadeIn(flash_in); - Delay(flash_in, true); + using (BeginDelayedSequence(flash_in, true)) + { + //after the flash, we can hide some elements that were behind it + ring.FadeOut(); + circle.FadeOut(); + number.FadeOut(); - //after the flash, we can hide some elements that were behind it - ring.FadeOut(); - circle.FadeOut(); - number.FadeOut(); + FadeOut(800); + ScaleTo(Scale * 1.5f, 400, EasingTypes.OutQuad); + } - FadeOut(800); - ScaleTo(Scale * 1.5f, 400, EasingTypes.OutQuad); Expire(); break; } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index 57a9804330..2711ec1a62 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -17,6 +17,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables : base(hitObject) { AccentColour = HitObject.ComboColour; + Alpha = 0; } protected override OsuJudgement CreateJudgement() => new OsuJudgement { MaxScore = OsuScoreResult.Hit300 }; @@ -25,10 +26,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { Flush(); - UpdateInitialState(); - using (BeginAbsoluteSequence(HitObject.StartTime - TIME_PREEMPT, true)) { + UpdateInitialState(); + UpdatePreemptState(); using (BeginDelayedSequence(TIME_PREEMPT + Judgement.TimeOffset, true)) @@ -36,8 +37,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } } - protected virtual void UpdateCurrentState(ArmedState state) + protected virtual void UpdateInitialState() { + Hide(); } protected virtual void UpdatePreemptState() @@ -45,9 +47,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables FadeIn(TIME_FADEIN); } - protected virtual void UpdateInitialState() + protected virtual void UpdateCurrentState(ArmedState state) { - Alpha = 0; } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index b80f1d7178..c6c009e8f2 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -28,10 +28,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public DrawableSlider(Slider s) : base(s) { - // Since the DrawableSlider itself is just a container without a size we need to - // pass all input through. - AlwaysReceiveInput = true; - SliderBouncer bouncer1; slider = s; @@ -129,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/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 3722d13ffc..840acb8221 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -38,8 +38,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public DrawableSpinner(Spinner s) : base(s) { - AlwaysReceiveInput = true; - Origin = Anchor.Centre; Position = s.Position; 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/SliderBouncer.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBouncer.cs index 65679dd7d3..a34ff30a43 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBouncer.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBouncer.cs @@ -37,8 +37,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces protected override void LoadComplete() { base.LoadComplete(); - icon.RotateTo(360, 1000); - icon.Loop(); + using (icon.BeginLoopedSequence()) + icon.RotateTo(360, 1000); } 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 29d6d1f147..f3ddf683d2 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs @@ -31,7 +31,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { spinner = s; - AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; Children = new Drawable[] @@ -40,6 +39,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces }; } + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + private bool tracking; public bool Tracking { diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 4a6b972f4a..910918297f 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -111,7 +111,7 @@ namespace osu.Game.Tests.Beatmaps.IO return osu; } - private void ensureLoaded(GameHost host, int timeout = 10000) + private void ensureLoaded(GameHost host, int timeout = 60000) { IEnumerable resultSets = null; diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 1ac6261621..b59dbac722 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -93,6 +93,7 @@ namespace osu.Game.Beatmaps.Drawables { new BeatmapBackgroundSprite(working) { + RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, FillMode = FillMode.Fill, diff --git a/osu.Game/Graphics/Backgrounds/Background.cs b/osu.Game/Graphics/Backgrounds/Background.cs index 7c47635276..8eb2ddc0ab 100644 --- a/osu.Game/Graphics/Backgrounds/Background.cs +++ b/osu.Game/Graphics/Backgrounds/Background.cs @@ -26,6 +26,7 @@ namespace osu.Game.Graphics.Backgrounds Add(Sprite = new Sprite { + RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, Colour = Color4.DarkGray, diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index c0defceac0..5d8a5753b0 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -23,6 +23,16 @@ namespace osu.Game.Graphics.Containers /// protected double EarlyActivationMilliseconds; + /// + /// The time in milliseconds until the next beat. + /// + public double TimeUntilNextBeat { get; private set; } + + /// + /// The time in milliseconds since the last beat + /// + public double TimeSinceLastBeat { get; private set; } + protected override void Update() { if (Beatmap.Value?.Track == null) @@ -42,12 +52,16 @@ namespace osu.Game.Graphics.Containers if (currentTrackTime < timingPoint.Time) beatIndex--; + TimeUntilNextBeat = (timingPoint.Time - currentTrackTime) % timingPoint.BeatLength; + if (TimeUntilNextBeat < 0) + TimeUntilNextBeat += timingPoint.BeatLength; + + TimeSinceLastBeat = timingPoint.BeatLength - TimeUntilNextBeat; + if (timingPoint == lastTimingPoint && beatIndex == lastBeat) return; - double offsetFromBeat = (timingPoint.Time - currentTrackTime) % timingPoint.BeatLength; - - using (BeginDelayedSequence(offsetFromBeat, true)) + using (BeginDelayedSequence(-TimeSinceLastBeat, true)) OnNewBeat(beatIndex, timingPoint, effectPoint, Beatmap.Value.Track.CurrentAmplitudes); lastBeat = beatIndex; 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/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 2d5952a3ce..19475b00c9 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -19,8 +19,6 @@ namespace osu.Game.Graphics.Containers public ParallaxContainer() { - AlwaysReceiveInput = true; - RelativeSizeAxes = Axes.Both; AddInternal(content = new Container { diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 183679fbd3..035f6f98b0 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -65,7 +65,6 @@ namespace osu.Game.Graphics.Cursor // as we are currently very dependent on having a running clock, let's make our own clock for the time being. Clock = new FramedClock(); - AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; for (int i = 0; i < max_sprites; i++) @@ -75,6 +74,8 @@ namespace osu.Game.Graphics.Cursor } } + 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/IHasAccentColour.cs b/osu.Game/Graphics/IHasAccentColour.cs index 672c59a935..9eb66d8fac 100644 --- a/osu.Game/Graphics/IHasAccentColour.cs +++ b/osu.Game/Graphics/IHasAccentColour.cs @@ -30,7 +30,7 @@ namespace osu.Game.Graphics public static void FadeAccent(this T accentedDrawable, Color4 newColour, double duration = 0, EasingTypes easing = EasingTypes.None) where T : Transformable, IHasAccentColour { - accentedDrawable.TransformTo(() => accentedDrawable.AccentColour, newColour, duration, easing, new TransformAccent()); + accentedDrawable.TransformTo(newColour, duration, easing, new TransformAccent()); } } } diff --git a/osu.Game/Graphics/Processing/RatioAdjust.cs b/osu.Game/Graphics/Processing/RatioAdjust.cs index dd039d5144..640814d8e1 100644 --- a/osu.Game/Graphics/Processing/RatioAdjust.cs +++ b/osu.Game/Graphics/Processing/RatioAdjust.cs @@ -12,7 +12,6 @@ namespace osu.Game.Graphics.Processing { public RatioAdjust() { - AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; } diff --git a/osu.Game/Graphics/Transforms/TransformAccent.cs b/osu.Game/Graphics/Transforms/TransformAccent.cs index d49f969c20..53a452ad8a 100644 --- a/osu.Game/Graphics/Transforms/TransformAccent.cs +++ b/osu.Game/Graphics/Transforms/TransformAccent.cs @@ -13,7 +13,7 @@ namespace osu.Game.Graphics.Transforms /// /// Current value of the transformed colour in linear colour space. /// - public override Color4 CurrentValue + public virtual Color4 CurrentValue { get { @@ -25,13 +25,7 @@ namespace osu.Game.Graphics.Transforms } } - public override void Apply(Drawable d) - { - base.Apply(d); - - var accented = d as IHasAccentColour; - if (accented != null) - accented.AccentColour = CurrentValue; - } + public override void Apply(Drawable d) => ((IHasAccentColour)d).AccentColour = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((IHasAccentColour)d).AccentColour; } } 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 8d113f4918..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 - protected override bool InternalContains(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 10c821e9bd..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 - protected override bool InternalContains(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/LoadingAnimation.cs b/osu.Game/Graphics/UserInterface/LoadingAnimation.cs index 27a888f0b5..eed5061abd 100644 --- a/osu.Game/Graphics/UserInterface/LoadingAnimation.cs +++ b/osu.Game/Graphics/UserInterface/LoadingAnimation.cs @@ -34,9 +34,8 @@ namespace osu.Game.Graphics.UserInterface { base.LoadComplete(); - spinner.RotateTo(360, 2000); - using (spinner.BeginDelayedSequence(2000)) - spinner.Loop(); + using (spinner.BeginLoopedSequence()) + spinner.RotateTo(360, 2000); } private const float transition_duration = 500; 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 37bf30646d..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); - protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos); - private bool isEnumType => typeof(T).IsEnum; public OsuTabControl() diff --git a/osu.Game/Graphics/UserInterface/PercentageCounter.cs b/osu.Game/Graphics/UserInterface/PercentageCounter.cs index 79cdc9effe..b51dd2287b 100644 --- a/osu.Game/Graphics/UserInterface/PercentageCounter.cs +++ b/osu.Game/Graphics/UserInterface/PercentageCounter.cs @@ -47,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface protected class TransformAccuracy : Transform { - public override double CurrentValue + public virtual double CurrentValue { get { @@ -59,11 +59,8 @@ namespace osu.Game.Graphics.UserInterface } } - public override void Apply(Drawable d) - { - base.Apply(d); - ((PercentageCounter)d).DisplayedCount = CurrentValue; - } + public override void Apply(Drawable d) => ((PercentageCounter)d).DisplayedCount = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((PercentageCounter)d).DisplayedCount; } } } diff --git a/osu.Game/Graphics/UserInterface/RollingCounter.cs b/osu.Game/Graphics/UserInterface/RollingCounter.cs index 4338dd23eb..db6e6ff44f 100644 --- a/osu.Game/Graphics/UserInterface/RollingCounter.cs +++ b/osu.Game/Graphics/UserInterface/RollingCounter.cs @@ -210,7 +210,6 @@ namespace osu.Game.Graphics.UserInterface transform.StartTime = TransformStartTime; transform.EndTime = TransformStartTime + rollingTotalDuration; - transform.StartValue = currentValue; transform.EndValue = newValue; transform.Easing = RollingEasing; diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index f98e84852a..6fe43e1fcc 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -58,7 +58,7 @@ namespace osu.Game.Graphics.UserInterface protected class TransformScore : Transform { - public override double CurrentValue + public virtual double CurrentValue { get { @@ -70,11 +70,8 @@ namespace osu.Game.Graphics.UserInterface } } - public override void Apply(Drawable d) - { - base.Apply(d); - ((ScoreCounter)d).DisplayedCount = CurrentValue; - } + public override void Apply(Drawable d) => ((ScoreCounter)d).DisplayedCount = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((ScoreCounter)d).DisplayedCount; } } } diff --git a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs index bee1a71894..7664eeee40 100644 --- a/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs +++ b/osu.Game/Graphics/UserInterface/SimpleComboCounter.cs @@ -39,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface private class TransformCounterCount : Transform { - public override int CurrentValue + public int CurrentValue { get { @@ -51,11 +51,8 @@ namespace osu.Game.Graphics.UserInterface } } - public override void Apply(Drawable d) - { - base.Apply(d); - ((SimpleComboCounter)d).DisplayedCount = CurrentValue; - } + public override void Apply(Drawable d) => ((SimpleComboCounter)d).DisplayedCount = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = ((SimpleComboCounter)d).DisplayedCount; } } } \ No newline at end of file diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index b504c70be7..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 } } - protected override bool InternalContains(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 306cdaddf0..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,22 +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) { - AlwaysReceiveInput = true, 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 23b8aac6a7..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; - protected override bool InternalContains(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..3c708bff67 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(); @@ -38,6 +38,7 @@ namespace osu.Game.Overlays.Direct { return new AsyncLoadWrapper(new BeatmapBackgroundSprite(new OnlineWorkingBeatmap(SetInfo.Beatmaps.FirstOrDefault(), textures, null)) { + RelativeSizeAxes = Axes.Both, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(400, EasingTypes.Out), }) { RelativeSizeAxes = Axes.Both }; 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/DragBar.cs b/osu.Game/Overlays/DragBar.cs index 07e0c76396..89bb81c70b 100644 --- a/osu.Game/Overlays/DragBar.cs +++ b/osu.Game/Overlays/DragBar.cs @@ -75,7 +75,7 @@ namespace osu.Game.Overlays private void updatePosition(float position, bool easing = true) { position = MathHelper.Clamp(position, 0, 1); - Fill.TransformTo(() => Fill.Width, position, easing ? 200 : 0, EasingTypes.OutQuint, new TransformSeek()); + Fill.TransformTo(position, easing ? 200 : 0, EasingTypes.OutQuint, new TransformSeek()); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -100,11 +100,8 @@ namespace osu.Game.Overlays private class TransformSeek : TransformFloat { - public override void Apply(Drawable d) - { - base.Apply(d); - d.Width = CurrentValue; - } + public override void Apply(Drawable d) => d.Width = CurrentValue; + public override void ReadIntoStartValue(Drawable d) => StartValue = d.Width; } } } 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..f6190f09af 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; @@ -397,6 +398,7 @@ namespace osu.Game.Overlays { sprite = new Sprite { + RelativeSizeAxes = Axes.Both, Colour = OsuColour.Gray(150), FillMode = FillMode.Fill, }, 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..74cced5ee9 100644 --- a/osu.Game/Overlays/Notifications/Notification.cs +++ b/osu.Game/Overlays/Notifications/Notification.cs @@ -7,12 +7,12 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Transforms; using osu.Framework.Input; 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 +152,7 @@ namespace osu.Game.Overlays.Notifications Expire(); } - private class CloseButton : ClickableContainer + private class CloseButton : OsuClickableContainer { private Color4 hoverColour; @@ -202,6 +202,8 @@ namespace osu.Game.Overlays.Notifications get { return pulsate; } set { + if (pulsate == value) return; + pulsate = value; pulsateLayer.ClearTransforms(); @@ -210,25 +212,12 @@ namespace osu.Game.Overlays.Notifications if (pulsate) { const float length = 1000; - pulsateLayer.Transforms.Add(new TransformAlpha + using (pulsateLayer.BeginLoopedSequence(length / 2)) { - StartTime = Time.Current, - EndTime = Time.Current + length, - StartValue = 1, - EndValue = 0.4f, - Easing = EasingTypes.In - }); - pulsateLayer.Transforms.Add(new TransformAlpha - { - StartTime = Time.Current + length, - EndTime = Time.Current + length * 2, - StartValue = 0.4f, - EndValue = 1, - Easing = EasingTypes.Out - }); - - //todo: figure why we can't add arbitrary delays at the end of loop. - pulsateLayer.Loop(length * 2); + pulsateLayer.FadeTo(0.4f, length, EasingTypes.In); + using (pulsateLayer.BeginDelayedSequence(length)) + pulsateLayer.FadeTo(1, length, EasingTypes.Out); + } } } } 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..464c9893d1 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; }); } @@ -261,8 +260,6 @@ namespace osu.Game.Overlays Radius = 8, }; - FadeEdgeEffectTo(0); - updateGlow(); Flush(true); } 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 d5f7683257..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; - protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || DisplayStyleControl.Dropdown.Contains(screenSpacePos); - protected SearchableListFilterControl() { if (!typeof(T).IsEnum) diff --git a/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs b/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs index 05ee38153d..25f6b4f60b 100644 --- a/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs +++ b/osu.Game/Overlays/SearchableList/SearchableListOverlay.cs @@ -82,7 +82,6 @@ namespace osu.Game.Overlays.SearchableList RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - AlwaysReceiveInput = true, Children = new Drawable[] { Header = CreateHeader(), diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 88f4599383..4a5a0de890 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; @@ -93,7 +93,7 @@ namespace osu.Game.Overlays new SidebarButton { Section = section, - Action = sectionsContainer.ScrollContainer.ScrollIntoView, + Action = b => sectionsContainer.ScrollContainer.ScrollTo(b), } ).ToArray() } 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/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 16e4f22ec8..a7e5f8dcc4 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -33,8 +33,6 @@ namespace osu.Game.Overlays.Toolbar public Toolbar() { - AlwaysReceiveInput = true; - Children = new Drawable[] { new ToolbarBackground(), @@ -55,7 +53,6 @@ namespace osu.Game.Overlays.Toolbar }, new FillFlowContainer { - AlwaysReceiveInput = true, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Direction = FillDirection.Horizontal, 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/Toolbar/ToolbarUserArea.cs b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs index 1928c0fc1f..c1fd234628 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs @@ -17,8 +17,6 @@ namespace osu.Game.Overlays.Toolbar public ToolbarUserArea() { - AlwaysReceiveInput = true; - RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; 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/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 00d678e11e..8fe1dd3e0a 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.UI // Check if the beatmap can be converted if (!converter.CanConvert(beatmap.Beatmap)) - throw new BeatmapInvalidForRulesetException($"{nameof(Beatmap)} can't be converted for the current ruleset."); + throw new BeatmapInvalidForRulesetException($"{nameof(Beatmap)} can not be converted for the current ruleset (converter: {converter})."); // Convert the beatmap Beatmap = converter.Convert(beatmap.Beatmap, isForCurrentRuleset); diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 612569a9ae..ff321a18a5 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -37,8 +37,6 @@ namespace osu.Game.Rulesets.UI /// Whether we want our internal coordinate system to be scaled to a specified width. protected Playfield(float? customWidth = null) { - AlwaysReceiveInput = true; - // Default height since we force relative size axes Size = Vector2.One; @@ -50,7 +48,6 @@ namespace osu.Game.Rulesets.UI { content = new Container { - AlwaysReceiveInput = true, RelativeSizeAxes = Axes.Both, } } @@ -100,19 +97,10 @@ namespace osu.Game.Rulesets.UI //dividing by the customwidth will effectively scale our content to the required container size. protected override Vector2 DrawScale => CustomWidth.HasValue ? new Vector2(DrawSize.X / CustomWidth.Value) : base.DrawScale; - - public ScaledContainer() - { - AlwaysReceiveInput = true; - } } public class HitObjectContainer : Container where U : Drawable { - public HitObjectContainer() - { - AlwaysReceiveInput = true; - } } } } 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 19bb084af4..8dad83bd0e 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -9,7 +9,6 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -17,6 +16,9 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Input; using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Graphics.Containers; +using osu.Framework.Audio.Track; +using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Screens.Menu { @@ -24,22 +26,23 @@ namespace osu.Game.Screens.Menu /// Button designed specifically for the osu!next main menu. /// In order to correctly flow, we have to use a negative margin on the parent container (due to the parallelogram shape). /// - public class Button : Container, IStateful + public class Button : BeatSyncedContainer, IStateful { private readonly Container iconText; 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; - protected override bool InternalContains(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; @@ -116,94 +119,40 @@ namespace osu.Game.Screens.Menu }; } + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + + if (!IsHovered) return; + + bool rightward = beatIndex % 2 == 1; + double duration = timingPoint.BeatLength / 2; + + icon.RotateTo(rightward ? 10 : -10, duration * 2, EasingTypes.InOutSine); + + icon.MoveToY(-10, duration, EasingTypes.Out); + icon.ScaleTo(Vector2.One, duration, EasingTypes.Out); + + using (icon.BeginDelayedSequence(duration)) + { + icon.MoveToY(0, duration, EasingTypes.In); + icon.ScaleTo(new Vector2(1, 0.9f), duration, EasingTypes.In); + } + } + 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); - int duration = 0; //(int)(Game.Audio.BeatLength / 2); - if (duration == 0) duration = 250; + double duration = TimeUntilNextBeat; icon.ClearTransforms(); - - icon.ScaleTo(1, 500, EasingTypes.OutElasticHalf); - - const double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; - double startTime = Time.Current + offset; - - icon.RotateTo(10, offset, EasingTypes.InOutSine); - icon.ScaleTo(new Vector2(1, 0.9f), offset, EasingTypes.Out); - - icon.Transforms.Add(new TransformRotation - { - StartValue = -10, - EndValue = 10, - StartTime = startTime, - EndTime = startTime + duration * 2, - Easing = EasingTypes.InOutSine, - LoopCount = -1, - LoopDelay = duration * 2 - }); - - icon.Transforms.Add(new TransformPosition - { - StartValue = Vector2.Zero, - EndValue = new Vector2(0, -10), - StartTime = startTime, - EndTime = startTime + duration, - Easing = EasingTypes.Out, - LoopCount = -1, - LoopDelay = duration - }); - - icon.Transforms.Add(new TransformScale - { - StartValue = new Vector2(1, 0.9f), - EndValue = Vector2.One, - StartTime = startTime, - EndTime = startTime + duration, - Easing = EasingTypes.Out, - LoopCount = -1, - LoopDelay = duration - }); - - icon.Transforms.Add(new TransformPosition - { - StartValue = new Vector2(0, -10), - EndValue = Vector2.Zero, - StartTime = startTime + duration, - EndTime = startTime + duration * 2, - Easing = EasingTypes.In, - LoopCount = -1, - LoopDelay = duration - }); - - icon.Transforms.Add(new TransformScale - { - StartValue = Vector2.One, - EndValue = new Vector2(1, 0.9f), - StartTime = startTime + duration, - EndTime = startTime + duration * 2, - Easing = EasingTypes.In, - LoopCount = -1, - LoopDelay = duration - }); - - icon.Transforms.Add(new TransformRotation - { - StartValue = 10, - EndValue = -10, - StartTime = startTime + duration * 2, - EndTime = startTime + duration * 4, - Easing = EasingTypes.InOutSine, - LoopCount = -1, - LoopDelay = duration * 2 - }); - + icon.RotateTo(10, duration, EasingTypes.InOutSine); + icon.ScaleTo(new Vector2(1, 0.9f), duration, EasingTypes.Out); return true; } @@ -212,7 +161,6 @@ namespace osu.Game.Screens.Menu icon.ClearTransforms(); icon.RotateTo(0, 500, EasingTypes.Out); icon.MoveTo(Vector2.Zero, 500, EasingTypes.Out); - icon.ScaleTo(0.7f, 500, EasingTypes.OutElasticHalf); icon.ScaleTo(Vector2.One, 200, EasingTypes.Out); if (State == ButtonState.Expanded) @@ -222,7 +170,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 +209,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