From 95a207ef56a9907fff4c892f7e36c47fbf6e843d Mon Sep 17 00:00:00 2001 From: KoziLord Date: Tue, 15 May 2018 00:17:42 +0200 Subject: [PATCH 01/57] Fixed the parallax background missing from the space occupied by the top toolbar. --- osu.Game/Screens/Ranking/Results.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 32161a0b8e..38dbf1a65d 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -160,7 +160,7 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - Scale = new Vector2(1 / circle_outer_scale / overscan), + Scale = new Vector2(1 / circle_outer_scale), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] From ca05fde14c7c9f984caf6c7fcbbdbe3ce78ed010 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Tue, 15 May 2018 00:47:03 +0200 Subject: [PATCH 02/57] Fix the Parallax Background not filling the entire Circle Container. --- osu.Game/Screens/Ranking/Results.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 38dbf1a65d..a2990d7902 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -159,8 +159,11 @@ namespace osu.Game.Screens.Ranking backgroundParallax = new ParallaxContainer { RelativeSizeAxes = Axes.Both, - ParallaxAmount = 0.01f, - Scale = new Vector2(1 / circle_outer_scale), + ParallaxAmount = 0.02f, + //Compensate for the Toolbar + Scale = new Vector2(1.06f / circle_outer_scale / overscan), + //Offset the background to account for the toolbar. + Position = new Vector2(0, -20), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] From be56d8cb8253a7c710579f54377f5563e9c01170 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Tue, 15 May 2018 00:53:31 +0200 Subject: [PATCH 03/57] Change the parallax amount --- osu.Game/Screens/Ranking/Results.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index a2990d7902..17e8666ebf 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -159,7 +159,7 @@ namespace osu.Game.Screens.Ranking backgroundParallax = new ParallaxContainer { RelativeSizeAxes = Axes.Both, - ParallaxAmount = 0.02f, + ParallaxAmount = 0.01f, //Compensate for the Toolbar Scale = new Vector2(1.06f / circle_outer_scale / overscan), //Offset the background to account for the toolbar. From be1159444d2fb9cb15f0019b275fa9f6a6df48e4 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Tue, 15 May 2018 15:56:49 +0200 Subject: [PATCH 04/57] Use the absolute value of ParallaxAmount to make sure we're not scaling stuff down when using a negative ParallaxAmount --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index dc635ce7e7..51be40c1e8 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers if (!parallaxEnabled) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint); - content.Scale = new Vector2(1 + ParallaxAmount); + content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount)); } }; } @@ -69,7 +69,7 @@ namespace osu.Game.Graphics.Containers double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint); - content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + ParallaxAmount), 0, 1000, Easing.OutQuint); + content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint); } firstUpdate = false; From 1e88f216f27831a8c5bc76cf09ce271be61e0580 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:27:18 +0200 Subject: [PATCH 05/57] Revert the ParallaxContainer changes I made by accident back. --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 4 ++-- osu.Game/Screens/Ranking/Results.cs | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 51be40c1e8..dc635ce7e7 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers if (!parallaxEnabled) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint); - content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount)); + content.Scale = new Vector2(1 + ParallaxAmount); } }; } @@ -69,7 +69,7 @@ namespace osu.Game.Graphics.Containers double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint); - content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint); + content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + ParallaxAmount), 0, 1000, Easing.OutQuint); } firstUpdate = false; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 17e8666ebf..32161a0b8e 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -160,10 +160,7 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - //Compensate for the Toolbar - Scale = new Vector2(1.06f / circle_outer_scale / overscan), - //Offset the background to account for the toolbar. - Position = new Vector2(0, -20), + Scale = new Vector2(1 / circle_outer_scale / overscan), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] From 428d0f5deec85cfb2153d8246301f3f269865346 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:30:16 +0200 Subject: [PATCH 06/57] Re-implement the fix after it got deleted in the previous commit. --- osu.Game/Screens/Ranking/Results.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 32161a0b8e..162c428444 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -160,8 +160,11 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - Scale = new Vector2(1 / circle_outer_scale / overscan), + //Compensate for the Toolbar + Scale = new Vector2(1.06f / circle_outer_scale / overscan), + //Offset the background to account for the toolbar. Anchor = Anchor.Centre, + Position = new Vector2(0, -20), Origin = Anchor.Centre, Children = new Drawable[] { From 3b708f650591a015ccd1e54721981f4316fbce4b Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:34:08 +0200 Subject: [PATCH 07/57] make it equal with the original codebase. --- osu.Game/Screens/Ranking/Results.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 162c428444..67949f8e14 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -160,17 +160,14 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - //Compensate for the Toolbar - Scale = new Vector2(1.06f / circle_outer_scale / overscan), - //Offset the background to account for the toolbar. + Scale = new Vector2(1 / circle_outer_scale / overscan), Anchor = Anchor.Centre, - Position = new Vector2(0, -20), Origin = Anchor.Centre, Children = new Drawable[] { new Sprite { - RelativeSizeAxes = Axes.Both, + RelativeSsizeAxes = Axes.Both, Alpha = 0.2f, Texture = Beatmap.Value.Background, Anchor = Anchor.Centre, From 705960dabbc32591ccd36841e66e101e41133189 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:36:26 +0200 Subject: [PATCH 08/57] Fix typo --- osu.Game/Screens/Ranking/Results.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 67949f8e14..32161a0b8e 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -167,7 +167,7 @@ namespace osu.Game.Screens.Ranking { new Sprite { - RelativeSsizeAxes = Axes.Both, + RelativeSizeAxes = Axes.Both, Alpha = 0.2f, Texture = Beatmap.Value.Background, Anchor = Anchor.Centre, From d2b2d3e2e078de26188030f79c1722e2f30d2589 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:38:46 +0200 Subject: [PATCH 09/57] Use the absolute value of ParallaxAmount to make sure we're not scaling things down when using a negative value for the Parallax (moving against the cursor instead of with it) --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index dc635ce7e7..51be40c1e8 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers if (!parallaxEnabled) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint); - content.Scale = new Vector2(1 + ParallaxAmount); + content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount)); } }; } @@ -69,7 +69,7 @@ namespace osu.Game.Graphics.Containers double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint); - content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + ParallaxAmount), 0, 1000, Easing.OutQuint); + content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint); } firstUpdate = false; From 79c64d16e43da33e3e21fdcefdd192da9eaba2b7 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 09:49:23 +0800 Subject: [PATCH 10/57] Realization on Catch Star Rating --- .../Difficulty/CatchDifficultyCalculator.cs | 160 +++++++++++++++++- .../Difficulty/CatchDifficultyHitObject.cs | 127 ++++++++++++++ 2 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index f8351b7519..5351bd746d 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -1,18 +1,174 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Catch.Difficulty { public class CatchDifficultyCalculator : DifficultyCalculator { - public CatchDifficultyCalculator(IBeatmap beatmap) : base(beatmap) + private const double STAR_SCALING_FACTOR = 0.145; + private const float PLAYFIELD_WIDTH = CatchPlayfield.BASE_WIDTH; + + private readonly List difficultyHitObjects = new List(); + + public CatchDifficultyCalculator(IBeatmap beatmap) + : base(beatmap) { } - public override double Calculate(Dictionary categoryDifficulty = null) => 0; + public CatchDifficultyCalculator(IBeatmap beatmap, Mod[] mods) + : base(beatmap, mods) + { + } + + public override double Calculate(Dictionary categoryDifficulty = null) + { + + difficultyHitObjects.Clear(); + + float circleSize = Beatmap.BeatmapInfo.BaseDifficulty.CircleSize; + float catcherWidth = (1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f * 172; + //float catcherWidth = (float)(305.0f / 1.6f * ((102.4f * (1.0f - 0.7 * (circleSize - 5.0f)) / 5.0f) / 128.0f * 0.7f)); + float catcherWidthHalf = catcherWidth / 2; + catcherWidthHalf *= 0.8f; + + foreach (var hitObject in Beatmap.HitObjects) + { + // We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations. + if (hitObject is Fruit) + { + difficultyHitObjects.Add(new CatchDifficultyHitObject((CatchHitObject)hitObject, catcherWidthHalf)); + } + if (hitObject is JuiceStream) + { + IEnumerator nestedHitObjectsEnumerator = hitObject.NestedHitObjects.GetEnumerator(); + while (nestedHitObjectsEnumerator.MoveNext()) + { + CatchHitObject objectInJuiceStream = (CatchHitObject)nestedHitObjectsEnumerator.Current; + if (!(objectInJuiceStream is TinyDroplet)) + difficultyHitObjects.Add(new CatchDifficultyHitObject(objectInJuiceStream, catcherWidthHalf)); + } + } + } + + difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime)); + + if (!CalculateStrainValues()) return 0; + + double starRating = Math.Sqrt(CalculateDifficulty()) * STAR_SCALING_FACTOR; + + if (categoryDifficulty != null) + { + categoryDifficulty["Aim"] = starRating; + + double ar = Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate; + double preEmpt = BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / TimeRate; + + categoryDifficulty["AR"] = preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0; + + //categoryDifficulty.Add("AR", (preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0).ToString("0.00", GameBase.nfi)); + //categoryDifficulty.Add("Max combo", DifficultyHitObjects.Count.ToString(GameBase.nfi)); + } + + return starRating; + } + + protected bool CalculateStrainValues() + { + // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. + using (List.Enumerator hitObjectsEnumerator = difficultyHitObjects.GetEnumerator()) + { + + if (!hitObjectsEnumerator.MoveNext()) return false; + + CatchDifficultyHitObject currentHitObject = hitObjectsEnumerator.Current; + CatchDifficultyHitObject nextHitObject; + + // First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject. + while (hitObjectsEnumerator.MoveNext()) + { + nextHitObject = hitObjectsEnumerator.Current; + nextHitObject.CalculateStrains(currentHitObject, TimeRate); + currentHitObject = nextHitObject; + } + + return true; + } + } + + /// + /// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP. + /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. + /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. + /// + protected const double STRAIN_STEP = 750; + + /// + /// The weighting of each strain value decays to this number * it's previous value + /// + protected const double DECAY_WEIGHT = 0.94; + + protected double CalculateDifficulty() + { + // The strain step needs to be adjusted for the algorithm to be considered equal with speed changing mods + double actualStrainStep = STRAIN_STEP * TimeRate; + + // Find the highest strain value within each strain step + List highestStrains = new List(); + double intervalEndTime = actualStrainStep; + double maximumStrain = 0; // We need to keep track of the maximum strain in the current interval + + CatchDifficultyHitObject previousHitObject = null; + foreach (CatchDifficultyHitObject hitObject in difficultyHitObjects) + { + // While we are beyond the current interval push the currently available maximum to our strain list + while (hitObject.BaseHitObject.StartTime > intervalEndTime) + { + highestStrains.Add(maximumStrain); + + // The maximum strain of the next interval is not zero by default! We need to take the last hitObject we encountered, take its strain and apply the decay + // until the beginning of the next interval. + if (previousHitObject == null) + { + maximumStrain = 0; + } + else + { + double decay = Math.Pow(CatchDifficultyHitObject.DECAY_BASE, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); + maximumStrain = previousHitObject.Strain * decay; + } + + // Go to the next time interval + intervalEndTime += actualStrainStep; + } + + // Obtain maximum strain + maximumStrain = Math.Max(hitObject.Strain, maximumStrain); + + previousHitObject = hitObject; + } + + + // Build the weighted sum over the highest strains for each interval + double difficulty = 0; + double weight = 1; + highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. + + foreach (double strain in highestStrains) + { + difficulty += weight * strain; + weight *= DECAY_WEIGHT; + } + + return difficulty; + } } } diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs new file mode 100644 index 0000000000..14f9445c75 --- /dev/null +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs @@ -0,0 +1,127 @@ +using System; +using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Catch.UI; +using OpenTK; + +namespace osu.Game.Rulesets.Catch.Difficulty +{ + class CatchDifficultyHitObject + { + internal static readonly double DECAY_BASE = 0.20; + private const float NORMALIZED_HITOBJECT_RADIUS = 41.0f; + private const float ABSOLUTE_PLAYER_POSITIONING_ERROR = 16f; + private float playerPositioningError; + + internal CatchHitObject BaseHitObject; + + /// + /// Measures jump difficulty. CtB doesn't have something like button pressing speed or accuracy + /// + internal double Strain = 1; + + /// + /// This is required to keep track of lazy player movement (always moving only as far as necessary) + /// Without this quick repeat sliders / weirdly shaped streams might become ridiculously overrated + /// + internal float PlayerPositionOffset; + internal float LastMovement; + + internal float NormalizedPosition; + internal float ActualNormalizedPosition => NormalizedPosition + PlayerPositionOffset; + + internal CatchDifficultyHitObject(CatchHitObject baseHitObject, float catcherWidthHalf) + { + BaseHitObject = baseHitObject; + + // We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps. + float scalingFactor = NORMALIZED_HITOBJECT_RADIUS / catcherWidthHalf; + + playerPositioningError = ABSOLUTE_PLAYER_POSITIONING_ERROR;// * scalingFactor; + NormalizedPosition = baseHitObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor; + } + + private const double DIRECTION_CHANGE_BONUS = 12.5; + internal void CalculateStrains(CatchDifficultyHitObject previousHitObject, double timeRate) + { + // Rather simple, but more specialized things are inherently inaccurate due to the big difference playstyles and opinions make. + // See Taiko feedback thread. + double timeElapsed = (BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime) / timeRate; + double decay = Math.Pow(DECAY_BASE, timeElapsed / 1000); + + // Update new position with lazy movement. + PlayerPositionOffset = + MathHelper.Clamp( + previousHitObject.ActualNormalizedPosition, + NormalizedPosition - (NORMALIZED_HITOBJECT_RADIUS - playerPositioningError), + NormalizedPosition + (NORMALIZED_HITOBJECT_RADIUS - playerPositioningError)) // Obtain new lazy position, but be stricter by allowing for an error of a certain degree of the player. + - NormalizedPosition; // Subtract HitObject position to obtain offset + + LastMovement = DistanceTo(previousHitObject); + double addition = spacingWeight(LastMovement); + + if (NormalizedPosition < previousHitObject.NormalizedPosition) + { + LastMovement = -LastMovement; + } + + CatchHitObject previousHitCircle = previousHitObject.BaseHitObject; + + double additionBonus = 0; + double sqrtTime = Math.Sqrt(Math.Max(timeElapsed, 25)); + + // Direction changes give an extra point! + if (Math.Abs(LastMovement) > 0.1) + { + if (Math.Abs(previousHitObject.LastMovement) > 0.1 && Math.Sign(LastMovement) != Math.Sign(previousHitObject.LastMovement)) + { + double bonus = DIRECTION_CHANGE_BONUS / sqrtTime; + + // Weight bonus by how + double bonusFactor = Math.Min(playerPositioningError, Math.Abs(LastMovement)) / playerPositioningError; + + // We want time to play a role twice here! + addition += bonus * bonusFactor; + + // Bonus for tougher direction switches and "almost" hyperdashes at this point + if (previousHitCircle != null && previousHitCircle.DistanceToHyperDash <= 10.0f / CatchPlayfield.BASE_WIDTH) + { + additionBonus += 0.3 * bonusFactor; + } + } + + // Base bonus for every movement, giving some weight to streams. + addition += 7.5 * Math.Min(Math.Abs(LastMovement), NORMALIZED_HITOBJECT_RADIUS * 2) / (NORMALIZED_HITOBJECT_RADIUS * 6) / sqrtTime; + } + + // Bonus for "almost" hyperdashes at corner points + if (previousHitCircle != null && previousHitCircle.DistanceToHyperDash <= 10.0f / CatchPlayfield.BASE_WIDTH) + { + if (!previousHitCircle.HyperDash) + { + additionBonus += 1.0; + } + else + { + // After a hyperdash we ARE in the correct position. Always! + PlayerPositionOffset = 0; + } + + addition *= 1.0 + additionBonus * ((10 - previousHitCircle.DistanceToHyperDash * CatchPlayfield.BASE_WIDTH) / 10); + } + + addition *= 850.0 / Math.Max(timeElapsed, 25); + + Strain = previousHitObject.Strain * decay + addition; + } + + private static double spacingWeight(float distance) + { + return Math.Pow(distance, 1.3) / 500; + } + + internal float DistanceTo(CatchDifficultyHitObject other) + { + return Math.Abs(ActualNormalizedPosition - other.ActualNormalizedPosition); + } + } +} From 6bf5ea73d5f19ba4d706f9754a7169c5ae8e5f8e Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 09:53:20 +0800 Subject: [PATCH 11/57] Fix CatcherWidth --- .../Difficulty/CatchDifficultyCalculator.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 5351bd746d..59c512c469 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -35,8 +35,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty difficultyHitObjects.Clear(); float circleSize = Beatmap.BeatmapInfo.BaseDifficulty.CircleSize; - float catcherWidth = (1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f * 172; - //float catcherWidth = (float)(305.0f / 1.6f * ((102.4f * (1.0f - 0.7 * (circleSize - 5.0f)) / 5.0f) / 128.0f * 0.7f)); + float catcherWidth = (1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f * CatcherArea.CATCHER_SIZE; float catcherWidthHalf = catcherWidth / 2; catcherWidthHalf *= 0.8f; From 0ef718a09e6269343b6a3a04b1b3f9bfaaaf7d3a Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 09:55:07 +0800 Subject: [PATCH 12/57] Fixes on categoryDifficulty --- .../Difficulty/CatchDifficultyCalculator.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 59c512c469..63570d44b0 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -72,9 +72,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty double preEmpt = BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / TimeRate; categoryDifficulty["AR"] = preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0; - - //categoryDifficulty.Add("AR", (preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0).ToString("0.00", GameBase.nfi)); - //categoryDifficulty.Add("Max combo", DifficultyHitObjects.Count.ToString(GameBase.nfi)); + categoryDifficulty["Max combo"] = difficultyHitObjects.Count; } return starRating; From 44fd4b95bd7ce7c7ec58e6dc82cd57f5447ac2b1 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 09:58:46 +0800 Subject: [PATCH 13/57] We need DistanceToHyperDash for star rating calculation --- osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs index 548813fbd2..d55cdac115 100644 --- a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs @@ -24,6 +24,11 @@ namespace osu.Game.Rulesets.Catch.Objects public int ComboIndex { get; set; } + /// + /// The distance for a fruit to to next hyper if it's not a hyper. + /// + public float DistanceToHyperDash { get; set; } + /// /// The next fruit starts a new combo. Used for explodey. /// From 0405383e4e3eb352b2e78e428ab473f00e69fca6 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 10:12:18 +0800 Subject: [PATCH 14/57] Fixing code style --- .../Difficulty/CatchDifficultyCalculator.cs | 21 +++++-------------- .../Difficulty/CatchDifficultyHitObject.cs | 2 +- .../Difficulty/TaikoDifficultyCalculator.cs | 12 ++--------- .../Difficulty/DifficultyCalculator.cs | 15 +++++++++++++ 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 63570d44b0..83b5b3bb5c 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -31,7 +31,6 @@ namespace osu.Game.Rulesets.Catch.Difficulty public override double Calculate(Dictionary categoryDifficulty = null) { - difficultyHitObjects.Clear(); float circleSize = Beatmap.BeatmapInfo.BaseDifficulty.CircleSize; @@ -83,7 +82,6 @@ namespace osu.Game.Rulesets.Catch.Difficulty // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. using (List.Enumerator hitObjectsEnumerator = difficultyHitObjects.GetEnumerator()) { - if (!hitObjectsEnumerator.MoveNext()) return false; CatchDifficultyHitObject currentHitObject = hitObjectsEnumerator.Current; @@ -106,17 +104,17 @@ namespace osu.Game.Rulesets.Catch.Difficulty /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. /// - protected const double STRAIN_STEP = 750; + protected const double strain_step = 750; /// /// The weighting of each strain value decays to this number * it's previous value /// - protected const double DECAY_WEIGHT = 0.94; + protected const double decay_weight = 0.94; protected double CalculateDifficulty() { // The strain step needs to be adjusted for the algorithm to be considered equal with speed changing mods - double actualStrainStep = STRAIN_STEP * TimeRate; + double actualStrainStep = strain_step * TimeRate; // Find the highest strain value within each strain step List highestStrains = new List(); @@ -153,17 +151,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty previousHitObject = hitObject; } - - // Build the weighted sum over the highest strains for each interval - double difficulty = 0; - double weight = 1; - highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. - - foreach (double strain in highestStrains) - { - difficulty += weight * strain; - weight *= DECAY_WEIGHT; - } + // calculate maximun strain difficulty + double difficulty = StrainCalculator(highestStrains, decay_weight); return difficulty; } diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs index 14f9445c75..f4eefdd7cd 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs @@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty // We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps. float scalingFactor = NORMALIZED_HITOBJECT_RADIUS / catcherWidthHalf; - playerPositioningError = ABSOLUTE_PLAYER_POSITIONING_ERROR;// * scalingFactor; + playerPositioningError = ABSOLUTE_PLAYER_POSITIONING_ERROR; // * scalingFactor; NormalizedPosition = baseHitObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor; } diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs index 57e1e65064..197464c10a 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs @@ -122,16 +122,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty previousHitObject = hitObject; } - // Build the weighted sum over the highest strains for each interval - double difficulty = 0; - double weight = 1; - highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. - - foreach (double strain in highestStrains) - { - difficulty += weight * strain; - weight *= decay_weight; - } + // calculate maximun strain difficulty + double difficulty = StrainCalculator(highestStrains, decay_weight); return difficulty; } diff --git a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs index 070bc7ddb0..348435b0d0 100644 --- a/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs +++ b/osu.Game/Rulesets/Difficulty/DifficultyCalculator.cs @@ -37,5 +37,20 @@ namespace osu.Game.Rulesets.Difficulty } public abstract double Calculate(Dictionary categoryDifficulty = null); + + protected double StrainCalculator(List highestStrains, double decayWeight) + { + // Build the weighted sum over the highest strains for each interval + double difficulty = 0; + double weight = 1; + highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. + + foreach (double strain in highestStrains) + { + difficulty += weight * strain; + weight *= decayWeight; + } + return difficulty; + } } } From 886be8ce1f7c29d558e3a34f42863740c7ca6515 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 10:16:32 +0800 Subject: [PATCH 15/57] Adding lisence header --- .../Difficulty/CatchDifficultyCalculator.cs | 2 +- .../Difficulty/CatchDifficultyHitObject.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 83b5b3bb5c..19d1bab0ac 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty return true; } } - + /// /// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP. /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs index f4eefdd7cd..778ab9df28 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.UI; using OpenTK; @@ -76,7 +79,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty { double bonus = DIRECTION_CHANGE_BONUS / sqrtTime; - // Weight bonus by how + // Weight bonus by how double bonusFactor = Math.Min(playerPositioningError, Math.Abs(LastMovement)) / playerPositioningError; // We want time to play a role twice here! From 68a929eb0c1d78e38687f55b42b61c05d6a1e9a1 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 10:39:16 +0800 Subject: [PATCH 16/57] Fixing parameters naming --- .../Difficulty/CatchDifficultyCalculator.cs | 17 +++++------ .../Difficulty/CatchDifficultyHitObject.cs | 28 +++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 19d1bab0ac..31de9cfc8d 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -14,8 +14,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty { public class CatchDifficultyCalculator : DifficultyCalculator { - private const double STAR_SCALING_FACTOR = 0.145; - private const float PLAYFIELD_WIDTH = CatchPlayfield.BASE_WIDTH; + private const double star_scaling_factor = 0.145; + private const float playfield_width = CatchPlayfield.BASE_WIDTH; private readonly List difficultyHitObjects = new List(); @@ -54,6 +54,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty if (!(objectInJuiceStream is TinyDroplet)) difficultyHitObjects.Add(new CatchDifficultyHitObject(objectInJuiceStream, catcherWidthHalf)); } + // Dispose the enumerator after counting all fruits. + nestedHitObjectsEnumerator.Dispose(); } } @@ -61,7 +63,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty if (!CalculateStrainValues()) return 0; - double starRating = Math.Sqrt(CalculateDifficulty()) * STAR_SCALING_FACTOR; + double starRating = Math.Sqrt(CalculateDifficulty()) * star_scaling_factor; if (categoryDifficulty != null) { @@ -85,12 +87,11 @@ namespace osu.Game.Rulesets.Catch.Difficulty if (!hitObjectsEnumerator.MoveNext()) return false; CatchDifficultyHitObject currentHitObject = hitObjectsEnumerator.Current; - CatchDifficultyHitObject nextHitObject; // First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject. while (hitObjectsEnumerator.MoveNext()) { - nextHitObject = hitObjectsEnumerator.Current; + CatchDifficultyHitObject nextHitObject = hitObjectsEnumerator.Current; nextHitObject.CalculateStrains(currentHitObject, TimeRate); currentHitObject = nextHitObject; } @@ -104,12 +105,12 @@ namespace osu.Game.Rulesets.Catch.Difficulty /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. /// - protected const double strain_step = 750; + private const double strain_step = 750; /// /// The weighting of each strain value decays to this number * it's previous value /// - protected const double decay_weight = 0.94; + private const double decay_weight = 0.94; protected double CalculateDifficulty() { @@ -137,7 +138,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty } else { - double decay = Math.Pow(CatchDifficultyHitObject.DECAY_BASE, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); + double decay = Math.Pow(CatchDifficultyHitObject.decay_base, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); maximumStrain = previousHitObject.Strain * decay; } diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs index 778ab9df28..190c92b319 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs @@ -8,12 +8,12 @@ using OpenTK; namespace osu.Game.Rulesets.Catch.Difficulty { - class CatchDifficultyHitObject + internal class CatchDifficultyHitObject { - internal static readonly double DECAY_BASE = 0.20; - private const float NORMALIZED_HITOBJECT_RADIUS = 41.0f; - private const float ABSOLUTE_PLAYER_POSITIONING_ERROR = 16f; - private float playerPositioningError; + internal static readonly double decay_base = 0.20; + private const float normalized_hitobject_radius = 41.0f; + private const float absolute_player_positioning_error = 16f; + private readonly float playerPositioningError; internal CatchHitObject BaseHitObject; @@ -37,26 +37,26 @@ namespace osu.Game.Rulesets.Catch.Difficulty BaseHitObject = baseHitObject; // We will scale everything by this factor, so we can assume a uniform CircleSize among beatmaps. - float scalingFactor = NORMALIZED_HITOBJECT_RADIUS / catcherWidthHalf; + float scalingFactor = normalized_hitobject_radius / catcherWidthHalf; - playerPositioningError = ABSOLUTE_PLAYER_POSITIONING_ERROR; // * scalingFactor; + playerPositioningError = absolute_player_positioning_error; // * scalingFactor; NormalizedPosition = baseHitObject.X * CatchPlayfield.BASE_WIDTH * scalingFactor; } - private const double DIRECTION_CHANGE_BONUS = 12.5; + private const double direction_change_bonus = 12.5; internal void CalculateStrains(CatchDifficultyHitObject previousHitObject, double timeRate) { // Rather simple, but more specialized things are inherently inaccurate due to the big difference playstyles and opinions make. // See Taiko feedback thread. double timeElapsed = (BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime) / timeRate; - double decay = Math.Pow(DECAY_BASE, timeElapsed / 1000); + double decay = Math.Pow(decay_base, timeElapsed / 1000); // Update new position with lazy movement. PlayerPositionOffset = MathHelper.Clamp( previousHitObject.ActualNormalizedPosition, - NormalizedPosition - (NORMALIZED_HITOBJECT_RADIUS - playerPositioningError), - NormalizedPosition + (NORMALIZED_HITOBJECT_RADIUS - playerPositioningError)) // Obtain new lazy position, but be stricter by allowing for an error of a certain degree of the player. + NormalizedPosition - (normalized_hitobject_radius - playerPositioningError), + NormalizedPosition + (normalized_hitobject_radius - playerPositioningError)) // Obtain new lazy position, but be stricter by allowing for an error of a certain degree of the player. - NormalizedPosition; // Subtract HitObject position to obtain offset LastMovement = DistanceTo(previousHitObject); @@ -77,9 +77,9 @@ namespace osu.Game.Rulesets.Catch.Difficulty { if (Math.Abs(previousHitObject.LastMovement) > 0.1 && Math.Sign(LastMovement) != Math.Sign(previousHitObject.LastMovement)) { - double bonus = DIRECTION_CHANGE_BONUS / sqrtTime; + double bonus = direction_change_bonus / sqrtTime; - // Weight bonus by how + // Weight bonus by how double bonusFactor = Math.Min(playerPositioningError, Math.Abs(LastMovement)) / playerPositioningError; // We want time to play a role twice here! @@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty } // Base bonus for every movement, giving some weight to streams. - addition += 7.5 * Math.Min(Math.Abs(LastMovement), NORMALIZED_HITOBJECT_RADIUS * 2) / (NORMALIZED_HITOBJECT_RADIUS * 6) / sqrtTime; + addition += 7.5 * Math.Min(Math.Abs(LastMovement), normalized_hitobject_radius * 2) / (normalized_hitobject_radius * 6) / sqrtTime; } // Bonus for "almost" hyperdashes at corner points From 871743204b00983179fff782745cdea1bf341b5a Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 10:41:58 +0800 Subject: [PATCH 17/57] Fixing parameters naming --- osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs index 190c92b319..d9b16c2a0b 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs @@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty { double bonus = direction_change_bonus / sqrtTime; - // Weight bonus by how + // Weight bonus by how double bonusFactor = Math.Min(playerPositioningError, Math.Abs(LastMovement)) / playerPositioningError; // We want time to play a role twice here! From 2e5bc4323ad553b8f85fef881b552b8e8c9e956d Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 13:31:00 +0800 Subject: [PATCH 18/57] Fixing null reference exception bugs --- .../Difficulty/CatchDifficultyCalculator.cs | 9 +++++---- .../Difficulty/CatchDifficultyHitObject.cs | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 31de9cfc8d..2fa946f41c 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty difficultyHitObjects.Clear(); float circleSize = Beatmap.BeatmapInfo.BaseDifficulty.CircleSize; - float catcherWidth = (1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f * CatcherArea.CATCHER_SIZE; + float catcherWidth = ((1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f) * CatcherArea.CATCHER_SIZE; float catcherWidthHalf = catcherWidth / 2; catcherWidthHalf *= 0.8f; @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty double ar = Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate; double preEmpt = BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / TimeRate; - categoryDifficulty["AR"] = preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0; + categoryDifficulty["AR"] = (preEmpt > 1200.0) ? -(preEmpt - 1800.0) / 120.0 : (-(preEmpt - 1200.0) / 150.0) + 5.0; categoryDifficulty["Max combo"] = difficultyHitObjects.Count; } @@ -92,7 +92,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty while (hitObjectsEnumerator.MoveNext()) { CatchDifficultyHitObject nextHitObject = hitObjectsEnumerator.Current; - nextHitObject.CalculateStrains(currentHitObject, TimeRate); + if (nextHitObject != null) + nextHitObject.CalculateStrains(currentHitObject, TimeRate); currentHitObject = nextHitObject; } @@ -111,7 +112,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty /// The weighting of each strain value decays to this number * it's previous value /// private const double decay_weight = 0.94; - + protected double CalculateDifficulty() { // The strain step needs to be adjusted for the algorithm to be considered equal with speed changing mods diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs index d9b16c2a0b..72fc6d211b 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs @@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty { internal class CatchDifficultyHitObject { - internal static readonly double decay_base = 0.20; + internal static readonly double DECAY_BASE = 0.20; private const float normalized_hitobject_radius = 41.0f; private const float absolute_player_positioning_error = 16f; private readonly float playerPositioningError; @@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty // Rather simple, but more specialized things are inherently inaccurate due to the big difference playstyles and opinions make. // See Taiko feedback thread. double timeElapsed = (BaseHitObject.StartTime - previousHitObject.BaseHitObject.StartTime) / timeRate; - double decay = Math.Pow(decay_base, timeElapsed / 1000); + double decay = Math.Pow(DECAY_BASE, timeElapsed / 1000); // Update new position with lazy movement. PlayerPositionOffset = From 6d71f7f220940eb8bcc2750dd3e192b85fa6e777 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 13:35:02 +0800 Subject: [PATCH 19/57] Minor fixes --- osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 2fa946f41c..beee332504 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -112,7 +112,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty /// The weighting of each strain value decays to this number * it's previous value /// private const double decay_weight = 0.94; - + protected double CalculateDifficulty() { // The strain step needs to be adjusted for the algorithm to be considered equal with speed changing mods From 193a29860144f3e5c41b8b09c5492271ff07a2fd Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 13:36:57 +0800 Subject: [PATCH 20/57] Fixing minor bugs --- osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index beee332504..43c157df06 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -139,7 +139,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty } else { - double decay = Math.Pow(CatchDifficultyHitObject.decay_base, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); + double decay = Math.Pow(CatchDifficultyHitObject.DECAY_BASE, (intervalEndTime - previousHitObject.BaseHitObject.StartTime) / 1000); maximumStrain = previousHitObject.Strain * decay; } From 4784538d7349a2e1fcef059141c992524a2e2bd6 Mon Sep 17 00:00:00 2001 From: frankhjwx Date: Mon, 21 May 2018 13:53:48 +0800 Subject: [PATCH 21/57] Fixing minor bugs --- osu-framework | 2 +- .../Difficulty/CatchDifficultyCalculator.cs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/osu-framework b/osu-framework index 80e78fd45b..fac688633b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 80e78fd45bb79ca4bc46ecc05deb6058f3879faa +Subproject commit fac688633b8fcf34ae5d0514c26b03e217161eb4 diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 43c157df06..975e8eed58 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty difficultyHitObjects.Clear(); float circleSize = Beatmap.BeatmapInfo.BaseDifficulty.CircleSize; - float catcherWidth = ((1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f) * CatcherArea.CATCHER_SIZE; + float catcherWidth = (1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f * CatcherArea.CATCHER_SIZE; float catcherWidthHalf = catcherWidth / 2; catcherWidthHalf *= 0.8f; @@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty double ar = Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate; double preEmpt = BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / TimeRate; - categoryDifficulty["AR"] = (preEmpt > 1200.0) ? -(preEmpt - 1800.0) / 120.0 : (-(preEmpt - 1200.0) / 150.0) + 5.0; + categoryDifficulty["AR"] = preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0; categoryDifficulty["Max combo"] = difficultyHitObjects.Count; } @@ -92,8 +92,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty while (hitObjectsEnumerator.MoveNext()) { CatchDifficultyHitObject nextHitObject = hitObjectsEnumerator.Current; - if (nextHitObject != null) - nextHitObject.CalculateStrains(currentHitObject, TimeRate); + nextHitObject?.CalculateStrains(currentHitObject, TimeRate); currentHitObject = nextHitObject; } From ab3ac49a2d6ac9667709b61a694be91206ab9925 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 21:01:56 -0300 Subject: [PATCH 22/57] Add empty Match screen. --- osu.Game.Tests/Visual/TestCaseMatch.cs | 23 ++++++++++++ .../Screens/Multi/Screens/Lounge/Lounge.cs | 2 +- osu.Game/Screens/Multi/Screens/Match.cs | 37 ------------------- osu.Game/Screens/Multi/Screens/Match/Match.cs | 19 ++++++++++ osu.Game/Screens/Multi/Screens/MatchCreate.cs | 20 ---------- 5 files changed, 43 insertions(+), 58 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseMatch.cs delete mode 100644 osu.Game/Screens/Multi/Screens/Match.cs create mode 100644 osu.Game/Screens/Multi/Screens/Match/Match.cs delete mode 100644 osu.Game/Screens/Multi/Screens/MatchCreate.cs diff --git a/osu.Game.Tests/Visual/TestCaseMatch.cs b/osu.Game.Tests/Visual/TestCaseMatch.cs new file mode 100644 index 0000000000..9e62a19897 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseMatch.cs @@ -0,0 +1,23 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Online.Multiplayer; +using osu.Game.Screens.Multi.Screens.Match; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseMatch : OsuTestCase + { + public TestCaseMatch() + { + Room room = new Room + { + }; + + Match match = new Match(room); + + AddStep(@"show", () => Add(match)); + AddStep(@"exit", match.Exit); + } + } +} diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 60ffe2c0b9..c83ecee1f0 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge // open the room if its selected and is clicked again if (room.State == SelectionState.Selected) - Push(new Match()); + Push(new Match.Match(room.Room)); } private class RoomsFilterContainer : FillFlowContainer, IHasFilterableChildren diff --git a/osu.Game/Screens/Multi/Screens/Match.cs b/osu.Game/Screens/Multi/Screens/Match.cs deleted file mode 100644 index 4ba7fe9f6a..0000000000 --- a/osu.Game/Screens/Multi/Screens/Match.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; -using osu.Framework.Graphics; -using osu.Framework.Screens; -using osu.Game.Screens.Backgrounds; -using osu.Game.Screens.Play; -using osu.Game.Screens.Select; -using OpenTK.Graphics; - -namespace osu.Game.Screens.Multi.Screens -{ - public class Match : ScreenWhiteBox - { - protected override IEnumerable PossibleChildren => new[] { - typeof(MatchSongSelect), - typeof(Player), - }; - - protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - - protected override void OnEntering(Screen last) - { - base.OnEntering(last); - - Background.FadeColour(Color4.DarkGray, 500); - } - - protected override bool OnExiting(Screen next) - { - Background.FadeColour(Color4.White, 500); - return base.OnExiting(next); - } - } -} diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs new file mode 100644 index 0000000000..f70ed9eaa4 --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -0,0 +1,19 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Online.Multiplayer; + +namespace osu.Game.Screens.Multi.Screens.Match +{ + public class Match : MultiplayerScreen + { + private readonly Room room; + + public override string Title => room.Name.Value; + + public Match(Room room) + { + this.room = room; + } + } +} diff --git a/osu.Game/Screens/Multi/Screens/MatchCreate.cs b/osu.Game/Screens/Multi/Screens/MatchCreate.cs deleted file mode 100644 index 6b4e26d5e5..0000000000 --- a/osu.Game/Screens/Multi/Screens/MatchCreate.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; - -namespace osu.Game.Screens.Multi.Screens -{ - public class MatchCreate : ScreenWhiteBox - { - protected override IEnumerable PossibleChildren => new[] { - typeof(Match) - }; - - public MatchCreate() - { - ValidForResume = false; - } - } -} From 98819880c4a3018e2d840be335ce2a542629611d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 28 May 2018 22:11:01 -0300 Subject: [PATCH 23/57] Add match screen header. --- osu.Game.Tests/Visual/TestCaseMatch.cs | 17 ++ .../Screens/Multi/Screens/Match/Header.cs | 169 ++++++++++++++++++ osu.Game/Screens/Multi/Screens/Match/Match.cs | 23 +++ 3 files changed, 209 insertions(+) create mode 100644 osu.Game/Screens/Multi/Screens/Match/Header.cs diff --git a/osu.Game.Tests/Visual/TestCaseMatch.cs b/osu.Game.Tests/Visual/TestCaseMatch.cs index 9e62a19897..5dc330704d 100644 --- a/osu.Game.Tests/Visual/TestCaseMatch.cs +++ b/osu.Game.Tests/Visual/TestCaseMatch.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi.Screens.Match; @@ -12,6 +13,22 @@ namespace osu.Game.Tests.Visual { Room room = new Room { + Beatmap = + { + Value = new BeatmapInfo + { + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/765055/covers/cover.jpg?1526955337", + }, + }, + }, + }, + }, }; Match match = new Match(room); diff --git a/osu.Game/Screens/Multi/Screens/Match/Header.cs b/osu.Game/Screens/Multi/Screens/Match/Header.cs new file mode 100644 index 0000000000..b1f9e0dfc6 --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Match/Header.cs @@ -0,0 +1,169 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Overlays.SearchableList; +using OpenTK.Graphics; + +namespace osu.Game.Screens.Multi.Screens.Match +{ + public class Header : Container + { + private readonly Box tabStrip; + private readonly UpdateableBeatmapSetCover cover; + + public readonly OsuClickableContainer BeatmapButton; + + public BeatmapSetInfo BeatmapSet + { + set { cover.BeatmapSet = value; } + } + + public Header() + { + RelativeSizeAxes = Axes.X; + Height = 200; + + Children = new Drawable[] + { + cover = new UpdateableBeatmapSetCover + { + RelativeSizeAxes = Axes.Both, + Masking = true, + }, + tabStrip = new Box + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 1, + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING }, + Children = new Drawable[] + { + new Container + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Y, + Width = 200, + Padding = new MarginPadding { Vertical = 5 }, + Child = BeatmapButton = new BeatmapSelectButton + { + RelativeSizeAxes = Axes.Both, + }, + }, + new PageTabControl + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + tabStrip.Colour = colours.Yellow; + } + + private class BeatmapSelectButton : OsuClickableContainer + { + private const float corner_radius = 5; + private const float bg_opacity = 0.5f; + private const float transition_duration = 100; + + private readonly Box bg; + private readonly Container border; + + public BeatmapSelectButton() + { + Masking = true; + CornerRadius = corner_radius; + + Children = new Drawable[] + { + bg = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = bg_opacity, + }, + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = @"Exo2.0-Bold", + Text = "Select Beatmap", + }, + border = new Container + { + RelativeSizeAxes = Axes.Both, + Masking = true, + CornerRadius = corner_radius, + BorderThickness = 4, + Alpha = 0f, + Child = new Box // needs a child to show the border + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0), + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + border.BorderColour = colours.Yellow; + } + + protected override bool OnHover(InputState state) + { + border.FadeIn(transition_duration); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + base.OnHoverLost(state); + border.FadeOut(transition_duration); + } + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + bg.FadeTo(0.75f, 1000, Easing.Out); + return base.OnMouseDown(state, args); + } + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + { + bg.FadeTo(bg_opacity, transition_duration); + return base.OnMouseUp(state, args); + } + } + } + + public enum MatchHeaderPage + { + Settings, + Room, + } +} diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index f70ed9eaa4..82f5b53ee2 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -1,19 +1,42 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; +using osu.Game.Screens.Select; namespace osu.Game.Screens.Multi.Screens.Match { public class Match : MultiplayerScreen { private readonly Room room; + private readonly Bindable beatmapBind = new Bindable(); public override string Title => room.Name.Value; public Match(Room room) { this.room = room; + Header header; + + Children = new Drawable[] + { + header = new Header(), + }; + + header.BeatmapButton.Action = () => + { + Push(new MatchSongSelect()); + }; + + beatmapBind.ValueChanged += b => + { + header.BeatmapSet = b.BeatmapSet; + }; + + beatmapBind.BindTo(room.Beatmap); } } } From c8ce34b6d4a80f8c8a2414a3296e21642003f24d Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 01:51:04 -0300 Subject: [PATCH 24/57] Add Match Info. --- osu.Game.Tests/Visual/TestCaseMatch.cs | 17 +- .../Screens/Multi/Screens/Match/Header.cs | 5 +- osu.Game/Screens/Multi/Screens/Match/Info.cs | 194 ++++++++++++++++++ osu.Game/Screens/Multi/Screens/Match/Match.cs | 24 ++- 4 files changed, 234 insertions(+), 6 deletions(-) create mode 100644 osu.Game/Screens/Multi/Screens/Match/Info.cs diff --git a/osu.Game.Tests/Visual/TestCaseMatch.cs b/osu.Game.Tests/Visual/TestCaseMatch.cs index 5dc330704d..9c385feacb 100644 --- a/osu.Game.Tests/Visual/TestCaseMatch.cs +++ b/osu.Game.Tests/Visual/TestCaseMatch.cs @@ -1,22 +1,37 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets; using osu.Game.Screens.Multi.Screens.Match; namespace osu.Game.Tests.Visual { public class TestCaseMatch : OsuTestCase { - public TestCaseMatch() + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) { Room room = new Room { + Name = { Value = @"One Awesome Room" }, + Status = { Value = new RoomStatusOpen() }, + Availability = { Value = RoomAvailability.Public }, + Type = { Value = new GameTypeTeamVersus() }, Beatmap = { Value = new BeatmapInfo { + StarDifficulty = 5.02, + Ruleset = rulesets.GetRuleset(1), + Metadata = new BeatmapMetadata + { + Title = @"Paradigm Shift", + Artist = @"Morimori Atsushi", + AuthorString = @"eiri-", + }, BeatmapSet = new BeatmapSetInfo { OnlineInfo = new BeatmapSetOnlineInfo diff --git a/osu.Game/Screens/Multi/Screens/Match/Header.cs b/osu.Game/Screens/Multi/Screens/Match/Header.cs index b1f9e0dfc6..fde6859d95 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Header.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Header.cs @@ -20,6 +20,8 @@ namespace osu.Game.Screens.Multi.Screens.Match { public class Header : Container { + public const float HEIGHT = 200; + private readonly Box tabStrip; private readonly UpdateableBeatmapSetCover cover; @@ -33,10 +35,11 @@ namespace osu.Game.Screens.Multi.Screens.Match public Header() { RelativeSizeAxes = Axes.X; - Height = 200; + Height = HEIGHT; Children = new Drawable[] { + // todo: gradient over the cover cover = new UpdateableBeatmapSetCover { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game/Screens/Multi/Screens/Match/Info.cs b/osu.Game/Screens/Multi/Screens/Match/Info.cs new file mode 100644 index 0000000000..634b91cf7a --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Match/Info.cs @@ -0,0 +1,194 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.Multiplayer; +using osu.Game.Overlays.SearchableList; +using osu.Game.Screens.Multi.Components; + +namespace osu.Game.Screens.Multi.Screens.Match +{ + public class Info : Container + { + public const float HEIGHT = 128; + + private readonly OsuSpriteText name, availabilityStatus; + private readonly BeatmapTypeInfo beatmapTypeInfo; + + private OsuColour colours; + + public string Name + { + set { name.Text = value; } + } + + private RoomAvailability availability; + public RoomAvailability Availability + { + set + { + if (value == availability) return; + availability = value; + + if (IsLoaded) + updateAvailabilityStatus(); + } + } + + private RoomStatus status; + public RoomStatus Status + { + set + { + if (value == status) return; + status = value; + + if (IsLoaded) + updateAvailabilityStatus(); + } + } + + public BeatmapInfo Beatmap + { + set { beatmapTypeInfo.Beatmap = value; } + } + + public GameType Type + { + set { beatmapTypeInfo.Type = value; } + } + + public Info() + { + RelativeSizeAxes = Axes.X; + Height = HEIGHT; + + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"28242d"), + }, + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING }, + Children = new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Padding = new MarginPadding { Vertical = 20 }, + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + name = new OsuSpriteText + { + TextSize = 30, + }, + availabilityStatus = new OsuSpriteText + { + TextSize = 14, + }, + }, + }, + beatmapTypeInfo = new BeatmapTypeInfo + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }, + }, + }, + new ReadyButton + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Y, + Width = 200, + Padding = new MarginPadding { Vertical = 10 }, + }, + }, + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + this.colours = colours; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + updateAvailabilityStatus(); + } + + private void updateAvailabilityStatus() + { + if (status != null) + { + availabilityStatus.FadeColour(status.GetAppropriateColour(colours)); + availabilityStatus.Text = $"{availability.GetDescription()}, {status.Message}"; + } + } + + private class ReadyButton : TriangleButton + { + public readonly Bindable Ready = new Bindable(); + + protected override SpriteText CreateText() => new OsuSpriteText + { + Depth = -1, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Font = @"Exo2.0-Light", + TextSize = 30, + }; + + public ReadyButton() + { + Height = 1; + Text = "Ready"; + + Action = () => Ready.Value = !Ready.Value; + } + + [BackgroundDependencyLoader] + private void load() + { + BackgroundColour = OsuColour.FromHex(@"1187aa"); + Triangles.ColourLight = OsuColour.FromHex(@"277b9c"); + Triangles.ColourDark = OsuColour.FromHex(@"1f6682"); + Triangles.TriangleScale = 1.5f; + + // todo: visually select + Ready.ValueChanged += value => + { + if (value) + Text = "Not Ready"; + else + Text = "Ready"; + }; + } + } + } +} diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index 82f5b53ee2..e83769daa0 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -12,6 +12,11 @@ namespace osu.Game.Screens.Multi.Screens.Match public class Match : MultiplayerScreen { private readonly Room room; + + private readonly Bindable nameBind = new Bindable(); + private readonly Bindable statusBind = new Bindable(); + private readonly Bindable availabilityBind = new Bindable(); + private readonly Bindable typeBind = new Bindable(); private readonly Bindable beatmapBind = new Bindable(); public override string Title => room.Name.Value; @@ -20,22 +25,33 @@ namespace osu.Game.Screens.Multi.Screens.Match { this.room = room; Header header; + Info info; Children = new Drawable[] { header = new Header(), + info = new Info + { + Margin = new MarginPadding { Top = Header.HEIGHT }, + }, }; - header.BeatmapButton.Action = () => - { - Push(new MatchSongSelect()); - }; + header.BeatmapButton.Action = () => Push(new MatchSongSelect()); + nameBind.ValueChanged += n => info.Name = n; + statusBind.ValueChanged += s => info.Status = s; + availabilityBind.ValueChanged += a => info.Availability = a; + typeBind.ValueChanged += t => info.Type = t; beatmapBind.ValueChanged += b => { header.BeatmapSet = b.BeatmapSet; + info.Beatmap = b; }; + nameBind.BindTo(room.Name); + statusBind.BindTo(room.Status); + availabilityBind.BindTo(room.Availability); + typeBind.BindTo(room.Type); beatmapBind.BindTo(room.Beatmap); } } From 77ff0640c24a5005486337b8ac3cd95369b6a3c2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 01:53:45 -0300 Subject: [PATCH 25/57] Add a gradient over the cover in Header. --- osu.Game/Screens/Multi/Screens/Match/Header.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Multi/Screens/Match/Header.cs b/osu.Game/Screens/Multi/Screens/Match/Header.cs index fde6859d95..1d414e338c 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Header.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Header.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; @@ -39,12 +40,16 @@ namespace osu.Game.Screens.Multi.Screens.Match Children = new Drawable[] { - // todo: gradient over the cover cover = new UpdateableBeatmapSetCover { RelativeSizeAxes = Axes.Both, Masking = true, }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0), Color4.Black.Opacity(0.5f)), + }, tabStrip = new Box { Anchor = Anchor.BottomLeft, From 3915cb7f2f7cde41e6688905cd9bfed2c8487008 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 02:42:52 -0300 Subject: [PATCH 26/57] Add Match Participants, change Room.Users to IEnumerable. --- osu.Game.Tests/Visual/TestCaseMatch.cs | 38 ++++++++++ osu.Game/Online/Multiplayer/Room.cs | 3 +- .../Screens/Multi/Components/DrawableRoom.cs | 2 +- .../Screens/Multi/Components/RoomInspector.cs | 5 +- osu.Game/Screens/Multi/Screens/Match/Match.cs | 17 +++++ .../Multi/Screens/Match/Participants.cs | 71 +++++++++++++++++++ .../Multi/Screens/MultiplayerScreen.cs | 1 + 7 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 osu.Game/Screens/Multi/Screens/Match/Participants.cs diff --git a/osu.Game.Tests/Visual/TestCaseMatch.cs b/osu.Game.Tests/Visual/TestCaseMatch.cs index 9c385feacb..6f41723982 100644 --- a/osu.Game.Tests/Visual/TestCaseMatch.cs +++ b/osu.Game.Tests/Visual/TestCaseMatch.cs @@ -6,6 +6,7 @@ using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; using osu.Game.Screens.Multi.Screens.Match; +using osu.Game.Users; namespace osu.Game.Tests.Visual { @@ -44,6 +45,43 @@ namespace osu.Game.Tests.Visual }, }, }, + MaxParticipants = { Value = 5 }, + Participants = + { + Value = new[] + { + new User + { + Username = @"eiri-", + Id = 3388410, + Country = new Country { FlagName = @"US" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/3388410/00a8486a247831e1cc4375db519f611ac970bda8bc0057d78b0f540ea38c3e58.jpeg", + IsSupporter = true, + }, + new User + { + Username = @"Nepuri", + Id = 6637817, + Country = new Country { FlagName = @"DE" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/6637817/9085fc60248b6b5327a72c1dcdecf2dbedba810ae0ab6bcf7224e46b1339632a.jpeg", + IsSupporter = true, + }, + new User + { + Username = @"goheegy", + Id = 8057655, + Country = new Country { FlagName = @"GB" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8057655/21cec27c25a11dc197a4ec6a74253dbabb495949b0e0697113352f12007018c5.jpeg", + }, + new User + { + Username = @"Alumetri", + Id = 5371497, + Country = new Country { FlagName = @"RU" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/5371497/e023b8c7fbe3613e64bd4856703517ea50fbed8a5805dc9acda9efe9897c67e2.jpeg", + }, + } + }, }; Match match = new Match(room); diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index ae3fb5ec6e..b076afbcdb 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; using osu.Framework.Configuration; using osu.Game.Beatmaps; using osu.Game.Users; @@ -16,6 +17,6 @@ namespace osu.Game.Online.Multiplayer public Bindable Type = new Bindable(); public Bindable Beatmap = new Bindable(); public Bindable MaxParticipants = new Bindable(); - public Bindable Participants = new Bindable(); + public Bindable> Participants = new Bindable>(); } } diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index d31019a259..54bd0ae7cc 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Multi.Components private readonly Bindable statusBind = new Bindable(); private readonly Bindable typeBind = new Bindable(); private readonly Bindable beatmapBind = new Bindable(); - private readonly Bindable participantsBind = new Bindable(); + private readonly Bindable> participantsBind = new Bindable>(); public readonly Room Room; diff --git a/osu.Game/Screens/Multi/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Components/RoomInspector.cs index 14f4feab05..22bca1efc7 100644 --- a/osu.Game/Screens/Multi/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Components/RoomInspector.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 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.Framework.Allocation; using osu.Framework.Configuration; @@ -33,7 +34,7 @@ namespace osu.Game.Screens.Multi.Components private readonly Bindable typeBind = new Bindable(); private readonly Bindable beatmapBind = new Bindable(); private readonly Bindable maxParticipantsBind = new Bindable(); - private readonly Bindable participantsBind = new Bindable(); + private readonly Bindable> participantsBind = new Bindable>(); private OsuColour colours; private Box statusStrip; @@ -214,7 +215,7 @@ namespace osu.Game.Screens.Multi.Components participantsBind.ValueChanged += p => { - participantCount.Count = p.Length; + participantCount.Count = p.Count(); participantInfo.Participants = p; participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u)); }; diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index e83769daa0..3a2aef2ff4 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -1,23 +1,31 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Select; +using osu.Game.Users; namespace osu.Game.Screens.Multi.Screens.Match { public class Match : MultiplayerScreen { private readonly Room room; + private readonly Participants participants; private readonly Bindable nameBind = new Bindable(); private readonly Bindable statusBind = new Bindable(); private readonly Bindable availabilityBind = new Bindable(); private readonly Bindable typeBind = new Bindable(); private readonly Bindable beatmapBind = new Bindable(); + private readonly Bindable maxParticipantsBind = new Bindable(); + private readonly Bindable> participantsBind = new Bindable>(); + + protected override Container TransitionContent => participants; public override string Title => room.Name.Value; @@ -34,6 +42,11 @@ namespace osu.Game.Screens.Multi.Screens.Match { Margin = new MarginPadding { Top = Header.HEIGHT }, }, + participants = new Participants + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = Header.HEIGHT + Info.HEIGHT }, + }, }; header.BeatmapButton.Action = () => Push(new MatchSongSelect()); @@ -41,6 +54,8 @@ namespace osu.Game.Screens.Multi.Screens.Match statusBind.ValueChanged += s => info.Status = s; availabilityBind.ValueChanged += a => info.Availability = a; typeBind.ValueChanged += t => info.Type = t; + maxParticipantsBind.ValueChanged += m => { participants.Max = m; }; + participantsBind.ValueChanged += p => participants.Users = p; beatmapBind.ValueChanged += b => { @@ -53,6 +68,8 @@ namespace osu.Game.Screens.Multi.Screens.Match availabilityBind.BindTo(room.Availability); typeBind.BindTo(room.Type); beatmapBind.BindTo(room.Beatmap); + maxParticipantsBind.BindTo(room.MaxParticipants); + participantsBind.BindTo(room.Participants); } } } diff --git a/osu.Game/Screens/Multi/Screens/Match/Participants.cs b/osu.Game/Screens/Multi/Screens/Match/Participants.cs new file mode 100644 index 0000000000..11e27c0a18 --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Match/Participants.cs @@ -0,0 +1,71 @@ +// Copyright (c) 2007-2018 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.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Overlays.SearchableList; +using osu.Game.Screens.Multi.Components; +using osu.Game.Users; +using OpenTK; + +namespace osu.Game.Screens.Multi.Screens.Match +{ + public class Participants : Container + { + private readonly ParticipantCount count; + private readonly FillFlowContainer usersFlow; + + public IEnumerable Users + { + set { + usersFlow.Children = value.Select(u => new UserPanel(u) + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + Width = 300, + }).ToList(); + + count.Count = value.Count(); + } + } + + public int? Max + { + set { count.Max = value; } + } + + public Participants() + { + Child = new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING }, + Children = new Drawable[] + { + new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = 10 }, + Children = new Drawable[] + { + count = new ParticipantCount + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + }, + usersFlow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(5), + Padding = new MarginPadding { Top = 40 }, + }, + }, + }, + }, + }; + } + } +} diff --git a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs index 191fe66037..9daa4e732b 100644 --- a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs +++ b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs @@ -21,6 +21,7 @@ namespace osu.Game.Screens.Multi.Screens TransitionContent.MoveToX(200); + Content.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing); TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing); TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing); } From 94b54a0520d4f2d091d531786c63b527a8db2629 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 03:03:51 -0300 Subject: [PATCH 27/57] Adjust design of ReadyButton. --- osu.Game/Screens/Multi/Screens/Match/Info.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Multi/Screens/Match/Info.cs b/osu.Game/Screens/Multi/Screens/Match/Info.cs index 634b91cf7a..88dda4a67b 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Info.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Info.cs @@ -180,13 +180,31 @@ namespace osu.Game.Screens.Multi.Screens.Match Triangles.ColourDark = OsuColour.FromHex(@"1f6682"); Triangles.TriangleScale = 1.5f; - // todo: visually select + Container active; + Add(active = new Container + { + RelativeSizeAxes = Axes.Both, + Alpha = 0f, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.15f, + Blending = BlendingMode.Additive, + }, + }); + Ready.ValueChanged += value => { if (value) + { Text = "Not Ready"; + active.FadeIn(200); + } else + { Text = "Ready"; + active.FadeOut(200); + } }; } } From b4b4a8a157a0bbcb5e99269ff3772afeff7f2545 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 03:24:38 -0300 Subject: [PATCH 28/57] Add TestCaseMatchInfo. --- osu.Game.Tests/Visual/TestCaseMatch.cs | 2 + osu.Game.Tests/Visual/TestCaseMatchInfo.cs | 59 ++++++++++++++++++++ osu.Game/Screens/Multi/Screens/Match/Info.cs | 7 ++- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseMatchInfo.cs diff --git a/osu.Game.Tests/Visual/TestCaseMatch.cs b/osu.Game.Tests/Visual/TestCaseMatch.cs index 6f41723982..69c1a6a0b2 100644 --- a/osu.Game.Tests/Visual/TestCaseMatch.cs +++ b/osu.Game.Tests/Visual/TestCaseMatch.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using NUnit.Framework; using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; @@ -10,6 +11,7 @@ using osu.Game.Users; namespace osu.Game.Tests.Visual { + [TestFixture] public class TestCaseMatch : OsuTestCase { [BackgroundDependencyLoader] diff --git a/osu.Game.Tests/Visual/TestCaseMatchInfo.cs b/osu.Game.Tests/Visual/TestCaseMatchInfo.cs new file mode 100644 index 0000000000..f58bc0e30a --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseMatchInfo.cs @@ -0,0 +1,59 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets; +using osu.Game.Screens.Multi.Screens.Match; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseMatchInfo : OsuTestCase + { + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + Info info = new Info(); + Add(info); + + AddStep(@"set name", () => info.Name = @"Room Name?"); + AddStep(@"set availability", () => info.Availability = RoomAvailability.FriendsOnly); + AddStep(@"set status", () => info.Status = new RoomStatusPlaying()); + + AddStep(@"set beatmap", () => info.Beatmap = new BeatmapInfo + { + StarDifficulty = 2.4, + Ruleset = rulesets.GetRuleset(0), + Metadata = new BeatmapMetadata + { + Title = @"My Song", + Artist = @"VisualTests", + AuthorString = @"osu!lazer", + }, + }); + + AddStep(@"set type", () => info.Type = new GameTypeTagTeam()); + + AddStep(@"change name", () => info.Name = @"Room Name!"); + AddStep(@"change availability", () => info.Availability = RoomAvailability.InviteOnly); + AddStep(@"change status", () => info.Status = new RoomStatusOpen()); + + AddStep(@"change beatmap", () => info.Beatmap = new BeatmapInfo + { + StarDifficulty = 4.2, + Ruleset = rulesets.GetRuleset(3), + Metadata = new BeatmapMetadata + { + Title = @"Your Song", + Artist = @"Tester", + AuthorString = @"Someone", + }, + }); + + AddStep(@"change type", () => info.Type = new GameTypeTeamVersus()); + } + } +} diff --git a/osu.Game/Screens/Multi/Screens/Match/Info.cs b/osu.Game/Screens/Multi/Screens/Match/Info.cs index 88dda4a67b..e2efbad269 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Info.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Info.cs @@ -24,9 +24,12 @@ namespace osu.Game.Screens.Multi.Screens.Match private readonly OsuSpriteText name, availabilityStatus; private readonly BeatmapTypeInfo beatmapTypeInfo; + private readonly ReadyButton readyButton; private OsuColour colours; + public Bindable Ready => readyButton.Ready; + public string Name { set { name.Text = value; } @@ -116,7 +119,7 @@ namespace osu.Game.Screens.Multi.Screens.Match }, }, }, - new ReadyButton + readyButton = new ReadyButton { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -146,7 +149,7 @@ namespace osu.Game.Screens.Multi.Screens.Match { if (status != null) { - availabilityStatus.FadeColour(status.GetAppropriateColour(colours)); + availabilityStatus.FadeColour(status.GetAppropriateColour(colours), 100); availabilityStatus.Text = $"{availability.GetDescription()}, {status.Message}"; } } From 8595c821b438cf2d5c8a2d7bb3d06b8d46f9a1ec Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 03:34:02 -0300 Subject: [PATCH 29/57] Add TestCaseMatchHeader. --- osu.Game.Tests/Visual/TestCaseMatchHeader.cs | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseMatchHeader.cs diff --git a/osu.Game.Tests/Visual/TestCaseMatchHeader.cs b/osu.Game.Tests/Visual/TestCaseMatchHeader.cs new file mode 100644 index 0000000000..34f98f97c2 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseMatchHeader.cs @@ -0,0 +1,43 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Screens.Multi.Screens.Match; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseMatchHeader : OsuTestCase + { + public TestCaseMatchHeader() + { + Header header = new Header(); + Add(header); + + AddStep(@"set beatmap set", () => header.BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/760757/covers/cover.jpg?1526944540", + }, + }, + }); + + AddStep(@"change beatmap set", () => header.BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/761883/covers/cover.jpg?1525557400", + }, + }, + }); + + AddStep(@"null beatmap set", () => header.BeatmapSet = null); + } + } +} From 7edb82eb85db1bca1bbccaabca2a625242d16f3a Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 03:53:30 -0300 Subject: [PATCH 30/57] Add TestCaseMatchParticipants. --- osu.Game.Tests/Visual/TestCaseMatchInfo.cs | 2 - .../Visual/TestCaseMatchParticipants.cs | 56 +++++++++++++++++++ .../Multi/Screens/Match/Participants.cs | 3 + 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseMatchParticipants.cs diff --git a/osu.Game.Tests/Visual/TestCaseMatchInfo.cs b/osu.Game.Tests/Visual/TestCaseMatchInfo.cs index f58bc0e30a..da5f429363 100644 --- a/osu.Game.Tests/Visual/TestCaseMatchInfo.cs +++ b/osu.Game.Tests/Visual/TestCaseMatchInfo.cs @@ -22,7 +22,6 @@ namespace osu.Game.Tests.Visual AddStep(@"set name", () => info.Name = @"Room Name?"); AddStep(@"set availability", () => info.Availability = RoomAvailability.FriendsOnly); AddStep(@"set status", () => info.Status = new RoomStatusPlaying()); - AddStep(@"set beatmap", () => info.Beatmap = new BeatmapInfo { StarDifficulty = 2.4, @@ -40,7 +39,6 @@ namespace osu.Game.Tests.Visual AddStep(@"change name", () => info.Name = @"Room Name!"); AddStep(@"change availability", () => info.Availability = RoomAvailability.InviteOnly); AddStep(@"change status", () => info.Status = new RoomStatusOpen()); - AddStep(@"change beatmap", () => info.Beatmap = new BeatmapInfo { StarDifficulty = 4.2, diff --git a/osu.Game.Tests/Visual/TestCaseMatchParticipants.cs b/osu.Game.Tests/Visual/TestCaseMatchParticipants.cs new file mode 100644 index 0000000000..d6ae07252b --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseMatchParticipants.cs @@ -0,0 +1,56 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Game.Screens.Multi.Screens.Match; +using osu.Game.Users; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseMatchParticipants : OsuTestCase + { + public TestCaseMatchParticipants() + { + Participants participants; + Add(participants = new Participants + { + RelativeSizeAxes = Axes.Both, + }); + + AddStep(@"set max to null", () => participants.Max = null); + AddStep(@"set users", () => participants.Users = new[] + { + new User + { + Username = @"Feppla", + Id = 4271601, + Country = new Country { FlagName = @"SE" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg", + IsSupporter = true, + }, + new User + { + Username = @"Xilver", + Id = 3099689, + Country = new Country { FlagName = @"IL" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c2.jpg", + IsSupporter = true, + }, + new User + { + Username = @"Wucki", + Id = 5287410, + Country = new Country { FlagName = @"FI" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/5287410/5cfeaa9dd41cbce038ecdc9d781396ed4b0108089170bf7f50492ef8eadeb368.jpeg", + IsSupporter = true, + }, + }); + + AddStep(@"set max", () => participants.Max = 10); + AddStep(@"clear users", () => participants.Users = new User[] { }); + AddStep(@"set max to null", () => participants.Max = null); + } + } +} diff --git a/osu.Game/Screens/Multi/Screens/Match/Participants.cs b/osu.Game/Screens/Multi/Screens/Match/Participants.cs index 11e27c0a18..182aa1e04e 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Participants.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Participants.cs @@ -25,6 +25,7 @@ namespace osu.Game.Screens.Multi.Screens.Match Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Width = 300, + OnLoadComplete = d => d.FadeInFromZero(60), }).ToList(); count.Count = value.Count(); @@ -61,6 +62,8 @@ namespace osu.Game.Screens.Multi.Screens.Match AutoSizeAxes = Axes.Y, Spacing = new Vector2(5), Padding = new MarginPadding { Top = 40 }, + LayoutDuration = 200, + LayoutEasing = Easing.OutQuint, }, }, }, From 9a7e5a3e2c26a8113a3b3182e750ca76d1306a17 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 29 May 2018 04:16:19 -0300 Subject: [PATCH 31/57] Update TestCaseMatch. --- osu.Game.Tests/Visual/TestCaseMatch.cs | 47 +++++++++++++++++++ osu.Game.Tests/Visual/TestCaseMatchInfo.cs | 4 +- osu.Game/Screens/Multi/Screens/Match/Match.cs | 2 +- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseMatch.cs b/osu.Game.Tests/Visual/TestCaseMatch.cs index 69c1a6a0b2..bb22358425 100644 --- a/osu.Game.Tests/Visual/TestCaseMatch.cs +++ b/osu.Game.Tests/Visual/TestCaseMatch.cs @@ -89,6 +89,53 @@ namespace osu.Game.Tests.Visual Match match = new Match(room); AddStep(@"show", () => Add(match)); + AddStep(@"null beatmap", () => room.Beatmap.Value = null); + AddStep(@"change name", () => room.Name.Value = @"Two Awesome Rooms"); + AddStep(@"change status", () => room.Status.Value = new RoomStatusPlaying()); + AddStep(@"change availability", () => room.Availability.Value = RoomAvailability.FriendsOnly); + AddStep(@"change type", () => room.Type.Value = new GameTypeTag()); + AddStep(@"change beatmap", () => room.Beatmap.Value = new BeatmapInfo + { + StarDifficulty = 4.33, + Ruleset = rulesets.GetRuleset(2), + Metadata = new BeatmapMetadata + { + Title = @"Yasashisa no Riyuu", + Artist = @"ChouCho", + AuthorString = @"celerih", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/685391/covers/cover.jpg?1524597970", + }, + }, + }, + }); + + AddStep(@"null max participants", () => room.MaxParticipants.Value = null); + AddStep(@"change participants", () => room.Participants.Value = new[] + { + new User + { + Username = @"Spectator", + Id = 702598, + Country = new Country { FlagName = @"KR" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/702598/3bbf4cb8b8d2cf8b03145000a975ff27e191ab99b0920832e7dd67386280e288.jpeg", + IsSupporter = true, + }, + new User + { + Username = @"celerih", + Id = 4696296, + Country = new Country { FlagName = @"CA" }, + CoverUrl = @"https://assets.ppy.sh/user-profile-covers/4696296/7f8500731d0ac66d5472569d146a7be07d9460273361913f22c038867baddaef.jpeg", + }, + }); + AddStep(@"exit", match.Exit); } } diff --git a/osu.Game.Tests/Visual/TestCaseMatchInfo.cs b/osu.Game.Tests/Visual/TestCaseMatchInfo.cs index da5f429363..205da6932f 100644 --- a/osu.Game.Tests/Visual/TestCaseMatchInfo.cs +++ b/osu.Game.Tests/Visual/TestCaseMatchInfo.cs @@ -39,6 +39,8 @@ namespace osu.Game.Tests.Visual AddStep(@"change name", () => info.Name = @"Room Name!"); AddStep(@"change availability", () => info.Availability = RoomAvailability.InviteOnly); AddStep(@"change status", () => info.Status = new RoomStatusOpen()); + AddStep(@"null beatmap", () => info.Beatmap = null); + AddStep(@"change type", () => info.Type = new GameTypeTeamVersus()); AddStep(@"change beatmap", () => info.Beatmap = new BeatmapInfo { StarDifficulty = 4.2, @@ -50,8 +52,6 @@ namespace osu.Game.Tests.Visual AuthorString = @"Someone", }, }); - - AddStep(@"change type", () => info.Type = new GameTypeTeamVersus()); } } } diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index 3a2aef2ff4..525682e9c5 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -59,7 +59,7 @@ namespace osu.Game.Screens.Multi.Screens.Match beatmapBind.ValueChanged += b => { - header.BeatmapSet = b.BeatmapSet; + header.BeatmapSet = b?.BeatmapSet; info.Beatmap = b; }; From 97b473ef30ce254cadc75c76bc1630bc1c2186e3 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 1 Jun 2018 16:23:11 -0300 Subject: [PATCH 32/57] Expose tabs and hide beatmap select button in Header. --- osu.Game/Screens/Multi/Screens/Match/Header.cs | 12 +++++++++--- osu.Game/Screens/Multi/Screens/Match/Match.cs | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Match/Header.cs b/osu.Game/Screens/Multi/Screens/Match/Header.cs index 1d414e338c..7985ff5fcf 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Header.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Header.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -26,18 +27,21 @@ namespace osu.Game.Screens.Multi.Screens.Match private readonly Box tabStrip; private readonly UpdateableBeatmapSetCover cover; - public readonly OsuClickableContainer BeatmapButton; + public readonly PageTabControl Tabs; public BeatmapSetInfo BeatmapSet { set { cover.BeatmapSet = value; } } + public Action OnWantsSelectBeatmap; + public Header() { RelativeSizeAxes = Axes.X; Height = HEIGHT; + BeatmapSelectButton beatmapButton; Children = new Drawable[] { cover = new UpdateableBeatmapSetCover @@ -70,12 +74,12 @@ namespace osu.Game.Screens.Multi.Screens.Match RelativeSizeAxes = Axes.Y, Width = 200, Padding = new MarginPadding { Vertical = 5 }, - Child = BeatmapButton = new BeatmapSelectButton + Child = beatmapButton = new BeatmapSelectButton { RelativeSizeAxes = Axes.Both, }, }, - new PageTabControl + Tabs = new PageTabControl { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -84,6 +88,8 @@ namespace osu.Game.Screens.Multi.Screens.Match }, }, }; + + beatmapButton.Action = () => OnWantsSelectBeatmap?.Invoke(); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index 525682e9c5..47fe7b9145 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -49,7 +49,7 @@ namespace osu.Game.Screens.Multi.Screens.Match }, }; - header.BeatmapButton.Action = () => Push(new MatchSongSelect()); + header.OnWantsSelectBeatmap = () => Push(new MatchSongSelect()); nameBind.ValueChanged += n => info.Name = n; statusBind.ValueChanged += s => info.Status = s; availabilityBind.ValueChanged += a => info.Availability = a; From 507305742013cacec3dc54feeeb630fd44971dc2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 1 Jun 2018 16:34:03 -0300 Subject: [PATCH 33/57] Cleanup. --- osu.Game/Screens/Multi/Screens/Match/Header.cs | 2 +- osu.Game/Screens/Multi/Screens/Match/Participants.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Match/Header.cs b/osu.Game/Screens/Multi/Screens/Match/Header.cs index 7985ff5fcf..19e9dc4ad4 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Header.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Header.cs @@ -31,7 +31,7 @@ namespace osu.Game.Screens.Multi.Screens.Match public BeatmapSetInfo BeatmapSet { - set { cover.BeatmapSet = value; } + set => cover.BeatmapSet = value; } public Action OnWantsSelectBeatmap; diff --git a/osu.Game/Screens/Multi/Screens/Match/Participants.cs b/osu.Game/Screens/Multi/Screens/Match/Participants.cs index 182aa1e04e..9fa90f8752 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Participants.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Participants.cs @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Multi.Screens.Match public int? Max { - set { count.Max = value; } + set => count.Max = value; } public Participants() From da8b1f996fb127f8b92a34ab90c5c085a7a2a597 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 1 Jun 2018 17:16:35 -0300 Subject: [PATCH 34/57] Override Type in Match. --- osu.Game/Screens/Multi/Screens/Match/Match.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index 47fe7b9145..3c6f141bd3 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -27,6 +27,7 @@ namespace osu.Game.Screens.Multi.Screens.Match protected override Container TransitionContent => participants; + public override string Type => "room"; public override string Title => room.Name.Value; public Match(Room room) From 8c671f93fc9476439b4e306a0c0c7ba2299603be Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 18 Jun 2018 19:32:04 +0900 Subject: [PATCH 35/57] Always perform non-seeked scroll in the editor while audio is playing --- osu.Game/Screens/Edit/Editor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index d4f66c2f09..379484bae6 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -181,9 +181,9 @@ namespace osu.Game.Screens.Edit protected override bool OnScroll(InputState state) { if (state.Mouse.ScrollDelta.X + state.Mouse.ScrollDelta.Y > 0) - clock.SeekBackward(true); + clock.SeekBackward(!clock.IsRunning); else - clock.SeekForward(true); + clock.SeekForward(!clock.IsRunning); return true; } From d753df65a57bb1bc20e02138dc60f393133ad596 Mon Sep 17 00:00:00 2001 From: Tom Arrow Date: Tue, 19 Jun 2018 18:04:53 +0200 Subject: [PATCH 36/57] Remove default bindings for right actions --- osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 7b4978694b..b41a6f3c38 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -32,9 +32,7 @@ namespace osu.Game.Rulesets.Taiko new KeyBinding(InputKey.J, TaikoAction.RightCentre), new KeyBinding(InputKey.K, TaikoAction.RightRim), new KeyBinding(InputKey.MouseLeft, TaikoAction.LeftCentre), - new KeyBinding(InputKey.MouseLeft, TaikoAction.RightCentre), new KeyBinding(InputKey.MouseRight, TaikoAction.LeftRim), - new KeyBinding(InputKey.MouseRight, TaikoAction.RightRim), }; public override IEnumerable ConvertLegacyMods(LegacyMods mods) From f0c72438a3320fbfa6eeb752e447e1b2dfe965e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Jun 2018 17:06:02 +0900 Subject: [PATCH 37/57] Group ValueChanged attachment with bindings --- osu.Game/Screens/Multi/Screens/Match/Match.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index 3c6f141bd3..b231ed89e5 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -51,26 +51,31 @@ namespace osu.Game.Screens.Multi.Screens.Match }; header.OnWantsSelectBeatmap = () => Push(new MatchSongSelect()); - nameBind.ValueChanged += n => info.Name = n; - statusBind.ValueChanged += s => info.Status = s; - availabilityBind.ValueChanged += a => info.Availability = a; - typeBind.ValueChanged += t => info.Type = t; - maxParticipantsBind.ValueChanged += m => { participants.Max = m; }; - participantsBind.ValueChanged += p => participants.Users = p; - beatmapBind.ValueChanged += b => + beatmapBind.BindTo(room.Beatmap); + beatmapBind.BindValueChanged(b => { header.BeatmapSet = b?.BeatmapSet; info.Beatmap = b; - }; + }, true); nameBind.BindTo(room.Name); + nameBind.BindValueChanged(n => info.Name = n, true); + statusBind.BindTo(room.Status); + statusBind.BindValueChanged(s => info.Status = s, true); + availabilityBind.BindTo(room.Availability); + availabilityBind.BindValueChanged(a => info.Availability = a, true); + typeBind.BindTo(room.Type); - beatmapBind.BindTo(room.Beatmap); + typeBind.BindValueChanged(t => info.Type = t, true); + maxParticipantsBind.BindTo(room.MaxParticipants); + maxParticipantsBind.BindValueChanged(m => { participants.Max = m; }, true); + participantsBind.BindTo(room.Participants); + participantsBind.BindValueChanged(p => participants.Users = p, true); } } } From 39649747aaad9092a32d2d97e1897ecaecded170 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Jun 2018 17:25:22 +0900 Subject: [PATCH 38/57] Simplify and synchronise multiplayer screen transitions --- .../Multi/Screens/MultiplayerScreen.cs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs index 327d21a589..00c2613d54 100644 --- a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs +++ b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs @@ -10,9 +10,6 @@ namespace osu.Game.Screens.Multi.Screens { public abstract class MultiplayerScreen : OsuScreen { - private const Easing in_easing = Easing.OutQuint; - private const Easing out_easing = Easing.InSine; - protected virtual Container TransitionContent => Content; /// @@ -24,17 +21,15 @@ namespace osu.Game.Screens.Multi.Screens { base.OnEntering(last); - TransitionContent.MoveToX(200); - - Content.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing); - TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing); - TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing); + Content.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + TransitionContent.MoveToX(200).MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); } protected override bool OnExiting(Screen next) { - Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, out_easing); - TransitionContent.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, out_easing); + Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + TransitionContent.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); return base.OnExiting(next); } @@ -43,16 +38,16 @@ namespace osu.Game.Screens.Multi.Screens { base.OnResuming(last); - Content.FadeIn(WaveContainer.APPEAR_DURATION, in_easing); - TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing); + Content.FadeIn(WaveContainer.APPEAR_DURATION, Easing.OutQuint); + TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, Easing.OutQuint); } protected override void OnSuspending(Screen next) { base.OnSuspending(next); - Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, out_easing); - TransitionContent.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, out_easing); + Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); + TransitionContent.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, Easing.OutQuint); } } } From 96100a2200b424b774b4fb778b7affb41c3c434d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Jun 2018 17:41:48 +0900 Subject: [PATCH 39/57] Remove schedule logic (seems unnecessary) --- osu.Game/Screens/Multi/Screens/Match/Header.cs | 4 ++-- osu.Game/Screens/Multi/Screens/Match/Match.cs | 2 +- osu.Game/Screens/Select/MatchSongSelect.cs | 7 +------ 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Match/Header.cs b/osu.Game/Screens/Multi/Screens/Match/Header.cs index 19e9dc4ad4..2bd015a2d1 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Header.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Header.cs @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Multi.Screens.Match set => cover.BeatmapSet = value; } - public Action OnWantsSelectBeatmap; + public Action OnRequestSelectBeatmap; public Header() { @@ -89,7 +89,7 @@ namespace osu.Game.Screens.Multi.Screens.Match }, }; - beatmapButton.Action = () => OnWantsSelectBeatmap?.Invoke(); + beatmapButton.Action = () => OnRequestSelectBeatmap?.Invoke(); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Multi/Screens/Match/Match.cs b/osu.Game/Screens/Multi/Screens/Match/Match.cs index b231ed89e5..ce3f7825a4 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Match.cs @@ -50,7 +50,7 @@ namespace osu.Game.Screens.Multi.Screens.Match }, }; - header.OnWantsSelectBeatmap = () => Push(new MatchSongSelect()); + header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect()); beatmapBind.BindTo(room.Beatmap); beatmapBind.BindValueChanged(b => diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index a0c96d0cee..339392d5cf 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -7,12 +7,7 @@ namespace osu.Game.Screens.Select { protected override bool OnStart() { - Schedule(() => - { - // needs to be scheduled else we enter an infinite feedback loop. - if (IsCurrentScreen) Exit(); - }); - + if (IsCurrentScreen) Exit(); return true; } } From 2697579448b3212d7ecfeec4f31d7cc0278c1ecd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 09:54:13 +0900 Subject: [PATCH 40/57] Give TestLounge a background to make transitions work correctly --- osu.Game.Tests/Visual/TestCaseLounge.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index b96d705d5c..c5e0d1c4bf 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -8,6 +8,8 @@ using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; +using osu.Game.Screens; +using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Screens.Lounge; using osu.Game.Users; @@ -198,6 +200,8 @@ namespace osu.Game.Tests.Visual private class TestLounge : Lounge { + protected override BackgroundScreen CreateBackground() => new BackgroundScreenDefault(); + public IEnumerable ChildRooms => RoomsContainer.Children.Where(r => r.MatchingFilter); public Room SelectedRoom => Inspector.Room; From 4c068097c81f5eabb29fe944e4420f8552a8daf5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 10:12:12 +0900 Subject: [PATCH 41/57] Change required child to use same structure as other use cases --- osu.Game/Screens/Multi/Screens/Match/Header.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Match/Header.cs b/osu.Game/Screens/Multi/Screens/Match/Header.cs index 2bd015a2d1..02e717d4be 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Header.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Header.cs @@ -133,11 +133,12 @@ namespace osu.Game.Screens.Multi.Screens.Match Masking = true, CornerRadius = corner_radius, BorderThickness = 4, - Alpha = 0f, + Alpha = 0, Child = new Box // needs a child to show the border { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0), + Alpha = 0, + AlwaysPresent = true }, }, }; From 2a42418dbf6fbbe3f4537d2736bd627517809e87 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 10:19:37 +0900 Subject: [PATCH 42/57] Tidy up ReadyButton --- osu.Game/Screens/Multi/Screens/Match/Info.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Match/Info.cs b/osu.Game/Screens/Multi/Screens/Match/Info.cs index e2efbad269..ec93eb90b1 100644 --- a/osu.Game/Screens/Multi/Screens/Match/Info.cs +++ b/osu.Game/Screens/Multi/Screens/Match/Info.cs @@ -15,6 +15,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Overlays.SearchableList; using osu.Game.Screens.Multi.Components; +using OpenTK; namespace osu.Game.Screens.Multi.Screens.Match { @@ -124,7 +125,7 @@ namespace osu.Game.Screens.Multi.Screens.Match Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Y, - Width = 200, + Size = new Vector2(200, 1), Padding = new MarginPadding { Vertical = 10 }, }, }, @@ -167,14 +168,6 @@ namespace osu.Game.Screens.Multi.Screens.Match TextSize = 30, }; - public ReadyButton() - { - Height = 1; - Text = "Ready"; - - Action = () => Ready.Value = !Ready.Value; - } - [BackgroundDependencyLoader] private void load() { @@ -196,7 +189,9 @@ namespace osu.Game.Screens.Multi.Screens.Match }, }); - Ready.ValueChanged += value => + Action = () => Ready.Value = !Ready.Value; + + Ready.BindValueChanged(value => { if (value) { @@ -208,7 +203,7 @@ namespace osu.Game.Screens.Multi.Screens.Match Text = "Ready"; active.FadeOut(200); } - }; + }, true); } } } From 5d0c84783528fb3acead1f75327de5ddd413314a Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 21 Jun 2018 12:26:15 +0900 Subject: [PATCH 43/57] Fix post-merge errors --- .../Difficulty/CatchDifficultyAttributes.cs | 20 ++++ .../Difficulty/CatchDifficultyCalculator.cs | 98 ++++++++++--------- .../Difficulty/CatchDifficultyHitObject.cs | 2 +- .../Difficulty/TaikoDifficultyCalculator.cs | 12 ++- 4 files changed, 82 insertions(+), 50 deletions(-) create mode 100644 osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs new file mode 100644 index 0000000000..687cd03152 --- /dev/null +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs @@ -0,0 +1,20 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Rulesets.Difficulty; +using osu.Game.Rulesets.Mods; + +namespace osu.Game.Rulesets.Catch.Difficulty +{ + public class CatchDifficultyAttributes : DifficultyAttributes + { + public double AimRating; + public double ApproachRate; + public int MaxCombo; + + public CatchDifficultyAttributes(Mod[] mods, double starRating) + : base(mods, starRating) + { + } + } +} diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index acdec851d8..520a980d26 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -2,6 +2,8 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Internal; using osu.Game.Beatmaps; using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Mods; @@ -13,31 +15,39 @@ namespace osu.Game.Rulesets.Catch.Difficulty { public class CatchDifficultyCalculator : DifficultyCalculator { + + /// + /// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP. + /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. + /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. + /// + private const double strain_step = 750; + + /// + /// The weighting of each strain value decays to this number * it's previous value + /// + private const double decay_weight = 0.94; + private const double star_scaling_factor = 0.145; - private const float playfield_width = CatchPlayfield.BASE_WIDTH; - private readonly List difficultyHitObjects = new List(); - - public CatchDifficultyCalculator(IBeatmap beatmap) - : base(beatmap) + public CatchDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap) + : base(ruleset, beatmap) { } - public CatchDifficultyCalculator(IBeatmap beatmap, Mod[] mods) - : base(beatmap, mods) + protected override DifficultyAttributes Calculate(IBeatmap beatmap, Mod[] mods, double timeRate) { - } + if (!beatmap.HitObjects.Any()) + return new CatchDifficultyAttributes(mods, 0); - public override double Calculate(Dictionary categoryDifficulty = null) - { - difficultyHitObjects.Clear(); - - float circleSize = Beatmap.BeatmapInfo.BaseDifficulty.CircleSize; + float circleSize = beatmap.BeatmapInfo.BaseDifficulty.CircleSize; float catcherWidth = (1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f * CatcherArea.CATCHER_SIZE; float catcherWidthHalf = catcherWidth / 2; catcherWidthHalf *= 0.8f; - foreach (var hitObject in Beatmap.HitObjects) + var difficultyHitObjects = new List(); + + foreach (var hitObject in beatmap.HitObjects) { // We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations. if (hitObject is Fruit) @@ -60,28 +70,26 @@ namespace osu.Game.Rulesets.Catch.Difficulty difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime)); - if (!CalculateStrainValues()) return 0; + if (!calculateStrainValues(difficultyHitObjects, timeRate)) + return new CatchDifficultyAttributes(mods, 0); - double starRating = Math.Sqrt(CalculateDifficulty()) * star_scaling_factor; + double ar = beatmap.BeatmapInfo.BaseDifficulty.ApproachRate; + double preEmpt = BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / timeRate; - if (categoryDifficulty != null) + double starRating = Math.Sqrt(calculateDifficulty(difficultyHitObjects, timeRate)) * star_scaling_factor; + + return new CatchDifficultyAttributes(mods, starRating) { - categoryDifficulty["Aim"] = starRating; - - double ar = Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate; - double preEmpt = BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / TimeRate; - - categoryDifficulty["AR"] = preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0; - categoryDifficulty["Max combo"] = difficultyHitObjects.Count; - } - - return starRating; + AimRating = starRating, + ApproachRate = preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0, + MaxCombo = difficultyHitObjects.Count + }; } - protected bool CalculateStrainValues() + private bool calculateStrainValues(List objects, double timeRate) { // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. - using (List.Enumerator hitObjectsEnumerator = difficultyHitObjects.GetEnumerator()) + using (var hitObjectsEnumerator = objects.GetEnumerator()) { if (!hitObjectsEnumerator.MoveNext()) return false; @@ -91,7 +99,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty while (hitObjectsEnumerator.MoveNext()) { CatchDifficultyHitObject nextHitObject = hitObjectsEnumerator.Current; - nextHitObject?.CalculateStrains(currentHitObject, TimeRate); + nextHitObject?.CalculateStrains(currentHitObject, timeRate); currentHitObject = nextHitObject; } @@ -99,22 +107,10 @@ namespace osu.Game.Rulesets.Catch.Difficulty } } - /// - /// In milliseconds. For difficulty calculation we will only look at the highest strain value in each time interval of size STRAIN_STEP. - /// This is to eliminate higher influence of stream over aim by simply having more HitObjects with high strain. - /// The higher this value, the less strains there will be, indirectly giving long beatmaps an advantage. - /// - private const double strain_step = 750; - - /// - /// The weighting of each strain value decays to this number * it's previous value - /// - private const double decay_weight = 0.94; - - protected double CalculateDifficulty() + private double calculateDifficulty(List objects, double timeRate) { // The strain step needs to be adjusted for the algorithm to be considered equal with speed changing mods - double actualStrainStep = strain_step * TimeRate; + double actualStrainStep = strain_step * timeRate; // Find the highest strain value within each strain step List highestStrains = new List(); @@ -122,7 +118,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty double maximumStrain = 0; // We need to keep track of the maximum strain in the current interval CatchDifficultyHitObject previousHitObject = null; - foreach (CatchDifficultyHitObject hitObject in difficultyHitObjects) + foreach (CatchDifficultyHitObject hitObject in objects) { // While we are beyond the current interval push the currently available maximum to our strain list while (hitObject.BaseHitObject.StartTime > intervalEndTime) @@ -151,8 +147,16 @@ namespace osu.Game.Rulesets.Catch.Difficulty previousHitObject = hitObject; } - // calculate maximun strain difficulty - double difficulty = StrainCalculator(highestStrains, decay_weight); + // Build the weighted sum over the highest strains for each interval + double difficulty = 0; + double weight = 1; + highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. + + foreach (double strain in highestStrains) + { + difficulty += weight * strain; + weight *= decay_weight; + } return difficulty; } diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs index 72fc6d211b..720c1d8653 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyHitObject.cs @@ -8,7 +8,7 @@ using OpenTK; namespace osu.Game.Rulesets.Catch.Difficulty { - internal class CatchDifficultyHitObject + public class CatchDifficultyHitObject { internal static readonly double DECAY_BASE = 0.20; private const float normalized_hitobject_radius = 41.0f; diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs index 446dcfd0b4..473c205293 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoDifficultyCalculator.cs @@ -110,8 +110,16 @@ namespace osu.Game.Rulesets.Taiko.Difficulty previousHitObject = hitObject; } - // calculate maximun strain difficulty - double difficulty = StrainCalculator(highestStrains, decay_weight); + // Build the weighted sum over the highest strains for each interval + double difficulty = 0; + double weight = 1; + highestStrains.Sort((a, b) => b.CompareTo(a)); // Sort from highest to lowest strain. + + foreach (double strain in highestStrains) + { + difficulty += weight * strain; + weight *= decay_weight; + } return difficulty; } From 5f2d1d4a1e93289b55aad46fa7ddf74ff39798f2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 12:48:44 +0900 Subject: [PATCH 44/57] Dim TestCase background a bit --- osu.Game/Tests/OsuTestBrowser.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Tests/OsuTestBrowser.cs b/osu.Game/Tests/OsuTestBrowser.cs index 738bb2d642..217af8eb77 100644 --- a/osu.Game/Tests/OsuTestBrowser.cs +++ b/osu.Game/Tests/OsuTestBrowser.cs @@ -3,6 +3,7 @@ using osu.Framework.Platform; using osu.Framework.Testing; +using osu.Game.Graphics; using osu.Game.Screens.Backgrounds; namespace osu.Game.Tests @@ -13,7 +14,11 @@ namespace osu.Game.Tests { base.LoadComplete(); - LoadComponentAsync(new BackgroundScreenDefault { Depth = 10 }, AddInternal); + LoadComponentAsync(new BackgroundScreenDefault + { + Colour = OsuColour.Gray(0.5f), + Depth = 10 + }, AddInternal); // Have to construct this here, rather than in the constructor, because // we depend on some dependencies to be loaded within OsuGameBase.load(). From df0083e3d938d404855a73be9895656a3efb95f4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 12:48:57 +0900 Subject: [PATCH 45/57] Add tests for ParallaxContainer --- .../Visual/TestCaseParallaxContainer.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseParallaxContainer.cs diff --git a/osu.Game.Tests/Visual/TestCaseParallaxContainer.cs b/osu.Game.Tests/Visual/TestCaseParallaxContainer.cs new file mode 100644 index 0000000000..8c12589c6f --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseParallaxContainer.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Graphics.Containers; +using osu.Game.Screens.Backgrounds; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseParallaxContainer : OsuTestCase + { + public TestCaseParallaxContainer() + { + ParallaxContainer parallax; + + Add(parallax = new ParallaxContainer + { + Child = new BackgroundScreenDefault { Alpha = 0.8f } + }); + + AddStep("default parallax", () => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT); + AddStep("high parallax", () => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * 10); + AddStep("no parallax", () => parallax.ParallaxAmount = 0); + AddStep("negative parallax", () => parallax.ParallaxAmount = -ParallaxContainer.DEFAULT_PARALLAX_AMOUNT); + } + } +} From 74f732038f7542fe489bf6fe409e2a2db93a3a79 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 12:49:07 +0900 Subject: [PATCH 46/57] Add documentation for negative values of ParallaxAmount --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 51be40c1e8..8e1e5d54fa 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -16,6 +16,9 @@ namespace osu.Game.Graphics.Containers { public const float DEFAULT_PARALLAX_AMOUNT = 0.02f; + /// + /// The amount of parallax movement. Negative values will reverse the direction of parallax relative to user input. + /// public float ParallaxAmount = DEFAULT_PARALLAX_AMOUNT; private Bindable parallaxEnabled; From 9314f49bc384774479f6ee9e92e6b5c1731fbed1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 21 Jun 2018 12:57:59 +0900 Subject: [PATCH 47/57] Expose the catch width from the Catcher --- .../Difficulty/CatchDifficultyCalculator.cs | 10 ++++------ osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 12 +++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 520a980d26..33ee1c0184 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -40,10 +40,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty if (!beatmap.HitObjects.Any()) return new CatchDifficultyAttributes(mods, 0); - float circleSize = beatmap.BeatmapInfo.BaseDifficulty.CircleSize; - float catcherWidth = (1.0f - 0.7f * (circleSize - 5) / 5) * 0.62064f * CatcherArea.CATCHER_SIZE; - float catcherWidthHalf = catcherWidth / 2; - catcherWidthHalf *= 0.8f; + var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty); + float halfCatchWidth = catcher.CatchWidth * 0.5f; var difficultyHitObjects = new List(); @@ -52,7 +50,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty // We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations. if (hitObject is Fruit) { - difficultyHitObjects.Add(new CatchDifficultyHitObject((CatchHitObject)hitObject, catcherWidthHalf)); + difficultyHitObjects.Add(new CatchDifficultyHitObject((CatchHitObject)hitObject, halfCatchWidth)); } if (hitObject is JuiceStream) { @@ -61,7 +59,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty { CatchHitObject objectInJuiceStream = (CatchHitObject)nestedHitObjectsEnumerator.Current; if (!(objectInJuiceStream is TinyDroplet)) - difficultyHitObjects.Add(new CatchDifficultyHitObject(objectInJuiceStream, catcherWidthHalf)); + difficultyHitObjects.Add(new CatchDifficultyHitObject(objectInJuiceStream, halfCatchWidth)); } // Dispose the enumerator after counting all fruits. nestedHitObjectsEnumerator.Dispose(); diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index b62e9997d4..8e61e8cabe 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -3,6 +3,7 @@ using System; using System.Linq; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -105,6 +106,11 @@ namespace osu.Game.Rulesets.Catch.UI public class Catcher : Container, IKeyBindingHandler { + /// + /// Width of the area that can be used to attempt catches during gameplay. + /// + internal float CatchWidth => CATCHER_SIZE * Math.Abs(Scale.X); + private Container caughtFruit; public Container ExplodingFruitTarget; @@ -232,15 +238,15 @@ namespace osu.Game.Rulesets.Catch.UI /// Whether the catch is possible. public bool AttemptCatch(CatchHitObject fruit) { - double halfCatcherWidth = CATCHER_SIZE * Math.Abs(Scale.X) * 0.5f; + float halfCatchWidth = CatchWidth * 0.5f; // this stuff wil disappear once we move fruit to non-relative coordinate space in the future. var catchObjectPosition = fruit.X * CatchPlayfield.BASE_WIDTH; var catcherPosition = Position.X * CatchPlayfield.BASE_WIDTH; var validCatch = - catchObjectPosition >= catcherPosition - halfCatcherWidth && - catchObjectPosition <= catcherPosition + halfCatcherWidth; + catchObjectPosition >= catcherPosition - halfCatchWidth && + catchObjectPosition <= catcherPosition + halfCatchWidth; if (validCatch && fruit.HyperDash) { From afcf91a4c591980c5d633b07f60a46015931743c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 21 Jun 2018 13:12:22 +0900 Subject: [PATCH 48/57] What the... --- osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs | 2 +- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 33ee1c0184..4dd9cd10db 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Internal; +using System.Linq; using osu.Game.Beatmaps; using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Mods; diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 8e61e8cabe..3b4a7b13e7 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; From 6aa0ca5cc98dd2d245f05fe30c461616798940ec Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 14:13:20 +0900 Subject: [PATCH 49/57] Add (one-way) migration for existing users --- osu.Desktop/osu.Desktop.csproj | 1 + ...111_UpdateTaikoDefaultBindings.Designer.cs | 376 ++++++++++++++++++ ...180621044111_UpdateTaikoDefaultBindings.cs | 19 + .../Migrations/OsuDbContextModelSnapshot.cs | 8 +- 4 files changed, 399 insertions(+), 5 deletions(-) create mode 100644 osu.Game/Migrations/20180621044111_UpdateTaikoDefaultBindings.Designer.cs create mode 100644 osu.Game/Migrations/20180621044111_UpdateTaikoDefaultBindings.cs diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 3cf95e9b3e..29d3b0e394 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -30,6 +30,7 @@ + diff --git a/osu.Game/Migrations/20180621044111_UpdateTaikoDefaultBindings.Designer.cs b/osu.Game/Migrations/20180621044111_UpdateTaikoDefaultBindings.Designer.cs new file mode 100644 index 0000000000..aaa11e88b6 --- /dev/null +++ b/osu.Game/Migrations/20180621044111_UpdateTaikoDefaultBindings.Designer.cs @@ -0,0 +1,376 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using osu.Game.Database; + +namespace osu.Game.Migrations +{ + [DbContext(typeof(OsuDbContext))] + [Migration("20180621044111_UpdateTaikoDefaultBindings")] + partial class UpdateTaikoDefaultBindings + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.1.1-rtm-30846"); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("ApproachRate"); + + b.Property("CircleSize"); + + b.Property("DrainRate"); + + b.Property("OverallDifficulty"); + + b.Property("SliderMultiplier"); + + b.Property("SliderTickRate"); + + b.HasKey("ID"); + + b.ToTable("BeatmapDifficulty"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("AudioLeadIn"); + + b.Property("BaseDifficultyID"); + + b.Property("BeatDivisor"); + + b.Property("BeatmapSetInfoID"); + + b.Property("Countdown"); + + b.Property("DistanceSpacing"); + + b.Property("GridSize"); + + b.Property("Hash"); + + b.Property("Hidden"); + + b.Property("LetterboxInBreaks"); + + b.Property("MD5Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapID"); + + b.Property("Path"); + + b.Property("RulesetID"); + + b.Property("SpecialStyle"); + + b.Property("StackLeniency"); + + b.Property("StarDifficulty"); + + b.Property("StoredBookmarks"); + + b.Property("TimelineZoom"); + + b.Property("Version"); + + b.Property("WidescreenStoryboard"); + + b.HasKey("ID"); + + b.HasIndex("BaseDifficultyID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("Hash"); + + b.HasIndex("MD5Hash"); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapID") + .IsUnique(); + + b.HasIndex("RulesetID"); + + b.ToTable("BeatmapInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Artist"); + + b.Property("ArtistUnicode"); + + b.Property("AudioFile"); + + b.Property("AuthorString") + .HasColumnName("Author"); + + b.Property("BackgroundFile"); + + b.Property("PreviewTime"); + + b.Property("Source"); + + b.Property("Tags"); + + b.Property("Title"); + + b.Property("TitleUnicode"); + + b.HasKey("ID"); + + b.ToTable("BeatmapMetadata"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("BeatmapSetInfoID"); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.HasKey("ID"); + + b.HasIndex("BeatmapSetInfoID"); + + b.HasIndex("FileInfoID"); + + b.ToTable("BeatmapSetFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("DeletePending"); + + b.Property("Hash"); + + b.Property("MetadataID"); + + b.Property("OnlineBeatmapSetID"); + + b.Property("Protected"); + + b.HasKey("ID"); + + b.HasIndex("DeletePending"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("MetadataID"); + + b.HasIndex("OnlineBeatmapSetID") + .IsUnique(); + + b.ToTable("BeatmapSetInfo"); + }); + + modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("IntKey") + .HasColumnName("Key"); + + b.Property("RulesetID"); + + b.Property("StringValue") + .HasColumnName("Value"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("Settings"); + }); + + modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("IntAction") + .HasColumnName("Action"); + + b.Property("KeysString") + .HasColumnName("Keys"); + + b.Property("RulesetID"); + + b.Property("Variant"); + + b.HasKey("ID"); + + b.HasIndex("IntAction"); + + b.HasIndex("RulesetID", "Variant"); + + b.ToTable("KeyBinding"); + }); + + modelBuilder.Entity("osu.Game.IO.FileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Hash"); + + b.Property("ReferenceCount"); + + b.HasKey("ID"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("ReferenceCount"); + + b.ToTable("FileInfo"); + }); + + modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Available"); + + b.Property("InstantiationInfo"); + + b.Property("Name"); + + b.Property("ShortName"); + + b.HasKey("ID"); + + b.HasIndex("Available"); + + b.HasIndex("ShortName") + .IsUnique(); + + b.ToTable("RulesetInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("FileInfoID"); + + b.Property("Filename") + .IsRequired(); + + b.Property("SkinInfoID"); + + b.HasKey("ID"); + + b.HasIndex("FileInfoID"); + + b.HasIndex("SkinInfoID"); + + b.ToTable("SkinFileInfo"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b => + { + b.Property("ID") + .ValueGeneratedOnAdd(); + + b.Property("Creator"); + + b.Property("DeletePending"); + + b.Property("Name"); + + b.HasKey("ID"); + + b.ToTable("SkinInfo"); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty") + .WithMany() + .HasForeignKey("BaseDifficultyID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") + .WithMany("Beatmaps") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("Beatmaps") + .HasForeignKey("MetadataID"); + + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") + .WithMany() + .HasForeignKey("RulesetID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") + .WithMany("Files") + .HasForeignKey("BeatmapSetInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("BeatmapSets") + .HasForeignKey("MetadataID"); + }); + + modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b => + { + b.HasOne("osu.Game.IO.FileInfo", "FileInfo") + .WithMany() + .HasForeignKey("FileInfoID") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("osu.Game.Skinning.SkinInfo") + .WithMany("Files") + .HasForeignKey("SkinInfoID") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/osu.Game/Migrations/20180621044111_UpdateTaikoDefaultBindings.cs b/osu.Game/Migrations/20180621044111_UpdateTaikoDefaultBindings.cs new file mode 100644 index 0000000000..98ce5def08 --- /dev/null +++ b/osu.Game/Migrations/20180621044111_UpdateTaikoDefaultBindings.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using osu.Framework.Logging; + +namespace osu.Game.Migrations +{ + public partial class UpdateTaikoDefaultBindings : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM KeyBinding WHERE RulesetID = 1"); + Logger.Log("osu!taiko bindings have been reset due to new defaults", LoggingTarget.Runtime, LogLevel.Important); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + // we can't really tell if these should be restored or not, so let's just not do so. + } + } +} diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index d750d50b5b..bd80cb743b 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -1,11 +1,9 @@ // +using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using osu.Game.Database; -using System; namespace osu.Game.Migrations { @@ -16,7 +14,7 @@ namespace osu.Game.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.0.3-rtm-10026"); + .HasAnnotation("ProductVersion", "2.1.1-rtm-30846"); modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => { From 566d125658a8e1071b27ee2e2a70babd94f9c8ed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 14:28:40 +0900 Subject: [PATCH 50/57] Change order of default initialisation to look better in settings --- osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index b41a6f3c38..609fd27bb4 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -27,12 +27,12 @@ namespace osu.Game.Rulesets.Taiko public override IEnumerable GetDefaultKeyBindings(int variant = 0) => new[] { + new KeyBinding(InputKey.MouseLeft, TaikoAction.LeftCentre), + new KeyBinding(InputKey.MouseRight, TaikoAction.LeftRim), new KeyBinding(InputKey.D, TaikoAction.LeftRim), new KeyBinding(InputKey.F, TaikoAction.LeftCentre), new KeyBinding(InputKey.J, TaikoAction.RightCentre), new KeyBinding(InputKey.K, TaikoAction.RightRim), - new KeyBinding(InputKey.MouseLeft, TaikoAction.LeftCentre), - new KeyBinding(InputKey.MouseRight, TaikoAction.LeftRim), }; public override IEnumerable ConvertLegacyMods(LegacyMods mods) From ed17a241f5551172df87be804c094e951a694ab8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 14:43:02 +0900 Subject: [PATCH 51/57] Decrease notification font size --- osu.Game/Overlays/Notifications/SimpleNotification.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Notifications/SimpleNotification.cs b/osu.Game/Overlays/Notifications/SimpleNotification.cs index a78bc8da81..25a832941e 100644 --- a/osu.Game/Overlays/Notifications/SimpleNotification.cs +++ b/osu.Game/Overlays/Notifications/SimpleNotification.cs @@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Notifications } }); - Content.Add(textDrawable = new OsuTextFlowContainer(t => t.TextSize = 16) + Content.Add(textDrawable = new OsuTextFlowContainer(t => t.TextSize = 14) { Colour = OsuColour.Gray(128), AutoSizeAxes = Axes.Y, From 87d94591e466e5ced6570d640dc0257d4d9486f4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 14:43:38 +0900 Subject: [PATCH 52/57] Start displaying notifications earlier Also show important notifications and more in total. --- osu.Game/OsuGame.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 36c76851c6..7f66c9fe8c 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -101,6 +101,8 @@ namespace osu.Game public OsuGame(string[] args = null) { this.args = args; + + forwardLoggedErrorsToNotifications(); } public void ToggleSettings() => settings.ToggleVisibility(); @@ -305,8 +307,6 @@ namespace osu.Game Depth = -6, }, overlayContent.Add); - forwardLoggedErrorsToNotifications(); - dependencies.Cache(settings); dependencies.Cache(onscreenDisplay); dependencies.Cache(social); @@ -394,31 +394,33 @@ namespace osu.Game private void forwardLoggedErrorsToNotifications() { - int recentErrorCount = 0; + int recentLogCount = 0; const double debounce = 5000; Logger.NewEntry += entry => { - if (entry.Level < LogLevel.Error || entry.Target == null) return; + if (entry.Level < LogLevel.Important || entry.Target == null) return; - if (recentErrorCount < 2) + if (recentLogCount < 3) { - notifications.Post(new SimpleNotification + bool lastDisplayable = recentLogCount == recentLogCount - 1; + + Schedule(() => notifications.Post(new SimpleNotification { - Icon = FontAwesome.fa_bomb, - Text = (recentErrorCount == 0 ? entry.Message : "Subsequent errors occurred and have been logged.") + "\nClick to view log files.", + Icon = entry.Level == LogLevel.Important ? FontAwesome.fa_exclamation_circle : FontAwesome.fa_bomb, + Text = (!lastDisplayable ? entry.Message : "Subsequent messages have been logged.") + "\n\nClick to view log files.", Activated = () => { Host.Storage.GetStorageForDirectory("logs").OpenInNativeExplorer(); return true; } - }); + })); } - Interlocked.Increment(ref recentErrorCount); + Interlocked.Increment(ref recentLogCount); - Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentErrorCount), debounce); + Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentLogCount), debounce); }; } From 6ec0aaee91d4713d730f66ce6e70ab763053fc15 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 14:50:42 +0900 Subject: [PATCH 53/57] Split out logic for subsequent log message and apply action to only itself --- osu.Game/OsuGame.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7f66c9fe8c..ba8685b5b2 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -402,14 +402,22 @@ namespace osu.Game { if (entry.Level < LogLevel.Important || entry.Target == null) return; - if (recentLogCount < 3) - { - bool lastDisplayable = recentLogCount == recentLogCount - 1; + const int short_term_display_limit = 3; + if (recentLogCount < short_term_display_limit) + { Schedule(() => notifications.Post(new SimpleNotification { Icon = entry.Level == LogLevel.Important ? FontAwesome.fa_exclamation_circle : FontAwesome.fa_bomb, - Text = (!lastDisplayable ? entry.Message : "Subsequent messages have been logged.") + "\n\nClick to view log files.", + Text = entry.Message, + })); + } + else if (recentLogCount == short_term_display_limit) + { + Schedule(() => notifications.Post(new SimpleNotification + { + Icon = FontAwesome.fa_ellipsis_h, + Text = "Subsequent messages have been logged. Click to view log files.", Activated = () => { Host.Storage.GetStorageForDirectory("logs").OpenInNativeExplorer(); @@ -419,7 +427,6 @@ namespace osu.Game } Interlocked.Increment(ref recentLogCount); - Scheduler.AddDelayed(() => Interlocked.Decrement(ref recentLogCount), debounce); }; } From a9cb214aa908a2fbbce3742d34c2f69b9f4093f4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 16:21:08 +0900 Subject: [PATCH 54/57] Replace usage of GetEnumerator --- .../Difficulty/CatchDifficultyCalculator.cs | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 4dd9cd10db..20bdaf875d 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -9,7 +9,6 @@ using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.UI; -using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Catch.Difficulty { @@ -53,17 +52,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty difficultyHitObjects.Add(new CatchDifficultyHitObject((CatchHitObject)hitObject, halfCatchWidth)); } if (hitObject is JuiceStream) - { - IEnumerator nestedHitObjectsEnumerator = hitObject.NestedHitObjects.GetEnumerator(); - while (nestedHitObjectsEnumerator.MoveNext()) - { - CatchHitObject objectInJuiceStream = (CatchHitObject)nestedHitObjectsEnumerator.Current; - if (!(objectInJuiceStream is TinyDroplet)) - difficultyHitObjects.Add(new CatchDifficultyHitObject(objectInJuiceStream, halfCatchWidth)); - } - // Dispose the enumerator after counting all fruits. - nestedHitObjectsEnumerator.Dispose(); - } + difficultyHitObjects.AddRange(hitObject.NestedHitObjects.OfType().Where(o => !(o is TinyDroplet)).Select(o => new CatchDifficultyHitObject(o, halfCatchWidth))); } difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime)); @@ -86,23 +75,20 @@ namespace osu.Game.Rulesets.Catch.Difficulty private bool calculateStrainValues(List objects, double timeRate) { + CatchDifficultyHitObject lastObject = null; + + if (!objects.Any()) return false; + // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. - using (var hitObjectsEnumerator = objects.GetEnumerator()) + foreach (var currentObject in objects) { - if (!hitObjectsEnumerator.MoveNext()) return false; + if (lastObject != null) + currentObject.CalculateStrains(lastObject, timeRate); - CatchDifficultyHitObject currentHitObject = hitObjectsEnumerator.Current; - - // First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject. - while (hitObjectsEnumerator.MoveNext()) - { - CatchDifficultyHitObject nextHitObject = hitObjectsEnumerator.Current; - nextHitObject?.CalculateStrains(currentHitObject, timeRate); - currentHitObject = nextHitObject; - } - - return true; + lastObject = currentObject; } + + return true; } private double calculateDifficulty(List objects, double timeRate) From 4982efce889d82dd2a026e640c23097b9789f8c9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 17:22:59 +0900 Subject: [PATCH 55/57] Remove vscode files from long-gone deploy project --- osu.Desktop.Deploy/.vscode/launch.json | 29 ------------ osu.Desktop.Deploy/.vscode/tasks.json | 64 -------------------------- 2 files changed, 93 deletions(-) delete mode 100644 osu.Desktop.Deploy/.vscode/launch.json delete mode 100644 osu.Desktop.Deploy/.vscode/tasks.json diff --git a/osu.Desktop.Deploy/.vscode/launch.json b/osu.Desktop.Deploy/.vscode/launch.json deleted file mode 100644 index 8c35d211bd..0000000000 --- a/osu.Desktop.Deploy/.vscode/launch.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [{ - "name": "Deploy (Debug)", - "request": "launch", - "type": "mono", - "program": "${workspaceRoot}/bin/Debug/net471/osu.Desktop.Deploy.exe", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Debug)", - "runtimeExecutable": null, - "env": {}, - "console": "internalConsole" - }, - { - "name": "Deploy (Release)", - "request": "launch", - "type": "clr", - "program": "${workspaceRoot}/bin/Release/net471/osu.Desktop.Deploy.exe", - "cwd": "${workspaceRoot}", - "preLaunchTask": "Build (Release)", - "runtimeExecutable": null, - "env": {}, - "console": "internalConsole" - } - ] -} \ No newline at end of file diff --git a/osu.Desktop.Deploy/.vscode/tasks.json b/osu.Desktop.Deploy/.vscode/tasks.json deleted file mode 100644 index 35bf9e7a0e..0000000000 --- a/osu.Desktop.Deploy/.vscode/tasks.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "command": "msbuild", - "type": "shell", - "suppressTaskName": true, - "args": [ - "/property:GenerateFullPaths=true", - "/property:DebugType=portable", - "/verbosity:minimal", - "/m" //parallel compiling support. - ], - "tasks": [{ - "taskName": "Build (Debug)", - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [ - "$msCompile" - ] - }, - { - "taskName": "Build (Release)", - "group": "build", - "args": [ - "/property:Configuration=Release" - ], - "problemMatcher": [ - "$msCompile" - ] - }, - { - "taskName": "Clean (Debug)", - "args": [ - "/target:Clean" - ], - "problemMatcher": [ - "$msCompile" - ] - }, - { - "taskName": "Clean (Release)", - "args": [ - "/target:Clean", - "/property:Configuration=Release" - ], - "problemMatcher": [ - "$msCompile" - ] - }, - { - "taskName": "Clean All", - "dependsOn": [ - "Clean (Debug)", - "Clean (Release)" - ], - "problemMatcher": [ - "$msCompile" - ] - } - ] -} \ No newline at end of file From c64f64814f2a44bce3856fbcdfdcb530a474c7b9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 17:32:10 +0900 Subject: [PATCH 56/57] Remove unnecessary AimRating --- .../Difficulty/CatchDifficultyAttributes.cs | 1 - .../Difficulty/CatchDifficultyCalculator.cs | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs index 687cd03152..f6535380c8 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyAttributes.cs @@ -8,7 +8,6 @@ namespace osu.Game.Rulesets.Catch.Difficulty { public class CatchDifficultyAttributes : DifficultyAttributes { - public double AimRating; public double ApproachRate; public int MaxCombo; diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 20bdaf875d..108c9ada14 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -60,14 +60,12 @@ namespace osu.Game.Rulesets.Catch.Difficulty if (!calculateStrainValues(difficultyHitObjects, timeRate)) return new CatchDifficultyAttributes(mods, 0); - double ar = beatmap.BeatmapInfo.BaseDifficulty.ApproachRate; - double preEmpt = BeatmapDifficulty.DifficultyRange(ar, 1800, 1200, 450) / timeRate; - + // this is the same as osu!, so there's potential to share the implementation... maybe + double preEmpt = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.ApproachRate, 1800, 1200, 450) / timeRate; double starRating = Math.Sqrt(calculateDifficulty(difficultyHitObjects, timeRate)) * star_scaling_factor; return new CatchDifficultyAttributes(mods, starRating) { - AimRating = starRating, ApproachRate = preEmpt > 1200.0 ? -(preEmpt - 1800.0) / 120.0 : -(preEmpt - 1200.0) / 150.0 + 5.0, MaxCombo = difficultyHitObjects.Count }; From 34498f7f86eb6e0baa7113d6ba59122c608febdc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 17:49:04 +0900 Subject: [PATCH 57/57] Use var where possible --- osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs index 108c9ada14..3d1013aad3 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchDifficultyCalculator.cs @@ -95,7 +95,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty double actualStrainStep = strain_step * timeRate; // Find the highest strain value within each strain step - List highestStrains = new List(); + var highestStrains = new List(); double intervalEndTime = actualStrainStep; double maximumStrain = 0; // We need to keep track of the maximum strain in the current interval