From 64c677a29dc43ef0a32266b02833ec2d673c5e75 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:42:37 +0900 Subject: [PATCH 01/32] Add IHasColumn. --- osu.Game.Rulesets.Mania/Objects/IHasColumn.cs | 11 +++++++++++ .../osu.Game.Rulesets.Mania.csproj | 1 + 2 files changed, 12 insertions(+) create mode 100644 osu.Game.Rulesets.Mania/Objects/IHasColumn.cs diff --git a/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs b/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs new file mode 100644 index 0000000000..daf7d217cd --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs @@ -0,0 +1,11 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +namespace osu.Game.Rulesets.Mania.Objects +{ + public interface IHasColumn + { + int Column { get; } + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index facffa757c..bc23661981 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -50,6 +50,7 @@ + From 53287936939e0a111c7dae0b8bebfa6b9f691d37 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:44:19 +0900 Subject: [PATCH 02/32] ManiaBaseHit -> ManiaHitObject. --- osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs | 4 ++-- osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs | 4 ++-- osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs | 4 ++-- .../Objects/{ManiaBaseHit.cs => ManiaHitObject.cs} | 4 ++-- osu.Game.Rulesets.Mania/Objects/Note.cs | 2 +- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 4 ++-- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 8 ++++---- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) rename osu.Game.Rulesets.Mania/Objects/{ManiaBaseHit.cs => ManiaHitObject.cs} (67%) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 847af965cc..10bebbdba7 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -11,11 +11,11 @@ using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Beatmaps { - internal class ManiaBeatmapConverter : BeatmapConverter + internal class ManiaBeatmapConverter : BeatmapConverter { protected override IEnumerable ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) }; - protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) + protected override IEnumerable ConvertHitObject(HitObject original, Beatmap beatmap) { yield return null; } diff --git a/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs b/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs index e9bcc60d2c..aaba4d94f0 100644 --- a/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; namespace osu.Game.Rulesets.Mania { - public class ManiaDifficultyCalculator : DifficultyCalculator + public class ManiaDifficultyCalculator : DifficultyCalculator { public ManiaDifficultyCalculator(Beatmap beatmap) : base(beatmap) @@ -21,6 +21,6 @@ namespace osu.Game.Rulesets.Mania return 0; } - protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); + protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs index 07a27b1643..72d1e5314b 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs @@ -12,9 +12,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawable { public class DrawableNote : Sprite { - private readonly ManiaBaseHit note; + private readonly ManiaHitObject note; - public DrawableNote(ManiaBaseHit note) + public DrawableNote(ManiaHitObject note) { this.note = note; Origin = Anchor.Centre; diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaBaseHit.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs similarity index 67% rename from osu.Game.Rulesets.Mania/Objects/ManiaBaseHit.cs rename to osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs index 4c15b69eb7..e991c1ad93 100644 --- a/osu.Game.Rulesets.Mania/Objects/ManiaBaseHit.cs +++ b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs @@ -5,8 +5,8 @@ using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { - public abstract class ManiaBaseHit : HitObject + public abstract class ManiaHitObject : HitObject, IHasColumn { - public int Column; + public int Column { get; set; } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 5a6d6003db..2cc993df64 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -3,7 +3,7 @@ namespace osu.Game.Rulesets.Mania.Objects { - public class Note : ManiaBaseHit + public class Note : ManiaHitObject { } } diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index ba0304a44a..96f04f79d4 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -8,13 +8,13 @@ using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Mania.Scoring { - internal class ManiaScoreProcessor : ScoreProcessor + internal class ManiaScoreProcessor : ScoreProcessor { public ManiaScoreProcessor() { } - public ManiaScoreProcessor(HitRenderer hitRenderer) + public ManiaScoreProcessor(HitRenderer hitRenderer) : base(hitRenderer) { } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 7fb8f95b4c..c007cdc80e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -13,7 +13,7 @@ using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Mania.UI { - public class ManiaHitRenderer : HitRenderer + public class ManiaHitRenderer : HitRenderer { private readonly int columns; @@ -25,10 +25,10 @@ namespace osu.Game.Rulesets.Mania.UI public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); - protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); + protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); - protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns); + protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns); - protected override DrawableHitObject GetVisualRepresentation(ManiaBaseHit h) => null; + protected override DrawableHitObject GetVisualRepresentation(ManiaHitObject h) => null; } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 5eea3d70c0..00f62b9869 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -11,7 +11,7 @@ using osu.Game.Rulesets.Mania.Judgements; namespace osu.Game.Rulesets.Mania.UI { - public class ManiaPlayfield : Playfield + public class ManiaPlayfield : Playfield { public ManiaPlayfield(int columns) { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index bc23661981..49331bf598 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -54,7 +54,7 @@ - + From d11e5d0060f88b6fd78a1dcad7d5ac1e9280b512 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 12:53:45 +0900 Subject: [PATCH 03/32] Add hit windows to Note/HoldNote. --- .../Judgements/HitWindows.cs | 162 ++++++++++++++++++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 23 ++- .../Objects/ManiaHitObject.cs | 1 + osu.Game.Rulesets.Mania/Objects/Note.cs | 12 ++ .../Objects/{ => Types}/IHasColumn.cs | 2 +- .../osu.Game.Rulesets.Mania.csproj | 3 +- 6 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Judgements/HitWindows.cs rename osu.Game.Rulesets.Mania/Objects/{ => Types}/IHasColumn.cs (79%) diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs new file mode 100644 index 0000000000..a1354314bf --- /dev/null +++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs @@ -0,0 +1,162 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Database; + +namespace osu.Game.Rulesets.Mania.Judgements +{ + public class HitWindows + { + #region Constants + + /// + /// PERFECT hit window at OD = 10. + /// + private const double perfect_min = 27.8; + /// + /// PERFECT hit window at OD = 5. + /// + private const double perfect_mid = 38.8; + /// + /// PERFECT hit window at OD = 0. + /// + private const double perfect_max = 44.8; + + /// + /// GREAT hit window at OD = 10. + /// + private const double great_min = 68; + /// + /// GREAT hit window at OD = 5. + /// + private const double great_mid = 98; + /// + /// GREAT hit window at OD = 0. + /// + private const double great_max = 128; + + /// + /// GOOD hit window at OD = 10. + /// + private const double good_min = 134; + /// + /// GOOD hit window at OD = 5. + /// + private const double good_mid = 164; + /// + /// GOOD hit window at OD = 0. + /// + private const double good_max = 194; + + /// + /// OK hit window at OD = 10. + /// + private const double ok_min = 194; + /// + /// OK hit window at OD = 5. + /// + private const double ok_mid = 224; + /// + /// OK hit window at OD = 0. + /// + private const double ok_max = 254; + + /// + /// BAD hit window at OD = 10. + /// + private const double bad_min = 242; + /// + /// BAD hit window at OD = 5. + /// + private const double bad_mid = 272; + /// + /// BAD hit window at OD = 0. + /// + private const double bad_max = 302; + + /// + /// MISS hit window at OD = 10. + /// + private const double miss_min = 316; + /// + /// MISS hit window at OD = 5. + /// + private const double miss_mid = 346; + /// + /// MISS hit window at OD = 0. + /// + private const double miss_max = 376; + + #endregion + + /// + /// Hit window for a PERFECT hit. + /// + public double Perfect = perfect_mid; + + /// + /// Hit window for a GREAT hit. + /// + public double Great = great_mid; + + /// + /// Hit window for a GOOD hit. + /// + public double Good = good_mid; + + /// + /// Hit window for an OK hit. + /// + public double Ok = ok_mid; + + /// + /// Hit window for a BAD hit. + /// + public double Bad = bad_mid; + + /// + /// Hit window for a MISS hit. + /// + public double Miss = miss_mid; + + public HitWindows() + { + } + + public HitWindows(double difficulty) + { + Perfect = BeatmapDifficulty.DifficultyRange(difficulty, perfect_max, perfect_mid, perfect_min); + Great = BeatmapDifficulty.DifficultyRange(difficulty, great_max, great_mid, great_min); + Good = BeatmapDifficulty.DifficultyRange(difficulty, good_max, good_mid, good_min); + Ok = BeatmapDifficulty.DifficultyRange(difficulty, ok_max, ok_mid, ok_min); + Bad = BeatmapDifficulty.DifficultyRange(difficulty, bad_max, bad_mid, bad_min); + Miss = BeatmapDifficulty.DifficultyRange(difficulty, miss_max, miss_mid, miss_min); + } + + public static HitWindows operator *(HitWindows windows, double value) + { + return new HitWindows + { + Perfect = windows.Perfect * value, + Great = windows.Great * value, + Good = windows.Good * value, + Ok = windows.Ok * value, + Bad = windows.Bad * value, + Miss = windows.Miss * value + }; + } + + public static HitWindows operator /(HitWindows windows, double value) + { + return new HitWindows + { + Perfect = windows.Perfect / value, + Great = windows.Great / value, + Good = windows.Good / value, + Ok = windows.Ok / value, + Bad = windows.Bad / value, + Miss = windows.Miss / value + }; + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index e8ce1da77f..e32eb3f147 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,9 +1,30 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Objects.Types; + namespace osu.Game.Rulesets.Mania.Objects { - public class HoldNote : Note + public class HoldNote : Note, IHasEndTime { + /// + /// Lenience of release hit windows. + /// + private const double release_window_lenience = 1.5; + + public double Duration { get; set; } + public double EndTime => StartTime + Duration; + + public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows(); + + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(timing, difficulty); + + ReleaseHitWindows = HitWindows * release_window_lenience; + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs index e991c1ad93..93aaa94f45 100644 --- a/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/ManiaHitObject.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Rulesets.Mania.Objects.Types; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 2cc993df64..83299ba7be 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -1,9 +1,21 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Beatmaps.Timing; +using osu.Game.Database; +using osu.Game.Rulesets.Mania.Judgements; + namespace osu.Game.Rulesets.Mania.Objects { public class Note : ManiaHitObject { + public HitWindows HitWindows { get; protected set; } = new HitWindows(); + + public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(timing, difficulty); + + HitWindows = new HitWindows(difficulty.OverallDifficulty); + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs similarity index 79% rename from osu.Game.Rulesets.Mania/Objects/IHasColumn.cs rename to osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs index daf7d217cd..7b98b2b4bb 100644 --- a/osu.Game.Rulesets.Mania/Objects/IHasColumn.cs +++ b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs @@ -2,7 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -namespace osu.Game.Rulesets.Mania.Objects +namespace osu.Game.Rulesets.Mania.Objects.Types { public interface IHasColumn { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 49331bf598..46a006b09c 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -48,9 +48,10 @@ + - + From 1fa42b26e87a9ef15a7eecd62522b23d19b21804 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 14:02:23 +0900 Subject: [PATCH 04/32] Make base DrawableHitObject uninheritable. --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index a300eeab31..f9b2cd5966 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -49,6 +49,10 @@ namespace osu.Game.Rulesets.Objects.Drawables } } + internal DrawableHitObject() + { + } + protected List Samples = new List(); protected void PlaySamples() From 956a7288fb27aa524a1ea3e8640bbe328f4c887b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 3 May 2017 15:50:42 +0900 Subject: [PATCH 05/32] Add basic DrawableNote. --- .../Tests/TestCaseManiaHitObjects.cs | 40 ++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../Objects/Drawable/DrawableNote.cs | 36 ----------- .../Drawables/DrawableManiaHitObject.cs | 52 +++++++++++++++ .../Objects/Drawables/DrawableNote.cs | 27 ++++++++ .../Objects/Drawables/Pieces/NotePiece.cs | 64 +++++++++++++++++++ .../osu.Game.Rulesets.Mania.csproj | 4 +- .../Objects/Drawables/DrawableHitObject.cs | 2 +- 8 files changed, 188 insertions(+), 38 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs delete mode 100644 osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs new file mode 100644 index 0000000000..b2baf26228 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -0,0 +1,40 @@ +// Copyright (c) 2007-2017 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.Testing; +using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Mania.Objects.Drawables; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseManiaHitObjects : TestCase + { + public override void Reset() + { + base.Reset(); + + Add(new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Width = 50, + Children = new[] + { + new DrawableNote(new Note()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + } + } + }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 135e4596c7..4312ac4d3b 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,6 +190,7 @@ + diff --git a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs deleted file mode 100644 index 72d1e5314b..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/Drawable/DrawableNote.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Framework.Allocation; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Textures; -using osu.Framework.Graphics.Transforms; -using osu.Framework.Graphics; -using OpenTK; - -namespace osu.Game.Rulesets.Mania.Objects.Drawable -{ - public class DrawableNote : Sprite - { - private readonly ManiaHitObject note; - - public DrawableNote(ManiaHitObject note) - { - this.note = note; - Origin = Anchor.Centre; - Scale = new Vector2(0.1f); - } - - [BackgroundDependencyLoader] - private void load(TextureStore textures) - { - Texture = textures.Get(@"Menu/logo"); - - const double duration = 0; - - Transforms.Add(new TransformPositionY { StartTime = note.StartTime - 200, EndTime = note.StartTime, StartValue = -0.1f, EndValue = 0.9f }); - Transforms.Add(new TransformAlpha { StartTime = note.StartTime + duration + 200, EndTime = note.StartTime + duration + 400, StartValue = 1, EndValue = 0 }); - Expire(true); - } - } -} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs new file mode 100644 index 0000000000..ebf99de72b --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -0,0 +1,52 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public abstract class DrawableManiaHitObject : DrawableHitObject + where TObject : ManiaHitObject + { + public override Color4 AccentColour + { + get { return base.AccentColour; } + set + { + base.AccentColour = value; + UpdateAccent(); + } + } + + public new TObject HitObject; + + protected override Container Content => noteFlow; + private FlowContainer noteFlow; + + public DrawableManiaHitObject(TObject hitObject) + : base(hitObject) + { + HitObject = hitObject; + + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + AddInternal(noteFlow = new FillFlowContainer + { + Name = "Main container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + }); + } + + protected override ManiaJudgement CreateJudgement() => new ManiaJudgement(); + + protected virtual void UpdateAccent() { } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs new file mode 100644 index 0000000000..d9603fb8ea --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableNote : DrawableManiaHitObject + { + private NotePiece headPiece; + + public DrawableNote(Note hitObject) + : base(hitObject) + { + Add(new NotePiece()); + } + + protected override void UpdateState(ArmedState state) + { + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs new file mode 100644 index 0000000000..e456dc3363 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces +{ + internal class NotePiece : Container, IHasAccentColour + { + private const float head_height = 10; + private const float head_colour_height = 6; + + private Box colouredBox; + + public NotePiece() + { + RelativeSizeAxes = Axes.X; + Height = head_height; + + Masking = true; + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both + }, + colouredBox = new Box + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.X, + Height = head_colour_height, + Alpha = 0.5f + } + }; + } + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + if (accentColour == value) + return; + accentColour = value; + + colouredBox.Colour = AccentColour; + + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = AccentColour + }; + } + } + } +} diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 46a006b09c..32925dcc45 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -51,9 +51,11 @@ + + + - diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index f9b2cd5966..21eca346c4 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// The colour used for various elements of this DrawableHitObject. /// - public Color4 AccentColour { get; protected set; } + public virtual Color4 AccentColour { get; set; } protected DrawableHitObject(TObject hitObject) { From f945c636c248e8822e6b2ffebd41af72a6f99922 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 4 May 2017 15:36:37 +0900 Subject: [PATCH 06/32] Make note accent colour work again. --- osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs | 4 +++- .../Objects/Drawables/DrawableNote.cs | 9 ++++++++- .../Objects/Drawables/Pieces/NotePiece.cs | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index b2baf26228..093b6f1e01 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using OpenTK.Graphics; namespace osu.Desktop.VisualTests.Tests { @@ -31,7 +32,8 @@ namespace osu.Desktop.VisualTests.Tests new DrawableNote(new Note()) { Anchor = Anchor.Centre, - Origin = Anchor.Centre + Origin = Anchor.Centre, + AccentColour = Color4.Red } } }); diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index d9603fb8ea..2b2b6e5b1a 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -17,7 +18,13 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableNote(Note hitObject) : base(hitObject) { - Add(new NotePiece()); + Add(headPiece = new NotePiece()); + } + + [BackgroundDependencyLoader] + private void load() + { + headPiece.AccentColour = AccentColour; } protected override void UpdateState(ArmedState state) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index e456dc3363..90456f4f62 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -35,7 +36,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.X, Height = head_colour_height, - Alpha = 0.5f + Alpha = 0.2f } }; } @@ -50,7 +51,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces return; accentColour = value; - colouredBox.Colour = AccentColour; + colouredBox.Colour = AccentColour.Lighten(0.9f); EdgeEffect = new EdgeEffect { From 4ad3e3d64eb821d45da43cb9b4067dfdc6227f41 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 4 May 2017 18:02:43 +0900 Subject: [PATCH 07/32] Basic implementation of hold notes (not finalized yet). --- .../Tests/TestCaseManiaHitObjects.cs | 40 +++++++++-- .../Objects/Drawables/DrawableHoldNote.cs | 72 +++++++++++++++++++ .../Drawables/DrawableManiaHitObject.cs | 68 ++++++++++++------ .../Objects/Drawables/DrawableNote.cs | 13 +++- .../Objects/Drawables/Pieces/BodyPiece.cs | 47 ++++++++++++ .../Objects/Drawables/Pieces/NotePiece.cs | 9 --- .../osu.Game.Rulesets.Mania.csproj | 2 + 7 files changed, 214 insertions(+), 37 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 093b6f1e01..a842406f99 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using OpenTK.Graphics; +using OpenTK; namespace osu.Desktop.VisualTests.Tests { @@ -21,19 +22,48 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(new Container + Add(new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, - Width = 50, - Children = new[] + Direction = FillDirection.Horizontal, + Spacing = new Vector2(10, 0), + // Imagine that the containers containing the drawable notes are the "columns" + Children = new Drawable[] { - new DrawableNote(new Note()) + new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AccentColour = Color4.Red + RelativeSizeAxes = Axes.Y, + Width = 50, + Children = new[] + { + new DrawableNote(new Note()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AccentColour = Color4.Red + } + } + }, + new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Y, + Width = 50, + Children = new[] + { + new DrawableHoldNote(new HoldNote()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AccentColour = Color4.Red, + Length = 0.4f + } + } } } }); diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs new file mode 100644 index 0000000000..7db65a6522 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -0,0 +1,72 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Framework.Graphics; +using osu.Framework.Allocation; +using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; +using OpenTK.Graphics; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableHoldNote : DrawableManiaHitObject + { + /// + /// Length of this hold note, relative to its parent. + /// + public float Length; + + private NotePiece headPiece; + private BodyPiece bodyPiece; + private NotePiece tailPiece; + + public DrawableHoldNote(HoldNote hitObject) + : base(hitObject) + { + Children = new Drawable[] + { + headPiece = new NotePiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre + }, + bodyPiece = new BodyPiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + }, + tailPiece = new NotePiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre + } + }; + } + + public override Color4 AccentColour + { + get { return AccentColour; } + set + { + if (base.AccentColour == value) + return; + base.AccentColour = value; + + headPiece.AccentColour = value; + bodyPiece.AccentColour = value; + tailPiece.AccentColour = value; + } + } + + + protected override void Update() + { + bodyPiece.Height = Parent.DrawSize.Y * Length; + } + + protected override void UpdateState(ArmedState state) + { + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index ebf99de72b..9f4c5f6ee2 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -4,6 +4,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Drawables; @@ -12,20 +13,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public abstract class DrawableManiaHitObject : DrawableHitObject where TObject : ManiaHitObject { - public override Color4 AccentColour - { - get { return base.AccentColour; } - set - { - base.AccentColour = value; - UpdateAccent(); - } - } - public new TObject HitObject; + private readonly Container glowContainer; + protected override Container Content => noteFlow; - private FlowContainer noteFlow; + private readonly FlowContainer noteFlow; public DrawableManiaHitObject(TObject hitObject) : base(hitObject) @@ -35,18 +28,53 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - AddInternal(noteFlow = new FillFlowContainer + InternalChildren = new Drawable[] { - Name = "Main container", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y - }); + glowContainer = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + AlwaysPresent = true, + Alpha = 0 + } + } + }, + noteFlow = new FillFlowContainer + { + Name = "Main container", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + } + }; + } + + public override Color4 AccentColour + { + get { return base.AccentColour; } + set + { + if (base.AccentColour == value) + return; + base.AccentColour = value; + + glowContainer.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 5, + Colour = value + }; + } } protected override ManiaJudgement CreateJudgement() => new ManiaJudgement(); - - protected virtual void UpdateAccent() { } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 2b2b6e5b1a..09443b6893 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -21,10 +21,17 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Add(headPiece = new NotePiece()); } - [BackgroundDependencyLoader] - private void load() + public override Color4 AccentColour { - headPiece.AccentColour = AccentColour; + get { return AccentColour; } + set + { + if (base.AccentColour == value) + return; + base.AccentColour = value; + + headPiece.AccentColour = value; + } } protected override void UpdateState(ArmedState state) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs new file mode 100644 index 0000000000..b2451c9995 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -0,0 +1,47 @@ +using System; +using OpenTK.Graphics; +using osu.Framework.Graphics; +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces +{ + internal class BodyPiece : Container, IHasAccentColour + { + private Box box; + + public BodyPiece() + { + RelativeSizeAxes = Axes.X; + Masking = true; + + Children = new[] + { + box = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.3f + } + }; + } + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + if (accentColour == value) + return; + accentColour = value; + + box.Colour = accentColour; + } + } + } +} diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 90456f4f62..0acb250f88 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -22,8 +22,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces RelativeSizeAxes = Axes.X; Height = head_height; - Masking = true; - Children = new[] { new Box @@ -52,13 +50,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces accentColour = value; colouredBox.Colour = AccentColour.Lighten(0.9f); - - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Glow, - Radius = 5, - Colour = AccentColour - }; } } } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 32925dcc45..be29b28a38 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -51,8 +51,10 @@ + + From 4f491519848cc9afab5babcaa56fd28171ffdc11 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 1 May 2017 21:29:57 +0800 Subject: [PATCH 08/32] Make metadata a member of WorkingBeatmap. --- osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 +++++-- osu.Game/Database/BeatmapDatabase.cs | 4 +++- osu.Game/Database/DatabaseWorkingBeatmap.cs | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs index 5e3f5b5133..b45574b761 100644 --- a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs @@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests.Beatmaps public class TestWorkingBeatmap : WorkingBeatmap { public TestWorkingBeatmap(Beatmap beatmap) - : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) + : base(beatmap.BeatmapInfo) { this.beatmap = beatmap; } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 589557b088..09a6ea7065 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -18,14 +18,17 @@ namespace osu.Game.Beatmaps public readonly BeatmapSetInfo BeatmapSetInfo; + public readonly BeatmapMetadata Metadata; + public readonly Bindable> Mods = new Bindable>(new Mod[] { }); public readonly bool WithStoryboard; - protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) { BeatmapInfo = beatmapInfo; - BeatmapSetInfo = beatmapSetInfo; + BeatmapSetInfo = beatmapSetInfo ?? beatmapInfo?.BeatmapSet; + Metadata = metadata ?? beatmapInfo?.Metadata ?? BeatmapSetInfo?.Metadata; WithStoryboard = withStoryboard; Mods.ValueChanged += mods => applyRateAdjustments(); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 0e814dea82..6f4559bc52 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -274,6 +274,8 @@ namespace osu.Game.Database if (beatmapSetInfo == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); + beatmapInfo.BeatmapSet = beatmapSetInfo; + //we need metadata GetChildren(beatmapSetInfo); //we also need a ruleset @@ -282,7 +284,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapSetInfo.Metadata; - WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, beatmapSetInfo, withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); previous?.TransferTo(working); diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 9fb3bed1e7..d3d5220e7f 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) - : base(beatmapInfo, beatmapSetInfo, withStoryboard) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) + : base(beatmapInfo, beatmapSetInfo, metadata, withStoryboard) { this.database = database; } From 146d57953d6f109f1114f8c51378fe6d9c0fb7f5 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 14:03:08 +0800 Subject: [PATCH 09/32] Use metadata field of WorkingBeatmap. --- osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs | 6 ++---- osu.Game/Database/DatabaseWorkingBeatmap.cs | 6 +++--- osu.Game/Overlays/MusicController.cs | 2 +- osu.Game/Screens/Menu/MainMenu.cs | 16 +++++++--------- osu.Game/Screens/Select/BeatmapDeleteDialog.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index db14a48af1..8431e5f812 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -51,14 +51,12 @@ namespace osu.Game.Beatmaps.Drawables title = new OsuSpriteText { Font = @"Exo2.0-BoldItalic", - Text = beatmap.BeatmapSetInfo.Metadata.Title, TextSize = 22, Shadow = true, }, artist = new OsuSpriteText { Font = @"Exo2.0-SemiBoldItalic", - Text = beatmap.BeatmapSetInfo.Metadata.Artist, TextSize = 17, Shadow = true, }, @@ -81,8 +79,8 @@ namespace osu.Game.Beatmaps.Drawables [BackgroundDependencyLoader] private void load(LocalisationEngine localisation) { - title.Current = localisation.GetUnicodePreference(beatmap.BeatmapSetInfo.Metadata.TitleUnicode, beatmap.BeatmapSetInfo.Metadata.Title); - artist.Current = localisation.GetUnicodePreference(beatmap.BeatmapSetInfo.Metadata.ArtistUnicode, beatmap.BeatmapSetInfo.Metadata.Artist); + title.Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title); + artist.Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist); } private class PanelBackground : BufferedContainer diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index d3d5220e7f..1c160a14e4 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -51,13 +51,13 @@ namespace osu.Game.Database protected override Texture GetBackground() { - if (BeatmapInfo?.Metadata?.BackgroundFile == null) + if (Metadata?.BackgroundFile == null) return null; try { using (var reader = getReader()) - return new TextureStore(new RawTextureLoaderStore(reader), false).Get(BeatmapInfo.Metadata.BackgroundFile); + return new TextureStore(new RawTextureLoaderStore(reader), false).Get(Metadata.BackgroundFile); } catch { return null; } } @@ -66,7 +66,7 @@ namespace osu.Game.Database { try { - var trackData = getReader()?.GetStream(BeatmapInfo.Metadata.AudioFile); + var trackData = getReader()?.GetStream(Metadata.AudioFile); return trackData == null ? null : new TrackBass(trackData); } catch { return null; } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 91d35db3bb..e3edaa0ca7 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -315,7 +315,7 @@ namespace osu.Game.Overlays } else { - BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; + BeatmapMetadata metadata = beatmap.Metadata; title.Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); artist.Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); } diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index a23efcd9d4..ed6a263b4c 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -65,7 +65,6 @@ namespace osu.Game.Screens.Menu private Bindable menuMusic; private TrackManager trackManager; - private WorkingBeatmap song; [BackgroundDependencyLoader] private void load(OsuGame game, OsuConfigManager config, BeatmapDatabase beatmaps) @@ -79,8 +78,7 @@ namespace osu.Game.Screens.Menu List choosableBeatmapSets = beatmaps.Query().ToList(); if (choosableBeatmapSets.Count > 0) { - song = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); - Beatmap = song; + Beatmap = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); } } @@ -106,15 +104,15 @@ namespace osu.Game.Screens.Menu { base.OnEntering(last); buttons.FadeInFromZero(500); - if (last is Intro && song != null) + if (last is Intro && Beatmap != null) { Task.Run(() => { - trackManager.SetExclusive(song.Track); - song.Track.Seek(song.Beatmap.Metadata.PreviewTime); - if (song.Beatmap.Metadata.PreviewTime == -1) - song.Track.Seek(song.Track.Length * 0.4f); - song.Track.Start(); + trackManager.SetExclusive(Beatmap.Track); + Beatmap.Track.Seek(Beatmap.Metadata.PreviewTime); + if (Beatmap.Metadata.PreviewTime == -1) + Beatmap.Track.Seek(Beatmap.Track.Length * 0.4f); + Beatmap.Track.Start(); }); } } diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index e6e9a86124..ac35f0e254 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; - BodyText = $@"{beatmap.Beatmap?.Metadata?.Artist} - {beatmap.Beatmap?.Metadata?.Title}"; + BodyText = $@"{beatmap?.Metadata?.Artist} - {beatmap?.Metadata?.Title}"; Buttons = new PopupDialogButton[] { new PopupDialogOkButton diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 7d0648ac11..4d7904123c 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -343,7 +343,7 @@ namespace osu.Game.Screens.Select { trackManager.SetExclusive(track); if (preview) - track.Seek(Beatmap.Beatmap.Metadata.PreviewTime); + track.Seek(Beatmap.Metadata.PreviewTime); track.Start(); } } From 767cfaaac39bcf02e62c66825678e21f30b4cff2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 15:37:53 +0800 Subject: [PATCH 10/32] Access database recursively. --- .../Beatmaps/IO/ImportBeatmapTest.cs | 7 +++--- osu.Game/Database/BeatmapDatabase.cs | 17 +++----------- osu.Game/Database/Database.cs | 4 ++-- osu.Game/Screens/Menu/MainMenu.cs | 22 ++++++++++--------- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 ++--- osu.Game/Screens/Select/SongSelect.cs | 2 +- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index b39db30fe8..cba150f91d 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -118,7 +118,7 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { while (!(resultSets = host.Dependencies.Get() - .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Any()) + .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526)).Any()) Thread.Sleep(50); }; @@ -135,15 +135,14 @@ namespace osu.Game.Tests.Beatmaps.IO waitAction = () => { while ((resultBeatmaps = host.Dependencies.Get() - .Query().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) + .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) Thread.Sleep(50); }; Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - //fetch children and check we can load from the post-storage path... - var set = host.Dependencies.Get().GetChildren(resultSets.First()); + var set = resultSets.First(); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 6f4559bc52..811a067116 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -36,14 +36,12 @@ namespace osu.Game.Database private void deletePending() { - foreach (var b in Query().Where(b => b.DeletePending)) + foreach (var b in GetAllWithChildren(b => b.DeletePending)) { try { Storage.Delete(b.Path); - GetChildren(b, true); - foreach (var i in b.Beatmaps) { if (i.Metadata != null) Connection.Delete(i.Metadata); @@ -269,20 +267,11 @@ namespace osu.Game.Database public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { - var beatmapSetInfo = Query().FirstOrDefault(s => s.ID == beatmapInfo.BeatmapSetInfoID); - - if (beatmapSetInfo == null) + if (beatmapInfo.BeatmapSet == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); - beatmapInfo.BeatmapSet = beatmapSetInfo; - - //we need metadata - GetChildren(beatmapSetInfo); - //we also need a ruleset - GetChildren(beatmapInfo); - if (beatmapInfo.Metadata == null) - beatmapInfo.Metadata = beatmapSetInfo.Metadata; + beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); diff --git a/osu.Game/Database/Database.cs b/osu.Game/Database/Database.cs index 23851b3b2e..9b49583875 100644 --- a/osu.Game/Database/Database.cs +++ b/osu.Game/Database/Database.cs @@ -48,9 +48,9 @@ namespace osu.Game.Database return Connection.Table(); } - public T GetWithChildren(object id) where T : class + public T GetWithChildren(object id, bool recursive = false) where T : class { - return Connection.GetWithChildren(id); + return Connection.GetWithChildren(id, recursive); } public List GetAllWithChildren(Expression> filter = null, bool recursive = true) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index ed6a263b4c..f8b8882d3d 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -1,13 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Threading.Tasks; +using OpenTK; +using OpenTK.Input; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Input; using osu.Framework.MathUtils; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Database; using osu.Game.Graphics.Containers; @@ -16,14 +19,8 @@ using osu.Game.Screens.Charts; using osu.Game.Screens.Direct; using osu.Game.Screens.Edit; using osu.Game.Screens.Multiplayer; -using OpenTK; using osu.Game.Screens.Select; using osu.Game.Screens.Tournament; -using osu.Framework.Input; -using OpenTK.Input; -using System.Threading.Tasks; -using System.Collections.Generic; -using System.Linq; namespace osu.Game.Screens.Menu { @@ -75,10 +72,15 @@ namespace osu.Game.Screens.Menu if (!menuMusic) { trackManager = game.Audio.Track; - List choosableBeatmapSets = beatmaps.Query().ToList(); - if (choosableBeatmapSets.Count > 0) + + var query = beatmaps.Query().Where(b => !b.DeletePending); + int count = query.Count(); + + if (count > 0) { - Beatmap = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren(choosableBeatmapSets[RNG.Next(0, choosableBeatmapSets.Count - 1)].ID).Beatmaps[0]); + var beatmap = query.ElementAt(RNG.Next(0, count - 1)); + beatmaps.GetChildren(beatmap, true); + Beatmap = beatmaps.GetWorkingBeatmap(beatmap.Beatmaps[0]); } } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index d05dd43b63..fbdaa948cc 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -220,13 +220,11 @@ namespace osu.Game.Screens.Select private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet) { - database.GetChildren(beatmapSet); - beatmapSet.Beatmaps.ForEach(b => + foreach(var b in beatmapSet.Beatmaps) { - database.GetChildren(b); if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; - }); + } return new BeatmapGroup(beatmapSet, database) { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 4d7904123c..51b67bdbef 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -183,7 +183,7 @@ namespace osu.Game.Screens.Select initialAddSetsTask = new CancellationTokenSource(); carousel.BeatmapsChanged = beatmapsLoaded; - carousel.Beatmaps = database.Query().Where(b => !b.DeletePending); + carousel.Beatmaps = database.GetAllWithChildren(b => !b.DeletePending); } private void beatmapsLoaded() From f37c857af8566c6366866f4d30acb72e028b2f46 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 6 May 2017 16:06:38 +0800 Subject: [PATCH 11/32] CI fixes. --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 4 ++-- osu.Game/Screens/Select/BeatmapDeleteDialog.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index cba150f91d..e259f700b1 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -118,7 +118,7 @@ namespace osu.Game.Tests.Beatmaps.IO Action waitAction = () => { while (!(resultSets = host.Dependencies.Get() - .GetAllWithChildren(s => s.OnlineBeatmapSetID == 241526)).Any()) + .Query().Where(s => s.OnlineBeatmapSetID == 241526)).Any()) Thread.Sleep(50); }; @@ -142,7 +142,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - var set = resultSets.First(); + var set = host.Dependencies.Get().GetChildren(resultSets.First(), true); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); diff --git a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs index ac35f0e254..0890625eb9 100644 --- a/osu.Game/Screens/Select/BeatmapDeleteDialog.cs +++ b/osu.Game/Screens/Select/BeatmapDeleteDialog.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select Icon = FontAwesome.fa_trash_o; HeaderText = @"Confirm deletion of"; - BodyText = $@"{beatmap?.Metadata?.Artist} - {beatmap?.Metadata?.Title}"; + BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}"; Buttons = new PopupDialogButton[] { new PopupDialogOkButton From 4c26a02e99bc59bfde504b54537fb1afd04065db Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 8 May 2017 16:42:53 +0800 Subject: [PATCH 12/32] Remove unnecessary arguments in WorkingBeatmap's constructor. --- osu.Game/Beatmaps/WorkingBeatmap.cs | 6 +++--- osu.Game/Database/BeatmapDatabase.cs | 2 +- osu.Game/Database/DatabaseWorkingBeatmap.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 09a6ea7065..0e8d8a9546 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -24,11 +24,11 @@ namespace osu.Game.Beatmaps public readonly bool WithStoryboard; - protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool withStoryboard = false) { BeatmapInfo = beatmapInfo; - BeatmapSetInfo = beatmapSetInfo ?? beatmapInfo?.BeatmapSet; - Metadata = metadata ?? beatmapInfo?.Metadata ?? BeatmapSetInfo?.Metadata; + BeatmapSetInfo = beatmapInfo.BeatmapSet; + Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata; WithStoryboard = withStoryboard; Mods.ValueChanged += mods => applyRateAdjustments(); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 811a067116..760b7ae353 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -273,7 +273,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; - WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard); previous?.TransferTo(working); diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 1c160a14e4..c56d6cea51 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) - : base(beatmapInfo, beatmapSetInfo, metadata, withStoryboard) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool withStoryboard = false) + : base(beatmapInfo, withStoryboard) { this.database = database; } From d852567d1d09a3e8475d2b9f914cf89328d05e18 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 20:33:59 +0900 Subject: [PATCH 13/32] Rewrite notes to have time-relative position and length. --- osu-framework | 2 +- .../Tests/TestCaseManiaHitObjects.cs | 20 +++++++--- .../Objects/Drawables/DrawableHoldNote.cs | 30 ++++++++------- .../Drawables/DrawableManiaHitObject.cs | 38 +++++++------------ .../Objects/Drawables/DrawableNote.cs | 9 ++++- .../Objects/Drawables/Pieces/BodyPiece.cs | 2 +- 6 files changed, 53 insertions(+), 48 deletions(-) diff --git a/osu-framework b/osu-framework index cebdfb1bbb..cd37a9cad9 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cebdfb1bbb260e5aaca0a01e06d7128b3d1faae4 +Subproject commit cd37a9cad9aaede267152cf3753cd31fe697cec4 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index a842406f99..c4aa5749b3 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -34,32 +34,40 @@ namespace osu.Desktop.VisualTests.Tests { new Container { + Name = "Normal note column", Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, + RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableNote(new Note()) + new DrawableNote(new Note + { + StartTime = 5000 + }) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, AccentColour = Color4.Red } } }, new Container { + Name = "Hold note column", Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, + RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableHoldNote(new HoldNote()) + new DrawableHoldNote(new HoldNote + { + StartTime = 5000, + Duration = 1000, + + }) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, AccentColour = Color4.Red, Length = 0.4f } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 7db65a6522..460c65dbbd 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics; using osu.Framework.Allocation; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; +using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Mania.Objects.Drawables { @@ -24,24 +25,31 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableHoldNote(HoldNote hitObject) : base(hitObject) { - Children = new Drawable[] + RelativeSizeAxes = Axes.Both; + Height = (float)HitObject.Duration; + + Add(new Drawable[] { - headPiece = new NotePiece - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre - }, bodyPiece = new BodyPiece { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, }, - tailPiece = new NotePiece + headPiece = new NotePiece { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre + }, + tailPiece = new NotePiece + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre } - }; + }); + + // The "length" of the hold note stops at the "base" of the tail piece + // but we want to contain the tail piece within our bounds + Height += (float)HitObject.Duration / headPiece.Height; } public override Color4 AccentColour @@ -59,12 +67,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } - - protected override void Update() - { - bodyPiece.Height = Parent.DrawSize.Y * Length; - } - protected override void UpdateState(ArmedState state) { } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 9f4c5f6ee2..28f9fa79b2 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -17,44 +18,31 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; - protected override Container Content => noteFlow; - private readonly FlowContainer noteFlow; - public DrawableManiaHitObject(TObject hitObject) : base(hitObject) { HitObject = hitObject; - RelativeSizeAxes = Axes.X; - AutoSizeAxes = Axes.Y; + Anchor = Anchor.TopCentre; + Origin = Anchor.BottomCentre; - InternalChildren = new Drawable[] + RelativePositionAxes = Axes.Y; + Y = (float)HitObject.StartTime; + + Add(glowContainer = new Container { - glowContainer = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Masking = true, - Children = new[] + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new[] { new Box { RelativeSizeAxes = Axes.Both, - AlwaysPresent = true, - Alpha = 0 + Alpha = 0, + AlwaysPresent = true } } - }, - noteFlow = new FillFlowContainer - { - Name = "Main container", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y - } - }; + }); } public override Color4 AccentColour diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 09443b6893..57990f2738 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -18,7 +18,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public DrawableNote(Note hitObject) : base(hitObject) { - Add(headPiece = new NotePiece()); + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + + Add(headPiece = new NotePiece + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre + }); } public override Color4 AccentColour diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index b2451c9995..7a61fd3a00 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces public BodyPiece() { - RelativeSizeAxes = Axes.X; + RelativeSizeAxes = Axes.Both; Masking = true; Children = new[] From 5b323ad4835a588b21bd6817354512ba83a1c721 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 20:55:20 +0900 Subject: [PATCH 14/32] Cleanups. --- .../Tests/TestCaseManiaHitObjects.cs | 43 +++++++++++++------ .../Judgements/HitWindows.cs | 2 +- .../Objects/Drawables/DrawableHoldNote.cs | 8 ++-- .../Drawables/DrawableManiaHitObject.cs | 12 +++--- .../Objects/Drawables/Pieces/BodyPiece.cs | 12 +++--- .../Objects/Drawables/Pieces/NotePiece.cs | 3 ++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 11 ++++- osu.Game.Rulesets.Mania/Objects/Note.cs | 8 +++- .../Objects/Types/IHasColumn.cs | 7 ++- 9 files changed, 71 insertions(+), 35 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index c4aa5749b3..97c65b799b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -39,15 +39,23 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, - RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableNote(new Note + new Container { - StartTime = 5000 - }) - { - AccentColour = Color4.Red + Name = "Timing section", + RelativeSizeAxes = Axes.Both, + RelativeCoordinateSpace = new Vector2(1, 10000), + Children = new[] + { + new DrawableNote(new Note + { + StartTime = 5000 + }) + { + AccentColour = Color4.Red + } + } } } }, @@ -58,18 +66,25 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Width = 50, - RelativeCoordinateSpace = new Vector2(1, 10000), Children = new[] { - new DrawableHoldNote(new HoldNote + new Container { - StartTime = 5000, - Duration = 1000, + Name = "Timing section", + RelativeSizeAxes = Axes.Both, + RelativeCoordinateSpace = new Vector2(1, 10000), + Children = new[] + { + new DrawableHoldNote(new HoldNote + { + StartTime = 5000, + Duration = 1000, - }) - { - AccentColour = Color4.Red, - Length = 0.4f + }) + { + AccentColour = Color4.Red + } + } } } } diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs index a1354314bf..7428f34882 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs @@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Mania.Judgements /// Hit window for a PERFECT hit. /// public double Perfect = perfect_mid; - + /// /// Hit window for a GREAT hit. /// diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 460c65dbbd..b6943a95ce 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -13,11 +13,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableHoldNote : DrawableManiaHitObject { - /// - /// Length of this hold note, relative to its parent. - /// - public float Length; - private NotePiece headPiece; private BodyPiece bodyPiece; private NotePiece tailPiece; @@ -30,6 +25,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Add(new Drawable[] { + // For now the body piece covers the entire height of the container + // whereas possibly in the future we don't want to extend under the head/tail. + // This will be fixed when new designs are given or the current design is finalized. bodyPiece = new BodyPiece { Anchor = Anchor.BottomCentre, diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 28f9fa79b2..f33a6fe699 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -34,14 +34,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.Both, Masking = true, Children = new[] + { + new Box { - new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0, - AlwaysPresent = true - } + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true } + } }); } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index 7a61fd3a00..ac2b7df06f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -1,16 +1,18 @@ -using System; -using OpenTK.Graphics; -using osu.Framework.Graphics; -// Copyright (c) 2007-2017 ppy Pty Ltd . +// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - +using System; +using OpenTK.Graphics; +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces { + /// + /// Represents length-wise portion of a hold note. + /// internal class BodyPiece : Container, IHasAccentColour { private Box box; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 0acb250f88..2584682833 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -10,6 +10,9 @@ using osu.Game.Graphics; namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces { + /// + /// Represents the static hit markers of notes. + /// internal class NotePiece : Container, IHasAccentColour { private const float head_height = 10; diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index e32eb3f147..a25b8fbf2a 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -8,17 +8,24 @@ using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Rulesets.Mania.Objects { + /// + /// Represents a hit object which requires pressing, holding, and releasing a key. + /// public class HoldNote : Note, IHasEndTime { /// - /// Lenience of release hit windows. + /// Lenience of release hit windows. This is to make cases where the hold note release + /// is timed alongside presses of other hit objects less awkward. /// private const double release_window_lenience = 1.5; public double Duration { get; set; } public double EndTime => StartTime + Duration; - public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows(); + /// + /// The key-release hit windows for this hold note. + /// + protected HitWindows ReleaseHitWindows = new HitWindows(); public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 83299ba7be..1d2e4169b5 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -7,9 +7,15 @@ using osu.Game.Rulesets.Mania.Judgements; namespace osu.Game.Rulesets.Mania.Objects { + /// + /// Represents a hit object which has a single hit press. + /// public class Note : ManiaHitObject { - public HitWindows HitWindows { get; protected set; } = new HitWindows(); + /// + /// The key-press hit window for this note. + /// + protected HitWindows HitWindows = new HitWindows(); public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { diff --git a/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs index 7b98b2b4bb..8281d0d9e4 100644 --- a/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs +++ b/osu.Game.Rulesets.Mania/Objects/Types/IHasColumn.cs @@ -1,11 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - namespace osu.Game.Rulesets.Mania.Objects.Types { + /// + /// A type of hit object which lies in one of a number of predetermined columns. + /// public interface IHasColumn { + /// + /// The column which the hit object lies in. + /// int Column { get; } } } From 89bfc0ff22a7d8eb4af1fcbacd1098f2710e167f Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 9 May 2017 20:55:38 +0900 Subject: [PATCH 15/32] Fix exception. --- osu.Game/Graphics/Cursor/CursorTrail.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Cursor/CursorTrail.cs b/osu.Game/Graphics/Cursor/CursorTrail.cs index 1bc1dea04f..11475a0f19 100644 --- a/osu.Game/Graphics/Cursor/CursorTrail.cs +++ b/osu.Game/Graphics/Cursor/CursorTrail.cs @@ -78,7 +78,7 @@ namespace osu.Game.Graphics.Cursor [BackgroundDependencyLoader] private void load(ShaderManager shaders, TextureStore textures) { - shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.Texture); + shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE); texture = textures.Get(@"Cursor/cursortrail"); Scale = new Vector2(1 / texture.ScaleAdjust); } From cdd71b496d18e7755d8a8b0557a2ae25ff277cab Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 9 May 2017 21:08:53 +0900 Subject: [PATCH 16/32] Fix unnecessary newline. --- osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 97c65b799b..4234140be6 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -78,8 +78,7 @@ namespace osu.Desktop.VisualTests.Tests new DrawableHoldNote(new HoldNote { StartTime = 5000, - Duration = 1000, - + Duration = 1000 }) { AccentColour = Color4.Red From 2e7812956a2af8614a3b7bc29a12565282e2cec2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 10 May 2017 14:15:11 +0900 Subject: [PATCH 17/32] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 1c95c94fab..3dd870dc42 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 1c95c94fab6852620cd82eb0899ca0132ac82667 +Subproject commit 3dd870dc42474978c0465d4276641431eba16c91 From 3b533de8acb5c3cf9c84abe8dbe67320f74ae6a6 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:29:54 +0900 Subject: [PATCH 18/32] Add xmldoc to HitWindows.cs. --- .../Judgements/HitWindows.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs index 7428f34882..2a0ce88506 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HitWindows.cs @@ -119,10 +119,17 @@ namespace osu.Game.Rulesets.Mania.Judgements /// public double Miss = miss_mid; + /// + /// Constructs default hit windows. + /// public HitWindows() { } + /// + /// Constructs hit windows by fitting a parameter to a 2-part piecewise linear function for each hit window. + /// + /// The parameter. public HitWindows(double difficulty) { Perfect = BeatmapDifficulty.DifficultyRange(difficulty, perfect_max, perfect_mid, perfect_min); @@ -133,6 +140,11 @@ namespace osu.Game.Rulesets.Mania.Judgements Miss = BeatmapDifficulty.DifficultyRange(difficulty, miss_max, miss_mid, miss_min); } + /// + /// Constructs new hit windows which have been multiplied by a value. + /// + /// The original hit windows. + /// The value to multiply each hit window by. public static HitWindows operator *(HitWindows windows, double value) { return new HitWindows @@ -146,6 +158,11 @@ namespace osu.Game.Rulesets.Mania.Judgements }; } + /// + /// Constructs new hit windows which have been divided by a value. + /// + /// The original hit windows. + /// The value to divide each hit window by. public static HitWindows operator /(HitWindows windows, double value) { return new HitWindows From 46149044093b83aeb81a44b70296ea215fa6f6f0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:38:59 +0900 Subject: [PATCH 19/32] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index cd37a9cad9..a1a62c14a5 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit cd37a9cad9aaede267152cf3753cd31fe697cec4 +Subproject commit a1a62c14a51654c933c5b077c725d566f167145b From cdf827df8ea19c902a74453959bd43657e4b3e0a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 13:11:36 +0900 Subject: [PATCH 20/32] CI fixes. --- .../Tests/TestCaseManiaHitObjects.cs | 5 ----- .../Objects/Drawables/DrawableHoldNote.cs | 11 ++++------- .../Objects/Drawables/DrawableManiaHitObject.cs | 3 +-- .../Objects/Drawables/DrawableNote.cs | 7 ++----- .../Objects/Drawables/Pieces/BodyPiece.cs | 3 +-- .../Objects/Drawables/Pieces/NotePiece.cs | 2 +- 6 files changed, 9 insertions(+), 22 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index 4234140be6..3ad83beb73 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -6,11 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using OpenTK.Graphics; using OpenTK; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index b6943a95ce..61dc2638a6 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -1,21 +1,18 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Game.Rulesets.Objects.Drawables; using osu.Framework.Graphics; -using osu.Framework.Allocation; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; -using osu.Framework.Graphics.Containers; namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableHoldNote : DrawableManiaHitObject { - private NotePiece headPiece; - private BodyPiece bodyPiece; - private NotePiece tailPiece; + private readonly NotePiece headPiece; + private readonly BodyPiece bodyPiece; + private readonly NotePiece tailPiece; public DrawableHoldNote(HoldNote hitObject) : base(hitObject) @@ -52,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return AccentColour; } + get { return base.AccentColour; } set { if (base.AccentColour == value) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index f33a6fe699..29e4137bba 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -18,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; - public DrawableManiaHitObject(TObject hitObject) + protected DrawableManiaHitObject(TObject hitObject) : base(hitObject) { HitObject = hitObject; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 57990f2738..bc194b7703 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -2,10 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK.Graphics; -using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Objects.Drawables; @@ -13,7 +10,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableNote : DrawableManiaHitObject { - private NotePiece headPiece; + private readonly NotePiece headPiece; public DrawableNote(Note hitObject) : base(hitObject) @@ -30,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public override Color4 AccentColour { - get { return AccentColour; } + get { return base.AccentColour; } set { if (base.AccentColour == value) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs index ac2b7df06f..ce61a7a86f 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/BodyPiece.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -15,7 +14,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces /// internal class BodyPiece : Container, IHasAccentColour { - private Box box; + private readonly Box box; public BodyPiece() { diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs index 2584682833..e01199e929 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/Pieces/NotePiece.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces private const float head_height = 10; private const float head_colour_height = 6; - private Box colouredBox; + private readonly Box colouredBox; public NotePiece() { From 6445bea864d2bd3fdd3e0f9fc21186a65569857e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:43:57 +0900 Subject: [PATCH 21/32] Make Playfield.HitObjects internal to playfields. Because not all playfields will be using this. --- osu.Game/Rulesets/UI/HitRenderer.cs | 11 ++++++++--- osu.Game/Rulesets/UI/Playfield.cs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 8ee67df95a..4ca77f71df 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -187,17 +187,19 @@ namespace osu.Game.Rulesets.UI 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); + public override IEnumerable Objects => Beatmap.HitObjects; + + protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judgement.Result != HitResult.None); /// /// The playfield. /// protected Playfield Playfield; + protected override Container Content => content; private readonly Container content; - public override IEnumerable Objects => Beatmap.HitObjects; + private List> drawableObjects; protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) @@ -224,6 +226,8 @@ namespace osu.Game.Rulesets.UI private void loadObjects() { + drawableObjects = new List>(Beatmap.HitObjects.Count); + foreach (TObject h in Beatmap.HitObjects) { var drawableObject = GetVisualRepresentation(h); @@ -233,6 +237,7 @@ namespace osu.Game.Rulesets.UI drawableObject.OnJudgement += onJudgement; + drawableObjects.Add(drawableObject); Playfield.Add(drawableObject); } diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 0586c0385a..612569a9ae 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.UI /// /// The HitObjects contained in this Playfield. /// - public HitObjectContainer> HitObjects; + protected HitObjectContainer> HitObjects; internal Container ScaledContent; From 2d2d1bedddf1664ef5037de502cc9b7885462b89 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:48:08 +0900 Subject: [PATCH 22/32] More concrete method to determine if all hit objects have been judged. Covers the case where nested hit objects are involved. --- .../Objects/Drawables/DrawableHitObject.cs | 14 ++++++++++++-- osu.Game/Rulesets/UI/HitRenderer.cs | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index a300eeab31..45ef2553b5 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -12,6 +12,7 @@ using Container = osu.Framework.Graphics.Containers.Container; using osu.Game.Rulesets.Objects.Types; using OpenTK.Graphics; using osu.Game.Audio; +using System.Linq; namespace osu.Game.Rulesets.Objects.Drawables { @@ -24,6 +25,11 @@ namespace osu.Game.Rulesets.Objects.Drawables public TJudgement Judgement; + /// + /// Whether this hit object has been judged. + /// + public virtual bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None; + protected abstract TJudgement CreateJudgement(); protected abstract void UpdateState(ArmedState state); @@ -86,6 +92,11 @@ namespace osu.Game.Rulesets.Objects.Drawables /// public Color4 AccentColour { get; protected set; } + /// + /// Whether this hit object and all of its nested hit objects have been judged. + /// + public sealed override bool Judged => base.Judged && (NestedHitObjects?.All(h => h.Judged) ?? true); + protected DrawableHitObject(TObject hitObject) { HitObject = hitObject; @@ -97,7 +108,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// Whether a hit was processed. protected bool UpdateJudgement(bool userTriggered) { - IPartialJudgement partial = Judgement as IPartialJudgement; + var partial = Judgement as IPartialJudgement; // Never re-process non-partial hits if (Judgement.Result != HitResult.None && partial == null) @@ -169,7 +180,6 @@ namespace osu.Game.Rulesets.Objects.Drawables } private List> nestedHitObjects; - protected IEnumerable> NestedHitObjects => nestedHitObjects; protected void AddNested(DrawableHitObject h) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 4ca77f71df..559014ce95 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -189,7 +189,7 @@ namespace osu.Game.Rulesets.UI public override IEnumerable Objects => Beatmap.HitObjects; - protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judgement.Result != HitResult.None); + protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judged); /// /// The playfield. From a762f820c68d900df075e3a571b3e25878c9e286 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 14:50:18 +0900 Subject: [PATCH 23/32] Fix possible nullrefs. --- osu.Game/Rulesets/UI/HitRenderer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 559014ce95..3ec5c353a0 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -199,7 +199,7 @@ namespace osu.Game.Rulesets.UI protected override Container Content => content; private readonly Container content; - private List> drawableObjects; + private readonly List> drawableObjects = new List>(); protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) @@ -226,7 +226,7 @@ namespace osu.Game.Rulesets.UI private void loadObjects() { - drawableObjects = new List>(Beatmap.HitObjects.Count); + drawableObjects.Capacity = Beatmap.HitObjects.Count; foreach (TObject h in Beatmap.HitObjects) { From b0e522345cda92b51033c72d9aeeb29a017bc0c2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 17:07:46 +0900 Subject: [PATCH 24/32] Combine DrawableHitObject classes into one --- .../Objects/Drawables/DrawableHitObject.cs | 43 +++++++------------ 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 21eca346c4..5622df9d14 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -15,9 +14,19 @@ using osu.Game.Audio; namespace osu.Game.Rulesets.Objects.Drawables { - public abstract class DrawableHitObject : Container, IStateful + public abstract class DrawableHitObject : Container + where TObject : HitObject where TJudgement : Judgement { + public event Action> OnJudgement; + + public TObject HitObject; + + /// + /// The colour used for various elements of this DrawableHitObject. + /// + public virtual Color4 AccentColour { get; set; } + public override bool HandleInput => Interactive; public bool Interactive = true; @@ -49,10 +58,6 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - internal DrawableHitObject() - { - } - protected List Samples = new List(); protected void PlaySamples() @@ -60,14 +65,6 @@ namespace osu.Game.Rulesets.Objects.Drawables Samples.ForEach(s => s?.Play()); } - [BackgroundDependencyLoader] - private void load() - { - //we may be setting a custom judgement in test cases or what not. - if (Judgement == null) - Judgement = CreateJudgement(); - } - protected override void LoadComplete() { base.LoadComplete(); @@ -75,20 +72,6 @@ namespace osu.Game.Rulesets.Objects.Drawables //force application of the state that was set before we loaded. UpdateState(State); } - } - - public abstract class DrawableHitObject : DrawableHitObject - where TObject : HitObject - where TJudgement : Judgement - { - public event Action> OnJudgement; - - public TObject HitObject; - - /// - /// The colour used for various elements of this DrawableHitObject. - /// - public virtual Color4 AccentColour { get; set; } protected DrawableHitObject(TObject hitObject) { @@ -170,6 +153,10 @@ namespace osu.Game.Rulesets.Objects.Drawables channel.Volume.Value = sample.Volume; Samples.Add(channel); } + + //we may be setting a custom judgement in test cases or what not. + if (Judgement == null) + Judgement = CreateJudgement(); } private List> nestedHitObjects; From 6fd95e0c5286ff4a1f6ac8321b43ba088bcd975c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 17:16:01 +0900 Subject: [PATCH 25/32] Fix post-merge breakage --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 07be689446..c5dbc27fd3 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -34,11 +34,6 @@ namespace osu.Game.Rulesets.Objects.Drawables public TJudgement Judgement; - /// - /// Whether this hit object has been judged. - /// - public virtual bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None; - protected abstract TJudgement CreateJudgement(); protected abstract void UpdateState(ArmedState state); @@ -82,7 +77,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// Whether this hit object and all of its nested hit objects have been judged. /// - public sealed override bool Judged => base.Judged && (NestedHitObjects?.All(h => h.Judged) ?? true); + public bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None && (NestedHitObjects?.All(h => h.Judged) ?? true); protected DrawableHitObject(TObject hitObject) { From 6cc54773e8493b20607a7aa9576a475b2dafc17c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Thu, 11 May 2017 17:18:22 +0900 Subject: [PATCH 26/32] Fix taiko right background not scaling with the playfield as intended. --- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 8e6f1c8556..23c7606a15 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -54,33 +54,33 @@ namespace osu.Game.Rulesets.Taiko.UI { AddInternal(new Drawable[] { - rightBackgroundContainer = new Container - { - Name = "Transparent playfield background", - RelativeSizeAxes = Axes.Both, - BorderThickness = 2, - Masking = true, - EdgeEffect = new EdgeEffect - { - Type = EdgeEffectType.Shadow, - Colour = Color4.Black.Opacity(0.2f), - Radius = 5, - }, - Children = new Drawable[] - { - rightBackground = new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0.6f - }, - } - }, new ScaleFixContainer { RelativeSizeAxes = Axes.X, Height = DEFAULT_PLAYFIELD_HEIGHT, Children = new[] { + rightBackgroundContainer = new Container + { + Name = "Transparent playfield background", + RelativeSizeAxes = Axes.Both, + BorderThickness = 2, + Masking = true, + EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Shadow, + Colour = Color4.Black.Opacity(0.2f), + Radius = 5, + }, + Children = new Drawable[] + { + rightBackground = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.6f + }, + } + }, new Container { Name = "Transparent playfield elements", From a2f6d8a3e68a2c7b4c014d80e3c5e282cd231c29 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 18:14:48 +0900 Subject: [PATCH 27/32] Fix broken test cases, remove some recursive lookup methods. --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 2 +- osu.Game/Database/BeatmapDatabase.cs | 3 +++ osu.Game/Database/Database.cs | 8 +++----- osu.Game/Screens/Menu/MainMenu.cs | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index e259f700b1..0e456941a1 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -142,7 +142,7 @@ namespace osu.Game.Tests.Beatmaps.IO Assert.IsTrue(waitAction.BeginInvoke(null, null).AsyncWaitHandle.WaitOne(timeout), @"Beatmaps did not import to the database in allocated time"); - var set = host.Dependencies.Get().GetChildren(resultSets.First(), true); + var set = host.Dependencies.Get().GetChildren(resultSets.First()); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count(), $@"Incorrect database beatmap count post-import ({resultBeatmaps.Count()} but should be {set.Beatmaps.Count})."); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 760b7ae353..de570d3e7e 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -267,6 +267,9 @@ namespace osu.Game.Database public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false) { + if (beatmapInfo.BeatmapSet == null) + beatmapInfo = GetChildren(beatmapInfo, true); + if (beatmapInfo.BeatmapSet == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); diff --git a/osu.Game/Database/Database.cs b/osu.Game/Database/Database.cs index 9b49583875..a55c0f570b 100644 --- a/osu.Game/Database/Database.cs +++ b/osu.Game/Database/Database.cs @@ -48,11 +48,9 @@ namespace osu.Game.Database return Connection.Table(); } - public T GetWithChildren(object id, bool recursive = false) where T : class - { - return Connection.GetWithChildren(id, recursive); - } - + /// + /// This is expensive. Use with caution. + /// public List GetAllWithChildren(Expression> filter = null, bool recursive = true) where T : class { diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index f8b8882d3d..c8a00e0671 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -79,7 +79,7 @@ namespace osu.Game.Screens.Menu if (count > 0) { var beatmap = query.ElementAt(RNG.Next(0, count - 1)); - beatmaps.GetChildren(beatmap, true); + beatmaps.GetChildren(beatmap); Beatmap = beatmaps.GetWorkingBeatmap(beatmap.Beatmaps[0]); } } From b258109a9ee1c9e98299a0543a7e99bfec18d2fe Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 18:27:14 +0900 Subject: [PATCH 28/32] Fix chat input box not always keeping focus as expected --- osu.Game/Overlays/ChatOverlay.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 457611dfab..dc586bd363 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -110,12 +110,18 @@ namespace osu.Game.Overlays { MoveToY(0, transition_length, EasingTypes.OutQuint); FadeIn(transition_length, EasingTypes.OutQuint); + + inputTextBox.HoldFocus = true; + base.PopIn(); } protected override void PopOut() { MoveToY(DrawSize.Y, transition_length, EasingTypes.InSine); FadeOut(transition_length, EasingTypes.InSine); + + inputTextBox.HoldFocus = false; + base.PopOut(); } [BackgroundDependencyLoader] From 7d221802a2fa0dc81f78204c644a6b861f23c746 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 19:27:02 +0900 Subject: [PATCH 29/32] Fix refresh tokens not working correctly Turns out there's plenty of slashes in refresh tokens. --- osu.Game/Online/API/OAuthToken.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/API/OAuthToken.cs b/osu.Game/Online/API/OAuthToken.cs index 4085e5602a..328888ab8a 100644 --- a/osu.Game/Online/API/OAuthToken.cs +++ b/osu.Game/Online/API/OAuthToken.cs @@ -41,13 +41,13 @@ namespace osu.Game.Online.API [JsonProperty(@"refresh_token")] public string RefreshToken; - public override string ToString() => $@"{AccessToken}/{AccessTokenExpiry.ToString(NumberFormatInfo.InvariantInfo)}/{RefreshToken}"; + public override string ToString() => $@"{AccessToken}|{AccessTokenExpiry.ToString(NumberFormatInfo.InvariantInfo)}|{RefreshToken}"; public static OAuthToken Parse(string value) { try { - string[] parts = value.Split('/'); + string[] parts = value.Split('|'); return new OAuthToken { AccessToken = parts[0], From 4e881644f60995a90325d99f77d00a99fad354a9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 19:35:07 +0900 Subject: [PATCH 30/32] Add thread-safety on access token validation logic. --- osu.Game/Online/API/OAuth.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index 0ee7e0e030..2f841b67b1 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -72,21 +72,28 @@ namespace osu.Game.Online.API } } + private static readonly object access_token_retrieval_lock = new object(); + /// /// Should be run before any API request to make sure we have a valid key. /// private bool ensureAccessToken() { - //todo: we need to mutex this to ensure only one authentication request is running at a time. - - //If we already have a valid access token, let's use it. + // if we already have a valid access token, let's use it. if (accessTokenValid) return true; - //If not, let's try using our refresh token to request a new access token. - if (!string.IsNullOrEmpty(Token?.RefreshToken)) - AuthenticateWithRefresh(Token.RefreshToken); + // we want to ensure only a single authentication update is happening at once. + lock (access_token_retrieval_lock) + { + // re-check if valid, in case another requrest completed and revalidated our access. + if (accessTokenValid) return true; - return accessTokenValid; + // if not, let's try using our refresh token to request a new access token. + if (!string.IsNullOrEmpty(Token?.RefreshToken)) + AuthenticateWithRefresh(Token.RefreshToken); + + return accessTokenValid; + } } private bool accessTokenValid => Token?.IsValid ?? false; From c3d2cdd2f2ab15c353a08f403fc1a55de06a71f6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 19:49:28 +0900 Subject: [PATCH 31/32] Fix typo --- osu.Game/Online/API/OAuth.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index 2f841b67b1..c96b21a855 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -85,7 +85,7 @@ namespace osu.Game.Online.API // we want to ensure only a single authentication update is happening at once. lock (access_token_retrieval_lock) { - // re-check if valid, in case another requrest completed and revalidated our access. + // re-check if valid, in case another request completed and revalidated our access. if (accessTokenValid) return true; // if not, let's try using our refresh token to request a new access token. From 9a1c662d1fb2e767f4118716ff348a1bccc4e208 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 May 2017 21:12:13 +0900 Subject: [PATCH 32/32] Update framework --- osu-framework | 2 +- osu.Game/Input/GlobalHotkeys.cs | 26 -------------------------- osu.Game/OsuGame.cs | 1 - osu.Game/osu.Game.csproj | 1 - 4 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 osu.Game/Input/GlobalHotkeys.cs diff --git a/osu-framework b/osu-framework index a1a62c14a5..682f078b2e 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a1a62c14a51654c933c5b077c725d566f167145b +Subproject commit 682f078b2efc82fa19342f499f14c4a8458843d5 diff --git a/osu.Game/Input/GlobalHotkeys.cs b/osu.Game/Input/GlobalHotkeys.cs deleted file mode 100644 index b1b22f7069..0000000000 --- a/osu.Game/Input/GlobalHotkeys.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using osu.Framework.Graphics; -using osu.Framework.Input; - -namespace osu.Game.Input -{ - public class GlobalHotkeys : Drawable - { - public Func Handler; - - public override bool HandleInput => true; - - public GlobalHotkeys() - { - RelativeSizeAxes = Axes.Both; - } - - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - return Handler(state, args); - } - } -} \ No newline at end of file diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index c9f41de5f2..ccead95ede 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Overlays; using osu.Framework.Input; -using osu.Game.Input; using OpenTK.Input; using osu.Framework.Logging; using osu.Game.Graphics.UserInterface.Volume; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index bd9f087cf7..fd15115fe2 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -284,7 +284,6 @@ -