From ae032cbf2376bce33f29bf4b34dc9471b8585323 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sun, 7 Jan 2018 23:40:00 +0300 Subject: [PATCH 01/31] Support HandleKeyboardInput, HandleMouseInput, CanReceiveKeyboardInput, CanReceiveMouseInput properties --- osu.Desktop/Overlays/VersionManager.cs | 3 ++- .../Objects/Drawables/Pieces/SpinnerBackground.cs | 3 ++- osu.Game/Graphics/Backgrounds/Triangles.cs | 4 +++- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 4 +++- osu.Game/Overlays/OnScreenDisplay.cs | 3 ++- osu.Game/Overlays/Profile/ProfileHeader.cs | 7 +++++-- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 4 +++- .../Edit/Layers/Selection/HitObjectSelectionBox.cs | 3 ++- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 3 ++- osu.Game/Screens/Menu/Button.cs | 4 +++- osu.Game/Screens/Menu/ButtonSystem.cs | 4 +++- osu.Game/Screens/Menu/LogoVisualisation.cs | 3 ++- osu.Game/Screens/Menu/MenuSideFlashes.cs | 3 ++- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 4 +++- osu.Game/Screens/Play/KeyCounterCollection.cs | 4 +++- osu.Game/Screens/Play/SongProgress.cs | 3 ++- osu.Game/Screens/Play/SquareGraph.cs | 3 ++- osu.Game/Screens/Select/BeatmapCarousel.cs | 3 ++- osu.Game/Storyboards/Drawables/DrawableStoryboard.cs | 3 ++- 19 files changed, 48 insertions(+), 20 deletions(-) diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 923356c610..090173f38d 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -31,7 +31,8 @@ namespace osu.Desktop.Overlays private OsuConfigManager config; private OsuGameBase game; - public override bool HandleInput => false; + public override bool HandleKeyboardInput => false; + public override bool HandleMouseInput => false; [BackgroundDependencyLoader] private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs index 7c96a2a8cf..c44d7594ad 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SpinnerBackground.cs @@ -11,7 +11,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces { public class SpinnerBackground : CircularContainer, IHasAccentColour { - public override bool HandleInput => false; + public override bool HandleKeyboardInput => false; + public override bool HandleMouseInput => false; protected Box Disc; diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 5e23389b89..6f9d83473f 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -30,7 +30,9 @@ namespace osu.Game.Graphics.Backgrounds /// private const float edge_smoothness = 1; - public override bool HandleInput => false; + public override bool HandleKeyboardInput => false; + public override bool HandleMouseInput => false; + public Color4 ColourLight = Color4.White; public Color4 ColourDark = Color4.Black; diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 99afc02d5d..566254886e 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -42,7 +42,9 @@ namespace osu.Game.Graphics.UserInterface //don't allow clicking between transitions and don't make the chevron clickable public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceiveMouseInputAt(screenSpacePos); - public override bool HandleInput => State == Visibility.Visible; + public override bool HandleKeyboardInput => handleInput; + public override bool HandleMouseInput => handleInput; + private bool handleInput => State == Visibility.Visible; private Visibility state; diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 6a1bd8e182..ce31f10fc4 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -22,7 +22,8 @@ namespace osu.Game.Overlays { private readonly Container box; - public override bool HandleInput => false; + public override bool HandleKeyboardInput => false; + public override bool HandleMouseInput => false; private readonly SpriteText textLine1; private readonly SpriteText textLine2; diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 6a9f4b84b0..450979a261 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -474,7 +474,8 @@ namespace osu.Game.Overlays.Profile private class LinkFlowContainer : OsuTextFlowContainer { - public override bool HandleInput => true; + public override bool HandleKeyboardInput => true; + public override bool HandleMouseInput => true; public LinkFlowContainer(Action defaultCreationParameters = null) : base(defaultCreationParameters) { @@ -488,7 +489,9 @@ namespace osu.Game.Overlays.Profile { private readonly OsuHoverContainer content; - public override bool HandleInput => content.Action != null; + public override bool HandleKeyboardInput => handleInput; + public override bool HandleMouseInput => handleInput; + private bool handleInput => content.Action != null; protected override Container Content => content ?? (Container)this; diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 0fa6fa23a2..2acc1075a3 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -87,7 +87,9 @@ namespace osu.Game.Overlays.Toolbar ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault(); } - public override bool HandleInput => !ruleset.Disabled; + public override bool HandleKeyboardInput => handleInput; + public override bool HandleMouseInput => handleInput; + private bool handleInput => !ruleset.Disabled; private void disabledChanged(bool isDisabled) => this.FadeColour(isDisabled ? Color4.Gray : Color4.White, 300); diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs index c840cb0c38..fcb2f8f57f 100644 --- a/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs +++ b/osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs @@ -165,7 +165,8 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection } private bool isActive = true; - public override bool HandleInput => isActive; + public override bool HandleKeyboardInput => isActive; + public override bool HandleMouseInput => isActive; public override void Hide() { diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 34c34e1d33..546281df44 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -61,7 +61,8 @@ namespace osu.Game.Rulesets.Objects.Drawables public new readonly TObject HitObject; - public override bool HandleInput => Interactive; + public override bool HandleKeyboardInput => Interactive; + public override bool HandleMouseInput => Interactive; public bool Interactive = true; /// diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index f5dd5cb500..fff2435cb4 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -222,7 +222,9 @@ namespace osu.Game.Screens.Menu boxHoverLayer.FadeOut(800, Easing.OutExpo); } - public override bool HandleInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f; + public override bool HandleKeyboardInput => handleInput; + public override bool HandleMouseInput => handleInput; + private bool handleInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f; protected override void Update() { diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 72fe4368f0..b77dc4a656 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -200,7 +200,9 @@ namespace osu.Game.Screens.Menu private MenuState state; - public override bool HandleInput => state != MenuState.Exit; + public override bool HandleKeyboardInput => handleInput; + public override bool HandleMouseInput => handleInput; + private bool handleInput=> state != MenuState.Exit; public MenuState State { diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index 3fb5cc6d0d..3a3f3d4650 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -64,7 +64,8 @@ namespace osu.Game.Screens.Menu private readonly float[] frequencyAmplitudes = new float[256]; - public override bool HandleInput => false; + public override bool HandleKeyboardInput => false; + public override bool HandleMouseInput => false; private Shader shader; private readonly Texture texture; diff --git a/osu.Game/Screens/Menu/MenuSideFlashes.cs b/osu.Game/Screens/Menu/MenuSideFlashes.cs index 3cf2ce8e89..f94e2bddc1 100644 --- a/osu.Game/Screens/Menu/MenuSideFlashes.cs +++ b/osu.Game/Screens/Menu/MenuSideFlashes.cs @@ -19,7 +19,8 @@ namespace osu.Game.Screens.Menu { public class MenuSideFlashes : BeatSyncedContainer { - public override bool HandleInput => false; + public override bool HandleKeyboardInput => false; + public override bool HandleMouseInput => false; private readonly Bindable beatmap = new Bindable(); diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index af222b82e2..8fa76e2e51 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -142,7 +142,9 @@ namespace osu.Game.Screens.Play } } - public override bool HandleInput => State == Visibility.Visible; + public override bool HandleKeyboardInput => handleInput; + public override bool HandleMouseInput => handleInput; + private bool handleInput => State == Visibility.Visible; protected override void PopIn() => this.FadeIn(transition_duration, Easing.In); protected override void PopOut() => this.FadeOut(transition_duration, Easing.In); diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index 554fbbaf61..c716841861 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -111,7 +111,9 @@ namespace osu.Game.Screens.Play } } - public override bool HandleInput => receptor == null; + public override bool HandleKeyboardInput => handleInput; + public override bool HandleMouseInput => handleInput; + private bool handleInput => receptor == null; private Receptor receptor; diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 897fe4bba7..8aad741ad1 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -28,7 +28,8 @@ namespace osu.Game.Screens.Play public Action OnSeek; - public override bool HandleInput => AllowSeeking; + public override bool HandleKeyboardInput => AllowSeeking; + public override bool HandleMouseInput => AllowSeeking; private IClock audioClock; public IClock AudioClock { set { audioClock = info.AudioClock = value; } } diff --git a/osu.Game/Screens/Play/SquareGraph.cs b/osu.Game/Screens/Play/SquareGraph.cs index 7bccad0c34..48013f7943 100644 --- a/osu.Game/Screens/Play/SquareGraph.cs +++ b/osu.Game/Screens/Play/SquareGraph.cs @@ -21,7 +21,8 @@ namespace osu.Game.Screens.Play public int ColumnCount => columns.Length; - public override bool HandleInput => false; + public override bool HandleKeyboardInput => false; + public override bool HandleMouseInput => false; private int progress; public int Progress diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 7a47bb9631..93b77fe1c4 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -51,7 +51,8 @@ namespace osu.Game.Screens.Select /// public Action SelectionChanged; - public override bool HandleInput => AllowSelection; + public override bool HandleKeyboardInput => AllowSelection; + public override bool HandleMouseInput => AllowSelection; /// /// Used to avoid firing null selections before the initial beatmaps have been loaded via . diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs index 7e8a80d86a..2489369493 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs @@ -26,7 +26,8 @@ namespace osu.Game.Storyboards.Drawables protected override Container Content => content; protected override Vector2 DrawScale => new Vector2(Parent.DrawHeight / 480); - public override bool HandleInput => false; + public override bool HandleKeyboardInput => false; + public override bool HandleMouseInput => false; private bool passing = true; public bool Passing From 2e235660ad6a5814d4dc0d4adb2baafc249c03b7 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 13:25:49 +0900 Subject: [PATCH 02/31] Fix skip button appearing below osu!mania's stage --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c24b5e0d2a..577991c500 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -176,13 +176,13 @@ namespace osu.Game.Screens.Play }, Children = new Drawable[] { - new SkipButton(firstObjectTime) { AudioClock = decoupledClock }, new Container { RelativeSizeAxes = Axes.Both, Clock = offsetClock, Child = RulesetContainer, }, + new SkipButton(firstObjectTime) { AudioClock = decoupledClock }, hudOverlay = new HUDOverlay { Anchor = Anchor.Centre, From 512e4d2c9fbf411cdf573ec3df82cc248a1aef5f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 18:13:17 +0900 Subject: [PATCH 03/31] Rewrite the way that cursor overrides are done game-wide --- .../Edit/OsuEditPlayfield.cs | 3 -- .../Edit/OsuEditRulesetContainer.cs | 3 ++ osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 15 ------ .../UI/OsuRulesetContainer.cs | 4 ++ .../Graphics/Cursor/IProvideLocalCursor.cs | 22 ++++++++ .../Graphics/Cursor/OsuCursorContainer.cs | 53 +++++++++++++++++++ osu.Game/OsuGame.cs | 4 -- osu.Game/OsuGameBase.cs | 23 +++----- osu.Game/Rulesets/UI/Playfield.cs | 5 -- osu.Game/Rulesets/UI/RulesetContainer.cs | 24 ++++++--- osu.Game/Screens/Menu/Disclaimer.cs | 7 ++- osu.Game/Screens/Menu/Intro.cs | 9 ++-- osu.Game/Screens/OsuScreen.cs | 2 - osu.Game/Screens/Play/Player.cs | 16 ++++-- osu.Game/osu.Game.csproj | 2 + 15 files changed, 132 insertions(+), 60 deletions(-) create mode 100644 osu.Game/Graphics/Cursor/IProvideLocalCursor.cs create mode 100644 osu.Game/Graphics/Cursor/OsuCursorContainer.cs diff --git a/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs b/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs index a3f0b79475..5f232b1889 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs @@ -1,15 +1,12 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Graphics.Cursor; using osu.Game.Rulesets.Osu.UI; namespace osu.Game.Rulesets.Osu.Edit { public class OsuEditPlayfield : OsuPlayfield { - protected override CursorContainer CreateCursor() => null; - protected override bool ProxyApproachCircles => false; } } diff --git a/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs b/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs index 96b9acbf78..56efc25fa5 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Graphics.Cursor; using osu.Game.Beatmaps; using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.UI; @@ -15,5 +16,7 @@ namespace osu.Game.Rulesets.Osu.Edit } protected override Playfield CreatePlayfield() => new OsuEditPlayfield(); + + protected override CursorContainer CreateCursor() => null; } } diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index e7d47da391..892df089f5 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -12,8 +12,6 @@ using osu.Game.Rulesets.UI; using System.Linq; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Osu.Judgements; -using osu.Game.Rulesets.Osu.UI.Cursor; -using osu.Framework.Graphics.Cursor; namespace osu.Game.Rulesets.Osu.UI { @@ -23,8 +21,6 @@ namespace osu.Game.Rulesets.Osu.UI private readonly Container judgementLayer; private readonly ConnectionRenderer connectionLayer; - public override bool ProvidingUserCursor => true; - // Todo: This should not be a thing, but is currently required for the editor // https://github.com/ppy/osu-framework/issues/1283 protected virtual bool ProxyApproachCircles => true; @@ -70,15 +66,6 @@ namespace osu.Game.Rulesets.Osu.UI }); } - protected override void LoadComplete() - { - base.LoadComplete(); - - var cursor = CreateCursor(); - if (cursor != null) - AddInternal(cursor); - } - public override void Add(DrawableHitObject h) { h.Depth = (float)h.HitObject.StartTime; @@ -113,7 +100,5 @@ namespace osu.Game.Rulesets.Osu.UI judgementLayer.Add(explosion); } - - protected virtual CursorContainer CreateCursor() => new GameplayCursor(); } } diff --git a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs index 5c7413a71e..526348062f 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Graphics.Cursor; using osu.Framework.Input; using OpenTK; using osu.Game.Beatmaps; @@ -10,6 +11,7 @@ using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Replays; using osu.Game.Rulesets.Osu.Scoring; +using osu.Game.Rulesets.Osu.UI.Cursor; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.Replays; @@ -49,5 +51,7 @@ namespace osu.Game.Rulesets.Osu.UI protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new OsuReplayInputHandler(replay); protected override Vector2 GetPlayfieldAspectAdjust() => new Vector2(0.75f); + + protected override CursorContainer CreateCursor() => new GameplayCursor(); } } diff --git a/osu.Game/Graphics/Cursor/IProvideLocalCursor.cs b/osu.Game/Graphics/Cursor/IProvideLocalCursor.cs new file mode 100644 index 0000000000..61631b1220 --- /dev/null +++ b/osu.Game/Graphics/Cursor/IProvideLocalCursor.cs @@ -0,0 +1,22 @@ +// 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.Cursor; + +namespace osu.Game.Graphics.Cursor +{ + public interface IProvideLocalCursor : IDrawable + { + /// + /// The cursor provided by this . + /// + CursorContainer LocalCursor { get; } + + /// + /// Whether the cursor provided by this should be displayed. + /// If this is false, a cursor occurring earlier in the draw hierarchy will be displayed instead. + /// + bool ProvidesUserCursor { get; } + } +} diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs new file mode 100644 index 0000000000..ca6b6085c2 --- /dev/null +++ b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs @@ -0,0 +1,53 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Input; + +namespace osu.Game.Graphics.Cursor +{ + public class OsuCursorContainer : Container, IProvideLocalCursor + { + protected override Container Content => content; + private readonly Container content; + + public CursorContainer LocalCursor { get; } + public bool ProvidesUserCursor => true; + + public OsuCursorContainer() + { + AddRangeInternal(new Drawable[] + { + LocalCursor = new MenuCursor { State = Visibility.Hidden }, + content = new Container { RelativeSizeAxes = Axes.Both } + }); + } + + private InputManager inputManager; + + protected override void LoadComplete() + { + base.LoadComplete(); + inputManager = GetContainingInputManager(); + } + + private IProvideLocalCursor currentTarget; + protected override void Update() + { + base.Update(); + + var newTarget = inputManager.HoveredDrawables.OfType().FirstOrDefault(t => t.ProvidesUserCursor) ?? this; + + if (currentTarget == newTarget) + return; + + currentTarget?.LocalCursor?.Hide(); + newTarget.LocalCursor?.Show(); + + currentTarget = newTarget; + } + } +} diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 5604ef8f3c..f0edcbbc6b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -297,8 +297,6 @@ namespace osu.Game else Toolbar.State = Visibility.Visible; }; - - Cursor.State = Visibility.Hidden; } private void forwardLoggedErrorsToNotifications() @@ -446,8 +444,6 @@ namespace osu.Game Beatmap.Disabled = applyRestrictions; mainContent.Padding = new MarginPadding { Top = ToolbarOffset }; - - Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 1982fa0db5..ff9264c598 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -52,8 +52,6 @@ namespace osu.Game protected override Container Content => content; - protected MenuCursor Cursor; - public Bindable Beatmap { get; private set; } private Bindable fpsDisplayVisible; @@ -211,21 +209,14 @@ namespace osu.Game GlobalKeyBindingInputManager globalBinding; - base.Content.Add(new DrawSizePreservingFillContainer + var cursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both }; + cursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this) { - Children = new Drawable[] - { - Cursor = new MenuCursor(), - globalBinding = new GlobalKeyBindingInputManager(this) - { - RelativeSizeAxes = Axes.Both, - Child = content = new OsuTooltipContainer(Cursor) - { - RelativeSizeAxes = Axes.Both, - } - } - } - }); + RelativeSizeAxes = Axes.Both, + Child = content = new OsuTooltipContainer(cursorContainer.LocalCursor) { RelativeSizeAxes = Axes.Both } + }; + + base.Content.Add(new DrawSizePreservingFillContainer { Child = cursorContainer }); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 6274301a47..e60ac00588 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -22,11 +22,6 @@ namespace osu.Game.Rulesets.UI public Container ScaledContent; - /// - /// Whether we are currently providing the local user a gameplay cursor. - /// - public virtual bool ProvidingUserCursor => false; - protected override Container Content => content; private readonly Container content; diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 4d559549b7..40f88ce577 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using osu.Framework.Graphics.Cursor; using osu.Framework.Input; using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Scoring; @@ -43,11 +44,6 @@ namespace osu.Game.Rulesets.UI /// public PassThroughInputManager KeyBindingInputManager; - /// - /// Whether we are currently providing the local user a gameplay cursor. - /// - public virtual bool ProvidingUserCursor => false; - /// /// Whether we have a replay loaded currently. /// @@ -61,6 +57,11 @@ namespace osu.Game.Rulesets.UI /// public Playfield Playfield => playfield.Value; + /// + /// The cursor provided by this . May be null if no cursor is provided. + /// + public readonly CursorContainer Cursor; + protected readonly Ruleset Ruleset; /// @@ -71,6 +72,8 @@ namespace osu.Game.Rulesets.UI { Ruleset = ruleset; playfield = new Lazy(CreatePlayfield); + + Cursor = CreateCursor(); } public abstract ScoreProcessor CreateScoreProcessor(); @@ -98,6 +101,12 @@ namespace osu.Game.Rulesets.UI ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null; } + + /// + /// Creates the cursor. May be null if the doesn't provide a custom cursor. + /// + protected virtual CursorContainer CreateCursor() => null; + /// /// Creates a Playfield. /// @@ -144,8 +153,6 @@ namespace osu.Game.Rulesets.UI /// protected readonly bool IsForCurrentRuleset; - public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor; - public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(this); protected override Container Content => content; @@ -212,6 +219,9 @@ namespace osu.Game.Rulesets.UI AddInternal(KeyBindingInputManager); KeyBindingInputManager.Add(Playfield); + if (Cursor != null) + KeyBindingInputManager.Add(Cursor); + loadObjects(); } diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 977c8828d2..a54abe8cf1 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -9,10 +9,12 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; +using osu.Game.Graphics.Cursor; +using osu.Framework.Graphics.Cursor; namespace osu.Game.Screens.Menu { - public class Disclaimer : OsuScreen + public class Disclaimer : OsuScreen, IProvideLocalCursor { private Intro intro; private readonly SpriteIcon icon; @@ -20,7 +22,8 @@ namespace osu.Game.Screens.Menu public override bool ShowOverlaysOnEnter => false; - public override bool HasLocalCursorDisplayed => true; + public CursorContainer LocalCursor => null; + public bool ProvidesUserCursor => true; public Disclaimer() { diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index fcee071f04..5fac56fafb 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -15,10 +15,12 @@ using osu.Game.Configuration; using osu.Game.Screens.Backgrounds; using OpenTK; using OpenTK.Graphics; +using osu.Game.Graphics.Cursor; +using osu.Framework.Graphics.Cursor; namespace osu.Game.Screens.Menu { - public class Intro : OsuScreen + public class Intro : OsuScreen, IProvideLocalCursor { private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; @@ -31,10 +33,11 @@ namespace osu.Game.Screens.Menu private SampleChannel welcome; private SampleChannel seeya; - public override bool HasLocalCursorDisplayed => true; - public override bool ShowOverlaysOnEnter => false; + public CursorContainer LocalCursor => null; + public bool ProvidesUserCursor => true; + protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); private Bindable menuVoice; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 0111dceb40..48ca4d5907 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -37,8 +37,6 @@ namespace osu.Game.Screens protected new OsuGameBase Game => base.Game as OsuGameBase; - public virtual bool HasLocalCursorDisplayed => false; - private OsuLogo logo; /// diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 577991c500..a2d1d161c4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -23,22 +23,22 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Ranking; using osu.Framework.Audio.Sample; +using osu.Framework.Graphics.Cursor; using osu.Game.Beatmaps; using osu.Game.Graphics; +using osu.Game.Graphics.Cursor; using osu.Game.Online.API; using osu.Game.Screens.Play.BreaksOverlay; using osu.Game.Storyboards.Drawables; namespace osu.Game.Screens.Play { - public class Player : OsuScreen + public class Player : OsuScreen, IProvideLocalCursor { protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); public override bool ShowOverlaysOnEnter => false; - public override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && RulesetContainer.ProvidingUserCursor; - public Action RestartRequested; public override bool AllowBeatmapRulesetChange => false; @@ -51,6 +51,9 @@ namespace osu.Game.Screens.Play public int RestartCount; + public CursorContainer LocalCursor => RulesetContainer.Cursor; + public bool ProvidesUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded; + private IAdjustableClock adjustableSourceClock; private FramedOffsetClock offsetClock; private DecoupleableInterpolatingFramedClock decoupledClock; @@ -152,6 +155,12 @@ namespace osu.Game.Screens.Play userAudioOffset.ValueChanged += v => offsetClock.Offset = v; userAudioOffset.TriggerChange(); + // We want the cursor to be above everything (including the skip button), but still be able to be controlled + // by the ruleset's input manager and replay, so we need to proxy it out from the ruleset container + var cursorProxyContainer = new Container { RelativeSizeAxes = Axes.Both }; + if (RulesetContainer.Cursor != null) + cursorProxyContainer.Add(RulesetContainer.Cursor.CreateProxy()); + Children = new Drawable[] { storyboardContainer = new Container @@ -195,6 +204,7 @@ namespace osu.Game.Screens.Play Clock = decoupledClock, Breaks = beatmap.Breaks }, + cursorProxyContainer } }, failOverlay = new FailOverlay diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index f87f664199..b87c1a0c6e 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -374,8 +374,10 @@ + + From a6c6523a86e8549e98c298f99f20481562797ae5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 18:21:17 +0900 Subject: [PATCH 04/31] Make SkipButton an OverlayContainer to use the menu cursor --- osu.Game/Screens/Play/SkipButton.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SkipButton.cs b/osu.Game/Screens/Play/SkipButton.cs index 55b2e21c53..827d77a73a 100644 --- a/osu.Game/Screens/Play/SkipButton.cs +++ b/osu.Game/Screens/Play/SkipButton.cs @@ -21,7 +21,7 @@ using osu.Game.Input.Bindings; namespace osu.Game.Screens.Play { - public class SkipButton : Container, IKeyBindingHandler + public class SkipButton : OverlayContainer, IKeyBindingHandler { private readonly double startTime; public IAdjustableClock AudioClock; @@ -36,6 +36,8 @@ namespace osu.Game.Screens.Play { this.startTime = startTime; + State = Visibility.Visible; + RelativePositionAxes = Axes.Both; RelativeSizeAxes = Axes.Both; @@ -112,6 +114,16 @@ namespace osu.Game.Screens.Play Expire(); } + protected override void PopIn() + { + this.FadeIn(); + } + + protected override void PopOut() + { + this.FadeOut(); + } + protected override void Update() { base.Update(); From 5952f1e7f19e3bf7b029aba917becf7f9536b5df Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 19:34:14 +0900 Subject: [PATCH 05/31] Adjust transforms for cursor transitions --- osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs | 12 ++++++++++++ osu.Game/Graphics/Cursor/MenuCursor.cs | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index 325f22f425..0aeb14514d 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -159,5 +159,17 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor 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); + } } } diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 39af99f02e..0de6279b2e 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -99,8 +99,8 @@ namespace osu.Game.Graphics.Cursor protected override void PopOut() { - ActiveCursor.FadeTo(0, 900, Easing.OutQuint); - ActiveCursor.ScaleTo(0, 500, Easing.In); + ActiveCursor.FadeTo(0, 250, Easing.OutQuint); + ActiveCursor.ScaleTo(0.6f, 250, Easing.In); } [BackgroundDependencyLoader] From 620e125fad1a47e6a7f196d90bac84928647fa42 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 19:34:55 +0900 Subject: [PATCH 06/31] Fix cursor being displayed on intro/disclaimer --- osu.Game/Graphics/Cursor/OsuCursorContainer.cs | 11 +++++++++++ osu.Game/OsuGame.cs | 2 ++ osu.Game/OsuGameBase.cs | 10 ++++++---- osu.Game/Screens/Menu/Disclaimer.cs | 8 ++------ osu.Game/Screens/Menu/Intro.cs | 8 ++------ osu.Game/Screens/OsuScreen.cs | 5 +++++ 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs index ca6b6085c2..8a25c9c587 100644 --- a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs @@ -14,6 +14,11 @@ namespace osu.Game.Graphics.Cursor protected override Container Content => content; private readonly Container content; + /// + /// Whether any cursors can be displayed. + /// + public bool CanShowCursor; + public CursorContainer LocalCursor { get; } public bool ProvidesUserCursor => true; @@ -39,6 +44,12 @@ namespace osu.Game.Graphics.Cursor { base.Update(); + if (!CanShowCursor) + { + currentTarget?.LocalCursor?.Hide(); + return; + } + var newTarget = inputManager.HoveredDrawables.OfType().FirstOrDefault(t => t.ProvidesUserCursor) ?? this; if (currentTarget == newTarget) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f0edcbbc6b..fb20fd57fa 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -444,6 +444,8 @@ namespace osu.Game Beatmap.Disabled = applyRestrictions; mainContent.Padding = new MarginPadding { Top = ToolbarOffset }; + + CursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index ff9264c598..c88ffd3739 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -44,6 +44,8 @@ namespace osu.Game protected KeyBindingStore KeyBindingStore; + protected OsuCursorContainer CursorContainer; + protected override string MainResourceFile => @"osu.Game.Resources.dll"; public APIAccess API; @@ -209,14 +211,14 @@ namespace osu.Game GlobalKeyBindingInputManager globalBinding; - var cursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both }; - cursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this) + CursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both }; + CursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this) { RelativeSizeAxes = Axes.Both, - Child = content = new OsuTooltipContainer(cursorContainer.LocalCursor) { RelativeSizeAxes = Axes.Both } + Child = content = new OsuTooltipContainer(CursorContainer.LocalCursor) { RelativeSizeAxes = Axes.Both } }; - base.Content.Add(new DrawSizePreservingFillContainer { Child = cursorContainer }); + base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorContainer }); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index a54abe8cf1..8285416ecb 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -9,21 +9,17 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; -using osu.Game.Graphics.Cursor; -using osu.Framework.Graphics.Cursor; namespace osu.Game.Screens.Menu { - public class Disclaimer : OsuScreen, IProvideLocalCursor + public class Disclaimer : OsuScreen { private Intro intro; private readonly SpriteIcon icon; private Color4 iconColour; public override bool ShowOverlaysOnEnter => false; - - public CursorContainer LocalCursor => null; - public bool ProvidesUserCursor => true; + public override bool CursorVisible => false; public Disclaimer() { diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 5fac56fafb..10b08d704d 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -15,12 +15,10 @@ using osu.Game.Configuration; using osu.Game.Screens.Backgrounds; using OpenTK; using OpenTK.Graphics; -using osu.Game.Graphics.Cursor; -using osu.Framework.Graphics.Cursor; namespace osu.Game.Screens.Menu { - public class Intro : OsuScreen, IProvideLocalCursor + public class Intro : OsuScreen { private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; @@ -34,9 +32,7 @@ namespace osu.Game.Screens.Menu private SampleChannel seeya; public override bool ShowOverlaysOnEnter => false; - - public CursorContainer LocalCursor => null; - public bool ProvidesUserCursor => true; + public override bool CursorVisible => false; protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 48ca4d5907..a2d41dc206 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -35,6 +35,11 @@ namespace osu.Game.Screens /// public virtual bool ShowOverlaysOnEnter => true; + /// + /// Whether this allows the cursor to be displayed. + /// + public virtual bool CursorVisible => true; + protected new OsuGameBase Game => base.Game as OsuGameBase; private OsuLogo logo; From 16d739580b12de0c5aef1916e9c337aa9614f769 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 19:36:35 +0900 Subject: [PATCH 07/31] IProvideLocalCursor -> IProvideCursor --- ...{IProvideLocalCursor.cs => IProvideCursor.cs} | 4 ++-- osu.Game/Graphics/Cursor/OsuCursorContainer.cs | 16 ++++++++-------- osu.Game/OsuGameBase.cs | 2 +- osu.Game/Screens/Play/Player.cs | 4 ++-- osu.Game/osu.Game.csproj | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) rename osu.Game/Graphics/Cursor/{IProvideLocalCursor.cs => IProvideCursor.cs} (84%) diff --git a/osu.Game/Graphics/Cursor/IProvideLocalCursor.cs b/osu.Game/Graphics/Cursor/IProvideCursor.cs similarity index 84% rename from osu.Game/Graphics/Cursor/IProvideLocalCursor.cs rename to osu.Game/Graphics/Cursor/IProvideCursor.cs index 61631b1220..eb17f72846 100644 --- a/osu.Game/Graphics/Cursor/IProvideLocalCursor.cs +++ b/osu.Game/Graphics/Cursor/IProvideCursor.cs @@ -6,12 +6,12 @@ using osu.Framework.Graphics.Cursor; namespace osu.Game.Graphics.Cursor { - public interface IProvideLocalCursor : IDrawable + public interface IProvideCursor : IDrawable { /// /// The cursor provided by this . /// - CursorContainer LocalCursor { get; } + CursorContainer Cursor { get; } /// /// Whether the cursor provided by this should be displayed. diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs index 8a25c9c587..bc4e084813 100644 --- a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs @@ -9,7 +9,7 @@ using osu.Framework.Input; namespace osu.Game.Graphics.Cursor { - public class OsuCursorContainer : Container, IProvideLocalCursor + public class OsuCursorContainer : Container, IProvideCursor { protected override Container Content => content; private readonly Container content; @@ -19,14 +19,14 @@ namespace osu.Game.Graphics.Cursor /// public bool CanShowCursor; - public CursorContainer LocalCursor { get; } + public CursorContainer Cursor { get; } public bool ProvidesUserCursor => true; public OsuCursorContainer() { AddRangeInternal(new Drawable[] { - LocalCursor = new MenuCursor { State = Visibility.Hidden }, + Cursor = new MenuCursor { State = Visibility.Hidden }, content = new Container { RelativeSizeAxes = Axes.Both } }); } @@ -39,24 +39,24 @@ namespace osu.Game.Graphics.Cursor inputManager = GetContainingInputManager(); } - private IProvideLocalCursor currentTarget; + private IProvideCursor currentTarget; protected override void Update() { base.Update(); if (!CanShowCursor) { - currentTarget?.LocalCursor?.Hide(); + currentTarget?.Cursor?.Hide(); return; } - var newTarget = inputManager.HoveredDrawables.OfType().FirstOrDefault(t => t.ProvidesUserCursor) ?? this; + var newTarget = inputManager.HoveredDrawables.OfType().FirstOrDefault(t => t.ProvidesUserCursor) ?? this; if (currentTarget == newTarget) return; - currentTarget?.LocalCursor?.Hide(); - newTarget.LocalCursor?.Show(); + currentTarget?.Cursor?.Hide(); + newTarget.Cursor?.Show(); currentTarget = newTarget; } diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index c88ffd3739..c615b212c3 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -215,7 +215,7 @@ namespace osu.Game CursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this) { RelativeSizeAxes = Axes.Both, - Child = content = new OsuTooltipContainer(CursorContainer.LocalCursor) { RelativeSizeAxes = Axes.Both } + Child = content = new OsuTooltipContainer(CursorContainer.Cursor) { RelativeSizeAxes = Axes.Both } }; base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorContainer }); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a2d1d161c4..4c294b08ff 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -33,7 +33,7 @@ using osu.Game.Storyboards.Drawables; namespace osu.Game.Screens.Play { - public class Player : OsuScreen, IProvideLocalCursor + public class Player : OsuScreen, IProvideCursor { protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap); @@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play public int RestartCount; - public CursorContainer LocalCursor => RulesetContainer.Cursor; + public CursorContainer Cursor => RulesetContainer.Cursor; public bool ProvidesUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded; private IAdjustableClock adjustableSourceClock; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b87c1a0c6e..7175e813f4 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -374,7 +374,7 @@ - + From 34aee4fea0eae02556b6f9c07dc8ab05f68e61fd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 19:37:57 +0900 Subject: [PATCH 08/31] Improve comments --- osu.Game/Graphics/Cursor/IProvideCursor.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Cursor/IProvideCursor.cs b/osu.Game/Graphics/Cursor/IProvideCursor.cs index eb17f72846..b36155a881 100644 --- a/osu.Game/Graphics/Cursor/IProvideCursor.cs +++ b/osu.Game/Graphics/Cursor/IProvideCursor.cs @@ -6,16 +6,19 @@ using osu.Framework.Graphics.Cursor; namespace osu.Game.Graphics.Cursor { + /// + /// Interface for s that display cursors which can replace the user's cursor. + /// public interface IProvideCursor : IDrawable { /// /// The cursor provided by this . + /// May be null if no cursor should be visible. /// CursorContainer Cursor { get; } /// - /// Whether the cursor provided by this should be displayed. - /// If this is false, a cursor occurring earlier in the draw hierarchy will be displayed instead. + /// Whether the cursor provided by this should be displayed as the user's cursor. /// bool ProvidesUserCursor { get; } } From 78441c05cb5d561d0601ea82a13a1e67b28d972e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 19:45:09 +0900 Subject: [PATCH 09/31] OsuCursorContainer -> OsuCursorVisualiser --- .../{OsuCursorContainer.cs => OsuCursorVisualiser.cs} | 7 +++++-- osu.Game/OsuGame.cs | 2 +- osu.Game/OsuGameBase.cs | 10 +++++----- osu.Game/osu.Game.csproj | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) rename osu.Game/Graphics/Cursor/{OsuCursorContainer.cs => OsuCursorVisualiser.cs} (85%) diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorVisualiser.cs similarity index 85% rename from osu.Game/Graphics/Cursor/OsuCursorContainer.cs rename to osu.Game/Graphics/Cursor/OsuCursorVisualiser.cs index bc4e084813..2b2ab593aa 100644 --- a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuCursorVisualiser.cs @@ -9,7 +9,10 @@ using osu.Framework.Input; namespace osu.Game.Graphics.Cursor { - public class OsuCursorContainer : Container, IProvideCursor + /// + /// Visualises different cursors depending on the currently-hovered s. + /// + public class OsuCursorVisualiser : Container, IProvideCursor { protected override Container Content => content; private readonly Container content; @@ -22,7 +25,7 @@ namespace osu.Game.Graphics.Cursor public CursorContainer Cursor { get; } public bool ProvidesUserCursor => true; - public OsuCursorContainer() + public OsuCursorVisualiser() { AddRangeInternal(new Drawable[] { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index fb20fd57fa..3dda26fc02 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -445,7 +445,7 @@ namespace osu.Game mainContent.Padding = new MarginPadding { Top = ToolbarOffset }; - CursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; + CursorVisualiser.CanShowCursor = currentScreen?.CursorVisible ?? false; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index c615b212c3..61ad4024f0 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -44,7 +44,7 @@ namespace osu.Game protected KeyBindingStore KeyBindingStore; - protected OsuCursorContainer CursorContainer; + protected OsuCursorVisualiser CursorVisualiser; protected override string MainResourceFile => @"osu.Game.Resources.dll"; @@ -211,14 +211,14 @@ namespace osu.Game GlobalKeyBindingInputManager globalBinding; - CursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both }; - CursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this) + CursorVisualiser = new OsuCursorVisualiser { RelativeSizeAxes = Axes.Both }; + CursorVisualiser.Child = globalBinding = new GlobalKeyBindingInputManager(this) { RelativeSizeAxes = Axes.Both, - Child = content = new OsuTooltipContainer(CursorContainer.Cursor) { RelativeSizeAxes = Axes.Both } + Child = content = new OsuTooltipContainer(CursorVisualiser.Cursor) { RelativeSizeAxes = Axes.Both } }; - base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorContainer }); + base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorVisualiser }); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7175e813f4..fd53a211e0 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -377,7 +377,7 @@ - + From d0b177e23390dfee9118453afc41ac1d0bde4c8f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 12 Jan 2018 19:50:09 +0900 Subject: [PATCH 10/31] Proxying isn't needed anymore --- osu.Game/Screens/Play/Player.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 4c294b08ff..a93c616c6a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -155,12 +155,6 @@ namespace osu.Game.Screens.Play userAudioOffset.ValueChanged += v => offsetClock.Offset = v; userAudioOffset.TriggerChange(); - // We want the cursor to be above everything (including the skip button), but still be able to be controlled - // by the ruleset's input manager and replay, so we need to proxy it out from the ruleset container - var cursorProxyContainer = new Container { RelativeSizeAxes = Axes.Both }; - if (RulesetContainer.Cursor != null) - cursorProxyContainer.Add(RulesetContainer.Cursor.CreateProxy()); - Children = new Drawable[] { storyboardContainer = new Container @@ -203,8 +197,7 @@ namespace osu.Game.Screens.Play Origin = Anchor.Centre, Clock = decoupledClock, Breaks = beatmap.Breaks - }, - cursorProxyContainer + } } }, failOverlay = new FailOverlay From 43f8a8e8c57adc0266412687d65c6d8cb3037505 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 15 Jan 2018 14:00:13 +0900 Subject: [PATCH 11/31] Rename OsuCursorVisualiser -> CursorOverrideContainer --- ...uCursorVisualiser.cs => CursorOverrideContainer.cs} | 6 +++--- osu.Game/OsuGame.cs | 2 +- osu.Game/OsuGameBase.cs | 10 +++++----- osu.Game/osu.Game.csproj | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) rename osu.Game/Graphics/Cursor/{OsuCursorVisualiser.cs => CursorOverrideContainer.cs} (85%) diff --git a/osu.Game/Graphics/Cursor/OsuCursorVisualiser.cs b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs similarity index 85% rename from osu.Game/Graphics/Cursor/OsuCursorVisualiser.cs rename to osu.Game/Graphics/Cursor/CursorOverrideContainer.cs index 2b2ab593aa..5035020492 100644 --- a/osu.Game/Graphics/Cursor/OsuCursorVisualiser.cs +++ b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs @@ -10,9 +10,9 @@ using osu.Framework.Input; namespace osu.Game.Graphics.Cursor { /// - /// Visualises different cursors depending on the currently-hovered s. + /// A container which provides a which can be overridden by hovered s. /// - public class OsuCursorVisualiser : Container, IProvideCursor + public class CursorOverrideContainer : Container, IProvideCursor { protected override Container Content => content; private readonly Container content; @@ -25,7 +25,7 @@ namespace osu.Game.Graphics.Cursor public CursorContainer Cursor { get; } public bool ProvidesUserCursor => true; - public OsuCursorVisualiser() + public CursorOverrideContainer() { AddRangeInternal(new Drawable[] { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 3dda26fc02..124b9364b3 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -445,7 +445,7 @@ namespace osu.Game mainContent.Padding = new MarginPadding { Top = ToolbarOffset }; - CursorVisualiser.CanShowCursor = currentScreen?.CursorVisible ?? false; + CursorOverrideContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 61ad4024f0..ef02f1a7ec 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -44,7 +44,7 @@ namespace osu.Game protected KeyBindingStore KeyBindingStore; - protected OsuCursorVisualiser CursorVisualiser; + protected CursorOverrideContainer CursorOverrideContainer; protected override string MainResourceFile => @"osu.Game.Resources.dll"; @@ -211,14 +211,14 @@ namespace osu.Game GlobalKeyBindingInputManager globalBinding; - CursorVisualiser = new OsuCursorVisualiser { RelativeSizeAxes = Axes.Both }; - CursorVisualiser.Child = globalBinding = new GlobalKeyBindingInputManager(this) + CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both }; + CursorOverrideContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this) { RelativeSizeAxes = Axes.Both, - Child = content = new OsuTooltipContainer(CursorVisualiser.Cursor) { RelativeSizeAxes = Axes.Both } + Child = content = new OsuTooltipContainer(CursorOverrideContainer.Cursor) { RelativeSizeAxes = Axes.Both } }; - base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorVisualiser }); + base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorOverrideContainer }); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index fd53a211e0..7b97d46531 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -377,7 +377,7 @@ - + From 7c419251440240847ae22afbbcd5a91c0de532ff Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 15 Jan 2018 14:07:09 +0900 Subject: [PATCH 12/31] ProvidesUserCursor -> ProvidingUserCursor, and update xmldoc --- osu.Game/Graphics/Cursor/CursorOverrideContainer.cs | 4 ++-- osu.Game/Graphics/Cursor/IProvideCursor.cs | 7 ++++--- osu.Game/Screens/Play/Player.cs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs index 5035020492..4b29414990 100644 --- a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs +++ b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs @@ -23,7 +23,7 @@ namespace osu.Game.Graphics.Cursor public bool CanShowCursor; public CursorContainer Cursor { get; } - public bool ProvidesUserCursor => true; + public bool ProvidingUserCursor => true; public CursorOverrideContainer() { @@ -53,7 +53,7 @@ namespace osu.Game.Graphics.Cursor return; } - var newTarget = inputManager.HoveredDrawables.OfType().FirstOrDefault(t => t.ProvidesUserCursor) ?? this; + var newTarget = inputManager.HoveredDrawables.OfType().FirstOrDefault(t => t.ProvidingUserCursor) ?? this; if (currentTarget == newTarget) return; diff --git a/osu.Game/Graphics/Cursor/IProvideCursor.cs b/osu.Game/Graphics/Cursor/IProvideCursor.cs index b36155a881..91b44234fb 100644 --- a/osu.Game/Graphics/Cursor/IProvideCursor.cs +++ b/osu.Game/Graphics/Cursor/IProvideCursor.cs @@ -12,14 +12,15 @@ namespace osu.Game.Graphics.Cursor public interface IProvideCursor : IDrawable { /// - /// The cursor provided by this . + /// The cursor provided by this . /// May be null if no cursor should be visible. /// CursorContainer Cursor { get; } /// - /// Whether the cursor provided by this should be displayed as the user's cursor. + /// Whether should be displayed as the singular user cursor. This will temporarily hide any other user cursor. + /// This value is checked every frame and may be used to control whether multiple cursors are displayed (e.g. watching replays). /// - bool ProvidesUserCursor { get; } + bool ProvidingUserCursor { get; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a93c616c6a..2ee58980f1 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -52,7 +52,7 @@ namespace osu.Game.Screens.Play public int RestartCount; public CursorContainer Cursor => RulesetContainer.Cursor; - public bool ProvidesUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded; + public bool ProvidingUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded; private IAdjustableClock adjustableSourceClock; private FramedOffsetClock offsetClock; From bfdfb52666015517059421009fdcdb7175d36316 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 15 Jan 2018 15:28:08 +0900 Subject: [PATCH 13/31] Fix a few usages of AllJudged possibly not being correct --- osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs | 2 +- osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 58f024870d..57a4888b2b 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -150,7 +150,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables holdStartTime = null; // If the key has been released too early, the user should not receive full score for the release - if (!tail.AllJudged) + if (!tail.IsHit) hasBroken = true; return true; diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs index 2fa6c8ed95..29d464f614 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs @@ -81,7 +81,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables if (timeOffset < 0) return; - int countHit = NestedHitObjects.Count(o => o.AllJudged); + int countHit = NestedHitObjects.Count(o => o.IsHit); if (countHit > HitObject.RequiredGoodHits) { From 053a29f9a751abe93eb421c23f39fee9e47679a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 31 Dec 2017 21:05:01 +0900 Subject: [PATCH 14/31] Make judgements visually smaller This is a temporary change based on people's feedback. Makes judgements feel a lot better. nb: This is one of my changes that I've had deployed sinfce the end-of-year 2017 build. --- osu.Game/Rulesets/Judgements/DrawableJudgement.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs index 0f6642ae0e..c1bf55b214 100644 --- a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs +++ b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs @@ -40,7 +40,8 @@ namespace osu.Game.Rulesets.Judgements Anchor = Anchor.Centre, Text = judgement.Result.GetDescription().ToUpper(), Font = @"Venera", - TextSize = 16 + Scale = new Vector2(0.85f, 1), + TextSize = 12 } }; } From 0ae0dac192f3905c1d33ac0c056b94e6ad01030e Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 15 Jan 2018 20:35:38 +0900 Subject: [PATCH 15/31] Fix DrawableHitObject not binding nested hitobject events --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index af14c43a3f..2db899c646 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -167,6 +167,11 @@ namespace osu.Game.Rulesets.Objects.Drawables { if (nestedHitObjects == null) nestedHitObjects = new List(); + + h.OnJudgement += (d, j) => OnJudgement?.Invoke(d, j); + h.OnJudgementRemoved += (d, j) => OnJudgementRemoved?.Invoke(d, j); + h.ApplyCustomUpdateState += (d, j) => ApplyCustomUpdateState?.Invoke(d, j); + nestedHitObjects.Add(h); } From c32ff9c43b7ac6d477c456fa916f4be58e837ea4 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 15 Jan 2018 20:22:41 +0900 Subject: [PATCH 16/31] Move nested playfields to the base Playfield --- osu.Game/Rulesets/UI/Playfield.cs | 23 ++++++++++++++++++- .../UI/Scrolling/ScrollingPlayfield.cs | 20 ---------------- .../UI/Scrolling/ScrollingRulesetContainer.cs | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 9b80bba891..e011908c04 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Objects.Drawables; @@ -23,6 +24,13 @@ namespace osu.Game.Rulesets.UI protected override Container Content => content; private readonly Container content; + private List nestedPlayfields; + + /// + /// All the s nested inside this playfield. + /// + public IReadOnlyList NestedPlayfields => nestedPlayfields; + /// /// A container for keeping track of DrawableHitObjects. /// @@ -64,7 +72,7 @@ namespace osu.Game.Rulesets.UI /// /// Performs post-processing tasks (if any) after all DrawableHitObjects are loaded into this Playfield. /// - public virtual void PostProcess() { } + public virtual void PostProcess() => nestedPlayfields?.ForEach(p => p.PostProcess()); /// /// Adds a DrawableHitObject to this Playfield. @@ -85,6 +93,19 @@ namespace osu.Game.Rulesets.UI /// The that occurred. public virtual void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { } + /// + /// Registers a as a nested . + /// This does not add the to the draw hierarchy. + /// + /// The to add. + protected void AddNested(Playfield otherPlayfield) + { + if (nestedPlayfields == null) + nestedPlayfields = new List(); + + nestedPlayfields.Add(otherPlayfield); + } + /// /// Creates the container that will be used to contain the s. /// diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs index 11185015b8..287e917c7b 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs @@ -1,7 +1,6 @@ // 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 osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -76,25 +75,6 @@ namespace osu.Game.Rulesets.UI.Scrolling HitObjects.TimeRange.BindTo(VisibleTimeRange); } - private List nestedPlayfields; - /// - /// All the s nested inside this playfield. - /// - public IEnumerable NestedPlayfields => nestedPlayfields; - - /// - /// Adds a to this playfield. The nested - /// will be given all of the same speed adjustments as this playfield. - /// - /// The to add. - protected void AddNested(ScrollingPlayfield otherPlayfield) - { - if (nestedPlayfields == null) - nestedPlayfields = new List(); - - nestedPlayfields.Add(otherPlayfield); - } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (!UserScrollSpeedAdjustment) diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingRulesetContainer.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingRulesetContainer.cs index 286545270f..5f6b6801ce 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingRulesetContainer.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingRulesetContainer.cs @@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.UI.Scrolling private void applySpeedAdjustment(MultiplierControlPoint controlPoint, ScrollingPlayfield playfield) { playfield.HitObjects.AddControlPoint(controlPoint); - playfield.NestedPlayfields.ForEach(p => applySpeedAdjustment(controlPoint, p)); + playfield.NestedPlayfields?.OfType().ForEach(p => applySpeedAdjustment(controlPoint, p)); } /// From 8c5ef0a33076ea2a1948a5a02154d2a1b93759a8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 15 Jan 2018 20:45:30 +0900 Subject: [PATCH 17/31] Remove base OnJudgement from Playfield to properly accomodate nested playfields --- osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs | 3 ++- osu.Game.Rulesets.Mania/UI/Column.cs | 5 +++-- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 11 ++++++----- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 4 +++- .../Tests/TestCaseTaikoPlayfield.cs | 8 ++++---- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 4 +++- osu.Game/Rulesets/UI/Playfield.cs | 8 -------- osu.Game/Rulesets/UI/RulesetContainer.cs | 7 +------ 8 files changed, 22 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs index 8ea30a2899..a2324671b2 100644 --- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs +++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs @@ -58,6 +58,7 @@ namespace osu.Game.Rulesets.Catch.UI public override void Add(DrawableHitObject h) { h.Depth = (float)h.HitObject.StartTime; + h.OnJudgement += OnJudgement; base.Add(h); @@ -65,6 +66,6 @@ namespace osu.Game.Rulesets.Catch.UI fruit.CheckPosition = CheckIfWeCanCatch; } - public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement); + public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement); } } diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index eef57897de..2f6759abf3 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -204,12 +204,13 @@ namespace osu.Game.Rulesets.Mania.UI public override void Add(DrawableHitObject hitObject) { hitObject.Depth = (float)hitObject.HitObject.StartTime; - hitObject.AccentColour = AccentColour; + hitObject.OnJudgement += OnJudgement; + HitObjects.Add(hitObject); } - public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) + public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { if (!judgement.IsHit) return; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 919518dbe8..0e53ac2d6d 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -192,11 +192,8 @@ namespace osu.Game.Rulesets.Mania.UI } } - public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) + public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { - var maniaObject = (ManiaHitObject)judgedObject.HitObject; - columns[maniaObject.Column].OnJudgement(judgedObject, judgement); - judgements.Clear(); judgements.Add(new DrawableManiaJudgement(judgement) { @@ -224,7 +221,11 @@ namespace osu.Game.Rulesets.Mania.UI } } - public override void Add(DrawableHitObject h) => Columns.ElementAt(((ManiaHitObject)h.HitObject).Column).Add(h); + public override void Add(DrawableHitObject h) + { + h.OnJudgement += OnJudgement; + Columns.ElementAt(((ManiaHitObject)h.HitObject).Column).Add(h); + } public void Add(DrawableBarLine barline) => HitObjects.Add(barline); diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 892df089f5..5310524089 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -70,6 +70,8 @@ namespace osu.Game.Rulesets.Osu.UI { h.Depth = (float)h.HitObject.StartTime; + h.OnJudgement += OnJudgement; + var c = h as IDrawableHitObjectWithProxiedApproach; if (c != null && ProxyApproachCircles) approachCircles.Add(c.ProxiedLayer.CreateProxy()); @@ -84,7 +86,7 @@ namespace osu.Game.Rulesets.Osu.UI .OrderBy(h => h.StartTime).OfType(); } - public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) + public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { var osuJudgement = (OsuJudgement)judgement; var osuObject = (OsuHitObject)judgedObject.HitObject; diff --git a/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs index 9500a1a747..fd396c201d 100644 --- a/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs @@ -143,18 +143,18 @@ namespace osu.Game.Rulesets.Taiko.Tests var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) }; - rulesetContainer.Playfield.OnJudgement(h, new TaikoJudgement { Result = hitResult }); + ((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new TaikoJudgement { Result = hitResult }); if (RNG.Next(10) == 0) { - rulesetContainer.Playfield.OnJudgement(h, new TaikoJudgement { Result = hitResult }); - rulesetContainer.Playfield.OnJudgement(h, new TaikoStrongHitJudgement()); + ((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new TaikoJudgement { Result = hitResult }); + ((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new TaikoStrongHitJudgement()); } } private void addMissJudgement() { - rulesetContainer.Playfield.OnJudgement(new DrawableTestHit(new Hit()), new TaikoJudgement { Result = HitResult.Miss }); + ((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(new DrawableTestHit(new Hit()), new TaikoJudgement { Result = HitResult.Miss }); } private void addBarLine(bool major, double delay = scroll_time) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 3c5093d82f..ba7807ec3d 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -209,6 +209,8 @@ namespace osu.Game.Rulesets.Taiko.UI { h.Depth = (float)h.HitObject.StartTime; + h.OnJudgement += OnJudgement; + base.Add(h); var barline = h as DrawableBarLine; @@ -221,7 +223,7 @@ namespace osu.Game.Rulesets.Taiko.UI swell.OnStart += () => topLevelHitContainer.Add(swell.CreateProxy()); } - public override void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) + public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { if (judgedObject.DisplayJudgement && judgementContainer.FirstOrDefault(j => j.JudgedObject == judgedObject) == null) { diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index e011908c04..b17ea07355 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; -using osu.Game.Rulesets.Judgements; using osu.Framework.Allocation; namespace osu.Game.Rulesets.UI @@ -86,13 +85,6 @@ namespace osu.Game.Rulesets.UI /// The DrawableHitObject to remove. public virtual void Remove(DrawableHitObject h) => HitObjects.Remove(h); - /// - /// Triggered when a new occurs on a . - /// - /// The object that occured for. - /// The that occurred. - public virtual void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { } - /// /// Registers a as a nested . /// This does not add the to the draw hierarchy. diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 40f88ce577..626b56ad67 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -262,12 +262,7 @@ namespace osu.Game.Rulesets.UI if (drawableObject == null) continue; - drawableObject.OnJudgement += (d, j) => - { - Playfield.OnJudgement(d, j); - OnJudgement?.Invoke(j); - }; - + drawableObject.OnJudgement += (d, j) => OnJudgement?.Invoke(j); drawableObject.OnJudgementRemoved += (d, j) => OnJudgementRemoved?.Invoke(j); Playfield.Add(drawableObject); From 65ecc18141ef81eb1945141e4269f7ace3f08a7e Mon Sep 17 00:00:00 2001 From: aQaTL Date: Mon, 15 Jan 2018 16:04:57 +0100 Subject: [PATCH 18/31] Cap ApproachRate in HardRock mod at 10.0f --- osu.Game/Rulesets/Mods/ModHardRock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Mods/ModHardRock.cs b/osu.Game/Rulesets/Mods/ModHardRock.cs index 97b2fe7d1e..c4c0f38faf 100644 --- a/osu.Game/Rulesets/Mods/ModHardRock.cs +++ b/osu.Game/Rulesets/Mods/ModHardRock.cs @@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mods { const float ratio = 1.4f; difficulty.CircleSize *= 1.3f; // CS uses a custom 1.3 ratio. - difficulty.ApproachRate *= ratio; + difficulty.ApproachRate = Math.Min(difficulty.ApproachRate * ratio, 10.0f); difficulty.DrainRate *= ratio; difficulty.OverallDifficulty *= ratio; } From 3c11978cfa76a32436c2e275cf887735e3c5351f Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Mon, 15 Jan 2018 21:42:17 +0300 Subject: [PATCH 19/31] Use local functions --- osu.Desktop/OsuGameDesktop.cs | 2 +- .../Patterns/Legacy/DistanceObjectPatternGenerator.cs | 2 +- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 4 ++-- osu.Game.Tests/Visual/TestCasePlaySongSelect.cs | 2 +- osu.Game/Overlays/OnScreenDisplay.cs | 2 +- osu.Game/Overlays/Profile/ProfileHeader.cs | 4 ++-- osu.Game/Screens/Menu/IntroSequence.cs | 2 +- osu.Game/Screens/Menu/OsuLogo.cs | 4 ++-- osu.Game/Screens/Select/SongSelect.cs | 4 ++-- osu.Game/Screens/Tournament/Drawings.cs | 6 +++--- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 8e6391168b..f37282366a 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -45,7 +45,7 @@ namespace osu.Desktop { protected override string LocateBasePath() { - Func checkExists = p => Directory.Exists(Path.Combine(p, "Songs")); + bool checkExists(string p) => Directory.Exists(Path.Combine(p, "Songs")); string stableInstallPath; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index d15303af39..1d739c114e 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -321,7 +321,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy break; } - Func isDoubleSample = sample => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH; + bool isDoubleSample(SampleInfo sample) => sample.Name == SampleInfo.HIT_CLAP && sample.Name == SampleInfo.HIT_FINISH; bool canGenerateTwoNotes = (convertType & PatternType.LowProbability) == 0; canGenerateTwoNotes &= HitObject.Samples.Any(isDoubleSample) || sampleInfoListAt(HitObject.StartTime).Any(isDoubleSample); diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 322f0ec608..ece1f626ec 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -117,8 +117,8 @@ namespace osu.Game.Tests.Beatmaps.IO //ensure we were stored to beatmap database backing... Assert.IsTrue(resultSets.Count() == 1, $@"Incorrect result count found ({resultSets.Count()} but should be 1)."); - Func> queryBeatmaps = () => store.QueryBeatmaps(s => s.BeatmapSet.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0); - Func> queryBeatmapSets = () => store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526); + IEnumerable queryBeatmaps() => store.QueryBeatmaps(s => s.BeatmapSet.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0); + IEnumerable queryBeatmapSets() => store.QueryBeatmapSets(s => s.OnlineBeatmapSetID == 241526); //if we don't re-check here, the set will be inserted but the beatmaps won't be present yet. waitForOrAssert(() => queryBeatmaps().Count() == 12, diff --git a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs index f16cf73039..809de2b8db 100644 --- a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs @@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual // this is by no means clean. should be replacing inside of OsuGameBase somehow. var context = new OsuDbContext(); - Func contextFactory = () => context; + OsuDbContext contextFactory() => context; dependencies.Cache(rulesets = new RulesetStore(contextFactory)); dependencies.Cache(manager = new BeatmapManager(storage, contextFactory, rulesets, null) diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 6a1bd8e182..d29941d590 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -121,7 +121,7 @@ namespace osu.Game.Overlays trackSetting(frameworkConfig.GetBindable(FrameworkSetting.AudioDevice), v => display(v, "Audio Device", string.IsNullOrEmpty(v) ? "Default" : v, v)); trackSetting(frameworkConfig.GetBindable(FrameworkSetting.ShowLogOverlay), v => display(v, "Debug Logs", v ? "visible" : "hidden", "Ctrl+F10")); - Action displayResolution = delegate { display(null, "Screen Resolution", frameworkConfig.Get(FrameworkSetting.Width) + "x" + frameworkConfig.Get(FrameworkSetting.Height)); }; + void displayResolution() => display(null, "Screen Resolution", frameworkConfig.Get(FrameworkSetting.Width) + "x" + frameworkConfig.Get(FrameworkSetting.Height)); trackSetting(frameworkConfig.GetBindable(FrameworkSetting.Width), v => displayResolution()); trackSetting(frameworkConfig.GetBindable(FrameworkSetting.Height), v => displayResolution()); diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 6a9f4b84b0..ed8eb258f4 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -319,11 +319,11 @@ namespace osu.Game.Overlays.Profile colourBar.Show(); } - Action boldItalic = t => + void boldItalic(SpriteText t) { t.Font = @"Exo2.0-BoldItalic"; t.Alpha = 1; - }; + } if (user.Age != null) { diff --git a/osu.Game/Screens/Menu/IntroSequence.cs b/osu.Game/Screens/Menu/IntroSequence.cs index 577eb33d18..6f346995e8 100644 --- a/osu.Game/Screens/Menu/IntroSequence.cs +++ b/osu.Game/Screens/Menu/IntroSequence.cs @@ -188,7 +188,7 @@ namespace osu.Game.Screens.Menu mediumRing.ResizeTo(130, 340, Easing.OutQuad); mediumRing.Foreground.ResizeTo(1, 880, Easing.Out); - Func remainingTime = () => length - TransformDelay; + double remainingTime() => length - TransformDelay; using (BeginDelayedSequence(250, true)) { diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 4a13ae421e..f6af204237 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -231,7 +231,7 @@ namespace osu.Game.Screens.Menu /// If true, the new animation is delayed until all previous transforms finish. If false, existing transformed are cleared. public void AppendAnimatingAction(Action action, bool waitForPrevious) { - Action runnableAction = () => + void runnableAction() { if (waitForPrevious) this.DelayUntilTransformsFinished().Schedule(action); @@ -240,7 +240,7 @@ namespace osu.Game.Screens.Menu ClearTransforms(); action(); } - }; + } if (IsLoaded) runnableAction(); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 7431a6e0e6..357931b878 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -266,7 +266,7 @@ namespace osu.Game.Screens.Select /// private void carouselSelectionChanged(BeatmapInfo beatmap) { - Action performLoad = delegate + void performLoad() { // We may be arriving here due to another component changing the bindable Beatmap. // In these cases, the other component has already loaded the beatmap, so we don't need to do so again. @@ -279,7 +279,7 @@ namespace osu.Game.Screens.Select } UpdateBeatmap(Beatmap.Value); - }; + } if (beatmap?.Equals(beatmapNoDebounce) == true) return; diff --git a/osu.Game/Screens/Tournament/Drawings.cs b/osu.Game/Screens/Tournament/Drawings.cs index 17a678c191..498dd7de6f 100644 --- a/osu.Game/Screens/Tournament/Drawings.cs +++ b/osu.Game/Screens/Tournament/Drawings.cs @@ -265,7 +265,7 @@ namespace osu.Game.Screens.Tournament private void writeResults(string text) { - Action writeAction = () => + void writeAction() { try { @@ -280,9 +280,9 @@ namespace osu.Game.Screens.Tournament { Logger.Error(ex, "Failed to write results."); } - }; + } - writeOp = writeOp?.ContinueWith(t => { writeAction(); }) ?? Task.Run(writeAction); + writeOp = writeOp?.ContinueWith(t => { writeAction(); }) ?? Task.Run((Action)writeAction); } private void reloadTeams() From c3ca40dcff48e7844c098ed4507f8bfc829b7e0f Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Mon, 15 Jan 2018 23:27:00 +0300 Subject: [PATCH 20/31] Local functions related CI fixes --- osu.Game/Screens/Menu/IntroSequence.cs | 1 - osu.Game/Screens/Menu/OsuLogo.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Screens/Menu/IntroSequence.cs b/osu.Game/Screens/Menu/IntroSequence.cs index 6f346995e8..ff3b4eba56 100644 --- a/osu.Game/Screens/Menu/IntroSequence.cs +++ b/osu.Game/Screens/Menu/IntroSequence.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using System.Linq; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index f6af204237..b91ff0d74b 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -245,7 +245,7 @@ namespace osu.Game.Screens.Menu if (IsLoaded) runnableAction(); else - Schedule(() => runnableAction()); + Schedule(runnableAction); } [BackgroundDependencyLoader] From 0459f0a0696cadc1ec4cf4212eff6adcb22c98ff Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 16 Jan 2018 13:40:02 +0900 Subject: [PATCH 21/31] Invert CanShowCursor conditional to fix cursor not showing in VisualTests --- osu.Game/Graphics/Cursor/CursorOverrideContainer.cs | 2 +- osu.Game/OsuGame.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs index 4b29414990..0fae4579fa 100644 --- a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs +++ b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs @@ -20,7 +20,7 @@ namespace osu.Game.Graphics.Cursor /// /// Whether any cursors can be displayed. /// - public bool CanShowCursor; + public bool CanShowCursor = true; public CursorContainer Cursor { get; } public bool ProvidingUserCursor => true; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 124b9364b3..b48e25f1fe 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -157,6 +157,11 @@ namespace osu.Game { base.LoadComplete(); + // The next time this is updated is in UpdateAfterChildren, which occurs too late and results + // in the cursor being shown for a few frames during the intro. + // This prevents the cursor from showing until we have a screen with CursorVisible = true + CursorOverrideContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; + // hook up notifications to components. BeatmapManager.PostNotification = n => notifications?.Post(n); BeatmapManager.GetStableStorage = GetStorageForStableInstall; From d230fd486e2cc023c59e024287a9422de00c58d1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 16 Jan 2018 15:28:00 +0900 Subject: [PATCH 22/31] Add automated cursor testcase --- osu.Game.Tests/Visual/TestCaseCursors.cs | 250 +++++++++++++++++++++++ osu.Game.Tests/osu.Game.Tests.csproj | 1 + 2 files changed, 251 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseCursors.cs diff --git a/osu.Game.Tests/Visual/TestCaseCursors.cs b/osu.Game.Tests/Visual/TestCaseCursors.cs new file mode 100644 index 0000000000..e0ce5fad77 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseCursors.cs @@ -0,0 +1,250 @@ +// 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.Cursor; +using osu.Framework.Graphics.Shapes; +using osu.Framework.MathUtils; +using osu.Framework.Testing.Input; +using osu.Game.Graphics.Cursor; +using osu.Game.Graphics.Sprites; +using OpenTK; +using OpenTK.Graphics; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseCursors : OsuTestCase + { + private readonly ManualInputManager inputManager; + private readonly CursorOverrideContainer cursorOverrideContainer; + private readonly CustomCursorBox[] cursorBoxes = new CustomCursorBox[6]; + + public TestCaseCursors() + { + Child = inputManager = new ManualInputManager + { + Child = cursorOverrideContainer = new CursorOverrideContainer + { + RelativeSizeAxes = Axes.Both, + Children = new[] + { + // Middle user + cursorBoxes[0] = new CustomCursorBox(Color4.Green) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.5f), + }, + // Top-left user + cursorBoxes[1] = new CustomCursorBox(Color4.Blue) + { + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.4f) + }, + // Bottom-right user + cursorBoxes[2] = new CustomCursorBox(Color4.Red) + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.4f) + }, + // Bottom-left local + cursorBoxes[3] = new CustomCursorBox(Color4.Magenta, false) + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.4f) + }, + // Top-right local + cursorBoxes[4] = new CustomCursorBox(Color4.Cyan, false) + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.4f) + }, + // Left-local + cursorBoxes[5] = new CustomCursorBox(Color4.Yellow, false) + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.2f, 1), + }, + } + } + }; + + returnUserInput(); + testUserCursor(); + testLocalCursor(); + testUserCursorOverride(); + testMultipleLocalCursors(); + } + + /// + /// Returns input back to the user. + /// + private void returnUserInput() + { + AddStep("Return user input", () => inputManager.UseParentState = true); + } + + /// + /// -- Green Box -- + /// Tests whether hovering in and out of a drawable that provides the user cursor (green) + /// results in the correct visibility state for that cursor. + /// + private void testUserCursor() + { + AddStep("Move to green area", () => inputManager.MoveMouseTo(cursorBoxes[0])); + AddAssert("Check green cursor visible", () => checkVisible(cursorBoxes[0].Cursor)); + AddAssert("Check green cursor at mouse", () => checkAtMouse(cursorBoxes[0].Cursor)); + AddStep("Move out", moveOut); + AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor)); + AddAssert("Check global cursor visible", () => checkVisible(cursorOverrideContainer.Cursor)); + } + + /// + /// -- Purple Box -- + /// Tests whether hovering in and out of a drawable that provides a local cursor (purple) + /// results in the correct visibility and state for that cursor. + /// + private void testLocalCursor() + { + AddStep("Move to purple area", () => inputManager.MoveMouseTo(cursorBoxes[3])); + AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor)); + AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor)); + AddAssert("Check global cursor visible", () => checkVisible(cursorOverrideContainer.Cursor)); + AddAssert("Check global cursor at mouse", () => checkAtMouse(cursorOverrideContainer.Cursor)); + AddStep("Move out", moveOut); + AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor)); + AddAssert("Check global cursor visible", () => checkVisible(cursorOverrideContainer.Cursor)); + } + + /// + /// -- Blue-Green Box Boundary -- + /// Tests whether overriding a user cursor (green) with another user cursor (blue) + /// results in the correct visibility and states for the cursors. + /// + private void testUserCursorOverride() + { + AddStep("Move to blue-green boundary", () => inputManager.MoveMouseTo(cursorBoxes[1].ScreenSpaceDrawQuad.BottomRight - new Vector2(10))); + AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor)); + AddAssert("Check green cursor invisible", () => !checkVisible(cursorBoxes[0].Cursor)); + AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor)); + AddStep("Move out", moveOut); + AddAssert("Check blue cursor not visible", () => !checkVisible(cursorBoxes[1].Cursor)); + AddAssert("Check green cursor not visible", () => !checkVisible(cursorBoxes[0].Cursor)); + } + + /// + /// -- Yellow-Purple Box Boundary -- + /// Tests whether multiple local cursors (purple + yellow) may be visible and at the mouse position at the same time. + /// + private void testMultipleLocalCursors() + { + AddStep("Move to yellow-purple boundary", () => inputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.BottomRight - new Vector2(10))); + AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor)); + AddAssert("Check purple cursor at mouse", () => checkAtMouse(cursorBoxes[3].Cursor)); + AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor)); + AddAssert("Check yellow cursor at mouse", () => checkAtMouse(cursorBoxes[5].Cursor)); + AddStep("Move out", moveOut); + AddAssert("Check purple cursor visible", () => checkVisible(cursorBoxes[3].Cursor)); + AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor)); + } + + /// + /// -- Yellow-Blue Box Boundary -- + /// Tests whether a local cursor (yellow) may be displayed along with a user cursor override (blue). + /// + private void testUserOverrideWithLocal() + { + AddStep("Move to yellow-blue boundary", () => inputManager.MoveMouseTo(cursorBoxes[5].ScreenSpaceDrawQuad.TopRight - new Vector2(10))); + AddAssert("Check blue cursor visible", () => checkVisible(cursorBoxes[1].Cursor)); + AddAssert("Check blue cursor at mouse", () => checkAtMouse(cursorBoxes[1].Cursor)); + AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor)); + AddAssert("Check yellow cursor at mouse", () => checkAtMouse(cursorBoxes[5].Cursor)); + AddStep("Move out", moveOut); + AddAssert("Check blue cursor invisible", () => !checkVisible(cursorBoxes[1].Cursor)); + AddAssert("Check yellow cursor visible", () => checkVisible(cursorBoxes[5].Cursor)); + } + + /// + /// Moves the cursor to a point not covered by any cursor containers. + /// + private void moveOut() + => inputManager.MoveMouseTo(new Vector2(inputManager.ScreenSpaceDrawQuad.Centre.X, inputManager.ScreenSpaceDrawQuad.TopLeft.Y)); + + /// + /// Checks if a cursor is visible. + /// + /// The cursor to check. + private bool checkVisible(CursorContainer cursorContainer) => cursorContainer.State == Visibility.Visible; + + /// + /// Checks if a cursor is at the current inputmanager screen position. + /// + /// The cursor to check. + private bool checkAtMouse(CursorContainer cursorContainer) + => Precision.AlmostEquals(inputManager.CurrentState.Mouse.NativeState.Position, cursorContainer.ToScreenSpace(cursorContainer.ActiveCursor.DrawPosition)); + + private class CustomCursorBox : Container, IProvideCursor + { + public CursorContainer Cursor { get; } + public bool ProvidingUserCursor { get; } + + public CustomCursorBox(Color4 cursorColour, bool providesUserCursor = true) + { + ProvidingUserCursor = providesUserCursor; + + Colour = cursorColour; + Masking = true; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.1f + }, + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Text = providesUserCursor ? "User cursor" : "Local cursor" + }, + Cursor = new TestCursorContainer + { + State = providesUserCursor ? Visibility.Hidden : Visibility.Visible, + } + }; + } + } + + private class TestCursorContainer : CursorContainer + { + protected override Drawable CreateCursor() => new TestCursor(); + + private class TestCursor : CircularContainer + { + public TestCursor() + { + Origin = Anchor.Centre; + + Size = new Vector2(50); + Masking = true; + + Blending = BlendingMode.Additive; + Alpha = 0.5f; + + Child = new Box { RelativeSizeAxes = Axes.Both }; + } + } + } + } +} diff --git a/osu.Game.Tests/osu.Game.Tests.csproj b/osu.Game.Tests/osu.Game.Tests.csproj index 2eb79f6b35..76b426bf5d 100644 --- a/osu.Game.Tests/osu.Game.Tests.csproj +++ b/osu.Game.Tests/osu.Game.Tests.csproj @@ -104,6 +104,7 @@ + From c309cc94540db54ebc48918f9ca45d2e016c8ab3 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 16 Jan 2018 15:37:32 +0900 Subject: [PATCH 23/31] Privatise OnJudgements as much as possible --- osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs | 4 ++-- osu.Game.Rulesets.Mania/UI/Column.cs | 4 ++-- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 4 ++-- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs index a2324671b2..7f56c3bbb1 100644 --- a/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs +++ b/osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs @@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Catch.UI public override void Add(DrawableHitObject h) { h.Depth = (float)h.HitObject.StartTime; - h.OnJudgement += OnJudgement; + h.OnJudgement += onJudgement; base.Add(h); @@ -66,6 +66,6 @@ namespace osu.Game.Rulesets.Catch.UI fruit.CheckPosition = CheckIfWeCanCatch; } - public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement); + private void onJudgement(DrawableHitObject judgedObject, Judgement judgement) => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, judgement); } } diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 2f6759abf3..d79a4d62c4 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -205,12 +205,12 @@ namespace osu.Game.Rulesets.Mania.UI { hitObject.Depth = (float)hitObject.HitObject.StartTime; hitObject.AccentColour = AccentColour; - hitObject.OnJudgement += OnJudgement; + hitObject.OnJudgement += onJudgement; HitObjects.Add(hitObject); } - public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) + private void onJudgement(DrawableHitObject judgedObject, Judgement judgement) { if (!judgement.IsHit) return; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 0e53ac2d6d..7d3df6cda7 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -192,7 +192,7 @@ namespace osu.Game.Rulesets.Mania.UI } } - public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) + internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { judgements.Clear(); judgements.Add(new DrawableManiaJudgement(judgement) diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 5310524089..17521f8992 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.UI { h.Depth = (float)h.HitObject.StartTime; - h.OnJudgement += OnJudgement; + h.OnJudgement += onJudgement; var c = h as IDrawableHitObjectWithProxiedApproach; if (c != null && ProxyApproachCircles) @@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Osu.UI .OrderBy(h => h.StartTime).OfType(); } - public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) + private void onJudgement(DrawableHitObject judgedObject, Judgement judgement) { var osuJudgement = (OsuJudgement)judgement; var osuObject = (OsuHitObject)judgedObject.HitObject; diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index ba7807ec3d..49c87f7480 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -223,7 +223,7 @@ namespace osu.Game.Rulesets.Taiko.UI swell.OnStart += () => topLevelHitContainer.Add(swell.CreateProxy()); } - public void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) + internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { if (judgedObject.DisplayJudgement && judgementContainer.FirstOrDefault(j => j.JudgedObject == judgedObject) == null) { From 4f7ccb8d939878b3646648348de917e10ab97bc9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 Jan 2018 18:38:47 +0900 Subject: [PATCH 24/31] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 49b563e2cf..95bd66da12 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 49b563e2cf170eb19006b98dd5b69c2398362d9e +Subproject commit 95bd66da12276f39335873972f713774306b4894 From 1174f344896a2670d41cabf79fda5b191572bbcb Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 16 Jan 2018 20:21:09 +0900 Subject: [PATCH 25/31] Update framework post-merge --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 95bd66da12..023a0abe17 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 95bd66da12276f39335873972f713774306b4894 +Subproject commit 023a0abe17490a118fe1ca85ea487462bff4277e From 39af9321cf3e1957a92d4bd233d7b00ca0a555a2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 Jan 2018 20:29:11 +0900 Subject: [PATCH 26/31] Remove unnecessary overrides --- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index 8fa76e2e51..615c124ea7 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -142,10 +142,6 @@ namespace osu.Game.Screens.Play } } - public override bool HandleKeyboardInput => handleInput; - public override bool HandleMouseInput => handleInput; - private bool handleInput => State == Visibility.Visible; - protected override void PopIn() => this.FadeIn(transition_duration, Easing.In); protected override void PopOut() => this.FadeOut(transition_duration, Easing.In); From e7a0a024664ee09989e308a08928c435ed21d680 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 Jan 2018 20:29:28 +0900 Subject: [PATCH 27/31] Don't limit keyboard input based on menu button scale --- osu.Game/Screens/Menu/Button.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index fff2435cb4..268be51347 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -222,9 +222,8 @@ namespace osu.Game.Screens.Menu boxHoverLayer.FadeOut(800, Easing.OutExpo); } - public override bool HandleKeyboardInput => handleInput; - public override bool HandleMouseInput => handleInput; - private bool handleInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f; + public override bool HandleKeyboardInput => state != ButtonState.Exploded; + public override bool HandleMouseInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f; protected override void Update() { From 5e1cd8ddc4c569c07ed31d69d1ed80eff93e6ee3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 Jan 2018 20:34:14 +0900 Subject: [PATCH 28/31] Apply conditionals directly rather than using an in-between property --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 6 +++--- osu.Game/Overlays/Profile/ProfileHeader.cs | 5 ++--- osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs | 5 ++--- osu.Game/Screens/Menu/ButtonSystem.cs | 5 ++--- osu.Game/Screens/Play/KeyCounterCollection.cs | 5 ++--- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 566254886e..5ee0aba9cf 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -42,9 +42,9 @@ namespace osu.Game.Graphics.UserInterface //don't allow clicking between transitions and don't make the chevron clickable public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceiveMouseInputAt(screenSpacePos); - public override bool HandleKeyboardInput => handleInput; - public override bool HandleMouseInput => handleInput; - private bool handleInput => State == Visibility.Visible; + + public override bool HandleKeyboardInput => State == Visibility.Visible; + public override bool HandleMouseInput => State == Visibility.Visible; private Visibility state; diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index c4819c5bc7..924b5d6c9d 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -489,9 +489,8 @@ namespace osu.Game.Overlays.Profile { private readonly OsuHoverContainer content; - public override bool HandleKeyboardInput => handleInput; - public override bool HandleMouseInput => handleInput; - private bool handleInput => content.Action != null; + public override bool HandleKeyboardInput => content.Action != null; + public override bool HandleMouseInput => content.Action != null; protected override Container Content => content ?? (Container)this; diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs index 2acc1075a3..6d58c78c37 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeSelector.cs @@ -87,9 +87,8 @@ namespace osu.Game.Overlays.Toolbar ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault(); } - public override bool HandleKeyboardInput => handleInput; - public override bool HandleMouseInput => handleInput; - private bool handleInput => !ruleset.Disabled; + public override bool HandleKeyboardInput => !ruleset.Disabled; + public override bool HandleMouseInput => !ruleset.Disabled; private void disabledChanged(bool isDisabled) => this.FadeColour(isDisabled ? Color4.Gray : Color4.White, 300); diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index a45f4429c4..72c26af2a6 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -199,9 +199,8 @@ namespace osu.Game.Screens.Menu private MenuState state; - public override bool HandleKeyboardInput => handleInput; - public override bool HandleMouseInput => handleInput; - private bool handleInput=> state != MenuState.Exit; + public override bool HandleKeyboardInput => state != MenuState.Exit; + public override bool HandleMouseInput => state != MenuState.Exit; public MenuState State { diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index c716841861..e40776ae4a 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -111,9 +111,8 @@ namespace osu.Game.Screens.Play } } - public override bool HandleKeyboardInput => handleInput; - public override bool HandleMouseInput => handleInput; - private bool handleInput => receptor == null; + public override bool HandleKeyboardInput => receptor == null; + public override bool HandleMouseInput => receptor == null; private Receptor receptor; From a5415b99aecb21ed74f8c9feb048288878325cf2 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 16 Jan 2018 20:35:07 +0900 Subject: [PATCH 29/31] Visualise the hovered drawabe --- osu.Game.Tests/Visual/TestCaseCursors.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseCursors.cs b/osu.Game.Tests/Visual/TestCaseCursors.cs index e0ce5fad77..20e6103436 100644 --- a/osu.Game.Tests/Visual/TestCaseCursors.cs +++ b/osu.Game.Tests/Visual/TestCaseCursors.cs @@ -5,6 +5,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Framework.Testing.Input; using osu.Game.Graphics.Cursor; @@ -198,6 +199,8 @@ namespace osu.Game.Tests.Visual public CursorContainer Cursor { get; } public bool ProvidingUserCursor { get; } + private readonly Box background; + public CustomCursorBox(Color4 cursorColour, bool providesUserCursor = true) { ProvidingUserCursor = providesUserCursor; @@ -207,7 +210,7 @@ namespace osu.Game.Tests.Visual Children = new Drawable[] { - new Box + background = new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.1f @@ -224,6 +227,18 @@ namespace osu.Game.Tests.Visual } }; } + + protected override bool OnHover(InputState state) + { + background.FadeTo(0.4f, 250, Easing.OutQuint); + return false; + } + + protected override void OnHoverLost(InputState state) + { + background.FadeTo(0.1f, 250); + base.OnHoverLost(state); + } } private class TestCursorContainer : CursorContainer From 06f0f2093c71f678b61faa4d9aef4748694b7f47 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 16 Jan 2018 20:35:39 +0900 Subject: [PATCH 30/31] Add a sample way to have local cursors move beyond their bounds --- osu.Game.Tests/Visual/TestCaseCursors.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game.Tests/Visual/TestCaseCursors.cs b/osu.Game.Tests/Visual/TestCaseCursors.cs index 20e6103436..363f6b53f0 100644 --- a/osu.Game.Tests/Visual/TestCaseCursors.cs +++ b/osu.Game.Tests/Visual/TestCaseCursors.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; @@ -81,10 +82,14 @@ namespace osu.Game.Tests.Visual }; returnUserInput(); + + AddToggleStep("Smooth transitions", b => cursorBoxes.ForEach(box => box.SmoothTransition = b)); + testUserCursor(); testLocalCursor(); testUserCursorOverride(); testMultipleLocalCursors(); + returnUserInput(); } /// @@ -196,9 +201,13 @@ namespace osu.Game.Tests.Visual private class CustomCursorBox : Container, IProvideCursor { + public bool SmoothTransition; + public CursorContainer Cursor { get; } public bool ProvidingUserCursor { get; } + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => base.ReceiveMouseInputAt(screenSpacePos) || SmoothTransition && !ProvidingUserCursor; + private readonly Box background; public CustomCursorBox(Color4 cursorColour, bool providesUserCursor = true) From 87d2cce61d3aaf1d1da59d4ee330660c2987a81b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 Jan 2018 00:47:14 +0900 Subject: [PATCH 31/31] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 023a0abe17..8f36ddab94 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 023a0abe17490a118fe1ca85ea487462bff4277e +Subproject commit 8f36ddab946ff538620081ede7719461d4732b79