From ab8a5afdb91034aa3c2c1e7435be2a6498124666 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 16 Mar 2017 17:38:36 +0900 Subject: [PATCH] AlwaysReceiveInput and InternalContains. --- .../Objects/Drawables/DrawableSlider.cs | 8 ++++---- .../Objects/Drawables/DrawableSpinner.cs | 4 ++-- .../Objects/Drawables/Pieces/SpinnerDisc.cs | 4 ++-- osu.Game/Graphics/Containers/ParallaxContainer.cs | 4 ++-- osu.Game/Graphics/Cursor/CursorTrail.cs | 2 +- osu.Game/Graphics/Processing/RatioAdjust.cs | 3 +-- osu.Game/Graphics/UserInterface/DialogButton.cs | 2 +- osu.Game/Graphics/UserInterface/TwoLayerButton.cs | 2 +- osu.Game/Modes/UI/Playfield.cs | 13 ++++++++++--- osu.Game/Overlays/Toolbar/Toolbar.cs | 13 ++++--------- osu.Game/Overlays/Toolbar/ToolbarUserArea.cs | 4 ++-- osu.Game/Screens/Menu/Button.cs | 5 +---- osu.Game/Screens/Menu/OsuLogo.cs | 5 +---- osu.Game/Screens/Play/KeyCounterCollection.cs | 7 +++---- osu.Game/Screens/Play/KeyCounterMouse.cs | 3 +-- osu.Game/Screens/Play/PauseOverlay.cs | 2 +- osu.Game/Screens/Select/FilterControl.cs | 6 +++--- osu.Game/Screens/Select/Footer.cs | 4 ++-- .../Screens/Select/Options/BeatmapOptionsButton.cs | 2 +- 19 files changed, 43 insertions(+), 50 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs index 036f12167a..5df2e26bc3 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs @@ -28,6 +28,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public DrawableSlider(Slider s) : base(s) { + // Since the DrawableSlider itself is just a container without a size we need to + // pass all input through. + AlwaysReceiveInput = true; + SliderBouncer bouncer1; slider = s; @@ -91,10 +95,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables } } - // Since the DrawableSlider itself is just a container without a size we need to - // pass all input through. - public override bool Contains(Vector2 screenSpacePos) => true; - private int currentRepeat; protected override void Update() diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs index be3048a9ba..97df378f86 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs @@ -24,6 +24,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables public DrawableSpinner(Spinner s) : base(s) { + AlwaysReceiveInput = true; + Origin = Anchor.Centre; Position = s.Position; @@ -69,8 +71,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables disc.Scale = scaleToCircle; } - public override bool Contains(Vector2 screenSpacePos) => true; - protected override void CheckJudgement(bool userTriggered) { if (Time.Current < HitObject.StartTime) return; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs index 34dec34cb4..906a3cd7c3 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Pieces/SpinnerDisc.cs @@ -19,8 +19,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces { public class SpinnerDisc : CircularContainer { - public override bool Contains(Vector2 screenSpacePos) => true; - protected Sprite Disc; public SRGBColour DiscColour @@ -101,6 +99,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces public SpinnerDisc() { + AlwaysReceiveInput = true; + RelativeSizeAxes = Axes.Both; Children = new Drawable[] diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 88627dbd30..c4cd1777e1 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -18,10 +18,10 @@ namespace osu.Game.Graphics.Containers private Bindable parallaxEnabled; - public override bool Contains(Vector2 screenSpacePos) => true; - public ParallaxContainer() { + AlwaysReceiveInput = true; + RelativeSizeAxes = Axes.Both; AddInternal(content = new Container { diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 09d1193661..ffd96d9622 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -18,7 +18,6 @@ namespace osu.Game.Graphics.Cursor { internal class CursorTrail : Drawable { - public override bool Contains(Vector2 screenSpacePos) => true; public override bool HandleInput => true; private int currentIndex; @@ -59,6 +58,7 @@ namespace osu.Game.Graphics.Cursor public CursorTrail() { + AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; for (int i = 0; i < max_sprites; i++) diff --git a/osu.Game/Graphics/Processing/RatioAdjust.cs b/osu.Game/Graphics/Processing/RatioAdjust.cs index 219d75c675..dd039d5144 100644 --- a/osu.Game/Graphics/Processing/RatioAdjust.cs +++ b/osu.Game/Graphics/Processing/RatioAdjust.cs @@ -10,10 +10,9 @@ namespace osu.Game.Graphics.Processing { internal class RatioAdjust : Container { - public override bool Contains(Vector2 screenSpacePos) => true; - public RatioAdjust() { + AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; } diff --git a/osu.Game/Graphics/UserInterface/DialogButton.cs b/osu.Game/Graphics/UserInterface/DialogButton.cs index 590c5bf393..49b5f1e509 100644 --- a/osu.Game/Graphics/UserInterface/DialogButton.cs +++ b/osu.Game/Graphics/UserInterface/DialogButton.cs @@ -88,7 +88,7 @@ namespace osu.Game.Graphics.UserInterface private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking - public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos); protected override bool OnClick(Framework.Input.InputState state) { diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 8221ef952f..0d4e72f92c 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -158,7 +158,7 @@ namespace osu.Game.Graphics.UserInterface } } - public override bool Contains(Vector2 screenSpacePos) => IconLayer.Contains(screenSpacePos) || TextLayer.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => IconLayer.Contains(screenSpacePos) || TextLayer.Contains(screenSpacePos); protected override bool OnHover(InputState state) { diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index 288b4bf352..bff461f649 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -18,7 +18,6 @@ namespace osu.Game.Modes.UI /// The HitObjects contained in this Playfield. /// public HitObjectContainer> HitObjects; - public override bool Contains(Vector2 screenSpacePos) => true; internal Container ScaledContent; @@ -31,6 +30,8 @@ namespace osu.Game.Modes.UI /// Whether we want our internal coordinate system to be scaled to a specified width. protected Playfield(float? customWidth = null) { + AlwaysReceiveInput = true; + AddInternal(ScaledContent = new ScaledContainer { CustomWidth = customWidth, @@ -77,12 +78,18 @@ namespace osu.Game.Modes.UI //dividing by the customwidth will effectively scale our content to the required container size. protected override Vector2 DrawScale => CustomWidth.HasValue ? new Vector2(DrawSize.X / CustomWidth.Value) : base.DrawScale; - public override bool Contains(Vector2 screenSpacePos) => true; + public ScaledContainer() + { + AlwaysReceiveInput = true; + } } public class HitObjectContainer : Container where U : Drawable { - public override bool Contains(Vector2 screenSpacePos) => true; + public HitObjectContainer() + { + AlwaysReceiveInput = true; + } } } } diff --git a/osu.Game/Overlays/Toolbar/Toolbar.cs b/osu.Game/Overlays/Toolbar/Toolbar.cs index 79698a4f3e..657334d1bb 100644 --- a/osu.Game/Overlays/Toolbar/Toolbar.cs +++ b/osu.Game/Overlays/Toolbar/Toolbar.cs @@ -35,10 +35,10 @@ namespace osu.Game.Overlays.Toolbar private const float alpha_hovering = 0.8f; private const float alpha_normal = 0.6f; - public override bool Contains(Vector2 screenSpacePos) => true; - public Toolbar() { + AlwaysReceiveInput = true; + Children = new Drawable[] { new ToolbarBackground(), @@ -63,8 +63,9 @@ namespace osu.Game.Overlays.Toolbar } } }, - new PassThroughFlowContainer + new FillFlowContainer { + AlwaysReceiveInput = true, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Direction = FillDirection.Horizontal, @@ -144,11 +145,5 @@ namespace osu.Game.Overlays.Toolbar MoveToY(-DrawSize.Y, transition_time, EasingTypes.OutQuint); FadeOut(transition_time); } - - private class PassThroughFlowContainer : FillFlowContainer - { - //needed to get input to the login overlay. - public override bool Contains(Vector2 screenSpacePos) => true; - } } } diff --git a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs index 9de0f290a5..7f28764b17 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarUserArea.cs @@ -15,10 +15,10 @@ namespace osu.Game.Overlays.Toolbar public override RectangleF BoundingBox => button.BoundingBox; - public override bool Contains(Vector2 screenSpacePos) => true; - public ToolbarUserArea() { + AlwaysReceiveInput = true; + RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 7af03d2f11..52872c858b 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -35,10 +35,7 @@ namespace osu.Game.Screens.Menu private Key triggerKey; private SampleChannel sampleClick; - public override bool Contains(Vector2 screenSpacePos) - { - return box.Contains(screenSpacePos); - } + protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); public Button(string text, string internalName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown) { diff --git a/osu.Game/Screens/Menu/OsuLogo.cs b/osu.Game/Screens/Menu/OsuLogo.cs index 01622fe096..259e98c483 100644 --- a/osu.Game/Screens/Menu/OsuLogo.cs +++ b/osu.Game/Screens/Menu/OsuLogo.cs @@ -50,10 +50,7 @@ namespace osu.Game.Screens.Menu } } - public override bool Contains(Vector2 screenSpacePos) - { - return logoContainer.Contains(screenSpacePos); - } + protected override bool InternalContains(Vector2 screenSpacePos) => logoContainer.Contains(screenSpacePos); public bool Ripple { diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index aa2bf47227..bbda7ae318 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -14,6 +14,8 @@ namespace osu.Game.Screens.Play { public KeyCounterCollection() { + AlwaysReceiveInput = true; + Direction = FillDirection.Horizontal; AutoSizeAxes = Axes.Both; } @@ -33,8 +35,6 @@ namespace osu.Game.Screens.Play counter.ResetCount(); } - public override bool Contains(Vector2 screenSpacePos) => true; - //further: change default values here and in KeyCounter if needed, instead of passing them in every constructor private bool isCounting; public bool IsCounting @@ -111,12 +111,11 @@ namespace osu.Game.Screens.Play public Receptor(KeyCounterCollection target) { + AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; this.target = target; } - public override bool Contains(Vector2 screenSpacePos) => true; - public override bool HandleInput => true; protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => target.Children.Any(c => c.TriggerKeyDown(state, args)); diff --git a/osu.Game/Screens/Play/KeyCounterMouse.cs b/osu.Game/Screens/Play/KeyCounterMouse.cs index 425bcffee5..b0b93e80e7 100644 --- a/osu.Game/Screens/Play/KeyCounterMouse.cs +++ b/osu.Game/Screens/Play/KeyCounterMouse.cs @@ -13,6 +13,7 @@ namespace osu.Game.Screens.Play public KeyCounterMouse(MouseButton button) : base(getStringRepresentation(button)) { + AlwaysReceiveInput = true; Button = button; } @@ -29,8 +30,6 @@ namespace osu.Game.Screens.Play } } - public override bool Contains(Vector2 screenSpacePos) => true; - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { if (args.Button == Button) IsLit = true; diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 0f3303fc29..b862adcd53 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -70,7 +70,6 @@ namespace osu.Game.Screens.Play private FillFlowContainer retryCounterContainer; - public override bool Contains(Vector2 screenSpacePos) => true; public override bool HandleInput => State == Visibility.Visible; protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In); @@ -217,6 +216,7 @@ namespace osu.Game.Screens.Play public PauseOverlay() { + AlwaysReceiveInput = true; RelativeSizeAxes = Axes.Both; } } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 7dd5c397fb..a655d0c4d4 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -60,7 +60,7 @@ namespace osu.Game.Screens.Select private SearchTextBox searchTextBox; - public override bool Contains(Vector2 screenSpacePos) => base.Contains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos); public FilterControl() { @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Select new Container { Padding = new MarginPadding(20), - BypassContainsCheck = true, + AlwaysReceiveInput = true, RelativeSizeAxes = Axes.Both, Width = 0.5f, Anchor = Anchor.TopRight, @@ -107,7 +107,7 @@ namespace osu.Game.Screens.Select Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - BypassContainsCheck = true, + AlwaysReceiveInput = true, Children = new Drawable[] { groupTabs = new OsuTabControl diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index fae1cb5d4d..0e369c78b9 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -26,8 +26,6 @@ namespace osu.Game.Screens.Select private const float padding = 80; - public override bool Contains(Vector2 screenSpacePos) => true; - public Action OnBack; public Action OnStart; @@ -69,6 +67,8 @@ namespace osu.Game.Screens.Select public Footer() { + AlwaysReceiveInput = true; + const float bottom_tool_height = 50; RelativeSizeAxes = Axes.X; diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs index cfe8eea07f..a0bc702aac 100644 --- a/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs +++ b/osu.Game/Screens/Select/Options/BeatmapOptionsButton.cs @@ -83,7 +83,7 @@ namespace osu.Game.Screens.Select.Options return false; } - public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos); public BeatmapOptionsButton() {