From 7d11e55d0610c1999072f05c837dca74cb68b910 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Mar 2018 19:43:33 +0900 Subject: [PATCH 01/27] Only block mouse input when the shaded portion of the SkipButton is hovered --- osu.Game/Screens/Play/SkipButton.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Play/SkipButton.cs b/osu.Game/Screens/Play/SkipButton.cs index 08bb26c72b..c77061e5d9 100644 --- a/osu.Game/Screens/Play/SkipButton.cs +++ b/osu.Game/Screens/Play/SkipButton.cs @@ -36,6 +36,8 @@ namespace osu.Game.Screens.Play public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + protected override bool BlockPassThroughMouse => fadeContainer.IsHovered; + public SkipButton(double startTime) { this.startTime = startTime; From 53edfedfc8e86a9ebd3fb2723ec2cbab5fd60a40 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Mar 2018 19:43:57 +0900 Subject: [PATCH 02/27] Remove unneeded HighFrequencyMousePosition from GameplayMenuOverlay --- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index 615c124ea7..29b68abc21 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -18,7 +18,7 @@ using System.Collections.Generic; namespace osu.Game.Screens.Play { - public abstract class GameplayMenuOverlay : OverlayContainer, IRequireHighFrequencyMousePosition + public abstract class GameplayMenuOverlay : OverlayContainer { private const int transition_duration = 200; private const int button_height = 70; From 60f851df3e092f74e596753b9e6d8eb385dbf4e6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Mar 2018 19:45:49 +0900 Subject: [PATCH 03/27] Add support for DrawInfo alpha when drawing CursorTrail --- .../UI/Cursor/CursorTrail.cs | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index 37ca0c021b..c56cd46131 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -3,9 +3,9 @@ using System; using System.Diagnostics; +using System.Runtime.InteropServices; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.OpenGL.Buffers; using osu.Framework.Graphics.OpenGL.Vertices; using osu.Framework.Graphics.Primitives; @@ -14,6 +14,7 @@ using osu.Framework.Graphics.Textures; using osu.Framework.Input; using osu.Framework.Timing; using OpenTK; +using OpenTK.Graphics; using OpenTK.Graphics.ES30; namespace osu.Game.Rulesets.Osu.UI.Cursor @@ -115,14 +116,16 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor protected override bool OnMouseMove(InputState state) { + Vector2 pos = state.Mouse.NativeState.Position; + if (lastPosition == null) { - lastPosition = state.Mouse.NativeState.Position; + lastPosition = pos; resampler.AddPosition(lastPosition.Value); return base.OnMouseMove(state); } - foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position)) + foreach (Vector2 pos2 in resampler.AddPosition(pos)) { Trace.Assert(lastPosition.HasValue); @@ -162,7 +165,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private class TrailDrawNodeSharedData { - public VertexBuffer VertexBuffer; + public VertexBuffer VertexBuffer; } private class TrailDrawNode : DrawNode @@ -188,7 +191,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor public override void Draw(Action vertexAction) { if (Shared.VertexBuffer == null) - Shared.VertexBuffer = new QuadVertexBuffer(max_sprites, BufferUsageHint.DynamicDraw); + Shared.VertexBuffer = new QuadVertexBuffer(max_sprites, BufferUsageHint.DynamicDraw); Shader.GetUniform("g_FadeClock").Value = Time; @@ -205,17 +208,19 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor int end = start; Vector2 pos = Parts[i].Position; - ColourInfo colour = DrawInfo.Colour; - colour.TopLeft.Linear.A = Parts[i].Time + colour.TopLeft.Linear.A; - colour.TopRight.Linear.A = Parts[i].Time + colour.TopRight.Linear.A; - colour.BottomLeft.Linear.A = Parts[i].Time + colour.BottomLeft.Linear.A; - colour.BottomRight.Linear.A = Parts[i].Time + colour.BottomRight.Linear.A; + float time = Parts[i].Time; Texture.DrawQuad( new Quad(pos.X - Size.X / 2, pos.Y - Size.Y / 2, Size.X, Size.Y), - colour, + DrawInfo.Colour, null, - v => Shared.VertexBuffer.Vertices[end++] = v); + v => Shared.VertexBuffer.Vertices[end++] = new TexturedTrailVertex + { + Position = v.Position, + TexturePosition = v.TexturePosition, + Time = time + 1, + Colour = v.Colour, + }); Parts[i].WasUpdated = false; } @@ -240,5 +245,26 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor Shader.Unbind(); } } + + [StructLayout(LayoutKind.Sequential)] + public struct TexturedTrailVertex : IEquatable, IVertex + { + [VertexMember(2, VertexAttribPointerType.Float)] + public Vector2 Position; + [VertexMember(4, VertexAttribPointerType.Float)] + public Color4 Colour; + [VertexMember(2, VertexAttribPointerType.Float)] + public Vector2 TexturePosition; + [VertexMember(1, VertexAttribPointerType.Float)] + public float Time; + + public bool Equals(TexturedTrailVertex other) + { + return Position.Equals(other.Position) + && TexturePosition.Equals(other.TexturePosition) + && Colour.Equals(other.Colour) + && Time.Equals(other.Time); + } + } } } From 69c0e95d9d987de074b3bb95e45b53fe422c56ab Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Mar 2018 20:06:08 +0900 Subject: [PATCH 04/27] Use a better fade effect for the gameplay cursor --- .../UI/Cursor/GameplayCursor.cs | 95 +++++++++++-------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index 0aeb14514d..34940a084a 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -20,13 +20,66 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor { protected override Drawable CreateCursor() => new OsuCursor(); + protected override Container Content => fadeContainer; + + private readonly Container fadeContainer; + public GameplayCursor() { - Add(new CursorTrail { Depth = 1 }); + InternalChild = fadeContainer = new Container + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new CursorTrail { Depth = 1 } + } + }; } private int downCount; + public bool OnPressed(OsuAction action) + { + switch (action) + { + case OsuAction.LeftButton: + case OsuAction.RightButton: + downCount++; + ActiveCursor.ScaleTo(1).ScaleTo(1.2f, 100, Easing.OutQuad); + break; + } + + return false; + } + + public bool OnReleased(OsuAction action) + { + switch (action) + { + case OsuAction.LeftButton: + case OsuAction.RightButton: + if (--downCount == 0) + ActiveCursor.ScaleTo(1, 200, Easing.OutQuad); + break; + } + + return false; + } + + public override bool HandleMouseInput => true; // OverlayContainer will set this false when we go hidden, but we always want to receive input. + + protected override void PopIn() + { + fadeContainer.FadeTo(1, 300, Easing.OutQuint); + ActiveCursor.ScaleTo(1, 400, Easing.OutQuint); + } + + protected override void PopOut() + { + fadeContainer.FadeTo(0.05f, 450, Easing.OutQuint); + ActiveCursor.ScaleTo(0.8f, 450, Easing.OutQuint); + } + public class OsuCursor : Container { private Container cursorContainer; @@ -131,45 +184,5 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor cursorContainer.Scale = new Vector2(scale); } } - - public bool OnPressed(OsuAction action) - { - switch (action) - { - case OsuAction.LeftButton: - case OsuAction.RightButton: - downCount++; - ActiveCursor.ScaleTo(1).ScaleTo(1.2f, 100, Easing.OutQuad); - break; - } - - return false; - } - - public bool OnReleased(OsuAction action) - { - switch (action) - { - case OsuAction.LeftButton: - case OsuAction.RightButton: - if (--downCount == 0) - ActiveCursor.ScaleTo(1, 200, Easing.OutQuad); - break; - } - - return false; - } - - protected override void PopIn() - { - ActiveCursor.FadeTo(1, 250, Easing.OutQuint); - ActiveCursor.ScaleTo(1, 400, Easing.OutQuint); - } - - protected override void PopOut() - { - ActiveCursor.FadeTo(0, 250, Easing.OutQuint); - ActiveCursor.ScaleTo(0.6f, 250, Easing.In); - } } } From f4965ee7d6d4c72a4f2a6ee24fb7fb6916b1990e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Mar 2018 20:06:25 +0900 Subject: [PATCH 05/27] Use high precision updating on CursorTrail Avoids bloackage --- osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index c56cd46131..d9a6b81f6b 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -19,7 +19,7 @@ using OpenTK.Graphics.ES30; namespace osu.Game.Rulesets.Osu.UI.Cursor { - internal class CursorTrail : Drawable + internal class CursorTrail : Drawable, IRequireHighFrequencyMousePosition { private int currentIndex; From 3ddaf1879d56a208834b36a1b9dd9ca6994760ec Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Mar 2018 20:11:27 +0900 Subject: [PATCH 06/27] CursorTrail always present, just to be safe --- osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index d9a6b81f6b..fed2105f21 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -32,6 +32,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private float time; + public override bool IsPresent => true; + private readonly TrailDrawNodeSharedData trailDrawNodeSharedData = new TrailDrawNodeSharedData(); private const int max_sprites = 2048; From 792a3ac469f758f37df40177a90599082ad859b4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Mar 2018 00:10:53 +0900 Subject: [PATCH 07/27] SkipButton -> SkipOverlay --- osu.Game.Tests/Visual/TestCaseSkipButton.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Play/{SkipButton.cs => SkipOverlay.cs} | 4 ++-- osu.Game/osu.Game.csproj | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename osu.Game/Screens/Play/{SkipButton.cs => SkipOverlay.cs} (95%) diff --git a/osu.Game.Tests/Visual/TestCaseSkipButton.cs b/osu.Game.Tests/Visual/TestCaseSkipButton.cs index a4d2019cd7..df94d5147f 100644 --- a/osu.Game.Tests/Visual/TestCaseSkipButton.cs +++ b/osu.Game.Tests/Visual/TestCaseSkipButton.cs @@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual { base.LoadComplete(); - Add(new SkipButton(Clock.CurrentTime + 5000)); + Add(new SkipOverlay(Clock.CurrentTime + 5000)); } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ad803ebc44..7f8881f463 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -183,7 +183,7 @@ namespace osu.Game.Screens.Play Alpha = 0, }, RulesetContainer, - new SkipButton(firstObjectTime) + new SkipOverlay(firstObjectTime) { Clock = Clock, // skip button doesn't want to use the audio clock directly ProcessCustomClock = false, diff --git a/osu.Game/Screens/Play/SkipButton.cs b/osu.Game/Screens/Play/SkipOverlay.cs similarity index 95% rename from osu.Game/Screens/Play/SkipButton.cs rename to osu.Game/Screens/Play/SkipOverlay.cs index c77061e5d9..5418a6c416 100644 --- a/osu.Game/Screens/Play/SkipButton.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -21,7 +21,7 @@ using osu.Game.Input.Bindings; namespace osu.Game.Screens.Play { - public class SkipButton : OverlayContainer, IKeyBindingHandler + public class SkipOverlay : OverlayContainer, IKeyBindingHandler { private readonly double startTime; @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Play protected override bool BlockPassThroughMouse => fadeContainer.IsHovered; - public SkipButton(double startTime) + public SkipOverlay(double startTime) { this.startTime = startTime; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 37e304d62d..406e251899 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -801,7 +801,7 @@ - + From d115c56742927401a82802bb0a21e5549e86f059 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Mar 2018 00:27:55 +0900 Subject: [PATCH 08/27] Avoid using input blocking --- osu.Game/Screens/Play/SkipOverlay.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 5418a6c416..923084c9e7 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -35,8 +35,7 @@ namespace osu.Game.Screens.Play private double displayTime; public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; - - protected override bool BlockPassThroughMouse => fadeContainer.IsHovered; + protected override bool BlockPassThroughMouse => false; public SkipOverlay(double startTime) { @@ -276,7 +275,7 @@ namespace osu.Game.Screens.Play flow.TransformSpacingTo(new Vector2(5), 500, Easing.OutQuint); box.FadeColour(colourHover, 500, Easing.OutQuint); background.FadeTo(0.4f, 500, Easing.OutQuint); - return base.OnHover(state); + return true; } protected override void OnHoverLost(InputState state) From 4aafc2228ecacf89b477f90bcbc7d60e0c192f3c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Mar 2018 00:53:40 +0900 Subject: [PATCH 09/27] Improve skip button behaviour when mouse buttons are down --- osu.Game/Screens/Play/SkipOverlay.cs | 37 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 923084c9e7..19ee0cb989 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -52,12 +52,6 @@ namespace osu.Game.Screens.Play Origin = Anchor.Centre; } - protected override bool OnMouseMove(InputState state) - { - fadeContainer.State = Visibility.Visible; - return base.OnMouseMove(state); - } - [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -122,15 +116,9 @@ namespace osu.Game.Screens.Play Expire(); } - protected override void PopIn() - { - this.FadeIn(); - } + protected override void PopIn() => this.FadeIn(); - protected override void PopOut() - { - this.FadeOut(); - } + protected override void PopOut() => this.FadeOut(); protected override void Update() { @@ -138,6 +126,13 @@ namespace osu.Game.Screens.Play remainingTimeBox.ResizeWidthTo((float)Math.Max(0, 1 - (Time.Current - displayTime) / (beginFadeTime - displayTime)), 120, Easing.OutQuint); } + protected override bool OnMouseMove(InputState state) + { + if (!state.Mouse.HasAnyButtonPressed) + fadeContainer.State = Visibility.Visible; + return base.OnMouseMove(state); + } + public bool OnPressed(GlobalAction action) { switch (action) @@ -177,7 +172,7 @@ namespace osu.Game.Screens.Play if (stateChanged) this.FadeIn(500, Easing.OutExpo); - if (!IsHovered) + if (!IsHovered && !IsDragged) using (BeginDelayedSequence(1000)) scheduledHide = Schedule(() => State = Visibility.Hidden); break; @@ -195,6 +190,18 @@ namespace osu.Game.Screens.Play base.LoadComplete(); State = Visibility.Visible; } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + scheduledHide?.Cancel(); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + State = Visibility.Visible; + return base.OnMouseUp(state, args); + } } private class Button : OsuClickableContainer From d3e91024a7cb9dd52185b5f067e304ffa8df3bd9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 8 Mar 2018 18:16:23 +0900 Subject: [PATCH 10/27] Block player enter when a drag initiates from an overlaying container --- osu.Game/Screens/Play/PlayerLoader.cs | 19 ++++++++++++++++--- .../PlayerSettings/PlayerSettingsGroup.cs | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 2950990779..e082e3f8de 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -22,7 +23,6 @@ namespace osu.Game.Screens.Play private Player player; private BeatmapMetadataDisplay info; - private VisualSettings visualSettings; private bool showOverlays = true; public override bool ShowOverlaysOnEnter => showOverlays; @@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play Anchor = Anchor.Centre, Origin = Anchor.Centre, }); - Add(visualSettings = new VisualSettings + Add(new VisualSettings { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -116,9 +116,22 @@ namespace osu.Game.Screens.Play logo.Delay(resuming ? 0 : 500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo); } + private bool weHandledMouseDown; + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + weHandledMouseDown = true; + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + weHandledMouseDown = false; + return base.OnMouseUp(state, args); + } + private void pushWhenLoaded() { - if (player.LoadState != LoadState.Ready || visualSettings.IsHovered) + if (player.LoadState != LoadState.Ready || !IsHovered || GetContainingInputManager().CurrentState.Mouse.HasAnyButtonPressed && !weHandledMouseDown) { Schedule(pushWhenLoaded); return; diff --git a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs index 95b464154a..e0de89535e 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlayerSettingsGroup.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -133,5 +134,8 @@ namespace osu.Game.Screens.Play.PlayerSettings } protected override Container Content => content; + + protected override bool OnHover(InputState state) => true; + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; } } From 94ed4ab01b3748a7df6c58925b5f68bb35278943 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 8 Mar 2018 20:28:55 +0900 Subject: [PATCH 11/27] Add debouncing to player loading Allows the mouse to temporarily exit and re-enter overlay elements without triggering a load --- osu.Game/Screens/Play/PlayerLoader.cs | 42 +++++++++++++++++---------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index e082e3f8de..b91272de75 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -13,6 +13,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Screens.Backgrounds; using OpenTK; using osu.Framework.Localisation; +using osu.Framework.Threading; using osu.Game.Screens.Menu; using osu.Game.Screens.Play.PlayerSettings; @@ -51,6 +52,7 @@ namespace osu.Game.Screens.Play Anchor = Anchor.Centre, Origin = Anchor.Centre, }); + Add(new VisualSettings { Anchor = Anchor.TopRight, @@ -100,7 +102,7 @@ namespace osu.Game.Screens.Play contentIn(); info.Delay(750).FadeIn(500); - this.Delay(2150).Schedule(pushWhenLoaded); + this.Delay(1800).Schedule(pushWhenLoaded); } protected override void LogoArriving(OsuLogo logo, bool resuming) @@ -129,29 +131,39 @@ namespace osu.Game.Screens.Play return base.OnMouseUp(state, args); } + private ScheduledDelegate pushDebounce; + + private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && (!GetContainingInputManager().CurrentState.Mouse.HasAnyButtonPressed || weHandledMouseDown); + private void pushWhenLoaded() { - if (player.LoadState != LoadState.Ready || !IsHovered || GetContainingInputManager().CurrentState.Mouse.HasAnyButtonPressed && !weHandledMouseDown) + Schedule(pushWhenLoaded); + + if (!readyForPush) { - Schedule(pushWhenLoaded); + pushDebounce?.Cancel(); + pushDebounce = null; return; } - contentOut(); - - this.Delay(250).Schedule(() => + if (pushDebounce == null) pushDebounce = Scheduler.AddDelayed(() => { - if (!IsCurrentScreen) return; + contentOut(); - if (!Push(player)) - Exit(); - else + this.Delay(250).Schedule(() => { - //By default, we want to load the player and never be returned to. - //Note that this may change if the player we load requested a re-run. - ValidForResume = false; - } - }); + if (!IsCurrentScreen) return; + + if (!Push(player)) + Exit(); + else + { + //By default, we want to load the player and never be returned to. + //Note that this may change if the player we load requested a re-run. + ValidForResume = false; + } + }); + }, 500); } protected override bool OnExiting(Screen next) From 3b766b8ec869c7503ea79c130c09a4608d58785d Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 9 Mar 2018 23:11:48 +0900 Subject: [PATCH 12/27] Make CaptureBox account for changes in hitobject states --- osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs index 269dd79bf7..6702678448 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs @@ -42,6 +42,13 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection private void load(OsuColour colours) { BorderColour = colours.Yellow; + } + + protected override void Update() + { + base.Update(); + + // Todo: We might need to optimise this // Move the rectangle to cover the hitobjects var topLeft = new Vector2(float.MaxValue, float.MaxValue); From 4a48136e4f558ca4cba581534de4c256be5e434b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 9 Mar 2018 23:12:34 +0900 Subject: [PATCH 13/27] Make hitobject positions adjustable --- .../Selection/Overlays/HitCircleOverlay.cs | 2 ++ .../Selection/Overlays/SliderOverlay.cs | 11 +++++---- .../Objects/Drawables/DrawableHitCircle.cs | 2 ++ .../Objects/Drawables/DrawableSlider.cs | 6 +++-- .../Objects/Drawables/DrawableSliderHead.cs | 14 +++++++++++ .../Objects/Drawables/DrawableSliderTail.cs | 4 +++- osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs | 24 +++++++++++++++++-- osu.Game.Rulesets.Osu/Objects/Slider.cs | 4 ++-- osu.Game.Rulesets.Osu/Objects/SliderCircle.cs | 19 +++++++++++++++ .../osu.Game.Rulesets.Osu.csproj | 2 ++ .../Edit/Layers/Selection/HitObjectOverlay.cs | 18 ++++++++++++++ .../Edit/Types/IHasEditablePosition.cs | 12 ++++++++++ osu.Game/osu.Game.csproj | 1 + 13 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs create mode 100644 osu.Game.Rulesets.Osu/Objects/SliderCircle.cs create mode 100644 osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs index 4e64783840..ea5104af18 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs @@ -22,6 +22,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays Scale = hitCircle.Scale; AddInternal(new RingPiece()); + + hitCircle.HitObject.PositionChanged += _ => Position = hitCircle.Position; } [BackgroundDependencyLoader] diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs index a035a683e9..f63d8f0c62 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs @@ -22,18 +22,22 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays { this.slider = slider; - var obj = (Slider)slider.HitObject; + Position = slider.Position; + + var sliderObject = (Slider)slider.HitObject; InternalChildren = new Drawable[] { - body = new SliderBody(obj) + body = new SliderBody(sliderObject) { AccentColour = Color4.Transparent, - PathWidth = obj.Scale * 64 + PathWidth = sliderObject.Scale * 64 }, new SliderCircleOverlay(slider.HeadCircle, slider), new SliderCircleOverlay(slider.TailCircle, slider), }; + + sliderObject.PositionChanged += _ => Position = slider.Position; } [BackgroundDependencyLoader] @@ -46,7 +50,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays { base.Update(); - Position = slider.Position; Size = slider.Size; OriginPosition = slider.OriginPosition; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 959c87bbba..d70b26e181 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -66,6 +66,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables //may not be so correct Size = circle.DrawSize; + + HitObject.PositionChanged += _ => Position = HitObject.StackedPosition; } protected override void CheckForJudgements(bool userTriggered, double timeOffset) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index f715ed075c..3fa047a780 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -55,8 +55,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables AlwaysPresent = true, Alpha = 0 }, - HeadCircle = new DrawableHitCircle(s.HeadCircle) { Position = s.TailCircle.Position - s.Position }, - TailCircle = new DrawableSliderTail(s.TailCircle) { Position = s.TailCircle.Position - s.Position } + HeadCircle = new DrawableSliderHead(s, s.HeadCircle), + TailCircle = new DrawableSliderTail(s, s.TailCircle) }; components.Add(Body); @@ -84,6 +84,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables components.Add(drawableRepeatPoint); AddNested(drawableRepeatPoint); } + + HitObject.PositionChanged += _ => Position = HitObject.StackedPosition; } [BackgroundDependencyLoader] diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs new file mode 100644 index 0000000000..dd31790ee0 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Osu.Objects.Drawables +{ + public class DrawableSliderHead : DrawableHitCircle + { + public DrawableSliderHead(Slider slider, HitCircle h) + : base(h) + { + Position = HitObject.Position - slider.Position; + } + } +} diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs index b907aea8c3..b277e7df7a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public bool Tracking { get; set; } - public DrawableSliderTail(HitCircle hitCircle) + public DrawableSliderTail(Slider slider, HitCircle hitCircle) : base(hitCircle) { Origin = Anchor.Centre; @@ -25,6 +25,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables FillMode = FillMode.Fit; AlwaysPresent = true; + + Position = HitObject.Position - slider.Position; } protected override void CheckForJudgements(bool userTriggered, double timeOffset) diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs index 9b9d88f0f6..93eaf70589 100644 --- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs @@ -1,23 +1,41 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects; using OpenTK; using osu.Game.Rulesets.Objects.Types; using OpenTK.Graphics; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Edit.Types; namespace osu.Game.Rulesets.Osu.Objects { - public abstract class OsuHitObject : HitObject, IHasCombo, IHasPosition + public abstract class OsuHitObject : HitObject, IHasCombo, IHasPosition, IHasEditablePosition { public const double OBJECT_RADIUS = 64; + public event Action PositionChanged; + public double TimePreempt = 600; public double TimeFadein = 400; - public Vector2 Position { get; set; } + private Vector2 position; + + public Vector2 Position + { + get => position; + set + { + if (position == value) + return; + position = value; + + PositionChanged?.Invoke(value); + } + } + public float X => Position.X; public float Y => Position.Y; @@ -48,5 +66,7 @@ namespace osu.Game.Rulesets.Osu.Objects Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2; } + + public virtual void SetPosition(Vector2 offset) => Position += offset; } } diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 76439ca530..a633e3957e 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Osu.Objects private void createSliderEnds() { - HeadCircle = new HitCircle + HeadCircle = new SliderCircle(this) { StartTime = StartTime, Position = Position, @@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Osu.Objects SampleControlPoint = SampleControlPoint }; - TailCircle = new HitCircle + TailCircle = new SliderCircle(this) { StartTime = EndTime, Position = EndPosition, diff --git a/osu.Game.Rulesets.Osu/Objects/SliderCircle.cs b/osu.Game.Rulesets.Osu/Objects/SliderCircle.cs new file mode 100644 index 0000000000..31ea67bbe0 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Objects/SliderCircle.cs @@ -0,0 +1,19 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; + +namespace osu.Game.Rulesets.Osu.Objects +{ + public class SliderCircle : HitCircle + { + private readonly Slider slider; + + public SliderCircle(Slider slider) + { + this.slider = slider; + } + + public override void SetPosition(Vector2 offset) => slider.SetPosition(offset); + } +} diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 8e8a01b009..d6fe87660f 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -87,6 +87,7 @@ + @@ -117,6 +118,7 @@ + diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs index 543dd2cc54..803e86ae77 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics.Containers; +using osu.Framework.Input; +using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Edit.Layers.Selection @@ -19,6 +21,22 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection State = Visibility.Visible; } + protected override bool OnDragStart(InputState state) => hitObject.HitObject is IHasEditablePosition; + + protected override bool OnDrag(InputState state) + { + switch (hitObject.HitObject) + { + case IHasEditablePosition editablePosition: + editablePosition.SetPosition(state.Mouse.Delta); + break; + } + + return true; + } + + protected override bool OnDragEnd(InputState state) => true; + protected override void PopIn() => Alpha = 1; protected override void PopOut() => Alpha = 0; } diff --git a/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs b/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs new file mode 100644 index 0000000000..79694e37a7 --- /dev/null +++ b/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; + +namespace osu.Game.Rulesets.Edit.Types +{ + public interface IHasEditablePosition + { + void SetPosition(Vector2 offset); + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index d10f0085cc..aee38d85bc 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -365,6 +365,7 @@ + From ad72d3816b7e90f648ff1509b1ebf1446e44b3d2 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 9 Mar 2018 23:43:50 +0900 Subject: [PATCH 14/27] Allow dragging anywhere in a capture box to move objects --- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 1 + .../Edit/Layers/Selection/CaptureBox.cs | 19 ++++++++++++ .../Edit/Layers/Selection/HitObjectOverlay.cs | 31 ++----------------- .../Layers/Selection/HitObjectOverlayLayer.cs | 29 ++++++++++++++--- .../Edit/Layers/Selection/SelectionLayer.cs | 6 ++++ 5 files changed, 53 insertions(+), 33 deletions(-) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index e6a51cc39b..383adca136 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -108,6 +108,7 @@ namespace osu.Game.Rulesets.Edit selectionLayer.ObjectSelected += hitObjectOverlayLayer.AddOverlay; selectionLayer.ObjectDeselected += hitObjectOverlayLayer.RemoveOverlay; + selectionLayer.SelectionMovementRequested += hitObjectOverlayLayer.MoveObjects; toolboxCollection.Items = new[] { new RadioButton("Select", () => setCompositionTool(null)) } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs index 6702678448..1454c78014 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs @@ -1,11 +1,13 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Game.Graphics; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; @@ -17,6 +19,11 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// public class CaptureBox : VisibilityContainer { + /// + /// Invoked when the captured s should be moved. + /// + public event Action MovementRequested; + private readonly IDrawable captureArea; private readonly IReadOnlyList capturedObjects; @@ -67,6 +74,18 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection Position = topLeft; } + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; + + protected override bool OnDragStart(InputState state) => true; + + protected override bool OnDrag(InputState state) + { + MovementRequested?.Invoke(state.Mouse.Delta); + return true; + } + + protected override bool OnDragEnd(InputState state) => true; + public override bool DisposeOnDeathRemoval => true; protected override void PopIn() => this.FadeIn(); diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs index 803e86ae77..8c58275943 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs @@ -2,42 +2,17 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics.Containers; -using osu.Framework.Input; -using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Edit.Layers.Selection { - public class HitObjectOverlay : OverlayContainer + public class HitObjectOverlay : Container { - // ReSharper disable once NotAccessedField.Local - // This will be used later to handle drag movement, etc - private readonly DrawableHitObject hitObject; + public readonly DrawableHitObject HitObject; public HitObjectOverlay(DrawableHitObject hitObject) { - this.hitObject = hitObject; - - State = Visibility.Visible; + HitObject = hitObject; } - - protected override bool OnDragStart(InputState state) => hitObject.HitObject is IHasEditablePosition; - - protected override bool OnDrag(InputState state) - { - switch (hitObject.HitObject) - { - case IHasEditablePosition editablePosition: - editablePosition.SetPosition(state.Mouse.Delta); - break; - } - - return true; - } - - protected override bool OnDragEnd(InputState state) => true; - - protected override void PopIn() => Alpha = 1; - protected override void PopOut() => Alpha = 0; } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs index 0b6e63d1fe..bb8496e9c6 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs @@ -1,20 +1,25 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; +using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input; +using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Objects.Drawables; +using OpenTK; namespace osu.Game.Rulesets.Edit.Layers.Selection { public class HitObjectOverlayLayer : CompositeDrawable { - private readonly Dictionary existingOverlays = new Dictionary(); + private readonly Container overlayContainer; public HitObjectOverlayLayer() { RelativeSizeAxes = Axes.Both; + + InternalChild = overlayContainer = new Container { RelativeSizeAxes = Axes.Both }; } /// @@ -27,8 +32,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection if (overlay == null) return; - existingOverlays[hitObject] = overlay; - AddInternal(overlay); + overlayContainer.Add(overlay); } /// @@ -37,13 +41,28 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// The to remove the overlay for. public void RemoveOverlay(DrawableHitObject hitObject) { - if (!existingOverlays.TryGetValue(hitObject, out var existing)) + var existing = overlayContainer.FirstOrDefault(h => h.HitObject == hitObject); + if (existing == null) return; existing.Hide(); existing.Expire(); } + public void MoveObjects(Vector2 offset) + { + // Todo: Various forms of snapping + foreach (var hitObject in overlayContainer.Select(o => o.HitObject.HitObject)) + { + switch (hitObject) + { + case IHasEditablePosition editablePosition: + editablePosition.SetPosition(offset); + break; + } + } + } + /// /// Creates a for a specific . /// diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs index 3895d34d7f..0383b933ab 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs @@ -27,6 +27,11 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// public event Action ObjectDeselected; + /// + /// Invoked when the selected s should be moved. + /// + public event Action SelectionMovementRequested; + private readonly Playfield playfield; public SelectionLayer(Playfield playfield) @@ -192,6 +197,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection return; AddInternal(captureBox = new CaptureBox(this, selectedHitObjects.ToList())); + captureBox.MovementRequested += v => SelectionMovementRequested?.Invoke(v); } } } From 376f6eec58afb79c510ad46ed0e7e8d0c9bd9955 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 10 Mar 2018 00:02:13 +0900 Subject: [PATCH 15/27] SetPosition -> OffsetPosition --- osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs | 2 +- osu.Game.Rulesets.Osu/Objects/SliderCircle.cs | 2 +- .../Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs | 2 +- osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs index 93eaf70589..339ad61b17 100644 --- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs @@ -67,6 +67,6 @@ namespace osu.Game.Rulesets.Osu.Objects Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2; } - public virtual void SetPosition(Vector2 offset) => Position += offset; + public virtual void OffsetPosition(Vector2 offset) => Position += offset; } } diff --git a/osu.Game.Rulesets.Osu/Objects/SliderCircle.cs b/osu.Game.Rulesets.Osu/Objects/SliderCircle.cs index 31ea67bbe0..1e83d02735 100644 --- a/osu.Game.Rulesets.Osu/Objects/SliderCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/SliderCircle.cs @@ -14,6 +14,6 @@ namespace osu.Game.Rulesets.Osu.Objects this.slider = slider; } - public override void SetPosition(Vector2 offset) => slider.SetPosition(offset); + public override void OffsetPosition(Vector2 offset) => slider.OffsetPosition(offset); } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs index bb8496e9c6..d391855f7a 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs @@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection switch (hitObject) { case IHasEditablePosition editablePosition: - editablePosition.SetPosition(offset); + editablePosition.OffsetPosition(state.Mouse.Delta); break; } } diff --git a/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs b/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs index 79694e37a7..3530dba8f4 100644 --- a/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs +++ b/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs @@ -7,6 +7,6 @@ namespace osu.Game.Rulesets.Edit.Types { public interface IHasEditablePosition { - void SetPosition(Vector2 offset); + void OffsetPosition(Vector2 offset); } } From 0e8fbc47b7610a8fc2f69e2a3aa47372c63d9b1f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 10 Mar 2018 00:02:51 +0900 Subject: [PATCH 16/27] Give HitObjectOverlayLayer full input state information --- osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs | 4 ++-- .../Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs | 3 +-- osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs index 1454c78014..970481032b 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs @@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// /// Invoked when the captured s should be moved. /// - public event Action MovementRequested; + public event Action MovementRequested; private readonly IDrawable captureArea; private readonly IReadOnlyList capturedObjects; @@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection protected override bool OnDrag(InputState state) { - MovementRequested?.Invoke(state.Mouse.Delta); + MovementRequested?.Invoke(state); return true; } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs index d391855f7a..438ba5e76d 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Objects.Drawables; -using OpenTK; namespace osu.Game.Rulesets.Edit.Layers.Selection { @@ -49,7 +48,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection existing.Expire(); } - public void MoveObjects(Vector2 offset) + public void MoveObjects(InputState state) { // Todo: Various forms of snapping foreach (var hitObject in overlayContainer.Select(o => o.HitObject.HitObject)) diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs index 0383b933ab..ca6c1c122a 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// /// Invoked when the selected s should be moved. /// - public event Action SelectionMovementRequested; + public event Action SelectionMovementRequested; private readonly Playfield playfield; From 4103c66cff25829c6acc0f9feb5ce5cff4060daa Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 10 Mar 2018 00:48:57 +0900 Subject: [PATCH 17/27] Move selection overlay to HitObjectOverlayLayer for extensibility --- .../Visual/TestCaseEditorSelectionLayer.cs | 2 +- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 3 +- .../Layers/Selection/HitObjectOverlayLayer.cs | 28 ++++++++------- .../Edit/Layers/Selection/SelectionLayer.cs | 26 +++++++------- .../{CaptureBox.cs => SelectionOverlay.cs} | 35 ++++++++++--------- osu.Game/osu.Game.csproj | 2 +- 6 files changed, 50 insertions(+), 46 deletions(-) rename osu.Game/Rulesets/Edit/Layers/Selection/{CaptureBox.cs => SelectionOverlay.cs} (68%) diff --git a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs index 8d12dfc517..dc8a13d044 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs @@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual { typeof(SelectionBox), typeof(SelectionLayer), - typeof(CaptureBox), + typeof(SelectionOverlay), typeof(HitObjectComposer), typeof(OsuHitObjectComposer), typeof(HitObjectOverlayLayer), diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 383adca136..914640622b 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -108,7 +108,8 @@ namespace osu.Game.Rulesets.Edit selectionLayer.ObjectSelected += hitObjectOverlayLayer.AddOverlay; selectionLayer.ObjectDeselected += hitObjectOverlayLayer.RemoveOverlay; - selectionLayer.SelectionMovementRequested += hitObjectOverlayLayer.MoveObjects; + selectionLayer.SelectionCleared += hitObjectOverlayLayer.RemoveSelectionOverlay; + selectionLayer.SelectionFinished += hitObjectOverlayLayer.AddSelectionOverlay; toolboxCollection.Items = new[] { new RadioButton("Select", () => setCompositionTool(null)) } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs index 438ba5e76d..24d594f59a 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs @@ -1,11 +1,10 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Input; -using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Edit.Layers.Selection @@ -48,18 +47,14 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection existing.Expire(); } - public void MoveObjects(InputState state) + private SelectionOverlay currentSelectionOverlay; + + public void AddSelectionOverlay() => AddInternal(currentSelectionOverlay = CreateSelectionOverlay(overlayContainer)); + + public void RemoveSelectionOverlay() { - // Todo: Various forms of snapping - foreach (var hitObject in overlayContainer.Select(o => o.HitObject.HitObject)) - { - switch (hitObject) - { - case IHasEditablePosition editablePosition: - editablePosition.OffsetPosition(state.Mouse.Delta); - break; - } - } + currentSelectionOverlay?.Hide(); + currentSelectionOverlay?.Expire(); } /// @@ -67,5 +62,12 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// /// The to create the overlay for. protected virtual HitObjectOverlay CreateOverlayFor(DrawableHitObject hitObject) => null; + + /// + /// Creates a which outlines s + /// and handles all hitobject movement/pattern adjustments. + /// + /// The overlays. + protected virtual SelectionOverlay CreateSelectionOverlay(IReadOnlyList overlays) => new SelectionOverlay(overlays); } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs index ca6c1c122a..2f8b9165c4 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs @@ -28,9 +28,14 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection public event Action ObjectDeselected; /// - /// Invoked when the selected s should be moved. + /// Invoked when the selection has been cleared. /// - public event Action SelectionMovementRequested; + public event Action SelectionCleared; + + /// + /// Invoked when the user has finished selecting all s. + /// + public event Action SelectionFinished; private readonly Playfield playfield; @@ -42,7 +47,6 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection } private SelectionBox selectionBox; - private CaptureBox captureBox; private readonly HashSet selectedHitObjects = new HashSet(); @@ -100,7 +104,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection if (!select(hitObject)) return; - clearCapture(); + clearSelection(); finishSelection(); } @@ -127,7 +131,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection if (!deselect(hitObject)) return; - clearCapture(); + clearSelection(); finishSelection(); } @@ -153,7 +157,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection selectedHitObjects.ForEach(h => ObjectDeselected?.Invoke(h)); selectedHitObjects.Clear(); - clearCapture(); + clearSelection(); } /// @@ -185,19 +189,13 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection select(target); } - private void clearCapture() - { - captureBox?.Hide(); - captureBox?.Expire(); - } + private void clearSelection() => SelectionCleared?.Invoke(); private void finishSelection() { if (selectedHitObjects.Count == 0) return; - - AddInternal(captureBox = new CaptureBox(this, selectedHitObjects.ToList())); - captureBox.MovementRequested += v => SelectionMovementRequested?.Invoke(v); + SelectionFinished?.Invoke(); } } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs similarity index 68% rename from osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs rename to osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs index 970481032b..c20769a912 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs @@ -1,14 +1,15 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Graphics; +using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; @@ -17,20 +18,13 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// /// A box which encloses s. /// - public class CaptureBox : VisibilityContainer + public class SelectionOverlay : VisibilityContainer { - /// - /// Invoked when the captured s should be moved. - /// - public event Action MovementRequested; + private readonly IReadOnlyList overlays; - private readonly IDrawable captureArea; - private readonly IReadOnlyList capturedObjects; - - public CaptureBox(IDrawable captureArea, IReadOnlyList capturedObjects) + public SelectionOverlay(IReadOnlyList overlays) { - this.captureArea = captureArea; - this.capturedObjects = capturedObjects; + this.overlays = overlays; Masking = true; BorderThickness = SelectionBox.BORDER_RADIUS; @@ -61,10 +55,10 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection var topLeft = new Vector2(float.MaxValue, float.MaxValue); var bottomRight = new Vector2(float.MinValue, float.MinValue); - foreach (var obj in capturedObjects) + foreach (var obj in overlays) { - topLeft = Vector2.ComponentMin(topLeft, captureArea.ToLocalSpace(obj.SelectionQuad.TopLeft)); - bottomRight = Vector2.ComponentMax(bottomRight, captureArea.ToLocalSpace(obj.SelectionQuad.BottomRight)); + topLeft = Vector2.ComponentMin(topLeft, Parent.ToLocalSpace(obj.HitObject.SelectionQuad.TopLeft)); + bottomRight = Vector2.ComponentMax(bottomRight, Parent.ToLocalSpace(obj.HitObject.SelectionQuad.BottomRight)); } topLeft -= new Vector2(5); @@ -80,7 +74,16 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection protected override bool OnDrag(InputState state) { - MovementRequested?.Invoke(state); + // Todo: Various forms of snapping + foreach (var hitObject in overlays.Select(o => o.HitObject.HitObject)) + { + switch (hitObject) + { + case IHasEditablePosition editablePosition: + editablePosition.OffsetPosition(state.Mouse.Delta); + break; + } + } return true; } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index aee38d85bc..fa99ae616a 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -362,7 +362,7 @@ - + From 92b302971f3f04ef3a852aab3098dca1a49563ab Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sat, 10 Mar 2018 01:23:53 +0900 Subject: [PATCH 18/27] Trim whitespace --- osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs index 339ad61b17..574063d4a5 100644 --- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs @@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.Objects if (position == value) return; position = value; - + PositionChanged?.Invoke(value); } } From df2815f19e658326d8197f642e6fde4a257679ad Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 11 Mar 2018 02:11:25 +0900 Subject: [PATCH 19/27] Add TestCase for GameplayCursor --- .../Tests/TestCaseGameplayCursor.cs | 33 +++++++++++++++++++ .../osu.Game.Rulesets.Osu.csproj | 1 + 2 files changed, 34 insertions(+) create mode 100644 osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs diff --git a/osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs b/osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs new file mode 100644 index 0000000000..0504c47123 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs @@ -0,0 +1,33 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Collections.Generic; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; +using osu.Game.Graphics.Cursor; +using osu.Game.Rulesets.Osu.UI.Cursor; +using osu.Game.Tests.Visual; + +namespace osu.Game.Rulesets.Osu.Tests +{ + [TestFixture] + public class TestCaseGameplayCursor : OsuTestCase, IProvideCursor + { + private GameplayCursor cursor; + + public override IReadOnlyList RequiredTypes => new [] { typeof(CursorTrail) }; + + public CursorContainer Cursor => cursor; + + public bool ProvidingUserCursor => true; + + [BackgroundDependencyLoader] + private void load() + { + Add(cursor = new GameplayCursor() { RelativeSizeAxes = Axes.Both }); + } + } +} diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 92cac71ad3..a7c060cd79 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -130,6 +130,7 @@ + From 5092fe5596c36e65c62be0cc453e7858d6a88a4e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 11 Mar 2018 02:11:56 +0900 Subject: [PATCH 20/27] Adjust cursor trail display length In line with shader change at https://github.com/ppy/osu-resources/pull/41/commits/ad5ddec7b2a2b989bd67eaa38919fb0619ed8a6f --- osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs index fed2105f21..dedfa28b7b 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/CursorTrail.cs @@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor const int fade_clock_reset_threshold = 1000000; - time = (float)(Time.Current - timeOffset) / 500f; + time = (float)(Time.Current - timeOffset) / 300f; if (time > fade_clock_reset_threshold) resetTime(); } From ccc3c573abd6e1ae018947db37f5f27d7475b483 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 11 Mar 2018 02:20:00 +0900 Subject: [PATCH 21/27] Fix resharper not fixing --- osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs b/osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs index 0504c47123..273422f2e9 100644 --- a/osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/Tests/TestCaseGameplayCursor.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.Tests [BackgroundDependencyLoader] private void load() { - Add(cursor = new GameplayCursor() { RelativeSizeAxes = Axes.Both }); + Add(cursor = new GameplayCursor { RelativeSizeAxes = Axes.Both }); } } } From 212142429f7ff0e6322c8b404a1ff90114458022 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 12 Mar 2018 17:25:34 +0900 Subject: [PATCH 22/27] Derive from IHasPosition --- osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs | 2 +- osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs index 574063d4a5..d9aed23414 100644 --- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs @@ -12,7 +12,7 @@ using osu.Game.Rulesets.Edit.Types; namespace osu.Game.Rulesets.Osu.Objects { - public abstract class OsuHitObject : HitObject, IHasCombo, IHasPosition, IHasEditablePosition + public abstract class OsuHitObject : HitObject, IHasCombo, IHasEditablePosition { public const double OBJECT_RADIUS = 64; diff --git a/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs b/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs index 3530dba8f4..fa101ed835 100644 --- a/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs +++ b/osu.Game/Rulesets/Edit/Types/IHasEditablePosition.cs @@ -1,11 +1,12 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Rulesets.Objects.Types; using OpenTK; namespace osu.Game.Rulesets.Edit.Types { - public interface IHasEditablePosition + public interface IHasEditablePosition : IHasPosition { void OffsetPosition(Vector2 offset); } From 8c4bcb4a04a8c45598c92c56f5ee65e6f7a2f761 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 12 Mar 2018 17:33:10 +0900 Subject: [PATCH 23/27] Only accept drag movement on the overlays --- .../Edit/Layers/Selection/Overlays/SliderOverlay.cs | 3 +++ osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs index f63d8f0c62..d478130868 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs @@ -8,6 +8,7 @@ using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; +using OpenTK; using OpenTK.Graphics; namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays @@ -56,5 +57,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays // Need to cause one update body.UpdateProgress(0); } + + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => body.ReceiveMouseInputAt(screenSpacePos); } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs index c20769a912..c3bb5911f8 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs @@ -68,6 +68,8 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection Position = topLeft; } + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => overlays.Any(o => o.ReceiveMouseInputAt(screenSpacePos)); + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; protected override bool OnDragStart(InputState state) => true; From ef8d59591445d0f18cddb4003ab7aa5ce859cf47 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 14 Mar 2018 11:44:19 +0900 Subject: [PATCH 24/27] Apply formatting changes --- osu.Game/Screens/Play/PlayerLoader.cs | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 3f25ef8a5e..cdb6f36a6f 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -112,6 +112,7 @@ namespace osu.Game.Screens.Play } private bool weHandledMouseDown; + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { weHandledMouseDown = true; @@ -139,24 +140,25 @@ namespace osu.Game.Screens.Play return; } - if (pushDebounce == null) pushDebounce = Scheduler.AddDelayed(() => - { - contentOut(); - - this.Delay(250).Schedule(() => + if (pushDebounce == null) + pushDebounce = Scheduler.AddDelayed(() => { - if (!IsCurrentScreen) return; + contentOut(); - if (!Push(player)) - Exit(); - else + this.Delay(250).Schedule(() => { - //By default, we want to load the player and never be returned to. - //Note that this may change if the player we load requested a re-run. - ValidForResume = false; - } - }); - }, 500); + if (!IsCurrentScreen) return; + + if (!Push(player)) + Exit(); + else + { + //By default, we want to load the player and never be returned to. + //Note that this may change if the player we load requested a re-run. + ValidForResume = false; + } + }); + }, 500); } protected override bool OnExiting(Screen next) From ea649f96504a72be9ebbcc55c2f70b6dd32e563b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 14 Mar 2018 12:01:15 +0900 Subject: [PATCH 25/27] Avoid scheduling during non-current screen --- osu.Game/Screens/Play/PlayerLoader.cs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index cdb6f36a6f..31e7313c0b 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -131,16 +131,22 @@ namespace osu.Game.Screens.Play private void pushWhenLoaded() { - Schedule(pushWhenLoaded); + if (!IsCurrentScreen) return; - if (!readyForPush) + try { - pushDebounce?.Cancel(); - pushDebounce = null; - return; - } + if (!readyForPush) + { + // as the pushDebounce below has a delay, we need to keep checking and cancel a future debounce + // if we become unready for push during the delay. + pushDebounce?.Cancel(); + pushDebounce = null; + return; + } + + if (pushDebounce != null) + return; - if (pushDebounce == null) pushDebounce = Scheduler.AddDelayed(() => { contentOut(); @@ -159,6 +165,11 @@ namespace osu.Game.Screens.Play } }); }, 500); + } + finally + { + Schedule(pushWhenLoaded); + } } protected override bool OnExiting(Screen next) From 81f82d98a14a3b09f412e49891da0c46e51515ea Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 14 Mar 2018 15:18:21 +0900 Subject: [PATCH 26/27] Rework a lot of naming and structure --- .../Selection/OsuHitObjectOverlayLayer.cs | 26 ---------- .../{HitCircleOverlay.cs => HitCircleMask.cs} | 6 +-- ...erCircleOverlay.cs => SliderCircleMask.cs} | 10 ++-- .../{SliderOverlay.cs => SliderMask.cs} | 10 ++-- .../Edit/OsuHitObjectComposer.cs | 18 +++++-- .../osu.Game.Rulesets.Osu.csproj | 7 ++- .../Visual/TestCaseEditorSelectionLayer.cs | 17 +++--- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 34 +++++++----- .../HitObjectOverlay.cs => HitObjectMask.cs} | 9 ++-- .../Edit/Layers/Selection/SelectionBox.cs | 49 ----------------- .../Screens/Compose}/Layers/BorderLayer.cs | 2 +- .../Compose/Layers/HitObjectMaskLayer.cs} | 37 +++++-------- .../Screens/Compose/Layers/SelectionBox.cs} | 15 +++--- .../Screens/Compose/Layers}/SelectionLayer.cs | 52 ++++++++++++++++--- osu.Game/Screens/Edit/Screens/EditorScreen.cs | 3 ++ osu.Game/osu.Game.csproj | 11 ++-- 16 files changed, 141 insertions(+), 165 deletions(-) delete mode 100644 osu.Game.Rulesets.Osu/Edit/Layers/Selection/OsuHitObjectOverlayLayer.cs rename osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/{HitCircleOverlay.cs => HitCircleMask.cs} (82%) rename osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/{SliderCircleOverlay.cs => SliderCircleMask.cs} (73%) rename osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/{SliderOverlay.cs => SliderMask.cs} (82%) rename osu.Game/Rulesets/Edit/{Layers/Selection/HitObjectOverlay.cs => HitObjectMask.cs} (56%) delete mode 100644 osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs rename osu.Game/{Rulesets/Edit => Screens/Edit/Screens/Compose}/Layers/BorderLayer.cs (92%) rename osu.Game/{Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs => Screens/Edit/Screens/Compose/Layers/HitObjectMaskLayer.cs} (51%) rename osu.Game/{Rulesets/Edit/Layers/Selection/SelectionOverlay.cs => Screens/Edit/Screens/Compose/Layers/SelectionBox.cs} (83%) rename osu.Game/{Rulesets/Edit/Layers/Selection => Screens/Edit/Screens/Compose/Layers}/SelectionLayer.cs (78%) diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/OsuHitObjectOverlayLayer.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/OsuHitObjectOverlayLayer.cs deleted file mode 100644 index e0d1b34ca5..0000000000 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/OsuHitObjectOverlayLayer.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Rulesets.Edit.Layers.Selection; -using osu.Game.Rulesets.Objects.Drawables; -using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays; -using osu.Game.Rulesets.Osu.Objects.Drawables; - -namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection -{ - public class OsuHitObjectOverlayLayer : HitObjectOverlayLayer - { - protected override HitObjectOverlay CreateOverlayFor(DrawableHitObject hitObject) - { - switch (hitObject) - { - case DrawableHitCircle circle: - return new HitCircleOverlay(circle); - case DrawableSlider slider: - return new SliderOverlay(slider); - } - - return base.CreateOverlayFor(hitObject); - } - } -} diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleMask.cs similarity index 82% rename from osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs rename to osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleMask.cs index ea5104af18..b48dd73bb5 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/HitCircleMask.cs @@ -4,15 +4,15 @@ using osu.Framework.Graphics; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Rulesets.Edit.Layers.Selection; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays { - public class HitCircleOverlay : HitObjectOverlay + public class HitCircleMask : HitObjectMask { - public HitCircleOverlay(DrawableHitCircle hitCircle) + public HitCircleMask(DrawableHitCircle hitCircle) : base(hitCircle) { Origin = Anchor.Centre; diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleMask.cs similarity index 73% rename from osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs rename to osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleMask.cs index 3c7f8a067b..2de8c2f64e 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderCircleMask.cs @@ -4,28 +4,28 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Rulesets.Edit.Layers.Selection; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using OpenTK; namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays { - public class SliderCircleOverlay : HitObjectOverlay + public class SliderCircleMask : HitObjectMask { - public SliderCircleOverlay(DrawableHitCircle sliderHead, DrawableSlider slider) + public SliderCircleMask(DrawableHitCircle sliderHead, DrawableSlider slider) : this(sliderHead, sliderHead.Position, slider) { } - public SliderCircleOverlay(DrawableSliderTail sliderTail, DrawableSlider slider) + public SliderCircleMask(DrawableSliderTail sliderTail, DrawableSlider slider) : this(sliderTail, sliderTail.Position, slider) { } private readonly DrawableOsuHitObject hitObject; - private SliderCircleOverlay(DrawableOsuHitObject hitObject, Vector2 position, DrawableSlider slider) + private SliderCircleMask(DrawableOsuHitObject hitObject, Vector2 position, DrawableSlider slider) : base(hitObject) { this.hitObject = hitObject; diff --git a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderMask.cs similarity index 82% rename from osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs rename to osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderMask.cs index d478130868..53f02617cd 100644 --- a/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderOverlay.cs +++ b/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderMask.cs @@ -4,7 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics; -using osu.Game.Rulesets.Edit.Layers.Selection; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; @@ -13,12 +13,12 @@ using OpenTK.Graphics; namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays { - public class SliderOverlay : HitObjectOverlay + public class SliderMask : HitObjectMask { private readonly SliderBody body; private readonly DrawableSlider slider; - public SliderOverlay(DrawableSlider slider) + public SliderMask(DrawableSlider slider) : base(slider) { this.slider = slider; @@ -34,8 +34,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays AccentColour = Color4.Transparent, PathWidth = sliderObject.Scale * 64 }, - new SliderCircleOverlay(slider.HeadCircle, slider), - new SliderCircleOverlay(slider.TailCircle, slider), + new SliderCircleMask(slider.HeadCircle, slider), + new SliderCircleMask(slider.TailCircle, slider), }; sliderObject.PositionChanged += _ => Position = slider.Position; diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 70d49a6b4f..026c85d909 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -5,10 +5,11 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; -using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Edit.Tools; -using osu.Game.Rulesets.Osu.Edit.Layers.Selection; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.UI; @@ -32,6 +33,17 @@ namespace osu.Game.Rulesets.Osu.Edit protected override ScalableContainer CreateLayerContainer() => new ScalableContainer(OsuPlayfield.BASE_SIZE.X) { RelativeSizeAxes = Axes.Both }; - protected override HitObjectOverlayLayer CreateHitObjectOverlayLayer() => new OsuHitObjectOverlayLayer(); + public override HitObjectMask CreateMaskFor(DrawableHitObject hitObject) + { + switch (hitObject) + { + case DrawableHitCircle circle: + return new HitCircleMask(circle); + case DrawableSlider slider: + return new SliderMask(slider); + } + + return base.CreateMaskFor(hitObject); + } } } diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index d6fe87660f..b8f56c1f5d 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -64,10 +64,9 @@ - - - - + + + diff --git a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs index dc8a13d044..a7e104dd81 100644 --- a/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs +++ b/osu.Game.Tests/Visual/TestCaseEditorSelectionLayer.cs @@ -8,13 +8,12 @@ using osu.Framework.Allocation; using OpenTK; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; -using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Edit; -using osu.Game.Rulesets.Osu.Edit.Layers.Selection; using osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Screens.Edit.Screens.Compose.Layers; using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Visual @@ -24,17 +23,15 @@ namespace osu.Game.Tests.Visual { public override IReadOnlyList RequiredTypes => new[] { - typeof(SelectionBox), typeof(SelectionLayer), - typeof(SelectionOverlay), + typeof(SelectionBox), typeof(HitObjectComposer), typeof(OsuHitObjectComposer), - typeof(HitObjectOverlayLayer), - typeof(OsuHitObjectOverlayLayer), - typeof(HitObjectOverlay), - typeof(HitCircleOverlay), - typeof(SliderOverlay), - typeof(SliderCircleOverlay) + typeof(HitObjectMaskLayer), + typeof(HitObjectMask), + typeof(HitCircleMask), + typeof(SliderMask), + typeof(SliderCircleMask) }; [BackgroundDependencyLoader] diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 914640622b..3dd8d503ed 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -10,10 +10,10 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Logging; using osu.Framework.Timing; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Edit.Layers; -using osu.Game.Rulesets.Edit.Layers.Selection; using osu.Game.Rulesets.Edit.Tools; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; +using osu.Game.Screens.Edit.Screens.Compose.Layers; using osu.Game.Screens.Edit.Screens.Compose.RadioButtons; namespace osu.Game.Rulesets.Edit @@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Edit return; } - HitObjectOverlayLayer hitObjectOverlayLayer = CreateHitObjectOverlayLayer(); + HitObjectMaskLayer hitObjectMaskLayer = new HitObjectMaskLayer(this); SelectionLayer selectionLayer = new SelectionLayer(rulesetContainer.Playfield); var layerBelowRuleset = new BorderLayer @@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Edit layerAboveRuleset.Children = new Drawable[] { selectionLayer, // Below object overlays for input - hitObjectOverlayLayer, + hitObjectMaskLayer, selectionLayer.CreateProxy() // Proxy above object overlays for selections }; @@ -106,10 +106,10 @@ namespace osu.Game.Rulesets.Edit } }; - selectionLayer.ObjectSelected += hitObjectOverlayLayer.AddOverlay; - selectionLayer.ObjectDeselected += hitObjectOverlayLayer.RemoveOverlay; - selectionLayer.SelectionCleared += hitObjectOverlayLayer.RemoveSelectionOverlay; - selectionLayer.SelectionFinished += hitObjectOverlayLayer.AddSelectionOverlay; + selectionLayer.ObjectSelected += hitObjectMaskLayer.AddOverlay; + selectionLayer.ObjectDeselected += hitObjectMaskLayer.RemoveOverlay; + selectionLayer.SelectionCleared += hitObjectMaskLayer.RemoveSelectionOverlay; + selectionLayer.SelectionFinished += hitObjectMaskLayer.AddSelectionOverlay; toolboxCollection.Items = new[] { new RadioButton("Select", () => setCompositionTool(null)) } @@ -140,14 +140,22 @@ namespace osu.Game.Rulesets.Edit protected abstract IReadOnlyList CompositionTools { get; } + /// + /// Creates a for a specific . + /// + /// The to create the overlay for. + public virtual HitObjectMask CreateMaskFor(DrawableHitObject hitObject) => null; + + /// + /// Creates a which outlines s + /// and handles all hitobject movement/pattern adjustments. + /// + /// The overlays. + public virtual SelectionBox CreateSelectionOverlay(IReadOnlyList overlays) => new SelectionBox(overlays); + /// /// Creates a which provides a layer above or below the . /// protected virtual ScalableContainer CreateLayerContainer() => new ScalableContainer { RelativeSizeAxes = Axes.Both }; - - /// - /// Creates the which overlays selected s. - /// - protected virtual HitObjectOverlayLayer CreateHitObjectOverlayLayer() => new HitObjectOverlayLayer(); } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs b/osu.Game/Rulesets/Edit/HitObjectMask.cs similarity index 56% rename from osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs rename to osu.Game/Rulesets/Edit/HitObjectMask.cs index 8c58275943..051b42fec6 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlay.cs +++ b/osu.Game/Rulesets/Edit/HitObjectMask.cs @@ -4,13 +4,16 @@ using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Objects.Drawables; -namespace osu.Game.Rulesets.Edit.Layers.Selection +namespace osu.Game.Rulesets.Edit { - public class HitObjectOverlay : Container + /// + /// A mask placed above a adding editing functionality. + /// + public class HitObjectMask : Container { public readonly DrawableHitObject HitObject; - public HitObjectOverlay(DrawableHitObject hitObject) + public HitObjectMask(DrawableHitObject hitObject) { HitObject = hitObject; } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs deleted file mode 100644 index 1c25846ee3..0000000000 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionBox.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Shapes; -using OpenTK.Graphics; - -namespace osu.Game.Rulesets.Edit.Layers.Selection -{ - /// - /// A box that represents a drag selection. - /// - public class SelectionBox : VisibilityContainer - { - public const float BORDER_RADIUS = 2; - - /// - /// Creates a new . - /// - public SelectionBox() - { - Masking = true; - BorderColour = Color4.White; - BorderThickness = BORDER_RADIUS; - - Child = new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0.1f - }; - } - - public void SetDragRectangle(RectangleF rectangle) - { - var topLeft = Parent.ToLocalSpace(rectangle.TopLeft); - var bottomRight = Parent.ToLocalSpace(rectangle.BottomRight); - - Position = topLeft; - Size = bottomRight - topLeft; - } - - public override bool DisposeOnDeathRemoval => true; - - protected override void PopIn() => this.FadeIn(250, Easing.OutQuint); - protected override void PopOut() => this.FadeOut(250, Easing.OutQuint); - } -} diff --git a/osu.Game/Rulesets/Edit/Layers/BorderLayer.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/BorderLayer.cs similarity index 92% rename from osu.Game/Rulesets/Edit/Layers/BorderLayer.cs rename to osu.Game/Screens/Edit/Screens/Compose/Layers/BorderLayer.cs index 54c30b8d89..49cf078d36 100644 --- a/osu.Game/Rulesets/Edit/Layers/BorderLayer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/BorderLayer.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using OpenTK.Graphics; -namespace osu.Game.Rulesets.Edit.Layers +namespace osu.Game.Screens.Edit.Screens.Compose.Layers { public class BorderLayer : Container { diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/HitObjectMaskLayer.cs similarity index 51% rename from osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs rename to osu.Game/Screens/Edit/Screens/Compose/Layers/HitObjectMaskLayer.cs index 24d594f59a..63b5538ad7 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectOverlayLayer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/HitObjectMaskLayer.cs @@ -1,23 +1,25 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects.Drawables; -namespace osu.Game.Rulesets.Edit.Layers.Selection +namespace osu.Game.Screens.Edit.Screens.Compose.Layers { - public class HitObjectOverlayLayer : CompositeDrawable + public class HitObjectMaskLayer : CompositeDrawable { - private readonly Container overlayContainer; + private readonly HitObjectComposer composer; + private readonly Container overlayContainer; - public HitObjectOverlayLayer() + public HitObjectMaskLayer(HitObjectComposer composer) { + this.composer = composer; RelativeSizeAxes = Axes.Both; - InternalChild = overlayContainer = new Container { RelativeSizeAxes = Axes.Both }; + InternalChild = overlayContainer = new Container { RelativeSizeAxes = Axes.Both }; } /// @@ -26,7 +28,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection /// The to create an overlay for. public void AddOverlay(DrawableHitObject hitObject) { - var overlay = CreateOverlayFor(hitObject); + var overlay = composer.CreateMaskFor(hitObject); if (overlay == null) return; @@ -47,27 +49,14 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection existing.Expire(); } - private SelectionOverlay currentSelectionOverlay; + private SelectionBox currentSelectionBox; - public void AddSelectionOverlay() => AddInternal(currentSelectionOverlay = CreateSelectionOverlay(overlayContainer)); + public void AddSelectionOverlay() => AddInternal(currentSelectionBox = composer.CreateSelectionOverlay(overlayContainer)); public void RemoveSelectionOverlay() { - currentSelectionOverlay?.Hide(); - currentSelectionOverlay?.Expire(); + currentSelectionBox?.Hide(); + currentSelectionBox?.Expire(); } - - /// - /// Creates a for a specific . - /// - /// The to create the overlay for. - protected virtual HitObjectOverlay CreateOverlayFor(DrawableHitObject hitObject) => null; - - /// - /// Creates a which outlines s - /// and handles all hitobject movement/pattern adjustments. - /// - /// The overlays. - protected virtual SelectionOverlay CreateSelectionOverlay(IReadOnlyList overlays) => new SelectionOverlay(overlays); } } diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionBox.cs similarity index 83% rename from osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs rename to osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionBox.cs index c3bb5911f8..0e5d824559 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionOverlay.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionBox.cs @@ -9,25 +9,28 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Graphics; +using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Types; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; -namespace osu.Game.Rulesets.Edit.Layers.Selection +namespace osu.Game.Screens.Edit.Screens.Compose.Layers { /// - /// A box which encloses s. + /// A box which surrounds s and provides interactive handles, context menus etc. /// - public class SelectionOverlay : VisibilityContainer + public class SelectionBox : VisibilityContainer { - private readonly IReadOnlyList overlays; + private readonly IReadOnlyList overlays; - public SelectionOverlay(IReadOnlyList overlays) + public const float BORDER_RADIUS = 2; + + public SelectionBox(IReadOnlyList overlays) { this.overlays = overlays; Masking = true; - BorderThickness = SelectionBox.BORDER_RADIUS; + BorderThickness = BORDER_RADIUS; InternalChild = new Box { diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionLayer.cs similarity index 78% rename from osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs rename to osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionLayer.cs index 2f8b9165c4..8c66007bb7 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs +++ b/osu.Game/Screens/Edit/Screens/Compose/Layers/SelectionLayer.cs @@ -8,12 +8,14 @@ using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Shapes; using osu.Framework.Input; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; using OpenTK; +using OpenTK.Graphics; -namespace osu.Game.Rulesets.Edit.Layers.Selection +namespace osu.Game.Screens.Edit.Screens.Compose.Layers { public class SelectionLayer : CompositeDrawable { @@ -46,7 +48,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection RelativeSizeAxes = Axes.Both; } - private SelectionBox selectionBox; + private DragBox dragBox; private readonly HashSet selectedHitObjects = new HashSet(); @@ -58,20 +60,20 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection protected override bool OnDragStart(InputState state) { - AddInternal(selectionBox = new SelectionBox()); + AddInternal(dragBox = new DragBox()); return true; } protected override bool OnDrag(InputState state) { - selectionBox.Show(); + dragBox.Show(); var dragPosition = state.Mouse.NativeState.Position; var dragStartPosition = state.Mouse.NativeState.PositionMouseDown ?? dragPosition; var screenSpaceDragQuad = new Quad(dragStartPosition.X, dragStartPosition.Y, dragPosition.X - dragStartPosition.X, dragPosition.Y - dragStartPosition.Y); - selectionBox.SetDragRectangle(screenSpaceDragQuad.AABBFloat); + dragBox.SetDragRectangle(screenSpaceDragQuad.AABBFloat); selectQuad(screenSpaceDragQuad); return true; @@ -79,8 +81,8 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection protected override bool OnDragEnd(InputState state) { - selectionBox.Hide(); - selectionBox.Expire(); + dragBox.Hide(); + dragBox.Expire(); finishSelection(); @@ -197,5 +199,41 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection return; SelectionFinished?.Invoke(); } + + /// + /// A box that represents a drag selection. + /// + private class DragBox : VisibilityContainer + { + /// + /// Creates a new . + /// + public DragBox() + { + Masking = true; + BorderColour = Color4.White; + BorderThickness = SelectionBox.BORDER_RADIUS; + + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.1f + }; + } + + public void SetDragRectangle(RectangleF rectangle) + { + var topLeft = Parent.ToLocalSpace(rectangle.TopLeft); + var bottomRight = Parent.ToLocalSpace(rectangle.BottomRight); + + Position = topLeft; + Size = bottomRight - topLeft; + } + + public override bool DisposeOnDeathRemoval => true; + + protected override void PopIn() => this.FadeIn(250, Easing.OutQuint); + protected override void PopOut() => this.FadeOut(250, Easing.OutQuint); + } } } diff --git a/osu.Game/Screens/Edit/Screens/EditorScreen.cs b/osu.Game/Screens/Edit/Screens/EditorScreen.cs index 2e654b4373..009830502e 100644 --- a/osu.Game/Screens/Edit/Screens/EditorScreen.cs +++ b/osu.Game/Screens/Edit/Screens/EditorScreen.cs @@ -8,6 +8,9 @@ using osu.Game.Beatmaps; namespace osu.Game.Screens.Edit.Screens { + /// + /// TODO: eventually make this inherit Screen and add a local scren stack inside the Editor. + /// public class EditorScreen : Container { public readonly Bindable Beatmap = new Bindable(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fa99ae616a..14d2381640 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -361,10 +361,7 @@ - - - - + @@ -379,6 +376,10 @@ + + + + @@ -393,8 +394,6 @@ - - From 7ded1635fa3ca0dab91fa67b0fece002e13c1103 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 16 Mar 2018 14:43:14 +0900 Subject: [PATCH 27/27] Update submodules --- osu-framework | 2 +- osu-resources | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index d29c8365ba..cd6f6e93c9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit d29c8365ba3cf7924b57cf22341f4af55658764c +Subproject commit cd6f6e93c958e3e4e98db08dd7a443cabcf4742f diff --git a/osu-resources b/osu-resources index 92ec3d10b1..7bb0782200 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 92ec3d10b12c5e9bfc1d3b05d3db174a506efd6d +Subproject commit 7bb0782200abadf73b79ed1a3bc1d5b926c6a81e