From 1139f0dbf248ebf29dc96d53faa64aae26de8c55 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 20 Jul 2018 17:04:33 +0900 Subject: [PATCH 1/6] Centralise method of disabling playfield judgements --- osu.Game.Rulesets.Mania/UI/Column.cs | 2 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 6 ------ osu.Game.Rulesets.Mania/UI/ManiaStage.cs | 2 +- osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs | 12 ------------ .../Edit/OsuEditRulesetContainer.cs | 3 --- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 2 -- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 3 +++ osu.Game/Rulesets/Edit/HitObjectComposer.cs | 7 +++++++ osu.Game/Rulesets/UI/Playfield.cs | 8 ++++++++ 9 files changed, 20 insertions(+), 25 deletions(-) delete mode 100644 osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index 063531da45..877189dd61 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.cs @@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Mania.UI internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { - if (!judgement.IsHit || !judgedObject.DisplayJudgement) + if (!judgement.IsHit || !judgedObject.DisplayJudgement || !DisplayJudgements) return; explosionContainer.Add(new HitExplosion(judgedObject) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index d6781a6e8f..f88169726e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; -using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Mania.Configuration; @@ -74,10 +73,5 @@ namespace osu.Game.Rulesets.Mania.UI { maniaConfig.BindWith(ManiaSetting.ScrollTime, VisibleTimeRange); } - - internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) - { - getStageByColumn(((ManiaHitObject)judgedObject.HitObject).Column).OnJudgement(judgedObject, judgement); - } } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs index a0ff8780ad..f386cf15a2 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaStage.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaStage.cs @@ -163,7 +163,7 @@ namespace osu.Game.Rulesets.Mania.UI internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { - if (!judgedObject.DisplayJudgement) + if (!judgedObject.DisplayJudgement || !DisplayJudgements) return; judgements.Clear(); diff --git a/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs b/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs deleted file mode 100644 index 6213bb1329..0000000000 --- a/osu.Game.Rulesets.Osu/Edit/OsuEditPlayfield.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Rulesets.Osu.UI; - -namespace osu.Game.Rulesets.Osu.Edit -{ - public class OsuEditPlayfield : OsuPlayfield - { - protected override bool DisplayJudgements => false; - } -} diff --git a/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs b/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs index ea33ec9ae0..6efa16bf56 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs @@ -4,7 +4,6 @@ using osu.Framework.Graphics.Cursor; using osu.Game.Beatmaps; using osu.Game.Rulesets.Osu.UI; -using osu.Game.Rulesets.UI; using OpenTK; namespace osu.Game.Rulesets.Osu.Edit @@ -16,8 +15,6 @@ namespace osu.Game.Rulesets.Osu.Edit { } - protected override Playfield CreatePlayfield() => new OsuEditPlayfield(); - protected override Vector2 PlayfieldArea => Vector2.One; protected override CursorContainer CreateCursor() => null; diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 04724931ae..b0ba9afee6 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -20,8 +20,6 @@ namespace osu.Game.Rulesets.Osu.UI private readonly JudgementContainer judgementLayer; private readonly ConnectionRenderer connectionLayer; - protected virtual bool DisplayJudgements => true; - public static readonly Vector2 BASE_SIZE = new Vector2(512, 384); public OsuPlayfield() diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index bb5994c2f2..4cb8dd48a7 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -226,6 +226,9 @@ namespace osu.Game.Rulesets.Taiko.UI internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { + if (!DisplayJudgements) + return; + if (judgedObject.DisplayJudgement && judgementContainer.FirstOrDefault(j => j.JudgedObject == judgedObject) == null) { judgementContainer.Add(new DrawableTaikoJudgement(judgement, judgedObject) diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index 0c91c9f548..b2f6e909d2 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -110,6 +110,13 @@ namespace osu.Game.Rulesets.Edit toolboxCollection.Items[0].Select(); } + protected override void LoadComplete() + { + base.LoadComplete(); + + rulesetContainer.Playfield.DisplayJudgements.Value = false; + } + protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index f2c9b49900..2f44d99e18 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Framework.Allocation; +using osu.Framework.Configuration; namespace osu.Game.Rulesets.UI { @@ -21,6 +22,11 @@ namespace osu.Game.Rulesets.UI public IReadOnlyList NestedPlayfields => nestedPlayfields; private List nestedPlayfields; + /// + /// Whether judgements should be displayed by this and and all nested s. + /// + public readonly BindableBool DisplayJudgements = new BindableBool(true); + /// /// A container for keeping track of DrawableHitObjects. /// @@ -73,6 +79,8 @@ namespace osu.Game.Rulesets.UI nestedPlayfields = new List(); nestedPlayfields.Add(otherPlayfield); + + otherPlayfield.DisplayJudgements.BindTo(DisplayJudgements); } /// From 82ea4456e42d7dd4b96243f5e97cb78347ecd2d7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 22 Jul 2018 22:47:25 +0200 Subject: [PATCH 2/6] Fix testing regression --- osu.Game.Tests/Visual/TestCasePlaySongSelect.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs index b94fb42bf0..41c45f00f3 100644 --- a/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/TestCasePlaySongSelect.cs @@ -54,6 +54,12 @@ namespace osu.Game.Tests.Visual public new BeatmapCarousel Carousel => base.Carousel; } + protected override void Dispose(bool isDisposing) + { + factory.ResetDatabase(); + base.Dispose(isDisposing); + } + [BackgroundDependencyLoader] private void load() { From 2169a473253247b8bddeee98b27b9511b181c6f7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Jul 2018 10:39:43 +0200 Subject: [PATCH 3/6] Prevent fatal failures on delete failures --- osu.Game/Tests/Visual/OsuTestCase.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/Tests/Visual/OsuTestCase.cs b/osu.Game/Tests/Visual/OsuTestCase.cs index 8e09ec849c..67a13bd850 100644 --- a/osu.Game/Tests/Visual/OsuTestCase.cs +++ b/osu.Game/Tests/Visual/OsuTestCase.cs @@ -62,7 +62,16 @@ namespace osu.Game.Tests.Visual } if (localStorage.IsValueCreated) - localStorage.Value.DeleteDirectory("."); + { + try + { + localStorage.Value.DeleteDirectory("."); + } + catch + { + // we don't really care if this fails; it will just leave folders lying around from test runs. + } + } } protected override ITestCaseTestRunner CreateRunner() => new OsuTestCaseTestRunner(); From 1b456fd7166a5645d9b3b058a8fbd7783a345518 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 23 Jul 2018 13:11:06 +0200 Subject: [PATCH 4/6] Fix a potential InvalidOperationException when entering song select Closes #3052. --- osu.Game/Screens/Select/Carousel/CarouselGroup.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/Carousel/CarouselGroup.cs b/osu.Game/Screens/Select/Carousel/CarouselGroup.cs index 2118cfdc78..ea461e7bd5 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselGroup.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselGroup.cs @@ -79,8 +79,13 @@ namespace osu.Game.Screens.Select.Carousel public override void Filter(FilterCriteria criteria) { base.Filter(criteria); - InternalChildren.Sort((x, y) => x.CompareTo(criteria, y)); - InternalChildren.ForEach(c => c.Filter(criteria)); + + var children = new List(InternalChildren); + + children.Sort((x, y) => x.CompareTo(criteria, y)); + children.ForEach(c => c.Filter(criteria)); + + InternalChildren = children; } protected virtual void ChildItemStateChanged(CarouselItem item, CarouselItemState value) From b38da34da9df8e8910e293a3a93766b58aab4bf0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 24 Jul 2018 12:11:14 +0200 Subject: [PATCH 5/6] Fix resetting database failing due to incorrect disposal logic --- osu.Game/Database/DatabaseContextFactory.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Database/DatabaseContextFactory.cs b/osu.Game/Database/DatabaseContextFactory.cs index c20d4569f6..e70d753114 100644 --- a/osu.Game/Database/DatabaseContextFactory.cs +++ b/osu.Game/Database/DatabaseContextFactory.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using System.Threading; using Microsoft.EntityFrameworkCore.Storage; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Platform; namespace osu.Game.Database @@ -115,7 +116,11 @@ namespace osu.Game.Database } } - private void recycleThreadContexts() => threadContexts = new ThreadLocal(CreateContext); + private void recycleThreadContexts() + { + threadContexts?.Values.ForEach(c => c.Dispose()); + threadContexts = new ThreadLocal(CreateContext, true); + } protected virtual OsuDbContext CreateContext() => new OsuDbContext(storage.GetDatabaseConnectionString(database_name)) { @@ -127,8 +132,6 @@ namespace osu.Game.Database lock (writeLock) { recycleThreadContexts(); - GC.Collect(); - GC.WaitForPendingFinalizers(); storage.DeleteDatabase(database_name); } } From 1d86083981b80ee725645ce9b10719c384a9687a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 24 Jul 2018 12:11:20 +0200 Subject: [PATCH 6/6] Hide unnecessary log output --- osu.Game/OsuGameBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 63cc883844..bada2a794d 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -224,7 +224,7 @@ namespace osu.Game // todo: we probably want a better (non-destructive) migrations/recovery process at a later point than this. contextFactory.ResetDatabase(); - Logger.Log("Database purged successfully.", LoggingTarget.Database, LogLevel.Important); + Logger.Log("Database purged successfully.", LoggingTarget.Database); // only run once more, then hard bail. using (var db = contextFactory.GetForWrite(false))