From 8173d01d788cf0bd7450f10881adea46e610a8a8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Apr 2017 10:15:39 +0900 Subject: [PATCH 1/5] Fix crash on changing play mode too early. --- osu.Game/Screens/Select/SongSelect.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 44204f5beb..3e8ddc0f64 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -167,13 +167,12 @@ namespace osu.Game.Screens.Select BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue); } - if (osu != null) - playMode.BindTo(osu.PlayMode); - playMode.ValueChanged += val => Beatmap.PreferredPlayMode = val; - if (database == null) database = beatmaps; + playMode.ValueChanged += val => { if (Beatmap != null) Beatmap.PreferredPlayMode = val; }; + if (osu != null) playMode.BindTo(osu.PlayMode); + database.BeatmapSetAdded += onBeatmapSetAdded; database.BeatmapSetRemoved += onBeatmapSetRemoved; From 4b1588a21d677a07283749be7c7ba81aa446914c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Apr 2017 17:27:01 +0900 Subject: [PATCH 2/5] Fix correct mode filter not being applied when first entering song select. --- osu.Game/Screens/Select/BeatmapCarousel.cs | 4 ++-- osu.Game/Screens/Select/FilterControl.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 7443603c8b..f104bf9a37 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -179,11 +179,11 @@ namespace osu.Game.Screens.Select public void Filter(FilterCriteria newCriteria = null, bool debounce = true) { - if (!IsLoaded) return; - if (newCriteria != null) criteria = newCriteria; + if (!IsLoaded) return; + Action perform = delegate { filterTask = null; diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 26daddc3a9..6d92b35993 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -173,9 +173,9 @@ namespace osu.Game.Screens.Select { sortTabs.AccentColour = colours.GreenLight; - if (osu != null) - playMode.BindTo(osu.PlayMode); + if (osu != null) playMode.BindTo(osu.PlayMode); playMode.ValueChanged += val => FilterChanged?.Invoke(CreateCriteria()); + playMode.TriggerChange(); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; From 4aafc172ca5e2056d316a0c8a49bc7af54c902c2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Apr 2017 17:38:13 +0900 Subject: [PATCH 3/5] Allow playfield to specify whether it has a cursor or not. --- osu.Game.Modes.Osu/UI/OsuPlayfield.cs | 2 ++ osu.Game/Modes/UI/HitRenderer.cs | 12 ++++++++++++ osu.Game/Modes/UI/Playfield.cs | 5 +++++ osu.Game/OsuGame.cs | 2 +- osu.Game/Screens/Play/Player.cs | 6 ++---- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 8090263fe1..d89bbfd131 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -21,6 +21,8 @@ namespace osu.Game.Modes.Osu.UI private readonly Container judgementLayer; private readonly ConnectionRenderer connectionLayer; + public override bool ProvidingUserCursor => true; + public override Vector2 Size { get diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index e36d2a101c..a958c61c68 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -42,6 +42,16 @@ namespace osu.Game.Modes.UI /// protected readonly KeyConversionInputManager KeyConversionInputManager; + /// + /// Whether we are currently providing the local user a gameplay cursor. + /// + public virtual bool ProvidingUserCursor => false; + + /// + /// Whether we have a replay loaded currently. + /// + public bool HasReplayLoaded => InputManager.ReplayInputHandler != null; + /// /// Whether all the HitObjects have been judged. /// @@ -157,6 +167,8 @@ namespace osu.Game.Modes.UI { public event Action OnJudgement; + public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor; + protected override Container Content => content; protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result != HitResult.None); diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index eff06ce80f..f31ee0f189 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -22,6 +22,11 @@ namespace osu.Game.Modes.UI internal 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/OsuGame.cs b/osu.Game/OsuGame.cs index d75f8b4d8e..7172aba3be 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -314,7 +314,7 @@ namespace osu.Game if (intro?.ChildScreen != null) intro.ChildScreen.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; - Cursor.State = currentScreen == null || currentScreen.HasLocalCursorDisplayed ? Visibility.Hidden : Visibility.Visible; + Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index b263b5507c..f160563c3b 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -31,9 +31,7 @@ namespace osu.Game.Screens.Play internal override bool ShowOverlays => false; - internal override bool HasLocalCursorDisplayed => !hasReplayLoaded && !IsPaused; - - private bool hasReplayLoaded => HitRenderer.InputManager.ReplayInputHandler != null; + internal override bool HasLocalCursorDisplayed => !IsPaused && HitRenderer.ProvidingUserCursor; public BeatmapInfo BeatmapInfo; @@ -305,7 +303,7 @@ namespace osu.Game.Screens.Play { if (pauseOverlay == null) return false; - if (hasReplayLoaded) + if (HitRenderer.HasReplayLoaded) return false; if (pauseOverlay.State != Visibility.Visible && !canPause) return true; From 8d16e1efa2114cf62e87fd03376b0e8d4a862b4e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Apr 2017 17:42:56 +0900 Subject: [PATCH 4/5] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index e9b388934e..cd715ac535 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit e9b388934ed77cbc1af3cdfd213eb754f71554ae +Subproject commit cd715ac535ace224188ac56f88a08c4c2908f51b From 863dc44c4d83455f1966f331d54dad49c2d084b2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Apr 2017 20:00:22 +0900 Subject: [PATCH 5/5] Some minor improvements. --- osu.Game/Graphics/Backgrounds/Triangles.cs | 22 +++++++++++-------- .../Notifications/NotificationSection.cs | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 8dff614f6c..830d0adc97 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -60,8 +60,8 @@ namespace osu.Game.Graphics.Backgrounds protected override void LoadComplete() { base.LoadComplete(); - for (int i = 0; i < aimTriangleCount; i++) - addTriangle(true); + + addTriangles(true); } private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio); @@ -83,8 +83,8 @@ namespace osu.Game.Graphics.Backgrounds t.Expire(); } - while (CreateNewTriangles && Children.Count() < aimTriangleCount) - addTriangle(false); + if (CreateNewTriangles) + addTriangles(false); } protected virtual Triangle CreateTriangle() @@ -113,12 +113,16 @@ namespace osu.Game.Graphics.Backgrounds protected virtual Color4 GetTriangleShade() => Interpolation.ValueAt(RNG.NextSingle(), ColourDark, ColourLight, 0, 1); - private void addTriangle(bool randomY) + private void addTriangles(bool randomY) { - var sprite = CreateTriangle(); - float triangleHeight = sprite.DrawHeight / DrawHeight; - sprite.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() * (1 + triangleHeight) - triangleHeight : 1); - Add(sprite); + int addCount = aimTriangleCount - Children.Count(); + for (int i = 0; i < addCount; i++) + { + var sprite = CreateTriangle(); + float triangleHeight = sprite.DrawHeight / DrawHeight; + sprite.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() * (1 + triangleHeight) - triangleHeight : 1); + Add(sprite); + } } } } diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs index 77fc010e6d..663c5cf90c 100644 --- a/osu.Game/Overlays/Notifications/NotificationSection.cs +++ b/osu.Game/Overlays/Notifications/NotificationSection.cs @@ -155,7 +155,7 @@ namespace osu.Game.Overlays.Notifications public void MarkAllRead() { - notifications.Children.ForEach(n => n.Read = true); + notifications?.Children.ForEach(n => n.Read = true); } } } \ No newline at end of file