From dcf879687d30fba36c5e7a1f19213ed63e84de27 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 20:45:01 +0900 Subject: [PATCH 01/83] Implement basic hold note + tick input. --- .../Tests/TestCaseManiaPlayfield.cs | 47 +++++ .../Legacy/DistanceObjectPatternGenerator.cs | 9 +- .../Legacy/EndTimeObjectPatternGenerator.cs | 9 +- .../Judgements/HoldNoteTailJudgement.cs | 13 ++ .../Judgements/HoldNoteTickJudgement.cs | 9 + .../Objects/Drawables/DrawableHoldNote.cs | 198 ++++++++++++++++-- .../Objects/Drawables/DrawableHoldNoteTick.cs | 75 +++++++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 42 ++-- .../Objects/HoldNoteTail.cs | 24 +++ .../Objects/HoldNoteTick.cs | 9 + .../osu.Game.Rulesets.Mania.csproj | 5 + 11 files changed, 406 insertions(+), 34 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs create mode 100644 osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 9dcba02849..27ad39fb1e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -11,6 +11,9 @@ using OpenTK; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Timing; +using osu.Framework.Configuration; +using OpenTK.Input; +using osu.Framework.Timing; namespace osu.Desktop.VisualTests.Tests { @@ -59,6 +62,48 @@ namespace osu.Desktop.VisualTests.Tests } }; + Action createPlayfieldWithNotesAcceptingInput = () => + { + Clear(); + + var rateAdjustClock = new StopwatchClock(true) { Rate = 0.2 }; + + ManiaPlayfield playField; + Add(playField = new ManiaPlayfield(4, new List { new TimingChange { BeatLength = 200 } }) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(1, -1), + Clock = new FramedClock(rateAdjustClock) + }); + + playField.Add(new DrawableNote(new Note + { + StartTime = 1000, + Column = 0 + }, new Bindable(Key.D))); + + playField.Add(new DrawableHoldNote(new HoldNote + { + StartTime = 1000, + Duration = 2000, + Column = 1 + }, new Bindable(Key.F))); + + playField.Add(new DrawableHoldNote(new HoldNote + { + StartTime = 1000, + Duration = 2000, + Column = 2 + }, new Bindable(Key.J))); + + playField.Add(new DrawableNote(new Note + { + StartTime = 1000, + Column = 3 + }, new Bindable(Key.K))); + }; + AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); @@ -76,6 +121,8 @@ namespace osu.Desktop.VisualTests.Tests AddWaitStep(10); AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); AddWaitStep(10); + + AddStep("Test", () => createPlayfieldWithNotesAcceptingInput()); } private void triggerKeyDown(Column column) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 718e0967da..279ac868f1 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -471,14 +471,17 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy } else { - newObject = new HoldNote + var holdNote = new HoldNote { StartTime = startTime, - Samples = sampleInfoListAt(startTime), - EndSamples = sampleInfoListAt(endTime), Column = column, Duration = endTime - startTime }; + + holdNote.HeadNote.Samples = sampleInfoListAt(startTime); + holdNote.TailNote.Samples = sampleInfoListAt(endTime); + + newObject = holdNote; } pattern.Add(newObject); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs index 8f438f9ff4..ddc7d77c0c 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs @@ -69,18 +69,21 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (holdNote) { - newObject = new HoldNote + var hold = new HoldNote { StartTime = HitObject.StartTime, - EndSamples = HitObject.Samples, Column = column, Duration = endTime - HitObject.StartTime }; - newObject.Samples.Add(new SampleInfo + hold.HeadNote.Samples.Add(new SampleInfo { Name = SampleInfo.HIT_NORMAL }); + + hold.TailNote.Samples = HitObject.Samples; + + newObject = hold; } else { diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs new file mode 100644 index 0000000000..df2f7e9e63 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs @@ -0,0 +1,13 @@ +// 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.Judgements +{ + public class HoldNoteTailJudgement : ManiaJudgement + { + /// + /// Whether the hold note has been released too early and shouldn't give full score for the release. + /// + public bool HasBroken; + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs new file mode 100644 index 0000000000..bead455c13 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs @@ -0,0 +1,9 @@ +// 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.Judgements +{ + public class HoldNoteTickJudgement : ManiaJudgement + { + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index f9d027e7ce..a8efe5d2f8 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -7,14 +7,47 @@ using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using OpenTK.Graphics; using osu.Framework.Configuration; using OpenTK.Input; +using osu.Framework.Input; +using OpenTK; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mania.Judgements; namespace osu.Game.Rulesets.Mania.Objects.Drawables { public class DrawableHoldNote : DrawableManiaHitObject { - private readonly NotePiece headPiece; + private readonly DrawableNote headNote; + private readonly DrawableNote tailNote; private readonly BodyPiece bodyPiece; - private readonly NotePiece tailPiece; + private readonly Container tickContainer; + + /// + /// Relative time at which the user started holding this note. + /// + private double holdStartTime; + + /// + /// Whether the hold note has been released too early and shouldn't give full score for the release. + /// + private bool hasBroken; + + private bool _holding; + /// + /// Whether the user is holding the hold note. + /// + private bool holding + { + get { return _holding; } + set + { + if (_holding == value) + return; + _holding = value; + + if (holding) + holdStartTime = Time.Current; + } + } public DrawableHoldNote(HoldNote hitObject, Bindable key = null) : base(hitObject, key) @@ -32,17 +65,39 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - headPiece = new NotePiece + tickContainer = new Container + { + RelativeSizeAxes = Axes.Both, + RelativeCoordinateSpace = new Vector2(1, (float)HitObject.Duration) + }, + headNote = new DrawableHoldNoteHead(this, key) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre }, - tailPiece = new NotePiece + tailNote = new DrawableHoldNoteTail(this, key) { Anchor = Anchor.BottomCentre, Origin = Anchor.TopCentre } }); + + foreach (var tick in HitObject.Ticks) + { + var drawableTick = new DrawableHoldNoteTick(tick) + { + IsHolding = () => holding, + HoldStartTime = () => holdStartTime + }; + + drawableTick.Y -= (float)HitObject.StartTime; + + tickContainer.Add(drawableTick); + AddNested(drawableTick); + } + + AddNested(headNote); + AddNested(tailNote); } public override Color4 AccentColour @@ -54,9 +109,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return; base.AccentColour = value; - headPiece.AccentColour = value; bodyPiece.AccentColour = value; - tailPiece.AccentColour = value; + headNote.AccentColour = value; + tailNote.AccentColour = value; } } @@ -64,14 +119,133 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { } - protected override void Update() + /// + /// Handles key down events on the body of the hold note. + /// + /// The input state. + /// The key down args. + /// Whether the key press was handled. + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (Time.Current > HitObject.StartTime) - headPiece.Colour = Color4.Green; - if (Time.Current > HitObject.EndTime) + // Make sure the keypress happened within reasonable bounds of the hold note + if (Time.Current < HitObject.StartTime || Time.Current > HitObject.EndTime) + return false; + + if (args.Key != Key) + return false; + + if (args.Repeat) + return false; + + holding = true; + + return true; + } + + /// + /// Handles key up events on the body of the hold note. + /// + /// The input state. + /// The key down args. + /// Whether the key press was handled. + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) + { + // Make sure that the user started holding the key during the hold note + if (!holding) + return false; + + if (args.Key != Key) + return false; + + holding = false; + + // If the key has been released too early, they should not receive full score for the release + if (!tailNote.Judged) + hasBroken = true; + + return true; + } + + private class DrawableHoldNoteHead : DrawableNote + { + private readonly DrawableHoldNote holdNote; + + public DrawableHoldNoteHead(DrawableHoldNote holdNote, Bindable key = null) + : base(holdNote.HitObject.HeadNote, key) { - bodyPiece.Colour = Color4.Green; - tailPiece.Colour = Color4.Green; + this.holdNote = holdNote; + + RelativePositionAxes = Axes.None; + Y = 0; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + if (!base.OnKeyDown(state, args)) + return false; + + // We only want to trigger a holding state from the head if the head has received a judgement + if (Judgement.Result == HitResult.None) + return false; + + // If the head has been missed, make sure the user also can't receive a full score for the release + if (Judgement.Result == HitResult.Miss) + holdNote.hasBroken = true; + + holdNote.holding = true; + + return true; + } + } + + private class DrawableHoldNoteTail : DrawableNote + { + private readonly DrawableHoldNote holdNote; + + public DrawableHoldNoteTail(DrawableHoldNote holdNote, Bindable key = null) + : base(holdNote.HitObject.TailNote, key) + { + this.holdNote = holdNote; + + RelativePositionAxes = Axes.None; + Y = 0; + } + + protected override ManiaJudgement CreateJudgement() => new HoldNoteTailJudgement(); + + protected override void CheckJudgement(bool userTriggered) + { + base.CheckJudgement(userTriggered); + + var tailJudgement = Judgement as HoldNoteTailJudgement; + if (tailJudgement == null) + return; + + tailJudgement.HasBroken = holdNote.hasBroken; + } + + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) + { + // Make sure that the user started holding the key during the hold note + if (!holdNote.holding) + return false; + + if (Judgement.Result != HitResult.None) + return false; + + if (args.Key != Key) + return false; + + UpdateJudgement(true); + + // Handled by the hold note, which will set holding = false + return false; + } + + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + // Tail doesn't handle key down + return false; } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs new file mode 100644 index 0000000000..13fde29bc2 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -0,0 +1,75 @@ +// 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 OpenTK.Input; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Input; +using osu.Game.Rulesets.Mania.Judgements; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableHoldNoteTick : DrawableManiaHitObject + { + public Func HoldStartTime; + public Func IsHolding; + + public DrawableHoldNoteTick(HoldNoteTick hitObject) + : base(hitObject, null) + { + RelativeSizeAxes = Axes.X; + + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.X, + Height = 1 + } + }; + } + + protected override ManiaJudgement CreateJudgement() => new HoldNoteTickJudgement(); + + protected override void CheckJudgement(bool userTriggered) + { + if (!userTriggered) + return; + + if (Time.Current < HitObject.StartTime) + return; + + + if (HoldStartTime?.Invoke() > HitObject.StartTime) + return; + + Judgement.ManiaResult = ManiaHitResult.Perfect; + Judgement.Result = HitResult.Hit; + } + + protected override void UpdateState(ArmedState state) + { + switch (State) + { + case ArmedState.Hit: + Colour = Color4.Green; + break; + } + } + + protected override void Update() + { + if (Judgement.Result != HitResult.None) + return; + + if (IsHolding?.Invoke() != true) + return; + + UpdateJudgement(true); + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 30e71aeb5d..926f434015 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.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 System.Collections.Generic; using osu.Game.Audio; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; @@ -12,32 +13,41 @@ namespace osu.Game.Rulesets.Mania.Objects /// /// Represents a hit object which requires pressing, holding, and releasing a key. /// - public class HoldNote : Note, IHasEndTime + public class HoldNote : ManiaHitObject, IHasEndTime { - /// - /// 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; - /// - /// The samples to be played when this hold note is released. - /// - public SampleInfoList EndSamples = new SampleInfoList(); + private Note headNote; + public Note HeadNote => headNote ?? (headNote = new Note { StartTime = StartTime }); + + private Note tailNote; + public Note TailNote => tailNote ?? (tailNote = new HoldNoteTail { StartTime = EndTime }); /// - /// The key-release hit windows for this hold note. + /// The length (in milliseconds) between ticks of this hold. /// - public HitWindows ReleaseHitWindows { get; protected set; } = new HitWindows(); + private double tickSpacing = 50; - public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + public IEnumerable Ticks => ticks ?? (ticks = createTicks()); + private List ticks; + + private List createTicks() { - base.ApplyDefaults(controlPointInfo, difficulty); + var ret = new List(); - ReleaseHitWindows = HitWindows * release_window_lenience; + if (tickSpacing == 0) + return ret; + + for (double t = StartTime + HeadNote.HitWindows.Great / 2; t <= EndTime - TailNote.HitWindows.Great / 2; t+= tickSpacing) + { + ret.Add(new HoldNoteTick + { + StartTime = t + }); + } + + return ret; } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs new file mode 100644 index 0000000000..6399277a2b --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs @@ -0,0 +1,24 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Database; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class HoldNoteTail : Note + { + /// + /// 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 override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + HitWindows *= release_window_lenience; + } + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs new file mode 100644 index 0000000000..805b2a0938 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs @@ -0,0 +1,9 @@ +// 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 class HoldNoteTick : ManiaHitObject + { + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 9442d7cf8f..91cb551414 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -57,10 +57,13 @@ + + + @@ -68,6 +71,8 @@ + + From 78067e085c858f8e6d8ab70ac9bf2699a3d0e3ca Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 20:53:47 +0900 Subject: [PATCH 02/83] Fix note input ordering. --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index ff763f87c4..495959b061 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -189,7 +189,12 @@ namespace osu.Game.Rulesets.Mania.UI } } - public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); + public override void Add(DrawableHitObject h) + { + h.Depth = (float)h.HitObject.StartTime; + + Columns.ElementAt(h.HitObject.Column).Add(h); + } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { From 4ef18ff135fd91e3e40274f507a545f438bfa590 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 20:54:01 +0900 Subject: [PATCH 03/83] Test case improvements. --- .../Tests/TestCaseManiaPlayfield.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 27ad39fb1e..8d0a87ae9d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -77,31 +77,34 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(rateAdjustClock) }); - playField.Add(new DrawableNote(new Note + for (int t = 1000; t <= 2000; t += 100) { - StartTime = 1000, - Column = 0 - }, new Bindable(Key.D))); + playField.Add(new DrawableNote(new Note + { + StartTime = t, + Column = 0 + }, new Bindable(Key.J))); + + playField.Add(new DrawableNote(new Note + { + StartTime = t, + Column = 3 + }, new Bindable(Key.K))); + } playField.Add(new DrawableHoldNote(new HoldNote { StartTime = 1000, - Duration = 2000, + Duration = 1000, Column = 1 }, new Bindable(Key.F))); playField.Add(new DrawableHoldNote(new HoldNote { StartTime = 1000, - Duration = 2000, + Duration = 1000, Column = 2 }, new Bindable(Key.J))); - - playField.Add(new DrawableNote(new Note - { - StartTime = 1000, - Column = 3 - }, new Bindable(Key.K))); }; AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); From d6b104d794d2fdebcd46949115c581f1b8d7565e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:24:18 +0900 Subject: [PATCH 04/83] Minor visual change for DrawableHoldNoteTick. --- .../Objects/Drawables/DrawableHoldNote.cs | 3 ++ .../Objects/Drawables/DrawableHoldNoteTick.cs | 50 ++++++++++++++++--- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index a8efe5d2f8..ee371b61ca 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -11,6 +11,7 @@ using osu.Framework.Input; using OpenTK; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets.Mania.Judgements; +using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Rulesets.Mania.Objects.Drawables { @@ -109,6 +110,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return; base.AccentColour = value; + tickContainer.Children.ForEach(t => t.AccentColour = value); + bodyPiece.AccentColour = value; headNote.AccentColour = value; tailNote.AccentColour = value; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 13fde29bc2..7a8f25e098 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -2,12 +2,12 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using OpenTK; using OpenTK.Graphics; -using OpenTK.Input; -using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Input; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Drawables; @@ -18,19 +18,55 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public Func HoldStartTime; public Func IsHolding; + private readonly Container glowContainer; + public DrawableHoldNoteTick(HoldNoteTick hitObject) : base(hitObject, null) { + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + RelativeSizeAxes = Axes.X; + Size = new Vector2(1); Children = new[] { - new Box + glowContainer = new CircularContainer { - RelativeSizeAxes = Axes.X, - Height = 1 + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Both, + Masking = true, + Children = new[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0, + AlwaysPresent = true + } + } } }; + + AccentColour = Color4.White; + } + + public override Color4 AccentColour + { + get { return base.AccentColour; } + set + { + base.AccentColour = value; + + glowContainer.EdgeEffect = new EdgeEffect + { + Type = EdgeEffectType.Glow, + Radius = 2f, + Roundness = 15f, + Colour = value.Opacity(0.3f) + }; + } } protected override ManiaJudgement CreateJudgement() => new HoldNoteTickJudgement(); @@ -56,7 +92,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables switch (State) { case ArmedState.Hit: - Colour = Color4.Green; + AccentColour = Color4.Green; break; } } From 21cdee02f3cfce00771a10bc3ee89ef7421fbbd2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:24:33 +0900 Subject: [PATCH 05/83] Get tickSpacing from beatmap. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 926f434015..b3e2482908 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -2,10 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using osu.Game.Audio; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; -using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Rulesets.Mania.Objects @@ -29,6 +27,14 @@ namespace osu.Game.Rulesets.Mania.Objects /// private double tickSpacing = 50; + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); + tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; + } + public IEnumerable Ticks => ticks ?? (ticks = createTicks()); private List ticks; From ed65b3559a72b27dc904268f36643d68a589983c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:25:01 +0900 Subject: [PATCH 06/83] CI fix. --- .../Objects/Drawables/DrawableHoldNoteTick.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 7a8f25e098..7c84157c26 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container glowContainer; public DrawableHoldNoteTick(HoldNoteTick hitObject) - : base(hitObject, null) + : base(hitObject) { Anchor = Anchor.TopCentre; Origin = Anchor.TopCentre; From a5b79b2192b5d34fb8f1d69363fe03495dcd77a9 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:56:49 +0900 Subject: [PATCH 07/83] Fix notes not getting accent colours. --- osu.Game.Rulesets.Mania/UI/Column.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/Column.cs b/osu.Game.Rulesets.Mania/UI/Column.cs index c8cb5f6387..6dfd5000d4 100644 --- a/osu.Game.Rulesets.Mania/UI/Column.cs +++ b/osu.Game.Rulesets.Mania/UI/Column.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 OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -188,7 +187,11 @@ namespace osu.Game.Rulesets.Mania.UI } } - public void Add(DrawableHitObject hitObject) => ControlPointContainer.Add(hitObject); + public void Add(DrawableHitObject hitObject) + { + hitObject.AccentColour = AccentColour; + ControlPointContainer.Add(hitObject); + } private bool onKeyDown(InputState state, KeyDownEventArgs args) { From 946cd4bfa380ca4a3684f1375f11ee94d708ef1c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 24 May 2017 21:57:38 +0900 Subject: [PATCH 08/83] General cleanup + more xmldocs. --- .../Tests/TestCaseManiaPlayfield.cs | 6 +-- .../Legacy/DistanceObjectPatternGenerator.cs | 4 +- .../Legacy/EndTimeObjectPatternGenerator.cs | 4 +- .../Objects/Drawables/DrawableHoldNote.cs | 45 ++++++++++++------- .../Objects/Drawables/DrawableHoldNoteTick.cs | 11 +++++ .../Objects/Drawables/DrawableNote.cs | 3 ++ osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 40 ++++++++++++++--- .../Objects/HoldNoteTail.cs | 24 ---------- .../Objects/HoldNoteTick.cs | 3 ++ .../osu.Game.Rulesets.Mania.csproj | 1 - 10 files changed, 86 insertions(+), 55 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 8d0a87ae9d..857c2c0ca7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -66,7 +66,7 @@ namespace osu.Desktop.VisualTests.Tests { Clear(); - var rateAdjustClock = new StopwatchClock(true) { Rate = 0.2 }; + var rateAdjustClock = new StopwatchClock(true) { Rate = 0.5 }; ManiaPlayfield playField; Add(playField = new ManiaPlayfield(4, new List { new TimingChange { BeatLength = 200 } }) @@ -83,7 +83,7 @@ namespace osu.Desktop.VisualTests.Tests { StartTime = t, Column = 0 - }, new Bindable(Key.J))); + }, new Bindable(Key.D))); playField.Add(new DrawableNote(new Note { @@ -125,7 +125,7 @@ namespace osu.Desktop.VisualTests.Tests AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); AddWaitStep(10); - AddStep("Test", () => createPlayfieldWithNotesAcceptingInput()); + AddStep("Notes with input", () => createPlayfieldWithNotesAcceptingInput()); } private void triggerKeyDown(Column column) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 279ac868f1..076bcdfaab 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -478,8 +478,8 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy Duration = endTime - startTime }; - holdNote.HeadNote.Samples = sampleInfoListAt(startTime); - holdNote.TailNote.Samples = sampleInfoListAt(endTime); + holdNote.Head.Samples = sampleInfoListAt(startTime); + holdNote.Tail.Samples = sampleInfoListAt(endTime); newObject = holdNote; } diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs index ddc7d77c0c..6ad7489e0f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/EndTimeObjectPatternGenerator.cs @@ -76,12 +76,12 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy Duration = endTime - HitObject.StartTime }; - hold.HeadNote.Samples.Add(new SampleInfo + hold.Head.Samples.Add(new SampleInfo { Name = SampleInfo.HIT_NORMAL }); - hold.TailNote.Samples = HitObject.Samples; + hold.Tail.Samples = HitObject.Samples; newObject = hold; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index ee371b61ca..cef4eecd38 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -15,15 +15,19 @@ using osu.Framework.Extensions.IEnumerableExtensions; namespace osu.Game.Rulesets.Mania.Objects.Drawables { + /// + /// Visualises a hit object. + /// public class DrawableHoldNote : DrawableManiaHitObject { - private readonly DrawableNote headNote; - private readonly DrawableNote tailNote; + private readonly DrawableNote head; + private readonly DrawableNote tail; + private readonly BodyPiece bodyPiece; private readonly Container tickContainer; /// - /// Relative time at which the user started holding this note. + /// Time at which the user started holding this hold note. /// private double holdStartTime; @@ -34,7 +38,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private bool _holding; /// - /// Whether the user is holding the hold note. + /// Whether the user is currently holding the hold note. /// private bool holding { @@ -71,12 +75,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.Both, RelativeCoordinateSpace = new Vector2(1, (float)HitObject.Duration) }, - headNote = new DrawableHoldNoteHead(this, key) + head = new HeadNote(this, key) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre }, - tailNote = new DrawableHoldNoteTail(this, key) + tail = new TailNote(this, key) { Anchor = Anchor.BottomCentre, Origin = Anchor.TopCentre @@ -91,14 +95,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables HoldStartTime = () => holdStartTime }; + // To make the ticks relative to ourselves we need to offset them backwards drawableTick.Y -= (float)HitObject.StartTime; tickContainer.Add(drawableTick); AddNested(drawableTick); } - AddNested(headNote); - AddNested(tailNote); + AddNested(head); + AddNested(tail); } public override Color4 AccentColour @@ -113,8 +118,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables tickContainer.Children.ForEach(t => t.AccentColour = value); bodyPiece.AccentColour = value; - headNote.AccentColour = value; - tailNote.AccentColour = value; + head.AccentColour = value; + tail.AccentColour = value; } } @@ -163,18 +168,21 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables holding = false; // If the key has been released too early, they should not receive full score for the release - if (!tailNote.Judged) + if (!tail.Judged) hasBroken = true; return true; } - private class DrawableHoldNoteHead : DrawableNote + /// + /// The head note of a hold. + /// + private class HeadNote : DrawableNote { private readonly DrawableHoldNote holdNote; - public DrawableHoldNoteHead(DrawableHoldNote holdNote, Bindable key = null) - : base(holdNote.HitObject.HeadNote, key) + public HeadNote(DrawableHoldNote holdNote, Bindable key = null) + : base(holdNote.HitObject.Head, key) { this.holdNote = holdNote; @@ -201,12 +209,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } - private class DrawableHoldNoteTail : DrawableNote + /// + /// The tail note of a hold. + /// + private class TailNote : DrawableNote { private readonly DrawableHoldNote holdNote; - public DrawableHoldNoteTail(DrawableHoldNote holdNote, Bindable key = null) - : base(holdNote.HitObject.TailNote, key) + public TailNote(DrawableHoldNote holdNote, Bindable key = null) + : base(holdNote.HitObject.Tail, key) { this.holdNote = holdNote; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 7c84157c26..8cd60e9901 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -13,9 +13,19 @@ using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Objects.Drawables { + /// + /// Visualises a hit object. + /// public class DrawableHoldNoteTick : DrawableManiaHitObject { + /// + /// References the time at which the user started holding the hold note. + /// public Func HoldStartTime; + + /// + /// References whether the user is currently holding the hold note. + /// public Func IsHolding; private readonly Container glowContainer; @@ -49,6 +59,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } }; + // Set the default glow AccentColour = Color4.White; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 42bb371975..658d409bb8 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -13,6 +13,9 @@ using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Objects.Drawables { + /// + /// Visualises a hit object. + /// public class DrawableNote : DrawableManiaHitObject { private readonly NotePiece headPiece; diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index b3e2482908..db317ddf7b 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -16,14 +16,20 @@ namespace osu.Game.Rulesets.Mania.Objects public double Duration { get; set; } public double EndTime => StartTime + Duration; - private Note headNote; - public Note HeadNote => headNote ?? (headNote = new Note { StartTime = StartTime }); + private Note head; + /// + /// The head note of the hold. + /// + public Note Head => head ?? (head = new Note { StartTime = StartTime }); - private Note tailNote; - public Note TailNote => tailNote ?? (tailNote = new HoldNoteTail { StartTime = EndTime }); + private Note tail; + /// + /// The tail note of the hold. + /// + public Note Tail => tail ?? (tail = new TailNote { StartTime = EndTime }); /// - /// The length (in milliseconds) between ticks of this hold. + /// The time between ticks of this hold. /// private double tickSpacing = 50; @@ -35,6 +41,9 @@ namespace osu.Game.Rulesets.Mania.Objects tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; } + /// + /// The scoring scoring ticks of the hold note. + /// public IEnumerable Ticks => ticks ?? (ticks = createTicks()); private List ticks; @@ -45,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.Objects if (tickSpacing == 0) return ret; - for (double t = StartTime + HeadNote.HitWindows.Great / 2; t <= EndTime - TailNote.HitWindows.Great / 2; t+= tickSpacing) + for (double t = StartTime + Head.HitWindows.Great / 2; t <= EndTime - Tail.HitWindows.Great / 2; t+= tickSpacing) { ret.Add(new HoldNoteTick { @@ -55,5 +64,24 @@ namespace osu.Game.Rulesets.Mania.Objects return ret; } + + /// + /// The tail of the hold note. + /// + private class TailNote : Note + { + /// + /// 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 override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + HitWindows *= release_window_lenience; + } + } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs deleted file mode 100644 index 6399277a2b..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/HoldNoteTail.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Database; - -namespace osu.Game.Rulesets.Mania.Objects -{ - public class HoldNoteTail : Note - { - /// - /// 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 override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) - { - base.ApplyDefaults(controlPointInfo, difficulty); - - HitWindows *= release_window_lenience; - } - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs index 805b2a0938..6c4cf127f3 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs @@ -3,6 +3,9 @@ namespace osu.Game.Rulesets.Mania.Objects { + /// + /// A scoring tick of a hold note. + /// public class HoldNoteTick : ManiaHitObject { } diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 91cb551414..7a8ec25fe4 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -71,7 +71,6 @@ - From 181648515b433c56006d1a8d9b2685e20c08fa63 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Wed, 24 May 2017 16:05:24 +0300 Subject: [PATCH 09/83] Moving icon to the beat on the TwoLayerButton --- .../Graphics/UserInterface/TwoLayerButton.cs | 118 +++++++++++------- 1 file changed, 71 insertions(+), 47 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 237aaa44a6..4aeaf6965d 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -5,18 +5,21 @@ using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using OpenTK; using OpenTK.Graphics; using osu.Game.Graphics.Sprites; using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Graphics.Containers; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.Audio.Track; +using System; namespace osu.Game.Graphics.UserInterface { public class TwoLayerButton : ClickableContainer { - private readonly TextAwesome icon; + private readonly IconBeatSyncedContainer iconBeatSyncedContainer; public Box IconLayer; public Box TextLayer; @@ -95,11 +98,10 @@ namespace osu.Game.Graphics.UserInterface }, } }, - icon = new TextAwesome + iconBeatSyncedContainer = new IconBeatSyncedContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - TextSize = 25, }, } }, @@ -146,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface { set { - icon.Icon = value; + iconBeatSyncedContainer.Icon = value; } } @@ -162,58 +164,16 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnHover(InputState state) { - icon.ClearTransforms(); - ResizeTo(SIZE_EXTENDED, transform_time, EasingTypes.OutElastic); - - int duration = 0; //(int)(Game.Audio.BeatLength / 2); - if (duration == 0) duration = pulse_length; - IconLayer.FadeColour(HoverColour, transform_time, EasingTypes.OutElastic); - const double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; - double startTime = Time.Current + offset; - - // basic pulse - icon.Transforms.Add(new TransformScale - { - StartValue = new Vector2(1.1f), - EndValue = Vector2.One, - StartTime = startTime, - EndTime = startTime + duration, - Easing = EasingTypes.Out, - LoopCount = -1, - LoopDelay = duration - }); - return true; } protected override void OnHoverLost(InputState state) { - icon.ClearTransforms(); - ResizeTo(SIZE_RETRACTED, transform_time, EasingTypes.OutElastic); - IconLayer.FadeColour(TextLayer.Colour, transform_time, EasingTypes.OutElastic); - - int duration = 0; //(int)(Game.Audio.BeatLength); - if (duration == 0) duration = pulse_length * 2; - - const double offset = 0; //(1 - Game.Audio.SyncBeatProgress) * duration; - double startTime = Time.Current + offset; - - // slow pulse - icon.Transforms.Add(new TransformScale - { - StartValue = new Vector2(1.1f), - EndValue = Vector2.One, - StartTime = startTime, - EndTime = startTime + duration, - Easing = EasingTypes.Out, - LoopCount = -1, - LoopDelay = duration - }); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) @@ -239,5 +199,69 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } + + private class IconBeatSyncedContainer : BeatSyncedContainer + { + private const double beat_in_time = 60; + + private readonly TextAwesome icon; + private readonly Container amplitudeContainer; + + public FontAwesome Icon { set { icon.Icon = value; } } + + public IconBeatSyncedContainer() + { + EarlyActivationMilliseconds = beat_in_time; + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + amplitudeContainer = new Container + { + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new Drawable[] + { + icon = new TextAwesome + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + TextSize = 25 + } + } + }, + }; + } + + private int lastBeatIndex; + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + + lastBeatIndex = beatIndex; + + var beatLength = timingPoint.BeatLength; + + float amplitudeAdjust = Math.Min(1, 0.4f + amplitudes.Maximum); + + if (beatIndex < 0) return; + + icon.ScaleTo(1 - 0.1f * amplitudeAdjust, beat_in_time, EasingTypes.Out); + using (icon.BeginDelayedSequence(beat_in_time)) + icon.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint); + } + + protected override void Update() + { + base.Update(); + + const float scale_adjust_cutoff = 0.4f; + + var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0; + amplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.1f, 75, EasingTypes.OutQuint); + } + } } } \ No newline at end of file From 9ea70b849b3ab88ffb8afade1d271487799ac934 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 25 May 2017 14:16:51 +0200 Subject: [PATCH 10/83] Fix initialize beatmap change animation of the music controller --- osu.Game/Overlays/MusicController.cs | 46 +++++++++++++++------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 4faa339bed..ff6b581480 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -264,32 +264,36 @@ namespace osu.Game.Overlays private void beatmapChanged(WorkingBeatmap beatmap) { - progressBar.IsEnabled = beatmap != null; - - bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current?.BeatmapInfo) ?? false; - - TransformDirection direction; - - if (audioEquals) - direction = TransformDirection.None; - else if (queuedDirection.HasValue) + if (current != null) { - direction = queuedDirection.Value; + progressBar.IsEnabled = beatmap != null; + + bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; + + TransformDirection direction; + + if (audioEquals) + direction = TransformDirection.None; + else if (queuedDirection.HasValue) + { + direction = queuedDirection.Value; + queuedDirection = null; + } + else + { + //figure out the best direction based on order in playlist. + var last = playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo.ID).Count(); + var next = beatmapBacking.Value == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmapBacking.Value.BeatmapSetInfo.ID).Count(); + + direction = last > next ? TransformDirection.Prev : TransformDirection.Next; + } + + + updateDisplay(beatmapBacking, direction); queuedDirection = null; } - else - { - //figure out the best direction based on order in playlist. - var last = current == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo.ID).Count(); - var next = beatmapBacking.Value == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmapBacking.Value.BeatmapSetInfo.ID).Count(); - - direction = last > next ? TransformDirection.Prev : TransformDirection.Next; - } current = beatmapBacking.Value; - - updateDisplay(beatmapBacking, direction); - queuedDirection = null; } private ScheduledDelegate pendingBeatmapSwitch; From c32d816f9cb26c531cdd4b81dca360acdf464a6f Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 25 May 2017 14:19:04 +0200 Subject: [PATCH 11/83] Removed new line --- osu-framework | 2 +- osu.Game/Overlays/MusicController.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu-framework b/osu-framework index 777996fb97..4de8400d5b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 777996fb9731ba1895a5ab1323cbbc97259ff741 +Subproject commit 4de8400d5b3169bddb9fea7b25ed2498a166c14d diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index ff6b581480..1ac189d8e2 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -288,7 +288,6 @@ namespace osu.Game.Overlays direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } - updateDisplay(beatmapBacking, direction); queuedDirection = null; } From 9de7e7bc40617f7538e1b738e2e8c20f97a84129 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 25 May 2017 17:49:47 +0200 Subject: [PATCH 12/83] Fixes --- osu.Game/Overlays/MusicController.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 1ac189d8e2..f1be55801f 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -264,14 +264,14 @@ namespace osu.Game.Overlays private void beatmapChanged(WorkingBeatmap beatmap) { + progressBar.IsEnabled = beatmap != null; + + TransformDirection direction = TransformDirection.None; + if (current != null) { - progressBar.IsEnabled = beatmap != null; - bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false; - TransformDirection direction; - if (audioEquals) direction = TransformDirection.None; else if (queuedDirection.HasValue) @@ -287,12 +287,12 @@ namespace osu.Game.Overlays direction = last > next ? TransformDirection.Prev : TransformDirection.Next; } - - updateDisplay(beatmapBacking, direction); - queuedDirection = null; } current = beatmapBacking.Value; + + updateDisplay(beatmapBacking, direction); + queuedDirection = null; } private ScheduledDelegate pendingBeatmapSwitch; From 79e731ec2a182cc5cb3032ad9c90aec0b9c2c6db Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Thu, 25 May 2017 20:20:30 +0200 Subject: [PATCH 13/83] Updated framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 4de8400d5b..8baad1b948 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4de8400d5b3169bddb9fea7b25ed2498a166c14d +Subproject commit 8baad1b9484b9f35724e2f965c18cfe710907d80 From c2d3b6c05ad5c8dfacb6d47fdceed144409ef16e Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 15:53:49 +0900 Subject: [PATCH 14/83] Remove late initialization of head + tail, keep them updated with start time and end time. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 29 +++++++++++++++++---- osu.Game/Rulesets/Objects/HitObject.cs | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index db317ddf7b..5069b4f623 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -13,20 +13,39 @@ namespace osu.Game.Rulesets.Mania.Objects /// public class HoldNote : ManiaHitObject, IHasEndTime { - public double Duration { get; set; } public double EndTime => StartTime + Duration; - private Note head; + private double duration; + public double Duration + { + get { return duration; } + set + { + duration = value; + Tail.StartTime = EndTime; + } + } + + public override double StartTime + { + get { return base.StartTime; } + set + { + base.StartTime = value; + Head.StartTime = value; + Tail.StartTime = EndTime; + } + } + /// /// The head note of the hold. /// - public Note Head => head ?? (head = new Note { StartTime = StartTime }); + public Note Head = new Note(); - private Note tail; /// /// The tail note of the hold. /// - public Note Tail => tail ?? (tail = new TailNote { StartTime = EndTime }); + public Note Tail = new TailNote(); /// /// The time between ticks of this hold. diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs index 5592681cab..b282965db8 100644 --- a/osu.Game/Rulesets/Objects/HitObject.cs +++ b/osu.Game/Rulesets/Objects/HitObject.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Objects /// /// The time at which the HitObject starts. /// - public double StartTime; + public virtual double StartTime { get; set; } /// /// The samples to be played when this hit object is hit. From d3206396e7b5474db47117541ce22487cfcbb38c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 16:10:04 +0900 Subject: [PATCH 15/83] Rewrite comments. --- .../Objects/Drawables/DrawableHoldNote.cs | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index cef4eecd38..cee2e103b9 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -127,15 +127,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { } - /// - /// Handles key down events on the body of the hold note. - /// - /// The input state. - /// The key down args. - /// Whether the key press was handled. protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - // Make sure the keypress happened within reasonable bounds of the hold note + // Make sure the keypress happened within the body of the hold note if (Time.Current < HitObject.StartTime || Time.Current > HitObject.EndTime) return false; @@ -145,17 +139,14 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (args.Repeat) return false; + // The user has pressed during the body of the hold note, after the head note and its hit windows have passed + // and within the limited range of the above if-statement. This state will be managed by the head note if the + // user has pressed during the hit windows of the head note. holding = true; return true; } - /// - /// Handles key up events on the body of the hold note. - /// - /// The input state. - /// The key down args. - /// Whether the key press was handled. protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) { // Make sure that the user started holding the key during the hold note @@ -167,7 +158,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables holding = false; - // If the key has been released too early, they should not receive full score for the release + // If the key has been released too early, the user should not receive full score for the release if (!tail.Judged) hasBroken = true; @@ -196,13 +187,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return false; // We only want to trigger a holding state from the head if the head has received a judgement - if (Judgement.Result == HitResult.None) + if (!Judged) return false; - // If the head has been missed, make sure the user also can't receive a full score for the release + // If the key has been released too early, the user should not receive full score for the release if (Judgement.Result == HitResult.Miss) holdNote.hasBroken = true; + // The head note also handles early hits before the body, but we want accurate early hits to count as the body being held + // The body doesn't handle these early early hits, so we have to explicitly set the holding state here holdNote.holding = true; return true; From 47e1b7b389e9347b22c6a1d1e28139ad4e000e80 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 16:28:39 +0900 Subject: [PATCH 16/83] Fix tick construction loop. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 5069b4f623..c241c4cf41 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -40,12 +40,12 @@ namespace osu.Game.Rulesets.Mania.Objects /// /// The head note of the hold. /// - public Note Head = new Note(); + public readonly Note Head = new Note(); /// /// The tail note of the hold. /// - public Note Tail = new TailNote(); + public readonly Note Tail = new TailNote(); /// /// The time between ticks of this hold. @@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Mania.Objects if (tickSpacing == 0) return ret; - for (double t = StartTime + Head.HitWindows.Great / 2; t <= EndTime - Tail.HitWindows.Great / 2; t+= tickSpacing) + for (double t = StartTime + tickSpacing; t <= EndTime - tickSpacing; t += tickSpacing) { ret.Add(new HoldNoteTick { From 3f4cbd02cdaf2def643a4df6a4be4b79c63edd39 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 16:29:20 +0900 Subject: [PATCH 17/83] Fix warnings. --- .../Patterns/Legacy/DistanceObjectPatternGenerator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 076bcdfaab..2d1f75e196 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -475,11 +475,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy { StartTime = startTime, Column = column, - Duration = endTime - startTime + Duration = endTime - startTime, + Head = { Samples = sampleInfoListAt(startTime) }, + Tail = { Samples = sampleInfoListAt(endTime) } }; - holdNote.Head.Samples = sampleInfoListAt(startTime); - holdNote.Tail.Samples = sampleInfoListAt(endTime); newObject = holdNote; } From 871d44d6281cd6a795ce824645ee43f40aed1f6d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 16:39:43 +0900 Subject: [PATCH 18/83] Renamings. --- .../Objects/Drawables/DrawableHoldNote.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index cee2e103b9..b9b94e7f45 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -75,12 +75,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables RelativeSizeAxes = Axes.Both, RelativeCoordinateSpace = new Vector2(1, (float)HitObject.Duration) }, - head = new HeadNote(this, key) + head = new DrawableHeadNote(this, key) { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre }, - tail = new TailNote(this, key) + tail = new DrawableTailNote(this, key) { Anchor = Anchor.BottomCentre, Origin = Anchor.TopCentre @@ -168,11 +168,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// /// The head note of a hold. /// - private class HeadNote : DrawableNote + private class DrawableHeadNote : DrawableNote { private readonly DrawableHoldNote holdNote; - public HeadNote(DrawableHoldNote holdNote, Bindable key = null) + public DrawableHeadNote(DrawableHoldNote holdNote, Bindable key = null) : base(holdNote.HitObject.Head, key) { this.holdNote = holdNote; @@ -205,11 +205,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// /// The tail note of a hold. /// - private class TailNote : DrawableNote + private class DrawableTailNote : DrawableNote { private readonly DrawableHoldNote holdNote; - public TailNote(DrawableHoldNote holdNote, Bindable key = null) + public DrawableTailNote(DrawableHoldNote holdNote, Bindable key = null) : base(holdNote.HitObject.Tail, key) { this.holdNote = holdNote; From 5eab6112552ca9e972ac8d06567fd4de02d54cc5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 26 May 2017 17:33:50 +0900 Subject: [PATCH 19/83] Fix some possible nullrefs on beatmap load failure --- osu.Game/Screens/Play/Player.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index a39e7dbab2..707d026e2b 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -293,7 +293,7 @@ namespace osu.Game.Screens.Play protected override bool OnExiting(Screen next) { - if (HasFailed || !ValidForResume || pauseContainer.AllowExit || HitRenderer.HasReplayLoaded) + if (HasFailed || !ValidForResume || pauseContainer?.AllowExit != false || HitRenderer?.HasReplayLoaded != false) { fadeOut(); return base.OnExiting(next); @@ -310,7 +310,7 @@ namespace osu.Game.Screens.Play HitRenderer?.FadeOut(fade_out_duration); Content.FadeOut(fade_out_duration); - hudOverlay.ScaleTo(0.7f, fade_out_duration * 3, EasingTypes.In); + hudOverlay?.ScaleTo(0.7f, fade_out_duration * 3, EasingTypes.In); Background?.FadeTo(1f, fade_out_duration); } From 3ec41a313b548d59a89fbdbd1e1b89a03b05c74c Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 18:48:18 +0900 Subject: [PATCH 20/83] Add base DrawableHitObject + HitObjectStartTimeComparer. --- .../Objects/Drawables/DrawableHitObject.cs | 49 ++++++++++++----- .../Objects/HitObjectStartTimeComparer.cs | 55 +++++++++++++++++++ 2 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index c5dbc27fd3..fcdcf672d5 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -15,28 +15,51 @@ using System.Linq; namespace osu.Game.Rulesets.Objects.Drawables { - public abstract class DrawableHitObject : Container - where TObject : HitObject - where TJudgement : Judgement + public abstract class DrawableHitObject : Container { - public event Action> OnJudgement; - - public TObject HitObject; + public readonly HitObject HitObject; /// /// The colour used for various elements of this DrawableHitObject. /// public virtual Color4 AccentColour { get; set; } + protected DrawableHitObject(HitObject hitObject) + { + HitObject = hitObject; + } + } + + public abstract class DrawableHitObject : DrawableHitObject + where TObject : HitObject + { + public new readonly TObject HitObject; + + protected DrawableHitObject(TObject hitObject) + : base(hitObject) + { + HitObject = hitObject; + } + } + + public abstract class DrawableHitObject : DrawableHitObject + where TObject : HitObject + where TJudgement : Judgement + { + public event Action> OnJudgement; + public override bool HandleInput => Interactive; public bool Interactive = true; public TJudgement Judgement; - protected abstract TJudgement CreateJudgement(); + protected List Samples = new List(); - protected abstract void UpdateState(ArmedState state); + protected DrawableHitObject(TObject hitObject) + : base(hitObject) + { + } private ArmedState state; public ArmedState State @@ -59,8 +82,6 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - protected List Samples = new List(); - protected void PlaySamples() { Samples.ForEach(s => s?.Play()); @@ -79,11 +100,6 @@ namespace osu.Game.Rulesets.Objects.Drawables /// public bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None && (NestedHitObjects?.All(h => h.Judged) ?? true); - protected DrawableHitObject(TObject hitObject) - { - HitObject = hitObject; - } - /// /// Process a hit of this hitobject. Carries out judgement. /// @@ -176,5 +192,8 @@ namespace osu.Game.Rulesets.Objects.Drawables h.OnJudgement += d => OnJudgement?.Invoke(d); nestedHitObjects.Add(h); } + + protected abstract TJudgement CreateJudgement(); + protected abstract void UpdateState(ArmedState state); } } diff --git a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs new file mode 100644 index 0000000000..e65bc4a99f --- /dev/null +++ b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs @@ -0,0 +1,55 @@ +// 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.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Objects +{ + /// + /// Compares two hit objects by their start time, falling back to creation order if their start time is equal. + /// + public class HitObjectStartTimeComparer : Drawable.CreationOrderDepthComparer + { + public override int Compare(Drawable x, Drawable y) + { + var hitObjectX = x as DrawableHitObject; + var hitObjectY = y as DrawableHitObject; + + // If either of the two drawables are not hit objects, fall back to the base comparer + if ((hitObjectX ?? hitObjectY) == null) + return base.Compare(x, y); + + // Compare by start time + int i = hitObjectX.HitObject.StartTime.CompareTo(hitObjectY.HitObject.StartTime); + if (i != 0) + return i; + + return base.Compare(x, y); + } + } + + /// + /// Compares two hit objects by their start time, falling back to creation order if their start time is equal. + /// This will compare the two hit objects in reverse order. + /// + public class HitObjectReverseStartTimeComparer : Drawable.ReverseCreationOrderDepthComparer + { + public override int Compare(Drawable x, Drawable y) + { + var hitObjectX = x as DrawableHitObject; + var hitObjectY = y as DrawableHitObject; + + // If either of the two drawables are not hit objects, fall back to the base comparer + if ((hitObjectX ?? hitObjectY) == null) + return base.Compare(x, y); + + // Compare by start time + int i = hitObjectY.HitObject.StartTime.CompareTo(hitObjectX.HitObject.StartTime); + if (i != 0) + return i; + + return base.Compare(x, y); + } + } +} \ No newline at end of file From e4b59314ea0735dc2607d3e56df6e2ec6a580d78 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 18:52:43 +0900 Subject: [PATCH 21/83] Use new HitObjectStartTimeComparer. --- osu-framework | 2 +- osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs | 3 +++ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 7 +------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/osu-framework b/osu-framework index 777996fb97..ea5a2a7e1a 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 777996fb9731ba1895a5ab1323cbbc97259ff741 +Subproject commit ea5a2a7e1abffb1515c020fd017b583b71780316 diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index cc8897840e..636c84d9dc 100644 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using OpenTK; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Timing { @@ -28,6 +29,8 @@ namespace osu.Game.Rulesets.Mania.Timing private readonly List drawableControlPoints; + protected override IComparer DepthComparer => new HitObjectStartTimeComparer(); + public ControlPointContainer(IEnumerable timingChanges) { drawableControlPoints = timingChanges.Select(t => new DrawableControlPoint(t)).ToList(); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 495959b061..ff763f87c4 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -189,12 +189,7 @@ namespace osu.Game.Rulesets.Mania.UI } } - public override void Add(DrawableHitObject h) - { - h.Depth = (float)h.HitObject.StartTime; - - Columns.ElementAt(h.HitObject.Column).Add(h); - } + public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { From f294fef29bcaf1264639c7ffc952e12c2056b25d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 18:56:21 +0900 Subject: [PATCH 22/83] Remove holding property in favor of a nullable hold start time. --- .../Objects/Drawables/DrawableHoldNote.cs | 33 ++++--------------- .../Objects/Drawables/DrawableHoldNoteTick.cs | 3 +- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index b9b94e7f45..5d7f3314cd 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -27,33 +27,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables private readonly Container tickContainer; /// - /// Time at which the user started holding this hold note. + /// Time at which the user started holding this hold note. Null if the user is not holding this hold note. /// - private double holdStartTime; + private double? holdStartTime; /// /// Whether the hold note has been released too early and shouldn't give full score for the release. /// private bool hasBroken; - private bool _holding; - /// - /// Whether the user is currently holding the hold note. - /// - private bool holding - { - get { return _holding; } - set - { - if (_holding == value) - return; - _holding = value; - - if (holding) - holdStartTime = Time.Current; - } - } - public DrawableHoldNote(HoldNote hitObject, Bindable key = null) : base(hitObject, key) { @@ -91,7 +73,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { var drawableTick = new DrawableHoldNoteTick(tick) { - IsHolding = () => holding, HoldStartTime = () => holdStartTime }; @@ -142,7 +123,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables // The user has pressed during the body of the hold note, after the head note and its hit windows have passed // and within the limited range of the above if-statement. This state will be managed by the head note if the // user has pressed during the hit windows of the head note. - holding = true; + holdStartTime = Time.Current; return true; } @@ -150,13 +131,13 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) { // Make sure that the user started holding the key during the hold note - if (!holding) + if (!holdStartTime.HasValue) return false; if (args.Key != Key) return false; - holding = false; + holdStartTime = null; // If the key has been released too early, the user should not receive full score for the release if (!tail.Judged) @@ -196,7 +177,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables // The head note also handles early hits before the body, but we want accurate early hits to count as the body being held // The body doesn't handle these early early hits, so we have to explicitly set the holding state here - holdNote.holding = true; + holdNote.holdStartTime = Time.Current; return true; } @@ -234,7 +215,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) { // Make sure that the user started holding the key during the hold note - if (!holdNote.holding) + if (!holdNote.holdStartTime.HasValue) return false; if (Judgement.Result != HitResult.None) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 8cd60e9901..9ecc77d3fc 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// /// References the time at which the user started holding the hold note. /// - public Func HoldStartTime; + public Func HoldStartTime; /// /// References whether the user is currently holding the hold note. @@ -90,7 +90,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (Time.Current < HitObject.StartTime) return; - if (HoldStartTime?.Invoke() > HitObject.StartTime) return; From 43a7923199fa4a4ff8b49b5a191ab90f131f7b01 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:22:17 +0900 Subject: [PATCH 23/83] Implement base mania judgement score. --- .../Judgements/ManiaJudgement.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs index 6e69da3da7..33083ca0f5 100644 --- a/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs +++ b/osu.Game.Rulesets.Mania/Judgements/ManiaJudgement.cs @@ -2,11 +2,37 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Judgements { public class ManiaJudgement : Judgement { + /// + /// The maximum possible hit result. + /// + public const ManiaHitResult MAX_HIT_RESULT = ManiaHitResult.Perfect; + + /// + /// The result value for the combo portion of the score. + /// + public int ResultValueForScore => Result == HitResult.Miss ? 0 : NumericResultForScore(ManiaResult); + + /// + /// The result value for the accuracy portion of the score. + /// + public int ResultValueForAccuracy => Result == HitResult.Miss ? 0 : NumericResultForAccuracy(ManiaResult); + + /// + /// The maximum result value for the combo portion of the score. + /// + public int MaxResultValueForScore => NumericResultForScore(MAX_HIT_RESULT); + + /// + /// The maximum result value for the accuracy portion of the score. + /// + public int MaxResultValueForAccuracy => NumericResultForAccuracy(MAX_HIT_RESULT); + public override string ResultString => string.Empty; public override string MaxResultString => string.Empty; @@ -15,5 +41,42 @@ namespace osu.Game.Rulesets.Mania.Judgements /// The hit result. /// public ManiaHitResult ManiaResult; + + public virtual int NumericResultForScore(ManiaHitResult result) + { + switch (result) + { + default: + return 0; + case ManiaHitResult.Bad: + return 50; + case ManiaHitResult.Ok: + return 100; + case ManiaHitResult.Good: + return 200; + case ManiaHitResult.Great: + case ManiaHitResult.Perfect: + return 300; + } + } + + public virtual int NumericResultForAccuracy(ManiaHitResult result) + { + switch (result) + { + default: + return 0; + case ManiaHitResult.Bad: + return 50; + case ManiaHitResult.Ok: + return 100; + case ManiaHitResult.Good: + return 200; + case ManiaHitResult.Great: + return 300; + case ManiaHitResult.Perfect: + return 305; + } + } } } From 4c67c13410f0b7567944672ac1ba29f66d91b84a Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:28:14 +0900 Subject: [PATCH 24/83] Add hold note tail judgement. --- .../Judgements/HoldNoteTailJudgement.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs index df2f7e9e63..d5cf57a5da 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTailJudgement.cs @@ -9,5 +9,29 @@ namespace osu.Game.Rulesets.Mania.Judgements /// Whether the hold note has been released too early and shouldn't give full score for the release. /// public bool HasBroken; + + public override int NumericResultForScore(ManiaHitResult result) + { + switch (result) + { + default: + return base.NumericResultForScore(result); + case ManiaHitResult.Great: + case ManiaHitResult.Perfect: + return base.NumericResultForScore(HasBroken ? ManiaHitResult.Good : result); + } + } + + public override int NumericResultForAccuracy(ManiaHitResult result) + { + switch (result) + { + default: + return base.NumericResultForAccuracy(result); + case ManiaHitResult.Great: + case ManiaHitResult.Perfect: + return base.NumericResultForAccuracy(HasBroken ? ManiaHitResult.Good : result); + } + } } } \ No newline at end of file From 02f582a3f80993177dc06dbbc322679e23f99bd3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:29:47 +0900 Subject: [PATCH 25/83] Add hold note tick judgement. --- osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs index bead455c13..d6a72c825a 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs @@ -5,5 +5,7 @@ namespace osu.Game.Rulesets.Mania.Judgements { public class HoldNoteTickJudgement : ManiaJudgement { + public override int NumericResultForScore(ManiaHitResult result) => 20; + public override int NumericResultForAccuracy(ManiaHitResult result) => 0; // Don't count ticks into accuracy } } \ No newline at end of file From 9517bfc2f18d948226d2a37649d73aea1771f48b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:33:23 +0900 Subject: [PATCH 26/83] Add file to csproj. --- osu.Game/osu.Game.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 25b692151f..c669ac1981 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -176,6 +176,7 @@ + From 2c23703ca6f85f7c792c9dca1392d3cf015212d1 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 26 May 2017 13:46:44 +0300 Subject: [PATCH 27/83] Removed amplitude container --- .../Graphics/UserInterface/TwoLayerButton.cs | 40 ++++--------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 4aeaf6965d..209d9fb468 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface { public class TwoLayerButton : ClickableContainer { - private readonly IconBeatSyncedContainer iconBeatSyncedContainer; + private readonly BouncingIcon bouncingIcon; public Box IconLayer; public Box TextLayer; @@ -98,7 +98,7 @@ namespace osu.Game.Graphics.UserInterface }, } }, - iconBeatSyncedContainer = new IconBeatSyncedContainer + bouncingIcon = new BouncingIcon { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -148,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface { set { - iconBeatSyncedContainer.Icon = value; + bouncingIcon.Icon = value; } } @@ -200,48 +200,34 @@ namespace osu.Game.Graphics.UserInterface return base.OnClick(state); } - private class IconBeatSyncedContainer : BeatSyncedContainer + private class BouncingIcon : BeatSyncedContainer { private const double beat_in_time = 60; private readonly TextAwesome icon; - private readonly Container amplitudeContainer; public FontAwesome Icon { set { icon.Icon = value; } } - public IconBeatSyncedContainer() + public BouncingIcon() { EarlyActivationMilliseconds = beat_in_time; AutoSizeAxes = Axes.Both; Children = new Drawable[] { - amplitudeContainer = new Container + icon = new TextAwesome { - AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Children = new Drawable[] - { - icon = new TextAwesome - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - TextSize = 25 - } - } - }, + TextSize = 25 + } }; } - private int lastBeatIndex; - protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) { base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); - lastBeatIndex = beatIndex; - var beatLength = timingPoint.BeatLength; float amplitudeAdjust = Math.Min(1, 0.4f + amplitudes.Maximum); @@ -252,16 +238,6 @@ namespace osu.Game.Graphics.UserInterface using (icon.BeginDelayedSequence(beat_in_time)) icon.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint); } - - protected override void Update() - { - base.Update(); - - const float scale_adjust_cutoff = 0.4f; - - var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0; - amplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.1f, 75, EasingTypes.OutQuint); - } } } } \ No newline at end of file From cbe36259c3eea9bd422aeaea816e22d400893ba6 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 07:49:45 -0300 Subject: [PATCH 28/83] Add BreadcrumbControl --- .../Tests/TestCaseBreadcrumbs.cs | 39 ++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../UserInterface/BreadcrumbControl.cs | 63 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 4 files changed, 104 insertions(+) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs create mode 100644 osu.Game/Graphics/UserInterface/BreadcrumbControl.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs new file mode 100644 index 0000000000..658d2f92b1 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs @@ -0,0 +1,39 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Game.Graphics.UserInterface; +using osu.Framework.Graphics; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseBreadcrumbs : TestCase + { + public override string Description => @"breadcrumb > control"; + + public override void Reset() + { + base.Reset(); + + BreadcrumbControl c; + Add(c = new BreadcrumbControl + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Width = 0.5f, + }); + + AddStep(@"first", () => c.Current.Value = BreadcrumbTab.Click); + AddStep(@"second", () => c.Current.Value = BreadcrumbTab.The); + AddStep(@"third", () => c.Current.Value = BreadcrumbTab.Circles); + } + + private enum BreadcrumbTab + { + Click, + The, + Circles, + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 7b7997063b..5a532d7234 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -223,6 +223,7 @@ + diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs new file mode 100644 index 0000000000..be3933f362 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -0,0 +1,63 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Graphics.UserInterface +{ + public class BreadcrumbControl : OsuTabControl + { + public static readonly float padding = 10; + + protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); + + public BreadcrumbControl() + { + Height = 28; + TabContainer.Spacing = new Vector2(padding, 0f); + Current.ValueChanged += tab => + { + foreach (TabItem t in TabContainer.Children) + { + if (!(t is BreadcrumbTabItem)) return; + + var tIndex = TabContainer.IndexOf(t); + var tabIndex = TabContainer.IndexOf(TabMap[tab]); + var hide = tIndex < tabIndex; + var hideChevron = tIndex <= tabIndex; + + t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); + t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); + (t as BreadcrumbTabItem).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + } + }; + } + + private class BreadcrumbTabItem : OsuTabItem + { + public readonly TextAwesome Chevron; + + //don't allow clicking between transitions and don't make the chevron clickable + protected override bool InternalContains(Vector2 screenSpacePos) => Alpha < 1f ? false : Text.Contains(screenSpacePos); + + public BreadcrumbTabItem(T value) : base(value) + { + Text.TextSize = 18; + Padding = new MarginPadding { Right = padding + 9 }; + Add(Chevron = new TextAwesome + { + Anchor = Anchor.CentreRight, + Origin = Anchor.CentreLeft, + TextSize = 12, + Icon = FontAwesome.fa_chevron_right, + Margin = new MarginPadding { Left = 10 }, + Alpha = 0f, + }); + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 25b692151f..4d1b1a1b11 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -450,6 +450,7 @@ + From 9ec6e0b692cf14b31e07079264aeceb736025d49 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:56:27 +0900 Subject: [PATCH 29/83] Fix hold note ticks changing combo. --- osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs index d6a72c825a..852f97b3f2 100644 --- a/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs +++ b/osu.Game.Rulesets.Mania/Judgements/HoldNoteTickJudgement.cs @@ -5,6 +5,8 @@ namespace osu.Game.Rulesets.Mania.Judgements { public class HoldNoteTickJudgement : ManiaJudgement { + public override bool AffectsCombo => false; + public override int NumericResultForScore(ManiaHitResult result) => 20; public override int NumericResultForAccuracy(ManiaHitResult result) => 0; // Don't count ticks into accuracy } From ab5e1bfc891e01f7a05c851591dae1cf4f9978e0 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 19:56:50 +0900 Subject: [PATCH 30/83] Add basic score calculations. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 6 + .../Scoring/ManiaScoreProcessor.cs | 148 ++++++++++++++++++ 2 files changed, 154 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index c241c4cf41..3550d561c1 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using System.Linq; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; using osu.Game.Rulesets.Objects.Types; @@ -60,6 +61,11 @@ namespace osu.Game.Rulesets.Mania.Objects tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; } + /// + /// Total number of hold note ticks. + /// + public int TotalTicks => Ticks.Count(); + /// /// The scoring scoring ticks of the hold note. /// diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 7a9572a0c7..2f4ce075c3 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -1,8 +1,11 @@ // 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.Beatmaps; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -10,6 +13,52 @@ namespace osu.Game.Rulesets.Mania.Scoring { internal class ManiaScoreProcessor : ScoreProcessor { + /// + /// The maximum score achievable. + /// Does _not_ include bonus score - for bonus score see . + /// + private const int max_score = 1000000; + + /// + /// The amount of the score attributed to combo. + /// + private const double combo_portion_max = max_score * 0.2; + + /// + /// The amount of the score attributed to accuracy. + /// + private const double accuracy_portion_max = max_score * 0.8; + + /// + /// The cumulative combo portion of the score. + /// + private double comboScore => combo_portion_max * comboPortion / maxComboPortion; + + /// + /// The cumulative accuracy portion of the score. + /// + private double accuracyScore => accuracy_portion_max * Math.Pow(Accuracy, 4) * totalHits / maxTotalHits; + + /// + /// The cumulative bonus score. + /// This is added on top of , thus the total score can exceed . + /// + private double bonusScore; + + private double maxComboPortion; + private double comboPortion; + private int maxTotalHits; + private int totalHits; + + private double hpIncreaseBad; + private double hpIncreaseOk; + private double hpIncreaseGood; + private double hpIncreaseGreat; + private double hpIncreasePerfect; + private double hpIncreaseTick; + private double hpIncreaseTickMiss; + private double hpIncreaseMiss; + public ManiaScoreProcessor() { } @@ -19,8 +68,107 @@ namespace osu.Game.Rulesets.Mania.Scoring { } + protected override void ComputeTargets(Beatmap beatmap) + { + foreach (var obj in beatmap.HitObjects) + { + if (obj is Note) + { + AddJudgement(new ManiaJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaHitResult.Perfect + }); + } + else if (obj is HoldNote) + { + // Head + AddJudgement(new ManiaJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT + }); + + // Ticks + for (int i = 0; i < ((HoldNote)obj).TotalTicks; i++) + { + AddJudgement(new HoldNoteTickJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT, + }); + } + + AddJudgement(new HoldNoteTailJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT + }); + } + } + + maxTotalHits = totalHits; + maxComboPortion = comboPortion; + } + protected override void OnNewJudgement(ManiaJudgement judgement) { + bool isTick = judgement is HoldNoteTickJudgement; + + if (!isTick) + totalHits++; + + switch (judgement.Result) + { + case HitResult.Miss: + if (isTick) + Health.Value += hpIncreaseTickMiss; + else + Health.Value += hpIncreaseMiss; + break; + case HitResult.Hit: + if (isTick) + { + Health.Value += hpIncreaseTick; + bonusScore += judgement.ResultValueForScore; + } + else + { + switch (judgement.ManiaResult) + { + case ManiaHitResult.Bad: + Health.Value += hpIncreaseBad; + break; + case ManiaHitResult.Ok: + Health.Value += hpIncreaseOk; + break; + case ManiaHitResult.Good: + Health.Value += hpIncreaseGood; + break; + case ManiaHitResult.Great: + Health.Value += hpIncreaseGreat; + break; + case ManiaHitResult.Perfect: + Health.Value += hpIncreasePerfect; + break; + } + + comboPortion += judgement.ResultValueForScore; + } + break; + } + + int scoreForAccuracy = 0; + int maxScoreForAccuracy = 0; + + foreach (var j in Judgements) + { + scoreForAccuracy += j.ResultValueForAccuracy; + maxScoreForAccuracy += j.MaxResultValueForAccuracy; + } + + Accuracy.Value = (double)scoreForAccuracy / maxScoreForAccuracy; + TotalScore.Value = comboScore + accuracyScore + bonusScore; } protected override void Reset() From 10f62eb8da15bd22268fca9b84a71755d932af55 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:25:24 +0900 Subject: [PATCH 31/83] Fix incorrect combo score. --- .../Scoring/ManiaScoreProcessor.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 2f4ce075c3..4a5ab639b9 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -29,6 +29,16 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private const double accuracy_portion_max = max_score * 0.8; + /// + /// The factor used to determine relevance of combos. + /// + private const double combo_base = 4; + + /// + /// The combo value at which hit objects result in the max score possible. + /// + private const int combo_relevance_cap = 400; + /// /// The cumulative combo portion of the score. /// @@ -153,7 +163,9 @@ namespace osu.Game.Rulesets.Mania.Scoring break; } - comboPortion += judgement.ResultValueForScore; + // A factor that is applied to make higher combos more relevant + double comboRelevance = Math.Min(Math.Max(0.5, Math.Log(Combo.Value, combo_base)), Math.Log(combo_relevance_cap, combo_base)); + comboPortion += judgement.ResultValueForScore * comboRelevance; } break; } From 95908af677aec6bf59bf1545233e3b4f8e35fa4d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:26:06 +0900 Subject: [PATCH 32/83] Fix resetting scoreprocessor. --- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 4a5ab639b9..18df7888b6 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -188,6 +188,10 @@ namespace osu.Game.Rulesets.Mania.Scoring base.Reset(); Health.Value = 1; + + bonusScore = 0; + comboPortion = 0; + totalHits = 0; } } } From ca080117349bc78789a0f1e79c27818666f46e22 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:26:26 +0900 Subject: [PATCH 33/83] Add basic (new) hp calculations. --- .../Scoring/ManiaScoreProcessor.cs | 98 +++++++++++-------- 1 file changed, 56 insertions(+), 42 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 18df7888b6..fc2e8bec10 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -60,14 +60,17 @@ namespace osu.Game.Rulesets.Mania.Scoring private int maxTotalHits; private int totalHits; - private double hpIncreaseBad; - private double hpIncreaseOk; - private double hpIncreaseGood; - private double hpIncreaseGreat; - private double hpIncreasePerfect; - private double hpIncreaseTick; - private double hpIncreaseTickMiss; - private double hpIncreaseMiss; + private double hpMultiplier = 1; + private const double hp_increase_bad = 0.005; + private const double hp_increase_ok = 0.010; + private const double hp_increase_good = 0.035; + private const double hp_increase_tick = 0.040; + private const double hp_increase_great = 0.055; + private const double hp_increase_perfect = 0.065; + + private double hpMissMultiplier = 1; + private const double hp_increase_tick_miss = -0.025; + private const double hp_increase_miss = -0.125; public ManiaScoreProcessor() { @@ -80,41 +83,52 @@ namespace osu.Game.Rulesets.Mania.Scoring protected override void ComputeTargets(Beatmap beatmap) { - foreach (var obj in beatmap.HitObjects) + while (true) { - if (obj is Note) + foreach (var obj in beatmap.HitObjects) { - AddJudgement(new ManiaJudgement + if (obj is Note) { - Result = HitResult.Hit, - ManiaResult = ManiaHitResult.Perfect - }); - } - else if (obj is HoldNote) - { - // Head - AddJudgement(new ManiaJudgement - { - Result = HitResult.Hit, - ManiaResult = ManiaJudgement.MAX_HIT_RESULT - }); - - // Ticks - for (int i = 0; i < ((HoldNote)obj).TotalTicks; i++) - { - AddJudgement(new HoldNoteTickJudgement + AddJudgement(new ManiaJudgement { Result = HitResult.Hit, - ManiaResult = ManiaJudgement.MAX_HIT_RESULT, + ManiaResult = ManiaHitResult.Perfect }); } - - AddJudgement(new HoldNoteTailJudgement + else if (obj is HoldNote) { - Result = HitResult.Hit, - ManiaResult = ManiaJudgement.MAX_HIT_RESULT - }); + // Head + AddJudgement(new ManiaJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT + }); + + // Ticks + for (int i = 0; i < ((HoldNote)obj).TotalTicks; i++) + { + AddJudgement(new HoldNoteTickJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT, + }); + } + + AddJudgement(new HoldNoteTailJudgement + { + Result = HitResult.Hit, + ManiaResult = ManiaJudgement.MAX_HIT_RESULT + }); + } } + + if (!HasFailed) + break; + + hpMultiplier *= 1.01; + hpMissMultiplier *= 0.98; + + Reset(); } maxTotalHits = totalHits; @@ -132,14 +146,14 @@ namespace osu.Game.Rulesets.Mania.Scoring { case HitResult.Miss: if (isTick) - Health.Value += hpIncreaseTickMiss; + Health.Value += hpMissMultiplier * hp_increase_tick_miss; else - Health.Value += hpIncreaseMiss; + Health.Value += hpMissMultiplier * hp_increase_miss; break; case HitResult.Hit: if (isTick) { - Health.Value += hpIncreaseTick; + Health.Value += hpMultiplier * hp_increase_tick; bonusScore += judgement.ResultValueForScore; } else @@ -147,19 +161,19 @@ namespace osu.Game.Rulesets.Mania.Scoring switch (judgement.ManiaResult) { case ManiaHitResult.Bad: - Health.Value += hpIncreaseBad; + Health.Value += hpMultiplier * hp_increase_bad; break; case ManiaHitResult.Ok: - Health.Value += hpIncreaseOk; + Health.Value += hpMultiplier * hp_increase_ok; break; case ManiaHitResult.Good: - Health.Value += hpIncreaseGood; + Health.Value += hpMultiplier * hp_increase_good; break; case ManiaHitResult.Great: - Health.Value += hpIncreaseGreat; + Health.Value += hpMultiplier * hp_increase_great; break; case ManiaHitResult.Perfect: - Health.Value += hpIncreasePerfect; + Health.Value += hpMultiplier * hp_increase_perfect; break; } From d052f093d5984e45ef7fbd45165f939231375c29 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 26 May 2017 14:29:45 +0300 Subject: [PATCH 34/83] Scaling on hover --- osu.Game/Graphics/UserInterface/TwoLayerButton.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs index 209d9fb468..ebaef661c4 100644 --- a/osu.Game/Graphics/UserInterface/TwoLayerButton.cs +++ b/osu.Game/Graphics/UserInterface/TwoLayerButton.cs @@ -167,6 +167,8 @@ namespace osu.Game.Graphics.UserInterface ResizeTo(SIZE_EXTENDED, transform_time, EasingTypes.OutElastic); IconLayer.FadeColour(HoverColour, transform_time, EasingTypes.OutElastic); + bouncingIcon.ScaleTo(1.1f, transform_time, EasingTypes.OutElastic); + return true; } @@ -174,6 +176,8 @@ namespace osu.Game.Graphics.UserInterface { ResizeTo(SIZE_RETRACTED, transform_time, EasingTypes.OutElastic); IconLayer.FadeColour(TextLayer.Colour, transform_time, EasingTypes.OutElastic); + + bouncingIcon.ScaleTo(1, transform_time, EasingTypes.OutElastic); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) From 3715171948983a9f95fe246143f56ef14e245d65 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:32:21 +0900 Subject: [PATCH 35/83] Ticks can't be missed. --- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index fc2e8bec10..1be92f6dc4 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -69,7 +69,6 @@ namespace osu.Game.Rulesets.Mania.Scoring private const double hp_increase_perfect = 0.065; private double hpMissMultiplier = 1; - private const double hp_increase_tick_miss = -0.025; private const double hp_increase_miss = -0.125; public ManiaScoreProcessor() @@ -145,9 +144,6 @@ namespace osu.Game.Rulesets.Mania.Scoring switch (judgement.Result) { case HitResult.Miss: - if (isTick) - Health.Value += hpMissMultiplier * hp_increase_tick_miss; - else Health.Value += hpMissMultiplier * hp_increase_miss; break; case HitResult.Hit: From b28b7af887261f8b67d8daba0aff7ff5876ec2a2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 26 May 2017 20:42:03 +0900 Subject: [PATCH 36/83] Scale HP with drain rate a bit. --- .../Scoring/ManiaScoreProcessor.cs | 102 ++++++++++++++++-- 1 file changed, 93 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 1be92f6dc4..12c8386ae7 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -3,6 +3,7 @@ using System; using osu.Game.Beatmaps; +using osu.Game.Database; using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Objects.Drawables; @@ -39,6 +40,71 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private const int combo_relevance_cap = 400; + /// + /// The hit HP multiplier at OD = 0. + /// + private const double hp_multiplier_min = 0.75; + + /// + /// The hit HP multiplier at OD = 0. + /// + private const double hp_multiplier_mid = 0.85; + + /// + /// The hit HP multiplier at OD = 0. + /// + private const double hp_multiplier_max = 1; + + /// + /// The default BAD hit HP increase. + /// + private const double hp_increase_bad = 0.005; + + /// + /// The default OK hit HP increase. + /// + private const double hp_increase_ok = 0.010; + + /// + /// The default GOOD hit HP increase. + /// + private const double hp_increase_good = 0.035; + + /// + /// The default tick hit HP increase. + /// + private const double hp_increase_tick = 0.040; + + /// + /// The default GREAT hit HP increase. + /// + private const double hp_increase_great = 0.055; + + /// + /// The default PERFECT hit HP increase. + /// + private const double hp_increase_perfect = 0.065; + + /// + /// The MISS HP multiplier at OD = 0. + /// + private const double hp_multiplier_miss_min = 0.5; + + /// + /// The MISS HP multiplier at OD = 5. + /// + private const double hp_multiplier_miss_mid = 0.75; + + /// + /// The MISS HP multiplier at OD = 10. + /// + private const double hp_multiplier_miss_max = 1; + + /// + /// The default MISS HP increase. + /// + private const double hp_increase_miss = -0.125; + /// /// The cumulative combo portion of the score. /// @@ -55,21 +121,35 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private double bonusScore; + /// + /// The achieved by a perfect playthrough. + /// private double maxComboPortion; + + /// + /// The portion of the score dedicated to combo. + /// private double comboPortion; + + /// + /// The achieved by a perfect playthrough. + /// private int maxTotalHits; + + /// + /// The total hits. + /// private int totalHits; - private double hpMultiplier = 1; - private const double hp_increase_bad = 0.005; - private const double hp_increase_ok = 0.010; - private const double hp_increase_good = 0.035; - private const double hp_increase_tick = 0.040; - private const double hp_increase_great = 0.055; - private const double hp_increase_perfect = 0.065; - + /// + /// The MISS HP multiplier. + /// private double hpMissMultiplier = 1; - private const double hp_increase_miss = -0.125; + + /// + /// The HIT HP multiplier. + /// + private double hpMultiplier = 1; public ManiaScoreProcessor() { @@ -82,6 +162,10 @@ namespace osu.Game.Rulesets.Mania.Scoring protected override void ComputeTargets(Beatmap beatmap) { + BeatmapDifficulty difficulty = beatmap.BeatmapInfo.Difficulty; + hpMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_min, hp_multiplier_mid, hp_multiplier_max); + hpMissMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_miss_min, hp_multiplier_miss_mid, hp_multiplier_miss_max); + while (true) { foreach (var obj in beatmap.HitObjects) From 64612ef34b99250921cf96b5c0dfc85ad40f2ea9 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 16:10:28 +0200 Subject: [PATCH 37/83] add multimod animation --- osu.Game/Overlays/Mods/ModButton.cs | 44 +++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 831b9082bd..68c1fb8592 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -27,6 +27,7 @@ namespace osu.Game.Overlays.Mods public class ModButton : ModButtonEmpty, IHasTooltip { private ModIcon foregroundIcon; + private ModIcon backgroundIcon; private readonly SpriteText text; private readonly Container iconsContainer; private SampleChannel sampleOn, sampleOff; @@ -35,6 +36,9 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; + private const EasingTypes modSwitchEasing = EasingTypes.InOutQuint; + private const double modSwitchDuration = 100; + private int _selectedIndex = -1; private int selectedIndex { @@ -45,6 +49,9 @@ namespace osu.Game.Overlays.Mods set { if (value == _selectedIndex) return; + + bool beforeSelected = Selected; + _selectedIndex = value; if (value >= Mods.Length) @@ -55,13 +62,30 @@ namespace osu.Game.Overlays.Mods { _selectedIndex = Mods.Length - 1; } - - iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); - iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + if (beforeSelected ^ Selected) + { + iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); + iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + } + else + { + foregroundIcon.RotateTo(15f, modSwitchDuration, modSwitchEasing); + backgroundIcon.RotateTo(-15f, modSwitchDuration, modSwitchEasing); + using (foregroundIcon.BeginDelayedSequence(modSwitchDuration)) + { + foregroundIcon.RotateTo(-15f); + foregroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + } + using (backgroundIcon.BeginDelayedSequence(modSwitchDuration)) + { + backgroundIcon.RotateTo(15f); + backgroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + } + } foregroundIcon.Highlighted = Selected; if (mod != null) - displayMod(SelectedMod ?? Mods[0]); + Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : modSwitchDuration); } } @@ -159,6 +183,8 @@ namespace osu.Game.Overlays.Mods private void displayMod(Mod mod) { + if(backgroundIcon != null) + backgroundIcon.Icon = foregroundIcon.Icon; foregroundIcon.Icon = mod.Icon; text.Text = mod.Name; } @@ -170,17 +196,17 @@ namespace osu.Game.Overlays.Mods { iconsContainer.Add(new[] { - new ModIcon(Mods[0]) + backgroundIcon = new ModIcon(Mods[1]) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, AutoSizeAxes = Axes.Both, Position = new Vector2(1.5f), }, foregroundIcon = new ModIcon(Mods[0]) { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, AutoSizeAxes = Axes.Both, Position = new Vector2(-1.5f), }, From db1dde72de27b276a023932e7ae999986b7882dc Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 26 May 2017 16:29:15 +0200 Subject: [PATCH 38/83] change constant names --- osu.Game/Overlays/Mods/ModButton.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 68c1fb8592..e1545ab1b8 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -36,8 +36,8 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; - private const EasingTypes modSwitchEasing = EasingTypes.InOutQuint; - private const double modSwitchDuration = 100; + private const EasingTypes mod_switch_easing = EasingTypes.InOutQuint; + private const double mod_switch_duration = 100; private int _selectedIndex = -1; private int selectedIndex @@ -69,23 +69,23 @@ namespace osu.Game.Overlays.Mods } else { - foregroundIcon.RotateTo(15f, modSwitchDuration, modSwitchEasing); - backgroundIcon.RotateTo(-15f, modSwitchDuration, modSwitchEasing); - using (foregroundIcon.BeginDelayedSequence(modSwitchDuration)) + foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); + backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); + using (foregroundIcon.BeginDelayedSequence(mod_switch_duration)) { foregroundIcon.RotateTo(-15f); - foregroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } - using (backgroundIcon.BeginDelayedSequence(modSwitchDuration)) + using (backgroundIcon.BeginDelayedSequence(mod_switch_duration)) { backgroundIcon.RotateTo(15f); - backgroundIcon.RotateTo(0f, modSwitchDuration, modSwitchEasing); + backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } } foregroundIcon.Highlighted = Selected; if (mod != null) - Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : modSwitchDuration); + Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : mod_switch_duration); } } From fb6ed159ca0042dc11ec2e33e22a030c97e00dba Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:03:51 -0300 Subject: [PATCH 39/83] Use padding for chevron margin --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index be3933f362..a54823e042 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -47,14 +47,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 18; - Padding = new MarginPadding { Right = padding + 9 }; + Padding = new MarginPadding { Right = padding + 9 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = 10 }, + Margin = new MarginPadding { Left = padding }, Alpha = 0f, }); } From 352d3d247bec1cd5be22715f3894d9aa37b74f94 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:21:37 -0300 Subject: [PATCH 40/83] Fix incorrect sizes --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index a54823e042..4ee0ba9e5e 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbControl() { - Height = 28; + Height = 26; TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { @@ -46,8 +46,8 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { - Text.TextSize = 18; - Padding = new MarginPadding { Right = padding + 9 }; //padding + chevron width + Text.TextSize = 16; + Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, From 4c127a6130368c87f85b98af2e10ca6218f2c0b2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:29:20 -0300 Subject: [PATCH 41/83] CI fixes --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 4ee0ba9e5e..3bc94da07b 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -1,17 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using OpenTK; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public static readonly float padding = 10; + public const float padding = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); @@ -23,8 +21,6 @@ namespace osu.Game.Graphics.UserInterface { foreach (TabItem t in TabContainer.Children) { - if (!(t is BreadcrumbTabItem)) return; - var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); var hide = tIndex < tabIndex; @@ -32,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); - (t as BreadcrumbTabItem).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } @@ -42,7 +38,7 @@ namespace osu.Game.Graphics.UserInterface public readonly TextAwesome Chevron; //don't allow clicking between transitions and don't make the chevron clickable - protected override bool InternalContains(Vector2 screenSpacePos) => Alpha < 1f ? false : Text.Contains(screenSpacePos); + protected override bool InternalContains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos); public BreadcrumbTabItem(T value) : base(value) { From c9971bb490a60714279b3b965b4ee4734a8f02c5 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:32:46 -0300 Subject: [PATCH 42/83] Don't store hideChevron --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 3bc94da07b..b19b1c805e 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -24,11 +24,10 @@ namespace osu.Game.Graphics.UserInterface var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); var hide = tIndex < tabIndex; - var hideChevron = tIndex <= tabIndex; t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); - ((BreadcrumbTabItem)t).Chevron.FadeTo(hideChevron ? 0f : 1f, 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } From 33d6b718be955c16a41d9e15b364eb9fae20aceb Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:36:00 -0300 Subject: [PATCH 43/83] padding -> PADDING --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index b19b1c805e..53e8275b56 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -9,14 +9,14 @@ namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public const float padding = 10; + public const float PADDING = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); public BreadcrumbControl() { Height = 26; - TabContainer.Spacing = new Vector2(padding, 0f); + TabContainer.Spacing = new Vector2(PADDING, 0f); Current.ValueChanged += tab => { foreach (TabItem t in TabContainer.Children) @@ -42,14 +42,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 16; - Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width + Padding = new MarginPadding { Right = PADDING + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = padding }, + Margin = new MarginPadding { Left = PADDING }, Alpha = 0f, }); } From 3699c399679a6273d710c33c436d55da5d0b7898 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 26 May 2017 16:46:09 -0300 Subject: [PATCH 44/83] PADDING -> padding, make private --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 53e8275b56..8fb0affe8d 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -9,14 +9,14 @@ namespace osu.Game.Graphics.UserInterface { public class BreadcrumbControl : OsuTabControl { - public const float PADDING = 10; + private const float padding = 10; protected override TabItem CreateTabItem(T value) => new BreadcrumbTabItem(value); public BreadcrumbControl() { Height = 26; - TabContainer.Spacing = new Vector2(PADDING, 0f); + TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { foreach (TabItem t in TabContainer.Children) @@ -42,14 +42,14 @@ namespace osu.Game.Graphics.UserInterface public BreadcrumbTabItem(T value) : base(value) { Text.TextSize = 16; - Padding = new MarginPadding { Right = PADDING + 8 }; //padding + chevron width + Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width Add(Chevron = new TextAwesome { Anchor = Anchor.CentreRight, Origin = Anchor.CentreLeft, TextSize = 12, Icon = FontAwesome.fa_chevron_right, - Margin = new MarginPadding { Left = PADDING }, + Margin = new MarginPadding { Left = padding }, Alpha = 0f, }); } From 731c15f91afa2cccfce8355b9f872c020202d639 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 27 May 2017 13:24:02 +0900 Subject: [PATCH 45/83] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index ea5a2a7e1a..16da101e76 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit ea5a2a7e1abffb1515c020fd017b583b71780316 +Subproject commit 16da101e76389f6b227fde511ddda8c8783f55ec From e86ccf61b3f70dfd8a22d4838d6789d2d8f94b4c Mon Sep 17 00:00:00 2001 From: Jorolf Date: Sat, 27 May 2017 09:52:02 +0200 Subject: [PATCH 46/83] use recursion --- osu.Game/Overlays/Mods/ModButton.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index e1545ab1b8..70197ba444 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -71,13 +71,11 @@ namespace osu.Game.Overlays.Mods { foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); - using (foregroundIcon.BeginDelayedSequence(mod_switch_duration)) + using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { foregroundIcon.RotateTo(-15f); foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - } - using (backgroundIcon.BeginDelayedSequence(mod_switch_duration)) - { + backgroundIcon.RotateTo(15f); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); } From 330bd4e11dc48205c11aff8f2839c6efe791a1b4 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 27 May 2017 20:22:19 +0900 Subject: [PATCH 47/83] Fix osu!direct hotkey overriding drawings hotkey (for now). --- osu.Game/OsuGame.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 886ff4f8d1..2c952ee514 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -255,6 +255,9 @@ namespace osu.Game settings.ToggleVisibility(); return true; case Key.D: + if (state.Keyboard.ShiftPressed || state.Keyboard.AltPressed) + return false; + direct.ToggleVisibility(); return true; } From e7087f22ea73394382f154ae6d24572feaf443a3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 27 May 2017 17:27:11 -0300 Subject: [PATCH 48/83] Change UserPanel test case data to use always available covers --- osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index 513bf24e0d..92d58c10c9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -32,14 +32,14 @@ namespace osu.Desktop.VisualTests.Tests Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" }, - CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3103765/5b012e13611d5761caa7e24fecb3d3a16e1cf48fc2a3032cfd43dd444af83d82.jpeg" + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" }) { Width = 300 }, peppy = new UserPanel(new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" }, - CoverUrl = @"https://assets.ppy.sh/user-profile-covers/2/08cad88747c235a64fca5f1b770e100f120827ded1ffe3b66bfcd19c940afa65.jpeg" + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" }) { Width = 300 }, }, }); From d4a9813af9cbd12b04df6d5b4f5e81ef16b41028 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 27 May 2017 18:19:09 -0300 Subject: [PATCH 49/83] Cleanup BreadcrumbTabItem visibility code --- .../UserInterface/BreadcrumbControl.cs | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 8fb0affe8d..1c303ee175 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -2,7 +2,9 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; +using osu.Framework; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface @@ -23,21 +25,44 @@ namespace osu.Game.Graphics.UserInterface { var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); - var hide = tIndex < tabIndex; - t.FadeTo(hide ? 0f : 1f, 500, EasingTypes.OutQuint); - t.ScaleTo(new Vector2(hide ? 0.8f : 1f, 1f), 500, EasingTypes.OutQuint); + ((BreadcrumbTabItem)t).State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } - private class BreadcrumbTabItem : OsuTabItem + private class BreadcrumbTabItem : OsuTabItem, IStateful { public readonly TextAwesome Chevron; //don't allow clicking between transitions and don't make the chevron clickable protected override bool InternalContains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos); + public override bool HandleInput => State == Visibility.Visible; + + private Visibility state; + public Visibility State + { + get { return state; } + set + { + if (value == state) return; + state = value; + + const float transition_duration = 500; + + if (State == Visibility.Visible) + { + FadeIn(transition_duration, EasingTypes.OutQuint); + ScaleTo(new Vector2(1f), transition_duration, EasingTypes.OutQuint); + } + else + { + FadeOut(transition_duration, EasingTypes.OutQuint); + ScaleTo(new Vector2(0.8f, 1f), transition_duration, EasingTypes.OutQuint); + } + } + } public BreadcrumbTabItem(T value) : base(value) { From bdeaf2dbb4a6a3a285f089c957b50746954bb906 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 18:34:12 +0900 Subject: [PATCH 50/83] Update method names in line with framework changes --- osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs | 4 ++-- osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs | 2 +- osu.Game/Overlays/Dialog/PopupDialog.cs | 4 ++-- osu.Game/Screens/Menu/ButtonSystem.cs | 8 ++++---- osu.Game/Screens/Play/FailOverlay.cs | 2 +- osu.Game/Screens/Play/KeyCounterCollection.cs | 8 ++++---- osu.Game/Screens/Play/PauseContainer.cs | 2 +- osu.Game/Screens/Play/SkipButton.cs | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 9dcba02849..18857b137b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -80,7 +80,7 @@ namespace osu.Desktop.VisualTests.Tests private void triggerKeyDown(Column column) { - column.TriggerKeyDown(new InputState(), new KeyDownEventArgs + column.TriggerOnKeyDown(new InputState(), new KeyDownEventArgs { Key = column.Key, Repeat = false @@ -89,7 +89,7 @@ namespace osu.Desktop.VisualTests.Tests private void triggerKeyUp(Column column) { - column.TriggerKeyUp(new InputState(), new KeyUpEventArgs + column.TriggerOnKeyUp(new InputState(), new KeyUpEventArgs { Key = column.Key }); diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index f2ae47354e..a758d5fdef 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -74,7 +74,7 @@ namespace osu.Game.Graphics.UserInterface.Volume return; } - volumeMeterMaster.TriggerWheel(state); + volumeMeterMaster.TriggerOnWheel(state); } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Dialog/PopupDialog.cs b/osu.Game/Overlays/Dialog/PopupDialog.cs index 47674de817..42819f7f87 100644 --- a/osu.Game/Overlays/Dialog/PopupDialog.cs +++ b/osu.Game/Overlays/Dialog/PopupDialog.cs @@ -71,7 +71,7 @@ namespace osu.Game.Overlays.Dialog private void pressButtonAtIndex(int index) { if (index < Buttons.Count()) - Buttons.Skip(index).First().TriggerClick(); + Buttons.Skip(index).First().TriggerOnClick(); } protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) @@ -80,7 +80,7 @@ namespace osu.Game.Overlays.Dialog if (args.Key == Key.Enter) { - Buttons.OfType().FirstOrDefault()?.TriggerClick(); + Buttons.OfType().FirstOrDefault()?.TriggerOnClick(); return true; } diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 72db445052..52039a8417 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -135,7 +135,7 @@ namespace osu.Game.Screens.Menu switch (args.Key) { case Key.Space: - osuLogo.TriggerClick(state); + osuLogo.TriggerOnClick(state); return true; case Key.Escape: switch (State) @@ -144,7 +144,7 @@ namespace osu.Game.Screens.Menu State = MenuState.Initial; return true; case MenuState.Play: - backButton.TriggerClick(); + backButton.TriggerOnClick(); return true; } @@ -178,10 +178,10 @@ namespace osu.Game.Screens.Menu State = MenuState.TopLevel; return; case MenuState.TopLevel: - buttonsTopLevel.First().TriggerClick(); + buttonsTopLevel.First().TriggerOnClick(); return; case MenuState.Play: - buttonsPlay.First().TriggerClick(); + buttonsPlay.First().TriggerOnClick(); return; } } diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index faff687ddb..3e31da2348 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play { if (!args.Repeat && args.Key == Key.Escape) { - Buttons.Children.Last().TriggerClick(); + Buttons.Children.Last().TriggerOnClick(); return true; } diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index 6e1c8a34e5..25cbfc14b7 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -131,13 +131,13 @@ namespace osu.Game.Screens.Play public override bool HandleInput => true; - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => target.Children.Any(c => c.TriggerKeyDown(state, args)); + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => target.Children.Any(c => c.TriggerOnKeyDown(state, args)); - protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) => target.Children.Any(c => c.TriggerKeyUp(state, args)); + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) => target.Children.Any(c => c.TriggerOnKeyUp(state, args)); - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => target.Children.Any(c => c.TriggerMouseDown(state, args)); + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => target.Children.Any(c => c.TriggerOnMouseDown(state, args)); - protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => target.Children.Any(c => c.TriggerMouseUp(state, args)); + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => target.Children.Any(c => c.TriggerOnMouseUp(state, args)); } } } diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs index 1de62048b7..f052bafd63 100644 --- a/osu.Game/Screens/Play/PauseContainer.cs +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -136,7 +136,7 @@ namespace osu.Game.Screens.Play { if (!args.Repeat && args.Key == Key.Escape) { - Buttons.Children.First().TriggerClick(); + Buttons.Children.First().TriggerOnClick(); return true; } diff --git a/osu.Game/Screens/Play/SkipButton.cs b/osu.Game/Screens/Play/SkipButton.cs index 86bbb26412..ee11fc0ca6 100644 --- a/osu.Game/Screens/Play/SkipButton.cs +++ b/osu.Game/Screens/Play/SkipButton.cs @@ -127,7 +127,7 @@ namespace osu.Game.Screens.Play switch (args.Key) { case Key.Space: - button.TriggerClick(); + button.TriggerOnClick(); return true; } From d749fc516dbafb9d3406f57c91a2e152ed930d8c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 20:08:46 +0900 Subject: [PATCH 51/83] Update focus handling in line with framework changes --- .../Graphics/UserInterface/FocusedTextBox.cs | 13 +++++++++++-- osu.Game/Overlays/ChatOverlay.cs | 2 +- osu.Game/Overlays/DirectOverlay.cs | 2 +- osu.Game/Overlays/LoginOverlay.cs | 3 ++- osu.Game/Overlays/Music/PlaylistOverlay.cs | 7 +++++-- .../Settings/Sections/General/LoginSettings.cs | 17 +++++++++++------ osu.Game/Overlays/SettingsOverlay.cs | 5 +++-- osu.Game/Screens/Select/FilterControl.cs | 11 ++++++++--- 8 files changed, 42 insertions(+), 18 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs index 2f53d00c7e..fe1d255bba 100644 --- a/osu.Game/Graphics/UserInterface/FocusedTextBox.cs +++ b/osu.Game/Graphics/UserInterface/FocusedTextBox.cs @@ -3,6 +3,7 @@ using OpenTK.Graphics; using OpenTK.Input; +using osu.Framework.Allocation; using osu.Framework.Input; using System; using System.Linq; @@ -23,11 +24,19 @@ namespace osu.Game.Graphics.UserInterface set { focus = value; - if (!focus) - TriggerFocusLost(); + if (!focus && HasFocus) + inputManager.ChangeFocus(null); } } + private InputManager inputManager; + + [BackgroundDependencyLoader] + private void load(UserInputManager inputManager) + { + this.inputManager = inputManager; + } + protected override bool OnFocus(InputState state) { var result = base.OnFocus(state); diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 686a1d513a..90068eb170 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -165,7 +165,7 @@ namespace osu.Game.Overlays protected override bool OnFocus(InputState state) { //this is necessary as inputTextBox is masked away and therefore can't get focus :( - inputTextBox.TriggerFocus(); + InputManager.ChangeFocus(inputTextBox); return false; } diff --git a/osu.Game/Overlays/DirectOverlay.cs b/osu.Game/Overlays/DirectOverlay.cs index 0930c825b6..b1bc7e0c04 100644 --- a/osu.Game/Overlays/DirectOverlay.cs +++ b/osu.Game/Overlays/DirectOverlay.cs @@ -189,7 +189,7 @@ namespace osu.Game.Overlays protected override bool OnFocus(InputState state) { - filter.Search.TriggerFocus(); + InputManager.ChangeFocus(filter.Search); return false; } diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index e555600028..e2c2148201 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Overlays.Settings.Sections.General; using OpenTK.Graphics; +using osu.Framework.Input; namespace osu.Game.Overlays { @@ -66,7 +67,7 @@ namespace osu.Game.Overlays settingsSection.Bounding = true; FadeIn(transition_time, EasingTypes.OutQuint); - settingsSection.TriggerFocus(); + InputManager.ChangeFocus(settingsSection); } protected override void PopOut() diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 5e433aa414..82596252b3 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -17,6 +17,7 @@ using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions; +using osu.Framework.Input; namespace osu.Game.Overlays.Music { @@ -35,10 +36,12 @@ namespace osu.Game.Overlays.Music private readonly Bindable beatmapBacking = new Bindable(); public IEnumerable BeatmapSets; + private InputManager inputManager; [BackgroundDependencyLoader] - private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours) + private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, UserInputManager inputManager) { + this.inputManager = inputManager; this.beatmaps = beatmaps; trackManager = game.Audio.Track; @@ -100,7 +103,7 @@ namespace osu.Game.Overlays.Music protected override void PopIn() { filter.Search.HoldFocus = true; - Schedule(() => filter.Search.TriggerFocus()); + Schedule(() => inputManager.ChangeFocus(filter.Search)); ResizeTo(new Vector2(1, playlist_height), transition_duration, EasingTypes.OutQuint); FadeIn(transition_duration, EasingTypes.OutQuint); diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 561f81d6c3..c22a6e7411 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -51,9 +51,12 @@ namespace osu.Game.Overlays.Settings.Sections.General Spacing = new Vector2(0f, 5f); } + private InputManager inputManager; + [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuColour colours, APIAccess api) + private void load(OsuColour colours, APIAccess api, UserInputManager inputManager) { + this.inputManager = inputManager; this.colours = colours; api?.Register(this); } @@ -160,12 +163,12 @@ namespace osu.Game.Overlays.Settings.Sections.General break; } - form?.TriggerFocus(); + if (form != null) inputManager.ChangeFocus(form); } protected override bool OnFocus(InputState state) { - form?.TriggerFocus(); + if (form != null) inputManager.ChangeFocus(form); return base.OnFocus(state); } @@ -174,6 +177,7 @@ namespace osu.Game.Overlays.Settings.Sections.General private TextBox username; private TextBox password; private APIAccess api; + private InputManager inputManager; private void performLogin() { @@ -182,8 +186,9 @@ namespace osu.Game.Overlays.Settings.Sections.General } [BackgroundDependencyLoader(permitNulls: true)] - private void load(APIAccess api, OsuConfigManager config) + private void load(APIAccess api, OsuConfigManager config, UserInputManager inputManager) { + this.inputManager = inputManager; this.api = api; Direction = FillDirection.Vertical; Spacing = new Vector2(0, 5); @@ -235,9 +240,9 @@ namespace osu.Game.Overlays.Settings.Sections.General Schedule(() => { if (string.IsNullOrEmpty(username.Text)) - username.TriggerFocus(); + inputManager.ChangeFocus(username); else - password.TriggerFocus(); + inputManager.ChangeFocus(password); }); return base.OnFocus(state); diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 943545e858..474631fd1e 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -134,12 +134,13 @@ namespace osu.Game.Overlays FadeTo(0, TRANSITION_LENGTH / 2); searchTextBox.HoldFocus = false; - searchTextBox.TriggerFocusLost(); + if (searchTextBox.HasFocus) + InputManager.ChangeFocus(null); } protected override bool OnFocus(InputState state) { - searchTextBox.TriggerFocus(state); + InputManager.ChangeFocus(searchTextBox); return false; } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 7c7863acd1..94bc60a6ca 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -154,7 +154,8 @@ namespace osu.Game.Screens.Select public void Deactivate() { searchTextBox.HoldFocus = false; - searchTextBox.TriggerFocusLost(); + if (searchTextBox.HasFocus) + inputManager.ChangeFocus(searchTextBox); } public void Activate() @@ -164,9 +165,13 @@ namespace osu.Game.Screens.Select private readonly Bindable ruleset = new Bindable(); - [BackgroundDependencyLoader(permitNulls:true)] - private void load(OsuColour colours, OsuGame osu) + private InputManager inputManager; + + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuColour colours, OsuGame osu, UserInputManager inputManager) { + this.inputManager = inputManager; + sortTabs.AccentColour = colours.GreenLight; if (osu != null) From 013b4f9b899f12ffeb019d4938d814545d1448ba Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:09:44 +0900 Subject: [PATCH 52/83] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 8baad1b948..91fc2f2906 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 8baad1b9484b9f35724e2f965c18cfe710907d80 +Subproject commit 91fc2f290642eaaa2d365ca02558f92eba9009ca From ed8b34d5edf45e132ada94c6f5f96310955dcf20 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:11:46 +0900 Subject: [PATCH 53/83] Fix drift when dragging chat beyond bounds --- osu.Game/Overlays/ChatOverlay.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 686a1d513a..fec5f11129 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -135,17 +135,20 @@ namespace osu.Game.Overlays channelTabs.Current.ValueChanged += newChannel => CurrentChannel = newChannel; } + private double startDragChatHeight; + protected override bool OnDragStart(InputState state) { - if (channelTabs.Hovering) - return true; + if (!channelTabs.Hovering) + return base.OnDragStart(state); - return base.OnDragStart(state); + startDragChatHeight = chatHeight.Value; + return true; } protected override bool OnDrag(InputState state) { - chatHeight.Value = Height - state.Mouse.Delta.Y / Parent.DrawSize.Y; + chatHeight.Value = startDragChatHeight - (state.Mouse.Position.Y - state.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y; return base.OnDrag(state); } From 3644198c6e615f46412549f3e2cb1e1a6c148fb6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:20:11 +0900 Subject: [PATCH 54/83] Fix CI issues --- osu.Game/Overlays/LoginOverlay.cs | 1 - .../Overlays/Settings/Sections/General/LoginSettings.cs | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/osu.Game/Overlays/LoginOverlay.cs b/osu.Game/Overlays/LoginOverlay.cs index e2c2148201..c3f41270ce 100644 --- a/osu.Game/Overlays/LoginOverlay.cs +++ b/osu.Game/Overlays/LoginOverlay.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Overlays.Settings.Sections.General; using OpenTK.Graphics; -using osu.Framework.Input; namespace osu.Game.Overlays { diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index c22a6e7411..00ca50927e 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -237,14 +237,7 @@ namespace osu.Game.Overlays.Settings.Sections.General protected override bool OnFocus(InputState state) { - Schedule(() => - { - if (string.IsNullOrEmpty(username.Text)) - inputManager.ChangeFocus(username); - else - inputManager.ChangeFocus(password); - }); - + Schedule(() => { inputManager.ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); }); return base.OnFocus(state); } } From 18bcec723a4f8fbc4b89421432a0438d4aa7445f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:29:41 +0900 Subject: [PATCH 55/83] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 91fc2f2906..0b9053ec3d 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 91fc2f290642eaaa2d365ca02558f92eba9009ca +Subproject commit 0b9053ec3d39b486165992374752b280c5eeef06 From bc47dedf27d5119243da88c340aebd7231973c74 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 28 May 2017 21:34:15 +0900 Subject: [PATCH 56/83] Add non-null assertion --- osu.Game/Overlays/ChatOverlay.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index fec5f11129..d442fe5db0 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -148,6 +148,8 @@ namespace osu.Game.Overlays protected override bool OnDrag(InputState state) { + Trace.Assert(state.Mouse.PositionMouseDown != null); + chatHeight.Value = startDragChatHeight - (state.Mouse.Position.Y - state.Mouse.PositionMouseDown.Value.Y) / Parent.DrawSize.Y; return base.OnDrag(state); } From 9e5a53aae7c6d3909744303005b0369a761e12b7 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 10:53:55 +0900 Subject: [PATCH 57/83] Fix possible nullrefs. --- osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs index e65bc4a99f..10f8e846ed 100644 --- a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs +++ b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Objects var hitObjectY = y as DrawableHitObject; // If either of the two drawables are not hit objects, fall back to the base comparer - if ((hitObjectX ?? hitObjectY) == null) + if ((hitObjectX?.HitObject ?? hitObjectY?.HitObject) == null) return base.Compare(x, y); // Compare by start time @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Objects var hitObjectY = y as DrawableHitObject; // If either of the two drawables are not hit objects, fall back to the base comparer - if ((hitObjectX ?? hitObjectY) == null) + if ((hitObjectX?.HitObject ?? hitObjectY?.HitObject) == null) return base.Compare(x, y); // Compare by start time From cf3743f698c84aca72f19ef9349963b03420b299 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 10:56:42 +0900 Subject: [PATCH 58/83] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 16da101e76..aa3e296968 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 16da101e76389f6b227fde511ddda8c8783f55ec +Subproject commit aa3e296968873208ca4460b00c0b82fe3aa8ff5c From cdf4fcea023d994839d5d2f0582229379e4464e2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:07:17 +0900 Subject: [PATCH 59/83] Fix input being reversed. --- osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs index 636c84d9dc..0a8bc2d44a 100644 --- a/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs +++ b/osu.Game.Rulesets.Mania/Timing/ControlPointContainer.cs @@ -29,8 +29,6 @@ namespace osu.Game.Rulesets.Mania.Timing private readonly List drawableControlPoints; - protected override IComparer DepthComparer => new HitObjectStartTimeComparer(); - public ControlPointContainer(IEnumerable timingChanges) { drawableControlPoints = timingChanges.Select(t => new DrawableControlPoint(t)).ToList(); @@ -131,6 +129,8 @@ namespace osu.Game.Rulesets.Mania.Timing /// private class AutoTimeRelativeContainer : Container { + protected override IComparer DepthComparer => new HitObjectReverseStartTimeComparer(); + public override void InvalidateFromChild(Invalidation invalidation) { // We only want to re-compute our size when a child's size or position has changed From cd1da469c743784433187adf80a7efe08c7f3fc8 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:09:26 +0900 Subject: [PATCH 60/83] Cleanup + actually fix possible nullrefs. --- osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs index 10f8e846ed..b089856dcb 100644 --- a/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs +++ b/osu.Game/Rulesets/Objects/HitObjectStartTimeComparer.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Objects var hitObjectY = y as DrawableHitObject; // If either of the two drawables are not hit objects, fall back to the base comparer - if ((hitObjectX?.HitObject ?? hitObjectY?.HitObject) == null) + if (hitObjectX?.HitObject == null || hitObjectY?.HitObject == null) return base.Compare(x, y); // Compare by start time @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Objects var hitObjectY = y as DrawableHitObject; // If either of the two drawables are not hit objects, fall back to the base comparer - if ((hitObjectX?.HitObject ?? hitObjectY?.HitObject) == null) + if (hitObjectX?.HitObject == null || hitObjectY?.HitObject == null) return base.Compare(x, y); // Compare by start time From e5e73b31b61c932fc39408e5a650369a4ad3cd6d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:42:43 +0900 Subject: [PATCH 61/83] Cleanup + slight xmldoc improvements. --- .../Scoring/ManiaScoreProcessor.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 12c8386ae7..95c5c58d51 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -105,6 +105,16 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private const double hp_increase_miss = -0.125; + /// + /// The MISS HP multiplier. This is multiplied to the miss hp increase. + /// + private double hpMissMultiplier = 1; + + /// + /// The HIT HP multiplier. This is multiplied to hit hp increases. + /// + private double hpMultiplier = 1; + /// /// The cumulative combo portion of the score. /// @@ -141,16 +151,6 @@ namespace osu.Game.Rulesets.Mania.Scoring /// private int totalHits; - /// - /// The MISS HP multiplier. - /// - private double hpMissMultiplier = 1; - - /// - /// The HIT HP multiplier. - /// - private double hpMultiplier = 1; - public ManiaScoreProcessor() { } From f17b8acd13d5afffc865f543761cfce2680702b3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:45:16 +0900 Subject: [PATCH 62/83] Remove erroneous tab. --- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index 95c5c58d51..ebf99206ee 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -228,7 +228,7 @@ namespace osu.Game.Rulesets.Mania.Scoring switch (judgement.Result) { case HitResult.Miss: - Health.Value += hpMissMultiplier * hp_increase_miss; + Health.Value += hpMissMultiplier * hp_increase_miss; break; case HitResult.Hit: if (isTick) From e63108bd75ecdf69169432aeb2bcfdc0e43b76b3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 11:56:31 +0900 Subject: [PATCH 63/83] Add base for bar lines. --- osu.Game.Rulesets.Mania/Objects/Barline.cs | 9 +++++++++ .../Objects/Drawables/DrawableBarline.cs | 7 +++++++ .../Objects/Drawables/DrawableMajorBarline.cs | 7 +++++++ osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 3 +++ 4 files changed, 26 insertions(+) create mode 100644 osu.Game.Rulesets.Mania/Objects/Barline.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs create mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/Barline.cs new file mode 100644 index 0000000000..a9ce0559dc --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Barline.cs @@ -0,0 +1,9 @@ +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class Barline : HitObject + { + public bool IsMajor; + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs new file mode 100644 index 0000000000..605b9f83df --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs @@ -0,0 +1,7 @@ +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableBarline + { + + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs new file mode 100644 index 0000000000..607cc66012 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs @@ -0,0 +1,7 @@ +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + public class DrawableMajorBarline + { + + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index 7a8ec25fe4..b45ce3c5df 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -62,6 +62,8 @@ + + @@ -70,6 +72,7 @@ + From 6101fe98e1df4a7cf2e3f1dae39aae021facccf5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:10:29 +0900 Subject: [PATCH 64/83] Always ApplyDefaults after parsing beatmaps to make sure hit objects are in their most loaded state. --- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 3 ++ .../Rulesets/Objects/Legacy/ConvertSlider.cs | 34 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index cb1d9d2fcd..c6aac3bb71 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -428,6 +428,9 @@ namespace osu.Game.Beatmaps.Formats break; } } + + foreach (var hitObject in beatmap.HitObjects) + hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.Difficulty); } internal enum LegacySampleBank diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index 7580404e81..ddee0c3154 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -6,20 +6,36 @@ using System; using System.Collections.Generic; using OpenTK; using osu.Game.Audio; +using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Database; namespace osu.Game.Rulesets.Objects.Legacy { internal abstract class ConvertSlider : HitObject, IHasCurve { + /// + /// Scoring distance with a speed-adjusted beat length of 1 second. + /// + private const float base_scoring_distance = 100; + + public readonly SliderCurve Curve = new SliderCurve(); + public List ControlPoints { get; set; } public CurveType CurveType { get; set; } - public double Distance { get; set; } + + public double Distance + { + get { return Curve.Distance; } + set { Curve.Distance = value; } + } public List RepeatSamples { get; set; } public int RepeatCount { get; set; } = 1; - public double EndTime { get; set; } - public double Duration { get; set; } + public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity; + public double Duration => EndTime - StartTime; + + public double Velocity; public Vector2 PositionAt(double progress) { @@ -35,5 +51,17 @@ namespace osu.Game.Rulesets.Objects.Legacy { throw new NotImplementedException(); } + + public override void ApplyDefaults(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) + { + base.ApplyDefaults(controlPointInfo, difficulty); + + TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); + DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); + + double scoringDistance = base_scoring_distance * difficulty.SliderMultiplier / difficultyPoint.SpeedMultiplier; + + Velocity = scoringDistance / timingPoint.BeatLength; + } } } From 231b1ae6102f18651a45120c69888c31b22246af Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:19:38 +0900 Subject: [PATCH 65/83] We don't need a curve. --- osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index ddee0c3154..b42cd47abb 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -18,21 +18,15 @@ namespace osu.Game.Rulesets.Objects.Legacy /// private const float base_scoring_distance = 100; - public readonly SliderCurve Curve = new SliderCurve(); - public List ControlPoints { get; set; } public CurveType CurveType { get; set; } - public double Distance - { - get { return Curve.Distance; } - set { Curve.Distance = value; } - } + public double Distance { get; set; } public List RepeatSamples { get; set; } public int RepeatCount { get; set; } = 1; - public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity; + public double EndTime => StartTime + RepeatCount * Distance / Velocity; public double Duration => EndTime - StartTime; public double Velocity; From c137ee822c98529d3590fdc14f53a976b4bb6fca Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 12:19:51 +0900 Subject: [PATCH 66/83] Give velocity a sane default value. --- osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs index b42cd47abb..8c2aead5ff 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertSlider.cs @@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Objects.Legacy public double EndTime => StartTime + RepeatCount * Distance / Velocity; public double Duration => EndTime - StartTime; - public double Velocity; + public double Velocity = 1; public Vector2 PositionAt(double progress) { From 79d249e5ad428e0fc784e1eaf2a363fcf0873219 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 13:48:31 +0900 Subject: [PATCH 67/83] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index aa3e296968..0f3db5da09 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit aa3e296968873208ca4460b00c0b82fe3aa8ff5c +Subproject commit 0f3db5da09d0e7c4d2ef3057030e018f34ba536e From ee7158aa9514c47dce10209aee6d84aed8fbdf20 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 14:44:42 +0900 Subject: [PATCH 68/83] Implement bar lines. --- osu.Game.Rulesets.Mania/Objects/Barline.cs | 14 +++- .../Objects/Drawables/DrawableBarline.cs | 69 ++++++++++++++++++- .../Objects/Drawables/DrawableMajorBarline.cs | 7 -- .../UI/ManiaHitRenderer.cs | 29 ++++++++ osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 51 ++++++++++---- .../osu.Game.Rulesets.Mania.csproj | 1 - 6 files changed, 146 insertions(+), 25 deletions(-) delete mode 100644 osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/Barline.cs index a9ce0559dc..9b229a8d52 100644 --- a/osu.Game.Rulesets.Mania/Objects/Barline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Barline.cs @@ -1,9 +1,19 @@ +using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { - public class Barline : HitObject + public class Barline : ManiaHitObject { - public bool IsMajor; + /// + /// The control point which this bar line is part of. + /// + public TimingControlPoint ControlPoint; + + /// + /// The index of the beat which this bar line represents within the control point. + /// This is a "major" beat at % == 0. + /// + public int BeatIndex; } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs index 605b9f83df..eee32a9da3 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs @@ -1,7 +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 OpenTK; +using OpenTK.Input; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Objects.Drawables; + namespace osu.Game.Rulesets.Mania.Objects.Drawables { - public class DrawableBarline + /// + /// Visualises a . Although this derives DrawableManiaHitObject, + /// this does not handle input/sound like a normal hit object. + /// + public class DrawableBarline : DrawableManiaHitObject { - + public DrawableBarline(Barline hitObject) + : base(hitObject, null) + { + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + + Add(new Box + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = 1 + }); + + int signatureRelativeIndex = hitObject.BeatIndex % (int)hitObject.ControlPoint.TimeSignature; + + switch (signatureRelativeIndex) + { + case 0: + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = -9, + Rotation = 90, + BypassAutoSizeAxes = Axes.Both + }); + + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = 9, + Rotation = -90, + BypassAutoSizeAxes = Axes.Both, + }); + break; + case 1: + case 3: + Alpha = 0.2f; + break; + } + } + + protected override void UpdateState(ArmedState state) + { + } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs deleted file mode 100644 index 607cc66012..0000000000 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableMajorBarline.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace osu.Game.Rulesets.Mania.Objects.Drawables -{ - public class DrawableMajorBarline - { - - } -} \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 95b7979e43..871306b98c 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -6,9 +6,11 @@ using System.Collections.Generic; using System.Linq; using OpenTK; using OpenTK.Input; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Lists; +using osu.Framework.MathUtils; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Beatmaps; @@ -85,6 +87,33 @@ namespace osu.Game.Rulesets.Mania.UI }; } + [BackgroundDependencyLoader] + private void load() + { + var maniaPlayfield = (ManiaPlayfield)Playfield; + + double lastObjectTime = (Objects.LastOrDefault() as IHasEndTime)?.EndTime ?? Objects.LastOrDefault()?.StartTime ?? double.MaxValue; + + SortedList timingPoints = Beatmap.ControlPointInfo.TimingPoints; + for (int i = 0; i < timingPoints.Count; i++) + { + TimingControlPoint point = timingPoints[i]; + + double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time - point.BeatLength : lastObjectTime + point.BeatLength * (int)point.TimeSignature; + + int index = 0; + for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) + { + maniaPlayfield.Add(new DrawableBarline(new Barline + { + StartTime = t, + ControlPoint = point, + BeatIndex = index + })); + } + } + } + public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index ff763f87c4..dcf725e091 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -21,6 +21,7 @@ using osu.Game.Rulesets.Mania.Timing; using osu.Framework.Input; using osu.Framework.Graphics.Transforms; using osu.Framework.MathUtils; +using osu.Game.Rulesets.Mania.Objects.Drawables; namespace osu.Game.Rulesets.Mania.UI { @@ -77,27 +78,40 @@ namespace osu.Game.Rulesets.Mania.UI { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Both, Masking = true, Children = new Drawable[] { - new Box + new Container { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black - }, - columns = new FillFlowContainer - { - Name = "Columns", + Name = "Masked elements", + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, - Direction = FillDirection.Horizontal, - Padding = new MarginPadding { Left = 1, Right = 1 }, - Spacing = new Vector2(1, 0) + Masking = true, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black + }, + columns = new FillFlowContainer + { + Name = "Columns", + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Padding = new MarginPadding { Left = 1, Right = 1 }, + Spacing = new Vector2(1, 0) + } + } }, new Container { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, Children = new[] @@ -105,7 +119,10 @@ namespace osu.Game.Rulesets.Mania.UI barlineContainer = new ControlPointContainer(timingChanges) { Name = "Bar lines", - RelativeSizeAxes = Axes.Both, + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + RelativeSizeAxes = Axes.Y + // Width is set in the Update method } } } @@ -190,6 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); + public void Add(DrawableBarline barline) => barlineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { @@ -234,6 +252,13 @@ namespace osu.Game.Rulesets.Mania.UI TransformTo(() => TimeSpan, newTimeSpan, duration, easing, new TransformTimeSpan()); } + protected override void Update() + { + // Due to masking differences, it is not possible to get the width of the columns container automatically + // While masking on effectively only the Y-axis, so we need to set the width of the bar line container manually + barlineContainer.Width = columns.Width; + } + private class TransformTimeSpan : Transform { public override double CurrentValue diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index b45ce3c5df..cc5e6dd81e 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -63,7 +63,6 @@ - From 44f1d906eac658aa586e1bc2ec326a8194f74f64 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 14:47:51 +0900 Subject: [PATCH 69/83] Store tick count locally, remove HoldNote TickCount. --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 5 ----- osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 3550d561c1..3d988d9dda 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -61,11 +61,6 @@ namespace osu.Game.Rulesets.Mania.Objects tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; } - /// - /// Total number of hold note ticks. - /// - public int TotalTicks => Ticks.Count(); - /// /// The scoring scoring ticks of the hold note. /// diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index ebf99206ee..798d4b8c5b 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Linq; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Rulesets.Mania.Judgements; @@ -170,6 +171,8 @@ namespace osu.Game.Rulesets.Mania.Scoring { foreach (var obj in beatmap.HitObjects) { + var holdNote = obj as HoldNote; + if (obj is Note) { AddJudgement(new ManiaJudgement @@ -178,7 +181,7 @@ namespace osu.Game.Rulesets.Mania.Scoring ManiaResult = ManiaHitResult.Perfect }); } - else if (obj is HoldNote) + else if (holdNote != null) { // Head AddJudgement(new ManiaJudgement @@ -188,7 +191,8 @@ namespace osu.Game.Rulesets.Mania.Scoring }); // Ticks - for (int i = 0; i < ((HoldNote)obj).TotalTicks; i++) + int tickCount = holdNote.Ticks.Count(); + for (int i = 0; i < tickCount; i++) { AddJudgement(new HoldNoteTickJudgement { From 4fce0c11891fdc8fbc7457391a8b9d406574e785 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:01:13 +0900 Subject: [PATCH 70/83] Rename Barline -> BarLine. --- osu.Game.Rulesets.Mania/Objects/{Barline.cs => BarLine.cs} | 2 +- .../Drawables/{DrawableBarline.cs => DrawableBarLine.cs} | 6 +++--- osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs | 2 +- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 2 +- osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename osu.Game.Rulesets.Mania/Objects/{Barline.cs => BarLine.cs} (92%) rename osu.Game.Rulesets.Mania/Objects/Drawables/{DrawableBarline.cs => DrawableBarLine.cs} (92%) diff --git a/osu.Game.Rulesets.Mania/Objects/Barline.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs similarity index 92% rename from osu.Game.Rulesets.Mania/Objects/Barline.cs rename to osu.Game.Rulesets.Mania/Objects/BarLine.cs index 9b229a8d52..b635977fd1 100644 --- a/osu.Game.Rulesets.Mania/Objects/Barline.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -3,7 +3,7 @@ using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { - public class Barline : ManiaHitObject + public class BarLine : ManiaHitObject { /// /// The control point which this bar line is part of. diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs similarity index 92% rename from osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs rename to osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index eee32a9da3..9b1e1e4e3d 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarline.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -12,12 +12,12 @@ using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Objects.Drawables { /// - /// Visualises a . Although this derives DrawableManiaHitObject, + /// Visualises a . Although this derives DrawableManiaHitObject, /// this does not handle input/sound like a normal hit object. /// - public class DrawableBarline : DrawableManiaHitObject + public class DrawableBarLine : DrawableManiaHitObject { - public DrawableBarline(Barline hitObject) + public DrawableBarLine(BarLine hitObject) : base(hitObject, null) { AutoSizeAxes = Axes.Y; diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 871306b98c..4ddb7ad42a 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -104,7 +104,7 @@ namespace osu.Game.Rulesets.Mania.UI int index = 0; for (double t = timingPoints[i].Time; Precision.DefinitelyBigger(endTime, t); t += point.BeatLength, index++) { - maniaPlayfield.Add(new DrawableBarline(new Barline + maniaPlayfield.Add(new DrawableBarLine(new BarLine { StartTime = t, ControlPoint = point, diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index dcf725e091..d1b6fbaf7c 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); - public void Add(DrawableBarline barline) => barlineContainer.Add(barline); + public void Add(DrawableBarLine barline) => barlineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index cc5e6dd81e..3d5614bd90 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -62,7 +62,7 @@ - + @@ -71,7 +71,7 @@ - + From 32550bda4f796c9b8f4694a77d7a3348fb967052 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:18:06 +0900 Subject: [PATCH 71/83] Make drawable bar line a bit more sane. --- .../Objects/Drawables/DrawableBarLine.cs | 57 +++++++++---------- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 10 ++-- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index 9b1e1e4e3d..e253989ebc 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -17,8 +17,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableBarLine : DrawableManiaHitObject { - public DrawableBarLine(BarLine hitObject) - : base(hitObject, null) + public DrawableBarLine(BarLine barLine) + : base(barLine, null) { AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; @@ -31,38 +31,35 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Height = 1 }); - int signatureRelativeIndex = hitObject.BeatIndex % (int)hitObject.ControlPoint.TimeSignature; + bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; - switch (signatureRelativeIndex) + if (isMajor) { - case 0: - Add(new EquilateralTriangle - { - Name = "Left triangle", - Anchor = Anchor.BottomLeft, - Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = -9, - Rotation = 90, - BypassAutoSizeAxes = Axes.Both - }); + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = -9, + Rotation = 90, + BypassAutoSizeAxes = Axes.Both + }); - Add(new EquilateralTriangle - { - Name = "Right triangle", - Anchor = Anchor.BottomRight, - Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = 9, - Rotation = -90, - BypassAutoSizeAxes = Axes.Both, - }); - break; - case 1: - case 3: - Alpha = 0.2f; - break; + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(12), + X = 9, + Rotation = -90, + BypassAutoSizeAxes = Axes.Both, + }); } + + if (!isMajor && barLine.BeatIndex % 2 == 1) + Alpha = 0.2f; } protected override void UpdateState(ArmedState state) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index d1b6fbaf7c..2e6b63579e 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.UI private readonly FlowContainer columns; public IEnumerable Columns => columns.Children; - private readonly ControlPointContainer barlineContainer; + private readonly ControlPointContainer barLineContainer; private List normalColumnColours = new List(); private Color4 specialColumnColour; @@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Mania.UI Padding = new MarginPadding { Top = HIT_TARGET_POSITION }, Children = new[] { - barlineContainer = new ControlPointContainer(timingChanges) + barLineContainer = new ControlPointContainer(timingChanges) { Name = "Bar lines", Anchor = Anchor.TopCentre, @@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Mania.UI } public override void Add(DrawableHitObject h) => Columns.ElementAt(h.HitObject.Column).Add(h); - public void Add(DrawableBarLine barline) => barlineContainer.Add(barline); + public void Add(DrawableBarLine barline) => barLineContainer.Add(barline); protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { @@ -242,7 +242,7 @@ namespace osu.Game.Rulesets.Mania.UI timeSpan = MathHelper.Clamp(timeSpan, time_span_min, time_span_max); - barlineContainer.TimeSpan = value; + barLineContainer.TimeSpan = value; Columns.ForEach(c => c.ControlPointContainer.TimeSpan = value); } } @@ -256,7 +256,7 @@ namespace osu.Game.Rulesets.Mania.UI { // Due to masking differences, it is not possible to get the width of the columns container automatically // While masking on effectively only the Y-axis, so we need to set the width of the bar line container manually - barlineContainer.Width = columns.Width; + barLineContainer.Width = columns.Width; } private class TransformTimeSpan : Transform From 4b6f2efa76a469cf039712fbaed361ad340697d3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 15:30:05 +0900 Subject: [PATCH 72/83] Cleanups. --- osu.Game.Rulesets.Mania/Objects/BarLine.cs | 3 +- .../Objects/Drawables/DrawableBarLine.cs | 35 +++++++++++-------- .../UI/ManiaHitRenderer.cs | 1 + 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/BarLine.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs index b635977fd1..50e326086e 100644 --- a/osu.Game.Rulesets.Mania/Objects/BarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -1,5 +1,4 @@ using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Mania.Objects { @@ -12,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Objects /// /// The index of the beat which this bar line represents within the control point. - /// This is a "major" beat at % == 0. + /// This is a "major" bar line if % == 0. /// public int BeatIndex; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index e253989ebc..7554472507 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -1,10 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; -using OpenTK.Input; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Objects.Drawables; @@ -17,18 +14,28 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables /// public class DrawableBarLine : DrawableManiaHitObject { + /// + /// Height of major bar line triangles. + /// + private const float triangle_height = 12; + + /// + /// Offset of the major bar line triangles from the sides of the bar line. + /// + private const float triangle_offset = 9; + public DrawableBarLine(BarLine barLine) - : base(barLine, null) + : base(barLine) { - AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; + Height = 1; Add(new Box { + Name = "Bar line", Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - Height = 1 + RelativeSizeAxes = Axes.Both, }); bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; @@ -40,10 +47,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Name = "Left triangle", Anchor = Anchor.BottomLeft, Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = -9, - Rotation = 90, - BypassAutoSizeAxes = Axes.Both + Size = new Vector2(triangle_height), + X = -triangle_offset, + Rotation = 90 }); Add(new EquilateralTriangle @@ -51,10 +57,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Name = "Right triangle", Anchor = Anchor.BottomRight, Origin = Anchor.TopCentre, - Size = new Vector2(12), - X = 9, - Rotation = -90, - BypassAutoSizeAxes = Axes.Both, + Size = new Vector2(triangle_height), + X = triangle_offset, + Rotation = -90 }); } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs index 4ddb7ad42a..57477147d5 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaHitRenderer.cs @@ -99,6 +99,7 @@ namespace osu.Game.Rulesets.Mania.UI { TimingControlPoint point = timingPoints[i]; + // Stop on the beat before the next timing point, or if there is no next timing point stop slightly past the last object double endTime = i < timingPoints.Count - 1 ? timingPoints[i + 1].Time - point.BeatLength : lastObjectTime + point.BeatLength * (int)point.TimeSignature; int index = 0; From 0327adcba8e14c3caf78e9390289f7c54f72659d Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 29 May 2017 15:35:50 +0900 Subject: [PATCH 73/83] Update HoldNote.cs --- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 3d988d9dda..92f570476e 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,8 +1,7 @@ -// 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.Collections.Generic; -using System.Linq; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Database; using osu.Game.Rulesets.Objects.Types; From 586fc782cf5ec2da379f518d3924bafe50fd43d5 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 16:00:14 +0900 Subject: [PATCH 74/83] Fix line endings. --- osu.Game.Rulesets.Mania/Objects/BarLine.cs | 37 +++-- .../Objects/Drawables/DrawableBarLine.cs | 146 +++++++++--------- 2 files changed, 93 insertions(+), 90 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Objects/BarLine.cs b/osu.Game.Rulesets.Mania/Objects/BarLine.cs index 50e326086e..76a3d3920d 100644 --- a/osu.Game.Rulesets.Mania/Objects/BarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/BarLine.cs @@ -1,18 +1,21 @@ -using osu.Game.Beatmaps.ControlPoints; - -namespace osu.Game.Rulesets.Mania.Objects -{ - public class BarLine : ManiaHitObject - { - /// - /// The control point which this bar line is part of. - /// - public TimingControlPoint ControlPoint; - - /// - /// The index of the beat which this bar line represents within the control point. - /// This is a "major" bar line if % == 0. - /// - public int BeatIndex; - } +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Beatmaps.ControlPoints; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class BarLine : ManiaHitObject + { + /// + /// The control point which this bar line is part of. + /// + public TimingControlPoint ControlPoint; + + /// + /// The index of the beat which this bar line represents within the control point. + /// This is a "major" bar line if % == 0. + /// + public int BeatIndex; + } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index 7554472507..0b4d8b2d4e 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -1,74 +1,74 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Sprites; -using osu.Game.Rulesets.Objects.Drawables; - -namespace osu.Game.Rulesets.Mania.Objects.Drawables -{ - /// - /// Visualises a . Although this derives DrawableManiaHitObject, - /// this does not handle input/sound like a normal hit object. - /// - public class DrawableBarLine : DrawableManiaHitObject - { - /// - /// Height of major bar line triangles. - /// - private const float triangle_height = 12; - - /// - /// Offset of the major bar line triangles from the sides of the bar line. - /// - private const float triangle_offset = 9; - - public DrawableBarLine(BarLine barLine) - : base(barLine) - { - RelativeSizeAxes = Axes.X; - Height = 1; - - Add(new Box - { - Name = "Bar line", - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.Both, - }); - - bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; - - if (isMajor) - { - Add(new EquilateralTriangle - { - Name = "Left triangle", - Anchor = Anchor.BottomLeft, - Origin = Anchor.TopCentre, - Size = new Vector2(triangle_height), - X = -triangle_offset, - Rotation = 90 - }); - - Add(new EquilateralTriangle - { - Name = "Right triangle", - Anchor = Anchor.BottomRight, - Origin = Anchor.TopCentre, - Size = new Vector2(triangle_height), - X = triangle_offset, - Rotation = -90 - }); - } - - if (!isMajor && barLine.BeatIndex % 2 == 1) - Alpha = 0.2f; - } - - protected override void UpdateState(ArmedState state) - { - } - } +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Objects.Drawables; + +namespace osu.Game.Rulesets.Mania.Objects.Drawables +{ + /// + /// Visualises a . Although this derives DrawableManiaHitObject, + /// this does not handle input/sound like a normal hit object. + /// + public class DrawableBarLine : DrawableManiaHitObject + { + /// + /// Height of major bar line triangles. + /// + private const float triangle_height = 12; + + /// + /// Offset of the major bar line triangles from the sides of the bar line. + /// + private const float triangle_offset = 9; + + public DrawableBarLine(BarLine barLine) + : base(barLine) + { + RelativeSizeAxes = Axes.X; + Height = 1; + + Add(new Box + { + Name = "Bar line", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.Both, + }); + + bool isMajor = barLine.BeatIndex % (int)barLine.ControlPoint.TimeSignature == 0; + + if (isMajor) + { + Add(new EquilateralTriangle + { + Name = "Left triangle", + Anchor = Anchor.BottomLeft, + Origin = Anchor.TopCentre, + Size = new Vector2(triangle_height), + X = -triangle_offset, + Rotation = 90 + }); + + Add(new EquilateralTriangle + { + Name = "Right triangle", + Anchor = Anchor.BottomRight, + Origin = Anchor.TopCentre, + Size = new Vector2(triangle_height), + X = triangle_offset, + Rotation = -90 + }); + } + + if (!isMajor && barLine.BeatIndex % 2 == 1) + Alpha = 0.2f; + } + + protected override void UpdateState(ArmedState state) + { + } + } } \ No newline at end of file From e529ced131563ef930d0eafdc4cf06c3c8026580 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Mon, 29 May 2017 16:18:01 +0900 Subject: [PATCH 75/83] Fix mania-specific beatmaps not setting samples correctly. --- .../Beatmaps/ManiaBeatmapConverter.cs | 22 ++++++++++++++++++- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 125d8cdded..0ed2a0ba6f 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -13,6 +13,7 @@ using osu.Game.Rulesets.Mania.MathUtils; using osu.Game.Database; using osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy; using OpenTK; +using osu.Game.Audio; namespace osu.Game.Rulesets.Mania.Beatmaps { @@ -161,9 +162,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps pattern.Add(new HoldNote { StartTime = HitObject.StartTime, - Samples = HitObject.Samples, Duration = endTimeData.Duration, Column = column, + Head = { Samples = sampleInfoListAt(HitObject.StartTime) }, + Tail = { Samples = sampleInfoListAt(endTimeData.EndTime) }, }); } else if (positionData != null) @@ -178,6 +180,24 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return pattern; } + + /// + /// Retrieves the sample info list at a point in time. + /// + /// The time to retrieve the sample info list from. + /// + private SampleInfoList sampleInfoListAt(double time) + { + var curveData = HitObject as IHasCurve; + + if (curveData == null) + return HitObject.Samples; + + double segmentTime = (curveData.EndTime - HitObject.StartTime) / curveData.RepeatCount; + + int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime); + return curveData.RepeatSamples[index]; + } } } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index c241c4cf41..8cd757734c 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -58,6 +58,9 @@ namespace osu.Game.Rulesets.Mania.Objects TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); tickSpacing = timingPoint.BeatLength / difficulty.SliderTickRate; + + Head.ApplyDefaults(controlPointInfo, difficulty); + Tail.ApplyDefaults(controlPointInfo, difficulty); } /// From 718eeb6df8e0ef6be1cfd78f66f9e52461806fb0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 16:18:07 +0900 Subject: [PATCH 76/83] Use linq to tidy up casting --- osu.Game/Graphics/UserInterface/BreadcrumbControl.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs index 1c303ee175..8d113f4918 100644 --- a/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs +++ b/osu.Game/Graphics/UserInterface/BreadcrumbControl.cs @@ -6,6 +6,7 @@ using osu.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; +using System.Linq; namespace osu.Game.Graphics.UserInterface { @@ -21,13 +22,13 @@ namespace osu.Game.Graphics.UserInterface TabContainer.Spacing = new Vector2(padding, 0f); Current.ValueChanged += tab => { - foreach (TabItem t in TabContainer.Children) + foreach (var t in TabContainer.Children.OfType()) { var tIndex = TabContainer.IndexOf(t); var tabIndex = TabContainer.IndexOf(TabMap[tab]); - ((BreadcrumbTabItem)t).State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; - ((BreadcrumbTabItem)t).Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); + t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible; + t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint); } }; } From 31cc6917bc5b11774a8d557a86902692e9a95e85 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 17:20:55 +0900 Subject: [PATCH 77/83] Tidy up code, improve transition, add directionality --- osu.Game/Overlays/Mods/ModButton.cs | 57 ++++++++++++++++------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 70197ba444..f13b60a3ca 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -36,59 +36,64 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; - private const EasingTypes mod_switch_easing = EasingTypes.InOutQuint; - private const double mod_switch_duration = 100; + private const EasingTypes mod_switch_easing = EasingTypes.InOutSine; + private const double mod_switch_duration = 140; - private int _selectedIndex = -1; - private int selectedIndex + // A selected index of -1 means not selected. + private int selectedIndex = -1; + + protected int SelectedIndex { get { - return _selectedIndex; + return selectedIndex; } set { - if (value == _selectedIndex) return; + if (value == selectedIndex) return; bool beforeSelected = Selected; - _selectedIndex = value; + int direction = value < selectedIndex ? -1 : 1; + + selectedIndex = value; if (value >= Mods.Length) - { - _selectedIndex = -1; - } + selectedIndex = -1; else if (value <= -2) - { - _selectedIndex = Mods.Length - 1; - } + selectedIndex = Mods.Length - 1; + if (beforeSelected ^ Selected) { iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); + displayMod(SelectedMod ?? Mods[0]); } else { - foregroundIcon.RotateTo(15f, mod_switch_duration, mod_switch_easing); - backgroundIcon.RotateTo(-15f, mod_switch_duration, mod_switch_easing); + const float rotate_angle = 16; + + foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing); + backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing); + + backgroundIcon.Icon = SelectedMod.Icon; using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { - foregroundIcon.RotateTo(-15f); + foregroundIcon.RotateTo(-rotate_angle * direction); foregroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - backgroundIcon.RotateTo(15f); + backgroundIcon.RotateTo(rotate_angle * direction); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); + + iconsContainer.Schedule(() => displayMod(SelectedMod ?? Mods[0])); } } - foregroundIcon.Highlighted = Selected; - if (mod != null) - Scheduler.AddDelayed(() => displayMod(SelectedMod ?? Mods[0]), beforeSelected ^ Selected ? 0 : mod_switch_duration); + foregroundIcon.Highlighted = Selected; } } - public bool Selected => selectedIndex != -1; - + public bool Selected => SelectedIndex != -1; private Color4 selectedColour; public Color4 SelectedColour @@ -139,7 +144,7 @@ namespace osu.Game.Overlays.Mods // the mods from Mod, only multiple if Mod is a MultiMod - public override Mod SelectedMod => Mods.ElementAtOrDefault(selectedIndex); + public override Mod SelectedMod => Mods.ElementAtOrDefault(SelectedIndex); [BackgroundDependencyLoader] private void load(AudioManager audio) @@ -164,19 +169,19 @@ namespace osu.Game.Overlays.Mods public void SelectNext() { - (++selectedIndex == -1 ? sampleOff : sampleOn).Play(); + (++SelectedIndex == -1 ? sampleOff : sampleOn).Play(); Action?.Invoke(SelectedMod); } public void SelectPrevious() { - (--selectedIndex == -1 ? sampleOff : sampleOn).Play(); + (--SelectedIndex == -1 ? sampleOff : sampleOn).Play(); Action?.Invoke(SelectedMod); } public void Deselect() { - selectedIndex = -1; + SelectedIndex = -1; } private void displayMod(Mod mod) From 7960b5cf26ea4209aa57861c83c905e2600a7de0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 29 May 2017 18:03:40 +0900 Subject: [PATCH 78/83] More refactoring Also allows rotation when reaching the end of the available mods. --- osu.Game/Overlays/Mods/ModButton.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index f13b60a3ca..9ff19caff3 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Mods public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; private const EasingTypes mod_switch_easing = EasingTypes.InOutSine; - private const double mod_switch_duration = 140; + private const double mod_switch_duration = 120; // A selected index of -1 means not selected. private int selectedIndex = -1; @@ -52,31 +52,34 @@ namespace osu.Game.Overlays.Mods { if (value == selectedIndex) return; + int direction = value < selectedIndex ? -1 : 1; bool beforeSelected = Selected; - int direction = value < selectedIndex ? -1 : 1; - - selectedIndex = value; + Mod modBefore = SelectedMod ?? Mods[0]; if (value >= Mods.Length) selectedIndex = -1; - else if (value <= -2) + else if (value < -1) selectedIndex = Mods.Length - 1; + else + selectedIndex = value; - if (beforeSelected ^ Selected) + Mod modAfter = SelectedMod ?? Mods[0]; + + if (beforeSelected != Selected) { iconsContainer.RotateTo(Selected ? 5f : 0f, 300, EasingTypes.OutElastic); iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, EasingTypes.OutElastic); - displayMod(SelectedMod ?? Mods[0]); } - else + + if (modBefore != modAfter) { const float rotate_angle = 16; foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing); backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing); - backgroundIcon.Icon = SelectedMod.Icon; + backgroundIcon.Icon = modAfter.Icon; using (iconsContainer.BeginDelayedSequence(mod_switch_duration, true)) { foregroundIcon.RotateTo(-rotate_angle * direction); @@ -85,7 +88,7 @@ namespace osu.Game.Overlays.Mods backgroundIcon.RotateTo(rotate_angle * direction); backgroundIcon.RotateTo(0f, mod_switch_duration, mod_switch_easing); - iconsContainer.Schedule(() => displayMod(SelectedMod ?? Mods[0])); + iconsContainer.Schedule(() => displayMod(modAfter)); } } From e4b876ff5b7e274a12bb80ab2b3f14384cf09f78 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 29 May 2017 18:10:02 +0900 Subject: [PATCH 79/83] Update ModButton.cs --- osu.Game/Overlays/Mods/ModButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 9ff19caff3..f7df67b66d 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -189,7 +189,7 @@ namespace osu.Game.Overlays.Mods private void displayMod(Mod mod) { - if(backgroundIcon != null) + if (backgroundIcon != null) backgroundIcon.Icon = foregroundIcon.Icon; foregroundIcon.Icon = mod.Icon; text.Text = mod.Name; From 2f063ee41d8e80663a1b6bb316bc74c5ce8a1060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 29 May 2017 18:20:51 +0200 Subject: [PATCH 80/83] Make triangle edges smooth again --- osu.Game/Graphics/Backgrounds/Triangles.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 9a19819af8..2e4fb79079 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -24,6 +24,12 @@ namespace osu.Game.Graphics.Backgrounds { private const float triangle_size = 100; + /// + /// How many screen-space pixels are smoothed over. + /// Same behavior as Sprite's EdgeSmoothness. + /// + private const float edge_smoothness = 1; + public override bool HandleInput => false; public Color4 ColourLight = Color4.White; @@ -211,20 +217,28 @@ namespace osu.Game.Graphics.Backgrounds Shader.Bind(); Texture.TextureGL.Bind(); + Vector2 localInflationAmount = edge_smoothness * DrawInfo.MatrixInverse.ExtractScale().Xy; + foreach (TriangleParticle particle in Parts) { - var offset = new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f); + var offset = triangle_size * new Vector2(particle.Scale * 0.5f, particle.Scale * 0.866f); + var size = new Vector2(2 * offset.X, offset.Y); var triangle = new Triangle( particle.Position * Size * DrawInfo.Matrix, - (particle.Position * Size + offset * triangle_size) * DrawInfo.Matrix, - (particle.Position * Size + new Vector2(-offset.X, offset.Y) * triangle_size) * DrawInfo.Matrix + (particle.Position * Size + offset) * DrawInfo.Matrix, + (particle.Position * Size + new Vector2(-offset.X, offset.Y)) * DrawInfo.Matrix ); ColourInfo colourInfo = DrawInfo.Colour; colourInfo.ApplyChild(particle.Colour); - Texture.DrawTriangle(triangle, colourInfo, null, Shared.VertexBatch.Add); + Texture.DrawTriangle( + triangle, + colourInfo, + null, + Shared.VertexBatch.Add, + Vector2.Divide(localInflationAmount, size)); } Shader.Unbind(); From d3f2d480a8b8f637d7b8d65d55523ce338a3e6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 29 May 2017 18:24:17 +0200 Subject: [PATCH 81/83] Fix incorrect triangle state within the first frame --- osu.Game/Graphics/Backgrounds/Triangles.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 2e4fb79079..dd46713102 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -109,6 +109,8 @@ namespace osu.Game.Graphics.Backgrounds Invalidate(Invalidation.DrawNode, shallPropagate: false); + addTriangles(false); + for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; @@ -118,7 +120,6 @@ namespace osu.Game.Graphics.Backgrounds (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : 1; - newParticle.Position += new Vector2(0, -(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950); newParticle.Colour.A = adjustedAlpha; @@ -132,8 +133,6 @@ namespace osu.Game.Graphics.Backgrounds if (bottomPos < 0) parts.RemoveAt(i); } - - addTriangles(false); } private void addTriangles(bool randomY) From db444a61cb466269fa943cfbf69b62ceb857f7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 29 May 2017 18:30:49 +0200 Subject: [PATCH 82/83] Reduce per-triangle per-frame computation significantly --- osu.Game/Graphics/Backgrounds/Triangles.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index dd46713102..2ecaf9f7c7 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -109,27 +109,27 @@ namespace osu.Game.Graphics.Backgrounds Invalidate(Invalidation.DrawNode, shallPropagate: false); - addTriangles(false); + if (CreateNewTriangles) + addTriangles(false); + + float adjustedAlpha = HideAlphaDiscrepancies ? + // Cubically scale alpha to make it drop off more sharply. + (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : + 1; + + float movedDistance = ((float)Time.Elapsed / 950) * Velocity * (50 / DrawHeight) / triangleScale; for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; - float adjustedAlpha = HideAlphaDiscrepancies ? - // Cubically scale alpha to make it drop off more sharply. - (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : - 1; - - newParticle.Position += new Vector2(0, -(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950); + // Scale moved distance by the size of the triangle. Smaller triangles should move more slowly. + newParticle.Position.Y += -parts[i].Scale * movedDistance; newParticle.Colour.A = adjustedAlpha; parts[i] = newParticle; - if (!CreateNewTriangles) - continue; - float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight; - if (bottomPos < 0) parts.RemoveAt(i); } From 298c0f5757610b92c07ec6a2983c89ccc354a1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 29 May 2017 19:08:06 +0200 Subject: [PATCH 83/83] Structure velocity code more clearly and avoid redundant parenthesis --- osu.Game/Graphics/Backgrounds/Triangles.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/Triangles.cs b/osu.Game/Graphics/Backgrounds/Triangles.cs index 2ecaf9f7c7..7a2345a80c 100644 --- a/osu.Game/Graphics/Backgrounds/Triangles.cs +++ b/osu.Game/Graphics/Backgrounds/Triangles.cs @@ -23,6 +23,7 @@ namespace osu.Game.Graphics.Backgrounds public class Triangles : Drawable { private const float triangle_size = 100; + private const float base_velocity = 50; /// /// How many screen-space pixels are smoothed over. @@ -117,14 +118,18 @@ namespace osu.Game.Graphics.Backgrounds (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : 1; - float movedDistance = ((float)Time.Elapsed / 950) * Velocity * (50 / DrawHeight) / triangleScale; + float elapsedSeconds = (float)Time.Elapsed / 1000; + // Since position is relative, the velocity needs to scale inversely with DrawHeight. + // Since we will later multiply by the scale of individual triangles we normalize by + // dividing by triangleScale. + float movedDistance = -elapsedSeconds * Velocity * base_velocity / (DrawHeight * triangleScale); for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; // Scale moved distance by the size of the triangle. Smaller triangles should move more slowly. - newParticle.Position.Y += -parts[i].Scale * movedDistance; + newParticle.Position.Y += parts[i].Scale * movedDistance; newParticle.Colour.A = adjustedAlpha; parts[i] = newParticle;