From 3b58f6a7e78d8244a6e60bf8b27078c84845fb3c Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Thu, 21 Dec 2023 21:07:12 -0500 Subject: [PATCH 001/508] Implement difficulty statistics --- global.json | 8 +- .../Drawables/DifficultyIconTooltip.cs | 100 +++++++++++++++++- 2 files changed, 103 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index 5dcd5f425a..7835999220 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "6.0.100", - "rollForward": "latestFeature" + "version": "6.0.0", + "rollForward": "latestFeature", + "allowPrerelease": true } -} - +} \ No newline at end of file diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index 3fa24bcc3e..7ea2c6a0a2 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -3,6 +3,7 @@ #nullable disable +using System; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -19,6 +20,13 @@ namespace osu.Game.Beatmaps.Drawables { private OsuSpriteText difficultyName; private StarRatingDisplay starRating; + private OsuSpriteText overallDifficulty; + private OsuSpriteText drainRate; + private OsuSpriteText circleSize; + private OsuSpriteText approachRate; + private OsuSpriteText BPM; + private OsuSpriteText maxCombo; + private OsuSpriteText length; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -35,6 +43,7 @@ namespace osu.Game.Beatmaps.Drawables Colour = colours.Gray3, RelativeSizeAxes = Axes.Both }, + // Headers new FillFlowContainer { AutoSizeAxes = Axes.Both, @@ -55,6 +64,84 @@ namespace osu.Game.Beatmaps.Drawables { Anchor = Anchor.Centre, Origin = Anchor.Centre, + }, + // Difficulty stats + new FillFlowContainer() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5), + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), + }, + overallDifficulty = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14), + }, + drainRate = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14), + }, + circleSize = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14), + }, + approachRate = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14), + }, + } + }, + // Misc stats + new FillFlowContainer() + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5), + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), + }, + length = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14), + }, + BPM = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14), + }, + maxCombo = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 14), + }, + } } } } @@ -68,10 +155,21 @@ namespace osu.Game.Beatmaps.Drawables if (displayedContent != null) starRating.Current.UnbindFrom(displayedContent.Difficulty); + // Header row displayedContent = content; - starRating.Current.BindTarget = displayedContent.Difficulty; difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; + + // Difficulty row + overallDifficulty.Text = "OD: " + displayedContent.BeatmapInfo.Difficulty.OverallDifficulty.ToString("0.##"); + drainRate.Text = "| HP: " + displayedContent.BeatmapInfo.Difficulty.DrainRate.ToString("0.##"); + circleSize.Text = "| CS: " + displayedContent.BeatmapInfo.Difficulty.CircleSize.ToString("0.##"); + approachRate.Text = "| AR: " + displayedContent.BeatmapInfo.Difficulty.ApproachRate.ToString("0.##"); + + // Misc row + length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length).ToString("mm\\:ss"); + BPM.Text = "| BPM: " + displayedContent.BeatmapInfo.BPM; + maxCombo.Text = "| Max Combo: " + displayedContent.BeatmapInfo.TotalObjectCount; } public void Move(Vector2 pos) => Position = pos; From 803329c5d8aa3a73ef9a58875adb8255f241a0ec Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:58:41 -0500 Subject: [PATCH 002/508] rollback my accidental global.json change --- global.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/global.json b/global.json index 7835999220..d6c2c37f77 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,6 @@ { "sdk": { - "version": "6.0.0", - "rollForward": "latestFeature", - "allowPrerelease": true + "version": "6.0.100", + "rollForward": "latestFeature" } } \ No newline at end of file From f7c1e66165b5415a3779961f852677fca073c3d5 Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Fri, 22 Dec 2023 17:28:02 -0500 Subject: [PATCH 003/508] Make the difficulty stats change based on the currently applied mods --- osu.Game/Beatmaps/Drawables/DifficultyIcon.cs | 10 ++- .../Drawables/DifficultyIconTooltip.cs | 61 ++++++++++++++----- .../OnlinePlay/DrawableRoomPlaylistItem.cs | 2 +- 3 files changed, 55 insertions(+), 18 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 1665ec52fa..44981003f2 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -14,6 +14,7 @@ using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osuTK; using osuTK.Graphics; @@ -39,6 +40,8 @@ namespace osu.Game.Beatmaps.Drawables private readonly IRulesetInfo ruleset; + private readonly Mod[]? mods; + private Drawable background = null!; private readonly Container iconContainer; @@ -58,11 +61,14 @@ namespace osu.Game.Beatmaps.Drawables /// Creates a new . Will use provided beatmap's for initial value. /// /// The beatmap to be displayed in the tooltip, and to be used for the initial star rating value. + /// The mods type beat /// An optional ruleset to be used for the icon display, in place of the beatmap's ruleset. - public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null) + public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null) : this(ruleset ?? beatmap.Ruleset) { this.beatmap = beatmap; + this.mods = mods; + Current.Value = new StarDifficulty(beatmap.StarRating, 0); } @@ -128,6 +134,6 @@ namespace osu.Game.Beatmaps.Drawables GetCustomTooltip() => new DifficultyIconTooltip(); DifficultyIconTooltipContent IHasCustomTooltip. - TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current) : null)!; + TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods) : null)!; } } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index 7ea2c6a0a2..0f5c94ac1d 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -4,6 +4,7 @@ #nullable disable using System; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -12,6 +13,8 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osuTK; namespace osu.Game.Beatmaps.Drawables @@ -24,7 +27,7 @@ namespace osu.Game.Beatmaps.Drawables private OsuSpriteText drainRate; private OsuSpriteText circleSize; private OsuSpriteText approachRate; - private OsuSpriteText BPM; + private OsuSpriteText bpm; private OsuSpriteText maxCombo; private OsuSpriteText length; @@ -66,7 +69,7 @@ namespace osu.Game.Beatmaps.Drawables Origin = Anchor.Centre, }, // Difficulty stats - new FillFlowContainer() + new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -81,7 +84,7 @@ namespace osu.Game.Beatmaps.Drawables Origin = Anchor.Centre, Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), }, - overallDifficulty = new OsuSpriteText + circleSize = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -93,13 +96,13 @@ namespace osu.Game.Beatmaps.Drawables Origin = Anchor.Centre, Font = OsuFont.GetFont(size: 14), }, - circleSize = new OsuSpriteText + approachRate = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Font = OsuFont.GetFont(size: 14), }, - approachRate = new OsuSpriteText + overallDifficulty = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -108,7 +111,7 @@ namespace osu.Game.Beatmaps.Drawables } }, // Misc stats - new FillFlowContainer() + new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -129,7 +132,7 @@ namespace osu.Game.Beatmaps.Drawables Origin = Anchor.Centre, Font = OsuFont.GetFont(size: 14), }, - BPM = new OsuSpriteText + bpm = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -155,20 +158,44 @@ namespace osu.Game.Beatmaps.Drawables if (displayedContent != null) starRating.Current.UnbindFrom(displayedContent.Difficulty); - // Header row displayedContent = content; + + // Header row starRating.Current.BindTarget = displayedContent.Difficulty; difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; + double rate = 1; + + if (displayedContent.Mods != null) + { + foreach (var mod in displayedContent.Mods.OfType()) + rate = mod.ApplyToRate(0, rate); + } + + double bpmAdjusted = displayedContent.BeatmapInfo.BPM * rate; + + BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(displayedContent.BeatmapInfo.Difficulty); + + if (displayedContent.Mods != null) + { + foreach (var mod in displayedContent.Mods.OfType()) + { + mod.ApplyToDifficulty(originalDifficulty); + } + } + + Ruleset ruleset = displayedContent.Ruleset.CreateInstance(); + BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); + // Difficulty row - overallDifficulty.Text = "OD: " + displayedContent.BeatmapInfo.Difficulty.OverallDifficulty.ToString("0.##"); - drainRate.Text = "| HP: " + displayedContent.BeatmapInfo.Difficulty.DrainRate.ToString("0.##"); - circleSize.Text = "| CS: " + displayedContent.BeatmapInfo.Difficulty.CircleSize.ToString("0.##"); - approachRate.Text = "| AR: " + displayedContent.BeatmapInfo.Difficulty.ApproachRate.ToString("0.##"); + circleSize.Text = "CS: " + adjustedDifficulty.CircleSize.ToString("0.##"); + drainRate.Text = "| HP: " + adjustedDifficulty.DrainRate.ToString("0.##"); + approachRate.Text = "| AR: " + adjustedDifficulty.ApproachRate.ToString("0.##"); + overallDifficulty.Text = "| OD: " + adjustedDifficulty.OverallDifficulty.ToString("0.##"); // Misc row - length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length).ToString("mm\\:ss"); - BPM.Text = "| BPM: " + displayedContent.BeatmapInfo.BPM; + length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString("mm\\:ss"); + bpm.Text = "| BPM: " + bpmAdjusted; maxCombo.Text = "| Max Combo: " + displayedContent.BeatmapInfo.TotalObjectCount; } @@ -183,11 +210,15 @@ namespace osu.Game.Beatmaps.Drawables { public readonly IBeatmapInfo BeatmapInfo; public readonly IBindable Difficulty; + public readonly IRulesetInfo Ruleset; + public readonly Mod[] Mods; - public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty) + public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[] mods) { BeatmapInfo = beatmapInfo; Difficulty = difficulty; + Ruleset = rulesetInfo; + Mods = mods; } } } diff --git a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs index 8f405399a7..eb23ed6f8f 100644 --- a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs +++ b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs @@ -283,7 +283,7 @@ namespace osu.Game.Screens.OnlinePlay } if (beatmap != null) - difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset) { Size = new Vector2(icon_height) }; + difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods) { Size = new Vector2(icon_height) }; else difficultyIconContainer.Clear(); From 1d4db3b7a95b894604a0717920fc2771fd7ef352 Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Tue, 26 Dec 2023 11:08:21 -0800 Subject: [PATCH 004/508] Fix `SkinEditorOverlay` freezing when `ReplayPlayer` screen exits early Originally when popping in, the ReplayPlayer was loaded first (if previous screen was MainMenu), and afterwards the SkinEditor component was loaded asynchronously. However, if the ReplayPlayer screen exits quickly (like in the event the beatmap has no objects), the skin editor component has not finished initializing (this is before it was even added to the component tree, so it's still not marked `Visible`), then the screen exiting will cause `OsuGame` to call SetTarget(newScreen) -> setTarget(...) which sees that the cached `skinEditor` is not visible yet, and hides/nulls the field. This is the point where LoadComponentAsync(editor, ...) finishes, and the callback sees that the cached skinEditor field is now different (null) than the one that was loaded, and never adds it to the component tree. This occurrence is unhandled and as such the SkinEditorOverlay never hides itself, consuming all input infinitely. This PR changes the loading to start loading the ReplayPlayer *after* the SkinEditor has been loaded and added to the component tree. Additionally, this lowers the exit delay for ReplayPlayer and changes the "no hit objects" notification to not be an error since it's a controlled exit. --- osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs | 8 ++++---- osu.Game/Screens/Play/Player.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs b/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs index bedaf12c9b..880921ca64 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs @@ -100,9 +100,6 @@ namespace osu.Game.Overlays.SkinEditor { globallyDisableBeatmapSkinSetting(); - if (lastTargetScreen is MainMenu) - PresentGameplay(); - if (skinEditor != null) { skinEditor.Show(); @@ -122,6 +119,9 @@ namespace osu.Game.Overlays.SkinEditor AddInternal(editor); + if (lastTargetScreen is MainMenu) + PresentGameplay(); + Debug.Assert(lastTargetScreen != null); SetTarget(lastTargetScreen); @@ -316,7 +316,7 @@ namespace osu.Game.Overlays.SkinEditor base.LoadComplete(); if (!LoadedBeatmapSuccessfully) - Scheduler.AddDelayed(this.Exit, 3000); + Scheduler.AddDelayed(this.Exit, RESULTS_DISPLAY_DELAY); } protected override void Update() diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c960ac357f..08d77d60d8 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -547,7 +547,7 @@ namespace osu.Game.Screens.Play if (playable.HitObjects.Count == 0) { - Logger.Log("Beatmap contains no hit objects!", level: LogLevel.Error); + Logger.Log("Beatmap contains no hit objects!", level: LogLevel.Important); return null; } } From 85a768d0c806d5c4579b762ae98e938eee135fe7 Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Tue, 26 Dec 2023 12:46:50 -0800 Subject: [PATCH 005/508] Don't reuse results delay const --- osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs b/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs index 880921ca64..10a032193f 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs @@ -316,7 +316,7 @@ namespace osu.Game.Overlays.SkinEditor base.LoadComplete(); if (!LoadedBeatmapSuccessfully) - Scheduler.AddDelayed(this.Exit, RESULTS_DISPLAY_DELAY); + Scheduler.AddDelayed(this.Exit, 1000); } protected override void Update() From 0c8b551c6618668902ae1f92e0828f24fd1427f2 Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Wed, 27 Dec 2023 14:45:56 -0800 Subject: [PATCH 006/508] SkinEditor lifetime fix & show gameplay If the SkinEditor was created already but not finished initializing, wait for it to initialize before handling a screen change, which could possibly null the skin editor. Additionally, in the case the skin editor is already loaded but hidden, make sure to show gameplay. --- osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs b/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs index 10a032193f..5f5323b584 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditorOverlay.cs @@ -103,6 +103,10 @@ namespace osu.Game.Overlays.SkinEditor if (skinEditor != null) { skinEditor.Show(); + + if (lastTargetScreen is MainMenu) + PresentGameplay(); + return; } @@ -252,7 +256,7 @@ namespace osu.Game.Overlays.SkinEditor Debug.Assert(skinEditor != null); - if (!target.IsLoaded) + if (!target.IsLoaded || !skinEditor.IsLoaded) { Scheduler.AddOnce(setTarget, target); return; From 75b9d0fe6666eba914fc87f5428414d8003c3edf Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Wed, 27 Dec 2023 23:02:45 -0800 Subject: [PATCH 007/508] Make flashlight scale with playfield When the playfield is shrunk with mods such as BarrelRoll, flashlight does not account for this, making it significantly easier to play. This makes it scale along with the playfield. --- .../Mods/TestSceneOsuModFlashlight.cs | 26 +++++++++++++++++++ osu.Game/Rulesets/Mods/ModFlashlight.cs | 13 +++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs b/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs index a353914cd5..2438038951 100644 --- a/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs +++ b/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs @@ -1,8 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; +using osu.Framework.Utils; +using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu.Mods; +using osu.Game.Rulesets.Osu.Objects; +using osuTK; namespace osu.Game.Rulesets.Osu.Tests.Mods { @@ -21,5 +26,26 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods [Test] public void TestComboBasedSize([Values] bool comboBasedSize) => CreateModTest(new ModTestData { Mod = new OsuModFlashlight { ComboBasedSize = { Value = comboBasedSize } }, PassCondition = () => true }); + + [Test] + public void TestPlayfieldBasedSize() + { + ModFlashlight mod = new OsuModFlashlight(); + CreateModTest(new ModTestData + { + Mod = mod, + PassCondition = () => + { + var flashlightOverlay = Player.DrawableRuleset.Overlays + .OfType.Flashlight>() + .First(); + + return Precision.AlmostEquals(mod.DefaultFlashlightSize * .5f, flashlightOverlay.GetSize()); + } + }); + + AddStep("adjust playfield scale", () => + Player.DrawableRuleset.Playfield.Scale = new Vector2(.5f)); + } } } diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs index 95406cc9e6..d714cd3c85 100644 --- a/osu.Game/Rulesets/Mods/ModFlashlight.cs +++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs @@ -86,6 +86,7 @@ namespace osu.Game.Rulesets.Mods flashlight.Depth = float.MinValue; flashlight.Combo.BindTo(Combo); + flashlight.GetPlayfieldScale = () => drawableRuleset.Playfield.Scale; drawableRuleset.Overlays.Add(flashlight); } @@ -102,6 +103,8 @@ namespace osu.Game.Rulesets.Mods public override bool RemoveCompletedTransforms => false; + internal Func? GetPlayfieldScale; + private readonly float defaultFlashlightSize; private readonly float sizeMultiplier; private readonly bool comboBasedSize; @@ -141,10 +144,18 @@ namespace osu.Game.Rulesets.Mods protected abstract string FragmentShader { get; } - protected float GetSize() + public float GetSize() { float size = defaultFlashlightSize * sizeMultiplier; + if (GetPlayfieldScale != null) + { + Vector2 playfieldScale = GetPlayfieldScale(); + float rulesetScaleAvg = (playfieldScale.X + playfieldScale.Y) / 2f; + + size *= rulesetScaleAvg; + } + if (isBreakTime.Value) size *= 2.5f; else if (comboBasedSize) From d2efa2e56a34a28a2656ca30885046aa33cd06f7 Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Sun, 14 Jan 2024 15:47:50 -0500 Subject: [PATCH 008/508] peppy said he prefers the version without pipes so ill remove the pipes --- osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index 0f5c94ac1d..a4ba2a27f6 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -189,14 +189,14 @@ namespace osu.Game.Beatmaps.Drawables // Difficulty row circleSize.Text = "CS: " + adjustedDifficulty.CircleSize.ToString("0.##"); - drainRate.Text = "| HP: " + adjustedDifficulty.DrainRate.ToString("0.##"); - approachRate.Text = "| AR: " + adjustedDifficulty.ApproachRate.ToString("0.##"); - overallDifficulty.Text = "| OD: " + adjustedDifficulty.OverallDifficulty.ToString("0.##"); + drainRate.Text = " HP: " + adjustedDifficulty.DrainRate.ToString("0.##"); + approachRate.Text = " AR: " + adjustedDifficulty.ApproachRate.ToString("0.##"); + overallDifficulty.Text = " OD: " + adjustedDifficulty.OverallDifficulty.ToString("0.##"); // Misc row length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString("mm\\:ss"); - bpm.Text = "| BPM: " + bpmAdjusted; - maxCombo.Text = "| Max Combo: " + displayedContent.BeatmapInfo.TotalObjectCount; + bpm.Text = " BPM: " + bpmAdjusted; + maxCombo.Text = " Max Combo: " + displayedContent.BeatmapInfo.TotalObjectCount; } public void Move(Vector2 pos) => Position = pos; From 0237c9c6d712ee07a9f877b589e80bcf53591045 Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Sun, 14 Jan 2024 15:57:16 -0500 Subject: [PATCH 009/508] peppy said he prefers the version without pipes so ill remove the pipes --- global.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/global.json b/global.json index d6c2c37f77..5dcd5f425a 100644 --- a/global.json +++ b/global.json @@ -3,4 +3,5 @@ "version": "6.0.100", "rollForward": "latestFeature" } -} \ No newline at end of file +} + From b6422bc8bdb88a5b19b41992fb90bec6a966368d Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Wed, 17 Jan 2024 09:07:17 -0500 Subject: [PATCH 010/508] Apply suggested changes - Change difficultyicon mods parameter docstring to be more professional - Add a parameter for controlling whether the difficulty statistics show or not. Defaults to false - Round the BPM in the tooltip to make sure it displays correctly --- osu.Game/Beatmaps/Drawables/DifficultyIcon.cs | 10 ++++-- .../Drawables/DifficultyIconTooltip.cs | 34 ++++++++++--------- .../OnlinePlay/DrawableRoomPlaylistItem.cs | 2 +- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 44981003f2..9c2a435cb0 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -42,6 +42,8 @@ namespace osu.Game.Beatmaps.Drawables private readonly Mod[]? mods; + private readonly bool showTooltip; + private Drawable background = null!; private readonly Container iconContainer; @@ -61,13 +63,15 @@ namespace osu.Game.Beatmaps.Drawables /// Creates a new . Will use provided beatmap's for initial value. /// /// The beatmap to be displayed in the tooltip, and to be used for the initial star rating value. - /// The mods type beat + /// An array of mods to account for in the calculations /// An optional ruleset to be used for the icon display, in place of the beatmap's ruleset. - public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null) + /// Whether to display a tooltip on hover. Defaults to false. + public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null, bool showTooltip = false) : this(ruleset ?? beatmap.Ruleset) { this.beatmap = beatmap; this.mods = mods; + this.showTooltip = showTooltip; Current.Value = new StarDifficulty(beatmap.StarRating, 0); } @@ -134,6 +138,6 @@ namespace osu.Game.Beatmaps.Drawables GetCustomTooltip() => new DifficultyIconTooltip(); DifficultyIconTooltipContent IHasCustomTooltip. - TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods) : null)!; + TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, showTooltip) : null)!; } } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index a4ba2a27f6..c5e276e6b4 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -31,6 +31,9 @@ namespace osu.Game.Beatmaps.Drawables private OsuSpriteText maxCombo; private OsuSpriteText length; + private FillFlowContainer difficultyFillFlowContainer; + private FillFlowContainer miscFillFlowContainer; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -69,21 +72,16 @@ namespace osu.Game.Beatmaps.Drawables Origin = Anchor.Centre, }, // Difficulty stats - new FillFlowContainer + difficultyFillFlowContainer = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Alpha = 0, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(5), Children = new Drawable[] { - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), - }, circleSize = new OsuSpriteText { Anchor = Anchor.Centre, @@ -111,21 +109,16 @@ namespace osu.Game.Beatmaps.Drawables } }, // Misc stats - new FillFlowContainer + miscFillFlowContainer = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Alpha = 0, AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Spacing = new Vector2(5), Children = new Drawable[] { - new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), - }, length = new OsuSpriteText { Anchor = Anchor.Centre, @@ -164,6 +157,13 @@ namespace osu.Game.Beatmaps.Drawables starRating.Current.BindTarget = displayedContent.Difficulty; difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; + // Don't show difficulty stats if showTooltip is false + if (!displayedContent.ShowTooltip) return; + + // Show the difficulty stats if showTooltip is true + difficultyFillFlowContainer.Show(); + miscFillFlowContainer.Show(); + double rate = 1; if (displayedContent.Mods != null) @@ -195,7 +195,7 @@ namespace osu.Game.Beatmaps.Drawables // Misc row length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString("mm\\:ss"); - bpm.Text = " BPM: " + bpmAdjusted; + bpm.Text = " BPM: " + Math.Round(bpmAdjusted, 0); maxCombo.Text = " Max Combo: " + displayedContent.BeatmapInfo.TotalObjectCount; } @@ -212,13 +212,15 @@ namespace osu.Game.Beatmaps.Drawables public readonly IBindable Difficulty; public readonly IRulesetInfo Ruleset; public readonly Mod[] Mods; + public readonly bool ShowTooltip; - public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[] mods) + public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[] mods, bool showTooltip = false) { BeatmapInfo = beatmapInfo; Difficulty = difficulty; Ruleset = rulesetInfo; Mods = mods; + ShowTooltip = showTooltip; } } } diff --git a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs index eb23ed6f8f..2a6387871f 100644 --- a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs +++ b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs @@ -283,7 +283,7 @@ namespace osu.Game.Screens.OnlinePlay } if (beatmap != null) - difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods) { Size = new Vector2(icon_height) }; + difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods, true) { Size = new Vector2(icon_height) }; else difficultyIconContainer.Clear(); From 9a6541356eb32899ffc54bd1db2a151e3db5b42e Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Wed, 17 Jan 2024 13:31:23 -0500 Subject: [PATCH 011/508] Refactor the extended tooltip variables to be more descriptive --- osu.Game/Beatmaps/Drawables/DifficultyIcon.cs | 10 +++++----- osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 9c2a435cb0..7a9b2fe389 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -42,7 +42,7 @@ namespace osu.Game.Beatmaps.Drawables private readonly Mod[]? mods; - private readonly bool showTooltip; + private readonly bool showExtendedTooltip; private Drawable background = null!; @@ -65,13 +65,13 @@ namespace osu.Game.Beatmaps.Drawables /// The beatmap to be displayed in the tooltip, and to be used for the initial star rating value. /// An array of mods to account for in the calculations /// An optional ruleset to be used for the icon display, in place of the beatmap's ruleset. - /// Whether to display a tooltip on hover. Defaults to false. - public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null, bool showTooltip = false) + /// Whether to include the difficulty stats in the tooltip or not. Defaults to false + public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null, bool showExtendedTooltip = false) : this(ruleset ?? beatmap.Ruleset) { this.beatmap = beatmap; this.mods = mods; - this.showTooltip = showTooltip; + this.showExtendedTooltip = showExtendedTooltip; Current.Value = new StarDifficulty(beatmap.StarRating, 0); } @@ -138,6 +138,6 @@ namespace osu.Game.Beatmaps.Drawables GetCustomTooltip() => new DifficultyIconTooltip(); DifficultyIconTooltipContent IHasCustomTooltip. - TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, showTooltip) : null)!; + TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, showExtendedTooltip) : null)!; } } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index c5e276e6b4..fae4100473 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -157,10 +157,10 @@ namespace osu.Game.Beatmaps.Drawables starRating.Current.BindTarget = displayedContent.Difficulty; difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; - // Don't show difficulty stats if showTooltip is false - if (!displayedContent.ShowTooltip) return; + // Don't show difficulty stats if showExtendedTooltip is false + if (!displayedContent.ShowExtendedTooltip) return; - // Show the difficulty stats if showTooltip is true + // Show the difficulty stats if showExtendedTooltip is true difficultyFillFlowContainer.Show(); miscFillFlowContainer.Show(); @@ -212,15 +212,15 @@ namespace osu.Game.Beatmaps.Drawables public readonly IBindable Difficulty; public readonly IRulesetInfo Ruleset; public readonly Mod[] Mods; - public readonly bool ShowTooltip; + public readonly bool ShowExtendedTooltip; - public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[] mods, bool showTooltip = false) + public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[] mods, bool showExtendedTooltip = false) { BeatmapInfo = beatmapInfo; Difficulty = difficulty; Ruleset = rulesetInfo; Mods = mods; - ShowTooltip = showTooltip; + ShowExtendedTooltip = showExtendedTooltip; } } } From 060ea1d4fd82899991eae7b9cdd8468c18dc551c Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Wed, 17 Jan 2024 14:04:13 -0500 Subject: [PATCH 012/508] Switch from using a constructor argument to using a public field for ShowExtendedTooltip --- osu.Game/Beatmaps/Drawables/DifficultyIcon.cs | 13 +++++++------ .../Screens/OnlinePlay/DrawableRoomPlaylistItem.cs | 8 +++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 7a9b2fe389..fc78d6f322 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -36,14 +36,17 @@ namespace osu.Game.Beatmaps.Drawables /// public bool ShowTooltip { get; set; } = true; + /// + /// Whether to include the difficulty stats in the tooltip or not. Defaults to false. Has no effect if is false. + /// + public bool ShowExtendedTooltip { get; set; } + private readonly IBeatmapInfo? beatmap; private readonly IRulesetInfo ruleset; private readonly Mod[]? mods; - private readonly bool showExtendedTooltip; - private Drawable background = null!; private readonly Container iconContainer; @@ -65,13 +68,11 @@ namespace osu.Game.Beatmaps.Drawables /// The beatmap to be displayed in the tooltip, and to be used for the initial star rating value. /// An array of mods to account for in the calculations /// An optional ruleset to be used for the icon display, in place of the beatmap's ruleset. - /// Whether to include the difficulty stats in the tooltip or not. Defaults to false - public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null, bool showExtendedTooltip = false) + public DifficultyIcon(IBeatmapInfo beatmap, IRulesetInfo? ruleset = null, Mod[]? mods = null) : this(ruleset ?? beatmap.Ruleset) { this.beatmap = beatmap; this.mods = mods; - this.showExtendedTooltip = showExtendedTooltip; Current.Value = new StarDifficulty(beatmap.StarRating, 0); } @@ -138,6 +139,6 @@ namespace osu.Game.Beatmaps.Drawables GetCustomTooltip() => new DifficultyIconTooltip(); DifficultyIconTooltipContent IHasCustomTooltip. - TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, showExtendedTooltip) : null)!; + TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, ShowExtendedTooltip) : null)!; } } diff --git a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs index 2a6387871f..8cfdc2e0e2 100644 --- a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs +++ b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs @@ -283,7 +283,13 @@ namespace osu.Game.Screens.OnlinePlay } if (beatmap != null) - difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods, true) { Size = new Vector2(icon_height) }; + { + difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods) + { + Size = new Vector2(icon_height), + ShowExtendedTooltip = true + }; + } else difficultyIconContainer.Clear(); From d80a5d44eedca57e8be969d771152edb4fe4b229 Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Thu, 18 Jan 2024 03:17:37 -0500 Subject: [PATCH 013/508] Add tests for DifficultyIcon --- .../Beatmaps/TestSceneDifficultyIcon.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs new file mode 100644 index 0000000000..aa2543eea1 --- /dev/null +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs @@ -0,0 +1,42 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +#nullable disable + +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Platform; +using osu.Game.Beatmaps.Drawables; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Osu; +using osu.Game.Tests.Beatmaps; + +namespace osu.Game.Tests.Visual.Beatmaps +{ + public partial class TestSceneDifficultyIcon : OsuTestScene + { + [Test] + public void createDifficultyIcon() + { + DifficultyIcon difficultyIcon = null; + + AddStep("create difficulty icon", () => + { + Child = difficultyIcon = new DifficultyIcon(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo, new OsuRuleset().RulesetInfo) + { + ShowTooltip = true, + ShowExtendedTooltip = true + }; + }); + + AddStep("hide extended tooltip", () => difficultyIcon.ShowExtendedTooltip = false); + + AddStep("hide tooltip", () => difficultyIcon.ShowTooltip = false); + + AddStep("show tooltip", () => difficultyIcon.ShowTooltip = true); + + AddStep("show extended tooltip", () => difficultyIcon.ShowExtendedTooltip = true); + } + } +} From 5c70c786b4581d91c5b2d069e04b9d774cf79351 Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Thu, 18 Jan 2024 03:18:44 -0500 Subject: [PATCH 014/508] Fix extended tooltip content still being shown despite ShowExtendedTooltip being false --- osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index fae4100473..fe23b49346 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -158,7 +158,12 @@ namespace osu.Game.Beatmaps.Drawables difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; // Don't show difficulty stats if showExtendedTooltip is false - if (!displayedContent.ShowExtendedTooltip) return; + if (!displayedContent.ShowExtendedTooltip) + { + difficultyFillFlowContainer.Hide(); + miscFillFlowContainer.Hide(); + return; + } // Show the difficulty stats if showExtendedTooltip is true difficultyFillFlowContainer.Show(); From 87369f8a808b29e3da0bde82027a439e763532dc Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:16:03 -0500 Subject: [PATCH 015/508] Conform to code style & remove unused imports --- osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs index aa2543eea1..79f9aec2e3 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs @@ -4,11 +4,7 @@ #nullable disable using NUnit.Framework; -using osu.Framework.Allocation; -using osu.Framework.Audio; -using osu.Framework.Platform; using osu.Game.Beatmaps.Drawables; -using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; using osu.Game.Tests.Beatmaps; @@ -17,7 +13,7 @@ namespace osu.Game.Tests.Visual.Beatmaps public partial class TestSceneDifficultyIcon : OsuTestScene { [Test] - public void createDifficultyIcon() + public void CreateDifficultyIcon() { DifficultyIcon difficultyIcon = null; From f12be60d8d33471fc8acb4ee54c369f4f4e928e8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 22 Jan 2024 17:18:22 +0900 Subject: [PATCH 016/508] Make test actually test multiple icons --- .../Beatmaps/TestSceneDifficultyIcon.cs | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs index 79f9aec2e3..80320c138b 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs @@ -4,27 +4,58 @@ #nullable disable using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Utils; using osu.Game.Beatmaps.Drawables; using osu.Game.Rulesets.Osu; using osu.Game.Tests.Beatmaps; +using osuTK; namespace osu.Game.Tests.Visual.Beatmaps { public partial class TestSceneDifficultyIcon : OsuTestScene { + private FillFlowContainer fill; + + protected override void LoadComplete() + { + base.LoadComplete(); + + Child = fill = new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + Width = 300, + Direction = FillDirection.Full, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; + } + [Test] public void CreateDifficultyIcon() { DifficultyIcon difficultyIcon = null; - AddStep("create difficulty icon", () => + AddRepeatStep("create difficulty icon", () => { - Child = difficultyIcon = new DifficultyIcon(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo, new OsuRuleset().RulesetInfo) + var rulesetInfo = new OsuRuleset().RulesetInfo; + var beatmapInfo = new TestBeatmap(rulesetInfo).BeatmapInfo; + + beatmapInfo.Difficulty.ApproachRate = RNG.Next(0, 10); + beatmapInfo.Difficulty.CircleSize = RNG.Next(0, 10); + beatmapInfo.Difficulty.OverallDifficulty = RNG.Next(0, 10); + beatmapInfo.Difficulty.DrainRate = RNG.Next(0, 10); + beatmapInfo.StarRating = RNG.NextSingle(0, 10); + beatmapInfo.BPM = RNG.Next(60, 300); + + fill.Add(difficultyIcon = new DifficultyIcon(beatmapInfo, rulesetInfo) { + Scale = new Vector2(2), ShowTooltip = true, ShowExtendedTooltip = true - }; - }); + }); + }, 10); AddStep("hide extended tooltip", () => difficultyIcon.ShowExtendedTooltip = false); From 2305a53a02b23185d83a9740ce876350adc711cc Mon Sep 17 00:00:00 2001 From: smallketchup82 <69545310+smallketchup82@users.noreply.github.com> Date: Mon, 22 Jan 2024 08:59:37 -0500 Subject: [PATCH 017/508] Remove max combo reading & remove unnecessary commas --- .../Drawables/DifficultyIconTooltip.cs | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index fe23b49346..7fe0080e89 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -28,7 +28,6 @@ namespace osu.Game.Beatmaps.Drawables private OsuSpriteText circleSize; private OsuSpriteText approachRate; private OsuSpriteText bpm; - private OsuSpriteText maxCombo; private OsuSpriteText length; private FillFlowContainer difficultyFillFlowContainer; @@ -64,12 +63,12 @@ namespace osu.Game.Beatmaps.Drawables { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold), + Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold) }, starRating = new StarRatingDisplay(default, StarRatingDisplaySize.Small) { Anchor = Anchor.Centre, - Origin = Anchor.Centre, + Origin = Anchor.Centre }, // Difficulty stats difficultyFillFlowContainer = new FillFlowContainer @@ -86,26 +85,26 @@ namespace osu.Game.Beatmaps.Drawables { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14), + Font = OsuFont.GetFont(size: 14) }, drainRate = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14), + Font = OsuFont.GetFont(size: 14) }, approachRate = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14), + Font = OsuFont.GetFont(size: 14) }, overallDifficulty = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14), - }, + Font = OsuFont.GetFont(size: 14) + } } }, // Misc stats @@ -123,19 +122,13 @@ namespace osu.Game.Beatmaps.Drawables { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14), + Font = OsuFont.GetFont(size: 14) }, bpm = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14), - }, - maxCombo = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14), + Font = OsuFont.GetFont(size: 14) }, } } @@ -201,7 +194,6 @@ namespace osu.Game.Beatmaps.Drawables // Misc row length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString("mm\\:ss"); bpm.Text = " BPM: " + Math.Round(bpmAdjusted, 0); - maxCombo.Text = " Max Combo: " + displayedContent.BeatmapInfo.TotalObjectCount; } public void Move(Vector2 pos) => Position = pos; From cc341b4119bd9a1aa8cb5aafe936088ff1e0f857 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 Jan 2024 15:21:19 +0900 Subject: [PATCH 018/508] Adjust beatmap carousel padding to avoid scrollbar disappearing underneath logo --- osu.Game/Screens/Select/BeatmapCarousel.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 70ecde3858..32a1b5cb58 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -215,6 +215,12 @@ namespace osu.Game.Screens.Select InternalChild = new OsuContextMenuContainer { RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding + { + // Avoid clash between scrollbar and osu! logo. + Top = 10, + Bottom = 100, + }, Children = new Drawable[] { setPool, From 64ba95bbd664964409224a8f589b473af7d6ca1e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 Jan 2024 21:11:33 +0900 Subject: [PATCH 019/508] Remove pointless comments --- osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index 7fe0080e89..6caaab1508 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -48,7 +48,6 @@ namespace osu.Game.Beatmaps.Drawables Colour = colours.Gray3, RelativeSizeAxes = Axes.Both }, - // Headers new FillFlowContainer { AutoSizeAxes = Axes.Both, @@ -70,7 +69,6 @@ namespace osu.Game.Beatmaps.Drawables Anchor = Anchor.Centre, Origin = Anchor.Centre }, - // Difficulty stats difficultyFillFlowContainer = new FillFlowContainer { Anchor = Anchor.Centre, @@ -107,7 +105,6 @@ namespace osu.Game.Beatmaps.Drawables } } }, - // Misc stats miscFillFlowContainer = new FillFlowContainer { Anchor = Anchor.Centre, @@ -146,11 +143,9 @@ namespace osu.Game.Beatmaps.Drawables displayedContent = content; - // Header row starRating.Current.BindTarget = displayedContent.Difficulty; difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; - // Don't show difficulty stats if showExtendedTooltip is false if (!displayedContent.ShowExtendedTooltip) { difficultyFillFlowContainer.Hide(); @@ -158,7 +153,6 @@ namespace osu.Game.Beatmaps.Drawables return; } - // Show the difficulty stats if showExtendedTooltip is true difficultyFillFlowContainer.Show(); miscFillFlowContainer.Show(); @@ -185,13 +179,11 @@ namespace osu.Game.Beatmaps.Drawables Ruleset ruleset = displayedContent.Ruleset.CreateInstance(); BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); - // Difficulty row circleSize.Text = "CS: " + adjustedDifficulty.CircleSize.ToString("0.##"); drainRate.Text = " HP: " + adjustedDifficulty.DrainRate.ToString("0.##"); approachRate.Text = " AR: " + adjustedDifficulty.ApproachRate.ToString("0.##"); overallDifficulty.Text = " OD: " + adjustedDifficulty.OverallDifficulty.ToString("0.##"); - // Misc row length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString("mm\\:ss"); bpm.Text = " BPM: " + Math.Round(bpmAdjusted, 0); } From 3c18efed0530c362ae363c84f5a5321c7e60eb3e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 Jan 2024 21:13:25 +0900 Subject: [PATCH 020/508] Remove transparency --- osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index 6caaab1508..fa07b150d5 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -44,7 +44,6 @@ namespace osu.Game.Beatmaps.Drawables { new Box { - Alpha = 0.9f, Colour = colours.Gray3, RelativeSizeAxes = Axes.Both }, From aeac0a2a9d83c741b65c81e04ab445061d94324d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 Jan 2024 21:16:12 +0900 Subject: [PATCH 021/508] Nullability --- .../Drawables/DifficultyIconTooltip.cs | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index fa07b150d5..803618f15e 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Linq; using osu.Framework.Allocation; @@ -21,17 +19,17 @@ namespace osu.Game.Beatmaps.Drawables { internal partial class DifficultyIconTooltip : VisibilityContainer, ITooltip { - private OsuSpriteText difficultyName; - private StarRatingDisplay starRating; - private OsuSpriteText overallDifficulty; - private OsuSpriteText drainRate; - private OsuSpriteText circleSize; - private OsuSpriteText approachRate; - private OsuSpriteText bpm; - private OsuSpriteText length; + private OsuSpriteText difficultyName = null!; + private StarRatingDisplay starRating = null!; + private OsuSpriteText overallDifficulty = null!; + private OsuSpriteText drainRate = null!; + private OsuSpriteText circleSize = null!; + private OsuSpriteText approachRate = null!; + private OsuSpriteText bpm = null!; + private OsuSpriteText length = null!; - private FillFlowContainer difficultyFillFlowContainer; - private FillFlowContainer miscFillFlowContainer; + private FillFlowContainer difficultyFillFlowContainer = null!; + private FillFlowContainer miscFillFlowContainer = null!; [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -133,7 +131,7 @@ namespace osu.Game.Beatmaps.Drawables }; } - private DifficultyIconTooltipContent displayedContent; + private DifficultyIconTooltipContent? displayedContent; public void SetContent(DifficultyIconTooltipContent content) { @@ -178,12 +176,12 @@ namespace osu.Game.Beatmaps.Drawables Ruleset ruleset = displayedContent.Ruleset.CreateInstance(); BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); - circleSize.Text = "CS: " + adjustedDifficulty.CircleSize.ToString("0.##"); - drainRate.Text = " HP: " + adjustedDifficulty.DrainRate.ToString("0.##"); - approachRate.Text = " AR: " + adjustedDifficulty.ApproachRate.ToString("0.##"); - overallDifficulty.Text = " OD: " + adjustedDifficulty.OverallDifficulty.ToString("0.##"); + circleSize.Text = @"CS: " + adjustedDifficulty.CircleSize.ToString(@"0.##"); + drainRate.Text = @" HP: " + adjustedDifficulty.DrainRate.ToString(@"0.##"); + approachRate.Text = @" AR: " + adjustedDifficulty.ApproachRate.ToString(@"0.##"); + overallDifficulty.Text = @" OD: " + adjustedDifficulty.OverallDifficulty.ToString(@"0.##"); - length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString("mm\\:ss"); + length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString(@"mm\:ss"); bpm.Text = " BPM: " + Math.Round(bpmAdjusted, 0); } @@ -199,10 +197,10 @@ namespace osu.Game.Beatmaps.Drawables public readonly IBeatmapInfo BeatmapInfo; public readonly IBindable Difficulty; public readonly IRulesetInfo Ruleset; - public readonly Mod[] Mods; + public readonly Mod[]? Mods; public readonly bool ShowExtendedTooltip; - public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[] mods, bool showExtendedTooltip = false) + public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[]? mods, bool showExtendedTooltip = false) { BeatmapInfo = beatmapInfo; Difficulty = difficulty; From 50300adef86222ed1554f512dafe857cf25d2cf3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 Jan 2024 21:17:29 +0900 Subject: [PATCH 022/508] Tidy things up --- .../Drawables/DifficultyIconTooltip.cs | 44 +++---------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index 803618f15e..71366de654 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -76,30 +76,10 @@ namespace osu.Game.Beatmaps.Drawables Spacing = new Vector2(5), Children = new Drawable[] { - circleSize = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14) - }, - drainRate = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14) - }, - approachRate = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14) - }, - overallDifficulty = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14) - } + circleSize = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, + drainRate = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, + approachRate = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, + overallDifficulty = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) } } }, miscFillFlowContainer = new FillFlowContainer @@ -112,18 +92,8 @@ namespace osu.Game.Beatmaps.Drawables Spacing = new Vector2(5), Children = new Drawable[] { - length = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14) - }, - bpm = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 14) - }, + length = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, + bpm = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, } } } @@ -168,9 +138,7 @@ namespace osu.Game.Beatmaps.Drawables if (displayedContent.Mods != null) { foreach (var mod in displayedContent.Mods.OfType()) - { mod.ApplyToDifficulty(originalDifficulty); - } } Ruleset ruleset = displayedContent.Ruleset.CreateInstance(); From 3f9c2b41f7080639d3f4d94097cfeb3238ee503a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 25 Jan 2024 21:28:08 +0900 Subject: [PATCH 023/508] Adjust `BeatSyncContainer`'s early animate offset based on source's rate --- osu.Game/Graphics/Containers/BeatSyncedContainer.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index f911311a09..a14dfd4d64 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -91,7 +91,17 @@ namespace osu.Game.Graphics.Containers if (IsBeatSyncedWithTrack) { - currentTrackTime = BeatSyncSource.Clock.CurrentTime + EarlyActivationMilliseconds; + double early = EarlyActivationMilliseconds; + + // In the case of gameplay, we are usually within a hierarchy with the correct rate applied to our `Drawable.Clock`. + // This means that the amount of early adjustment is adjusted in line with audio track rate changes. + // But other cases like the osu! logo at the main menu won't correctly have this rate information. + // + // So for cases where the rate of the source isn't in sync with our hierarchy, let's assume we need to account for it locally. + if (Clock.Rate == 1 && BeatSyncSource.Clock.Rate != Clock.Rate) + early *= BeatSyncSource.Clock.Rate; + + currentTrackTime = BeatSyncSource.Clock.CurrentTime + early; timingPoint = BeatSyncSource.ControlPoints?.TimingPointAt(currentTrackTime) ?? TimingControlPoint.DEFAULT; effectPoint = BeatSyncSource.ControlPoints?.EffectPointAt(currentTrackTime) ?? EffectControlPoint.DEFAULT; From 5d456c8d68fe61fa6fc97f8db235b0c6d429a55d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 29 Jan 2024 04:55:21 +0300 Subject: [PATCH 024/508] Rework drawing of graded circles --- .../Expanded/Accuracy/AccuracyCircle.cs | 87 +++++++++++-------- 1 file changed, 52 insertions(+), 35 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 0aff98df2b..8d32989110 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -169,46 +169,63 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy { new CircularProgress { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.X), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyX } - }, - new CircularProgress - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.S), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyX - virtual_ss_percentage } - }, - new CircularProgress - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.A), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyS } - }, - new CircularProgress - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.B), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyA } - }, - new CircularProgress - { - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.C), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyB } - }, - new CircularProgress - { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.D), InnerRadius = RANK_CIRCLE_RADIUS, Current = { Value = accuracyC } }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.C), + InnerRadius = RANK_CIRCLE_RADIUS, + Current = { Value = accuracyB - accuracyC }, + Rotation = (float)accuracyC * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.B), + InnerRadius = RANK_CIRCLE_RADIUS, + Current = { Value = accuracyA - accuracyB }, + Rotation = (float)accuracyB * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.A), + InnerRadius = RANK_CIRCLE_RADIUS, + Current = { Value = accuracyS - accuracyA }, + Rotation = (float)accuracyA * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.S), + InnerRadius = RANK_CIRCLE_RADIUS, + Current = { Value = accuracyX - accuracyS - virtual_ss_percentage }, + Rotation = (float)accuracyS * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.X), + InnerRadius = RANK_CIRCLE_RADIUS, + Current = { Value = 1f - (accuracyX - virtual_ss_percentage) }, + Rotation = (float)(accuracyX - virtual_ss_percentage) * 360 + }, new RankNotch((float)accuracyX), new RankNotch((float)(accuracyX - virtual_ss_percentage)), new RankNotch((float)accuracyS), From 32b0e0b7380fcb54219fea66b4f46f2a83ece1e1 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 29 Jan 2024 05:05:18 +0300 Subject: [PATCH 025/508] Remove RankNotch --- .../Expanded/Accuracy/AccuracyCircle.cs | 33 ++++++------- .../Ranking/Expanded/Accuracy/RankNotch.cs | 49 ------------------- 2 files changed, 14 insertions(+), 68 deletions(-) delete mode 100644 osu.Game/Screens/Ranking/Expanded/Accuracy/RankNotch.cs diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 8d32989110..7bd586ebb7 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -76,9 +76,9 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy private const double virtual_ss_percentage = 0.01; /// - /// The width of a in terms of accuracy. + /// The width of a solid "notch" in terms of accuracy that appears at the ends of the rank circles to add separation. /// - public const double NOTCH_WIDTH_PERCENTAGE = 1.0 / 360; + public const float NOTCH_WIDTH_PERCENTAGE = 2f / 360; /// /// The easing for the circle filling transforms. @@ -174,7 +174,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.D), InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyC } + Current = { Value = accuracyC - NOTCH_WIDTH_PERCENTAGE }, + Rotation = NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 }, new CircularProgress { @@ -183,8 +184,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.C), InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyB - accuracyC }, - Rotation = (float)accuracyC * 360 + Current = { Value = accuracyB - accuracyC - NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)accuracyC * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 }, new CircularProgress { @@ -193,8 +194,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.B), InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyA - accuracyB }, - Rotation = (float)accuracyB * 360 + Current = { Value = accuracyA - accuracyB - NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)accuracyB * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 }, new CircularProgress { @@ -203,8 +204,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.A), InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyS - accuracyA }, - Rotation = (float)accuracyA * 360 + Current = { Value = accuracyS - accuracyA - NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)accuracyA * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 }, new CircularProgress { @@ -213,8 +214,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.S), InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyX - accuracyS - virtual_ss_percentage }, - Rotation = (float)accuracyS * 360 + Current = { Value = accuracyX - accuracyS - virtual_ss_percentage - NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)accuracyS * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 }, new CircularProgress { @@ -223,15 +224,9 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.X), InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = 1f - (accuracyX - virtual_ss_percentage) }, - Rotation = (float)(accuracyX - virtual_ss_percentage) * 360 + Current = { Value = 1f - (accuracyX - virtual_ss_percentage) - NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)(accuracyX - virtual_ss_percentage) * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 }, - new RankNotch((float)accuracyX), - new RankNotch((float)(accuracyX - virtual_ss_percentage)), - new RankNotch((float)accuracyS), - new RankNotch((float)accuracyA), - new RankNotch((float)accuracyB), - new RankNotch((float)accuracyC), new BufferedContainer { Name = "Graded circle mask", diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/RankNotch.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/RankNotch.cs deleted file mode 100644 index 244acbe8b1..0000000000 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/RankNotch.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; -using osu.Game.Graphics; -using osuTK; - -namespace osu.Game.Screens.Ranking.Expanded.Accuracy -{ - /// - /// A solid "notch" of the that appears at the ends of the rank circles to add separation. - /// - public partial class RankNotch : CompositeDrawable - { - private readonly float position; - - public RankNotch(float position) - { - this.position = position; - - RelativeSizeAxes = Axes.Both; - } - - [BackgroundDependencyLoader] - private void load() - { - InternalChild = new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Rotation = position * 360f, - Child = new Box - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - RelativeSizeAxes = Axes.Y, - Height = AccuracyCircle.RANK_CIRCLE_RADIUS, - Width = (float)AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 360f, - Colour = OsuColour.Gray(0.3f), - EdgeSmoothness = new Vector2(1f) - } - }; - } - } -} From 5783838b07df8420916904ab307f91b23fb8a6ad Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 29 Jan 2024 05:14:24 +0300 Subject: [PATCH 026/508] Move graded circles into a separate class --- .../Expanded/Accuracy/AccuracyCircle.cs | 105 ++-------------- .../Expanded/Accuracy/GradedCircles.cs | 113 ++++++++++++++++++ 2 files changed, 120 insertions(+), 98 deletions(-) create mode 100644 osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 7bd586ebb7..3141810894 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -20,7 +20,6 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Skinning; -using osuTK; using osuTK.Graphics; namespace osu.Game.Screens.Ranking.Expanded.Accuracy @@ -73,7 +72,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy /// /// SS is displayed as a 1% region, otherwise it would be invisible. /// - private const double virtual_ss_percentage = 0.01; + public const double VIRTUAL_SS_PERCENTAGE = 0.01; /// /// The width of a solid "notch" in terms of accuracy that appears at the ends of the rank circles to add separation. @@ -88,7 +87,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy private readonly ScoreInfo score; private CircularProgress accuracyCircle; - private CircularProgress innerMask; + private GradedCircles gradedCircles; private Container badges; private RankText rankText; @@ -157,96 +156,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = ColourInfo.GradientVertical(Color4Extensions.FromHex("#7CF6FF"), Color4Extensions.FromHex("#BAFFA9")), InnerRadius = accuracy_circle_radius, }, - new BufferedContainer - { - Name = "Graded circles", - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Size = new Vector2(0.8f), - Padding = new MarginPadding(2), - Children = new Drawable[] - { - new CircularProgress - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.D), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyC - NOTCH_WIDTH_PERCENTAGE }, - Rotation = NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 - }, - new CircularProgress - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.C), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyB - accuracyC - NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)accuracyC * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 - }, - new CircularProgress - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.B), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyA - accuracyB - NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)accuracyB * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 - }, - new CircularProgress - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.A), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyS - accuracyA - NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)accuracyA * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 - }, - new CircularProgress - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.S), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = accuracyX - accuracyS - virtual_ss_percentage - NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)accuracyS * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 - }, - new CircularProgress - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.X), - InnerRadius = RANK_CIRCLE_RADIUS, - Current = { Value = 1f - (accuracyX - virtual_ss_percentage) - NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)(accuracyX - virtual_ss_percentage) * 360 + NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 - }, - new BufferedContainer - { - Name = "Graded circle mask", - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding(1), - Blending = new BlendingParameters - { - Source = BlendingType.DstColor, - Destination = BlendingType.OneMinusSrcColor, - SourceAlpha = BlendingType.One, - DestinationAlpha = BlendingType.SrcAlpha - }, - Child = innerMask = new CircularProgress - { - RelativeSizeAxes = Axes.Both, - InnerRadius = RANK_CIRCLE_RADIUS - 0.02f, - } - } - } - }, + gradedCircles = new GradedCircles(accuracyC, accuracyB, accuracyA, accuracyS, accuracyX), badges = new Container { Name = "Rank badges", @@ -259,7 +169,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy new RankBadge(accuracyB, Interpolation.Lerp(accuracyB, accuracyA, 0.5), getRank(ScoreRank.B)), // The S and A badges are moved down slightly to prevent collision with the SS badge. new RankBadge(accuracyA, Interpolation.Lerp(accuracyA, accuracyS, 0.25), getRank(ScoreRank.A)), - new RankBadge(accuracyS, Interpolation.Lerp(accuracyS, (accuracyX - virtual_ss_percentage), 0.25), getRank(ScoreRank.S)), + new RankBadge(accuracyS, Interpolation.Lerp(accuracyS, (accuracyX - VIRTUAL_SS_PERCENTAGE), 0.25), getRank(ScoreRank.S)), new RankBadge(accuracyX, accuracyX, getRank(ScoreRank.X)), } }, @@ -301,8 +211,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy }); } - using (BeginDelayedSequence(RANK_CIRCLE_TRANSFORM_DELAY)) - innerMask.FillTo(1f, RANK_CIRCLE_TRANSFORM_DURATION, ACCURACY_TRANSFORM_EASING); + gradedCircles.Transform(); using (BeginDelayedSequence(ACCURACY_TRANSFORM_DELAY)) { @@ -331,7 +240,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy if (score.Rank == ScoreRank.X || score.Rank == ScoreRank.XH) targetAccuracy = 1; else - targetAccuracy = Math.Min(accuracyX - virtual_ss_percentage - NOTCH_WIDTH_PERCENTAGE / 2, targetAccuracy); + targetAccuracy = Math.Min(accuracyX - VIRTUAL_SS_PERCENTAGE - NOTCH_WIDTH_PERCENTAGE / 2, targetAccuracy); // The accuracy circle gauge visually fills up a bit too much. // This wouldn't normally matter but we want it to align properly with the inner graded circle in the above cases. @@ -368,7 +277,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy if (badge.Accuracy > score.Accuracy) continue; - using (BeginDelayedSequence(inverseEasing(ACCURACY_TRANSFORM_EASING, Math.Min(accuracyX - virtual_ss_percentage, badge.Accuracy) / targetAccuracy) * ACCURACY_TRANSFORM_DURATION)) + using (BeginDelayedSequence(inverseEasing(ACCURACY_TRANSFORM_EASING, Math.Min(accuracyX - VIRTUAL_SS_PERCENTAGE, badge.Accuracy) / targetAccuracy) * ACCURACY_TRANSFORM_DURATION)) { badge.Appear(); diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs new file mode 100644 index 0000000000..51c4237528 --- /dev/null +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -0,0 +1,113 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; +using osu.Game.Scoring; +using osuTK; + +namespace osu.Game.Screens.Ranking.Expanded.Accuracy +{ + public partial class GradedCircles : BufferedContainer + { + private readonly CircularProgress innerMask; + + public GradedCircles(double accuracyC, double accuracyB, double accuracyA, double accuracyS, double accuracyX) + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + RelativeSizeAxes = Axes.Both; + Size = new Vector2(0.8f); + Padding = new MarginPadding(2); + Children = new Drawable[] + { + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.D), + InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, + Current = { Value = accuracyC - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, + Rotation = AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.C), + InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, + Current = { Value = accuracyB - accuracyC - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)accuracyC * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.B), + InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, + Current = { Value = accuracyA - accuracyB - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)accuracyB * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.A), + InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, + Current = { Value = accuracyS - accuracyA - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)accuracyA * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.S), + InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, + Current = { Value = accuracyX - accuracyS - AccuracyCircle.VIRTUAL_SS_PERCENTAGE - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)accuracyS * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + }, + new CircularProgress + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.ForRank(ScoreRank.X), + InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, + Current = { Value = 1f - (accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE) - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, + Rotation = (float)(accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE) * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + }, + new BufferedContainer + { + Name = "Graded circle mask", + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(1), + Blending = new BlendingParameters + { + Source = BlendingType.DstColor, + Destination = BlendingType.OneMinusSrcColor, + SourceAlpha = BlendingType.One, + DestinationAlpha = BlendingType.SrcAlpha + }, + Child = innerMask = new CircularProgress + { + RelativeSizeAxes = Axes.Both, + InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS - 0.02f, + } + } + }; + } + + public void Transform() + { + using (BeginDelayedSequence(AccuracyCircle.RANK_CIRCLE_TRANSFORM_DELAY)) + innerMask.FillTo(1f, AccuracyCircle.RANK_CIRCLE_TRANSFORM_DURATION, AccuracyCircle.ACCURACY_TRANSFORM_EASING); + } + } +} From 9c411ad48d81fa384619a6eb8c49c3e56f760fbc Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 29 Jan 2024 05:19:28 +0300 Subject: [PATCH 027/508] Simplify notch math --- .../Ranking/Expanded/Accuracy/GradedCircles.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs index 51c4237528..5241a4d983 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -31,7 +31,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = OsuColour.ForRank(ScoreRank.D), InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, Current = { Value = accuracyC - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + Rotation = AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 180 }, new CircularProgress { @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = OsuColour.ForRank(ScoreRank.C), InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, Current = { Value = accuracyB - accuracyC - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)accuracyC * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + Rotation = (float)(accuracyC + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, new CircularProgress { @@ -51,7 +51,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = OsuColour.ForRank(ScoreRank.B), InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, Current = { Value = accuracyA - accuracyB - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)accuracyB * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + Rotation = (float)(accuracyB + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, new CircularProgress { @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = OsuColour.ForRank(ScoreRank.A), InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, Current = { Value = accuracyS - accuracyA - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)accuracyA * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + Rotation = (float)(accuracyA + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, new CircularProgress { @@ -71,7 +71,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = OsuColour.ForRank(ScoreRank.S), InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, Current = { Value = accuracyX - accuracyS - AccuracyCircle.VIRTUAL_SS_PERCENTAGE - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)accuracyS * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + Rotation = (float)(accuracyS + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, new CircularProgress { @@ -81,7 +81,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = OsuColour.ForRank(ScoreRank.X), InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, Current = { Value = 1f - (accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE) - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)(accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE) * 360 + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f * 360 + Rotation = (float)(accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, new BufferedContainer { From 809ca81b9ccba45aa1ea29fe4645805b8e32e2e7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 29 Jan 2024 05:29:29 +0300 Subject: [PATCH 028/508] Add TestSceneGradedCircles --- .../Visual/Ranking/TestSceneGradedCircles.cs | 44 +++++++++++++++++++ .../Expanded/Accuracy/GradedCircles.cs | 6 +++ 2 files changed, 50 insertions(+) create mode 100644 osu.Game.Tests/Visual/Ranking/TestSceneGradedCircles.cs diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneGradedCircles.cs b/osu.Game.Tests/Visual/Ranking/TestSceneGradedCircles.cs new file mode 100644 index 0000000000..87fbca5c44 --- /dev/null +++ b/osu.Game.Tests/Visual/Ranking/TestSceneGradedCircles.cs @@ -0,0 +1,44 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Game.Rulesets.Osu; +using osu.Game.Rulesets.Scoring; +using osu.Game.Scoring; +using osu.Game.Screens.Ranking.Expanded.Accuracy; +using osuTK; + +namespace osu.Game.Tests.Visual.Ranking +{ + public partial class TestSceneGradedCircles : OsuTestScene + { + private readonly GradedCircles ring; + + public TestSceneGradedCircles() + { + ScoreProcessor scoreProcessor = new OsuRuleset().CreateScoreProcessor(); + double accuracyX = scoreProcessor.AccuracyCutoffFromRank(ScoreRank.X); + double accuracyS = scoreProcessor.AccuracyCutoffFromRank(ScoreRank.S); + + double accuracyA = scoreProcessor.AccuracyCutoffFromRank(ScoreRank.A); + double accuracyB = scoreProcessor.AccuracyCutoffFromRank(ScoreRank.B); + double accuracyC = scoreProcessor.AccuracyCutoffFromRank(ScoreRank.C); + + Add(new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(400), + Child = ring = new GradedCircles(accuracyC, accuracyB, accuracyA, accuracyS, accuracyX) + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + AddSliderStep("Progress", 0.0, 1.0, 1.0, p => ring.Progress = p); + } + } +} diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs index 5241a4d983..2ce8c511e0 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -12,6 +12,12 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy { public partial class GradedCircles : BufferedContainer { + public double Progress + { + get => innerMask.Current.Value; + set => innerMask.Current.Value = value; + } + private readonly CircularProgress innerMask; public GradedCircles(double accuracyC, double accuracyB, double accuracyA, double accuracyS, double accuracyX) From 3987faa21cc80c39b42f465d1ef3f3046e235843 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 29 Jan 2024 06:13:52 +0300 Subject: [PATCH 029/508] Rework GradedCircles to not use BufferedContainer --- .../Expanded/Accuracy/AccuracyCircle.cs | 5 +- .../Expanded/Accuracy/GradedCircles.cs | 118 ++++++++---------- 2 files changed, 52 insertions(+), 71 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 3141810894..5b929554ff 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -77,7 +77,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy /// /// The width of a solid "notch" in terms of accuracy that appears at the ends of the rank circles to add separation. /// - public const float NOTCH_WIDTH_PERCENTAGE = 2f / 360; + public const double NOTCH_WIDTH_PERCENTAGE = 2.0 / 360; /// /// The easing for the circle filling transforms. @@ -211,7 +211,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy }); } - gradedCircles.Transform(); + using (BeginDelayedSequence(RANK_CIRCLE_TRANSFORM_DELAY)) + gradedCircles.TransformTo(nameof(GradedCircles.Progress), 1.0, RANK_CIRCLE_TRANSFORM_DURATION, ACCURACY_TRANSFORM_EASING); using (BeginDelayedSequence(ACCURACY_TRANSFORM_DELAY)) { diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs index 2ce8c511e0..19c7a9b606 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; @@ -10,15 +11,31 @@ using osuTK; namespace osu.Game.Screens.Ranking.Expanded.Accuracy { - public partial class GradedCircles : BufferedContainer + public partial class GradedCircles : CompositeDrawable { + private double progress; + public double Progress { - get => innerMask.Current.Value; - set => innerMask.Current.Value = value; + get => progress; + set + { + progress = value; + dProgress.RevealProgress = value; + cProgress.RevealProgress = value; + bProgress.RevealProgress = value; + aProgress.RevealProgress = value; + sProgress.RevealProgress = value; + xProgress.RevealProgress = value; + } } - private readonly CircularProgress innerMask; + private readonly GradedCircle dProgress; + private readonly GradedCircle cProgress; + private readonly GradedCircle bProgress; + private readonly GradedCircle aProgress; + private readonly GradedCircle sProgress; + private readonly GradedCircle xProgress; public GradedCircles(double accuracyC, double accuracyB, double accuracyA, double accuracyS, double accuracyX) { @@ -27,93 +44,56 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy RelativeSizeAxes = Axes.Both; Size = new Vector2(0.8f); Padding = new MarginPadding(2); - Children = new Drawable[] + InternalChildren = new Drawable[] { - new CircularProgress + dProgress = new GradedCircle(0.0, accuracyC) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.D), - InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, - Current = { Value = accuracyC - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 180 }, - new CircularProgress + cProgress = new GradedCircle(accuracyC, accuracyB) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.C), - InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, - Current = { Value = accuracyB - accuracyC - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)(accuracyC + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, - new CircularProgress + bProgress = new GradedCircle(accuracyB, accuracyA) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.B), - InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, - Current = { Value = accuracyA - accuracyB - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)(accuracyB + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, - new CircularProgress + aProgress = new GradedCircle(accuracyA, accuracyS) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.A), - InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, - Current = { Value = accuracyS - accuracyA - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)(accuracyA + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, - new CircularProgress + sProgress = new GradedCircle(accuracyS, accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, Colour = OsuColour.ForRank(ScoreRank.S), - InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, - Current = { Value = accuracyX - accuracyS - AccuracyCircle.VIRTUAL_SS_PERCENTAGE - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)(accuracyS + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 }, - new CircularProgress + xProgress = new GradedCircle(accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE, 1.0) { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.Both, - Colour = OsuColour.ForRank(ScoreRank.X), - InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS, - Current = { Value = 1f - (accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE) - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE }, - Rotation = (float)(accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5f) * 360 - }, - new BufferedContainer - { - Name = "Graded circle mask", - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding(1), - Blending = new BlendingParameters - { - Source = BlendingType.DstColor, - Destination = BlendingType.OneMinusSrcColor, - SourceAlpha = BlendingType.One, - DestinationAlpha = BlendingType.SrcAlpha - }, - Child = innerMask = new CircularProgress - { - RelativeSizeAxes = Axes.Both, - InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS - 0.02f, - } + Colour = OsuColour.ForRank(ScoreRank.X) } }; } - public void Transform() + private partial class GradedCircle : CircularProgress { - using (BeginDelayedSequence(AccuracyCircle.RANK_CIRCLE_TRANSFORM_DELAY)) - innerMask.FillTo(1f, AccuracyCircle.RANK_CIRCLE_TRANSFORM_DURATION, AccuracyCircle.ACCURACY_TRANSFORM_EASING); + public double RevealProgress + { + set => Current.Value = Math.Clamp(value, startProgress, endProgress) - startProgress; + } + + private readonly double startProgress; + private readonly double endProgress; + + public GradedCircle(double startProgress, double endProgress) + { + this.startProgress = startProgress + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5; + this.endProgress = endProgress - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5; + + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + RelativeSizeAxes = Axes.Both; + InnerRadius = AccuracyCircle.RANK_CIRCLE_RADIUS; + Rotation = (float)this.startProgress * 360; + } } } } From 0c0ba7abefe04e16f3d153964f7fe8f139ba2373 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 29 Jan 2024 06:28:38 +0300 Subject: [PATCH 030/508] Adjust values to visually match previous --- osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs | 2 +- osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 5b929554ff..8304e7a542 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy /// /// Relative width of the rank circles. /// - public const float RANK_CIRCLE_RADIUS = 0.06f; + public const float RANK_CIRCLE_RADIUS = 0.05f; /// /// Relative width of the circle showing the accuracy. diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs index 19c7a9b606..efcb848530 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Origin = Anchor.Centre; RelativeSizeAxes = Axes.Both; Size = new Vector2(0.8f); - Padding = new MarginPadding(2); + Padding = new MarginPadding(2.5f); InternalChildren = new Drawable[] { dProgress = new GradedCircle(0.0, accuracyC) From 5a1b0004db37148191ccbc349b8bd6fe4ca9e502 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 2 Feb 2024 01:17:28 +0300 Subject: [PATCH 031/508] Add failing test case --- .../Visual/Gameplay/TestScenePlayerLoader.cs | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index f97372e9b6..b2e607d9a3 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -24,9 +24,11 @@ using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; +using osu.Game.Screens.Menu; using osu.Game.Screens.Play; using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Utils; +using osuTK; using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay @@ -53,6 +55,9 @@ namespace osu.Game.Tests.Visual.Gameplay [Cached] private readonly VolumeOverlay volumeOverlay; + [Cached] + private readonly OsuLogo logo; + [Cached(typeof(BatteryInfo))] private readonly LocalBatteryInfo batteryInfo = new LocalBatteryInfo(); @@ -76,7 +81,14 @@ namespace osu.Game.Tests.Visual.Gameplay Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, }, - changelogOverlay = new ChangelogOverlay() + changelogOverlay = new ChangelogOverlay(), + logo = new OsuLogo + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Scale = new Vector2(0.5f), + Position = new Vector2(128f), + }, }); } @@ -204,6 +216,36 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("loads after idle", () => !loader.IsCurrentScreen()); } + [Test] + public void TestLoadNotBlockedOnOsuLogo() + { + AddStep("load dummy beatmap", () => resetPlayer(false)); + AddUntilStep("wait for current", () => loader.IsCurrentScreen()); + + AddUntilStep("wait for load ready", () => + { + moveMouse(); + return player?.LoadState == LoadState.Ready; + }); + + // move mouse in logo while waiting for load to still proceed (it shouldn't be blocked when hovering logo). + AddUntilStep("move mouse in logo", () => + { + moveMouse(); + return !loader.IsCurrentScreen(); + }); + + void moveMouse() + { + notificationOverlay.State.Value = Visibility.Hidden; + + InputManager.MoveMouseTo( + logo.ScreenSpaceDrawQuad.TopLeft + + (logo.ScreenSpaceDrawQuad.BottomRight - logo.ScreenSpaceDrawQuad.TopLeft) + * RNG.NextSingle(0.3f, 0.7f)); + } + } + [Test] public void TestLoadContinuation() { From 0502997ae958e0697fcdbcad2555e80c52b6a22d Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 2 Feb 2024 01:02:13 +0300 Subject: [PATCH 032/508] Stop blocking player loader when hovering over osu! logo --- osu.Game/Screens/Play/PlayerLoader.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 232de53ac3..201511529e 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -106,8 +106,8 @@ namespace osu.Game.Screens.Play && ReadyForGameplay; protected virtual bool ReadyForGameplay => - // not ready if the user is hovering one of the panes, unless they are idle. - (IsHovered || idleTracker.IsIdle.Value) + // not ready if the user is hovering one of the panes (logo is excluded), unless they are idle. + (IsHovered || osuLogo?.IsHovered == true || idleTracker.IsIdle.Value) // not ready if the user is dragging a slider or otherwise. && inputManager.DraggedDrawable == null // not ready if a focused overlay is visible, like settings. @@ -306,10 +306,14 @@ namespace osu.Game.Screens.Play return base.OnExiting(e); } + private OsuLogo? osuLogo; + protected override void LogoArriving(OsuLogo logo, bool resuming) { base.LogoArriving(logo, resuming); + osuLogo = logo; + const double duration = 300; if (!resuming) logo.MoveTo(new Vector2(0.5f), duration, Easing.OutQuint); @@ -328,6 +332,7 @@ namespace osu.Game.Screens.Play { base.LogoExiting(logo); content.StopTracking(); + osuLogo = null; } protected override void LogoSuspending(OsuLogo logo) @@ -338,6 +343,8 @@ namespace osu.Game.Screens.Play logo .FadeOut(CONTENT_OUT_DURATION / 2, Easing.OutQuint) .ScaleTo(logo.Scale * 0.8f, CONTENT_OUT_DURATION * 2, Easing.OutQuint); + + osuLogo = null; } #endregion From 498d93be614cfd9057ca9c3af0ff63f4c581b3f2 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sat, 3 Feb 2024 16:59:48 +0100 Subject: [PATCH 033/508] Add way to associate with files and URIs on Windows --- .../TestSceneWindowsAssociationManager.cs | 106 +++++++ .../WindowsAssociationManagerStrings.cs | 39 +++ osu.Game/Updater/WindowsAssociationManager.cs | 268 ++++++++++++++++++ osu.sln.DotSettings | 1 + 4 files changed, 414 insertions(+) create mode 100644 osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs create mode 100644 osu.Game/Localisation/WindowsAssociationManagerStrings.cs create mode 100644 osu.Game/Updater/WindowsAssociationManager.cs diff --git a/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs b/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs new file mode 100644 index 0000000000..72256860fd --- /dev/null +++ b/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs @@ -0,0 +1,106 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.Versioning; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; +using osu.Framework.Platform; +using osu.Game.Graphics.Sprites; +using osu.Game.Tests.Resources; +using osu.Game.Updater; + +namespace osu.Game.Tests.Visual.Updater +{ + [SupportedOSPlatform("windows")] + [Ignore("These tests modify the windows registry and open programs")] + public partial class TestSceneWindowsAssociationManager : OsuTestScene + { + private static readonly string exe_path = Path.ChangeExtension(typeof(TestSceneWindowsAssociationManager).Assembly.Location, ".exe"); + + [Resolved] + private GameHost host { get; set; } = null!; + + private readonly WindowsAssociationManager associationManager; + + public TestSceneWindowsAssociationManager() + { + Children = new Drawable[] + { + new OsuSpriteText { Text = Environment.CommandLine }, + associationManager = new WindowsAssociationManager(exe_path, "osu.Test"), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + if (Environment.CommandLine.Contains(".osz", StringComparison.Ordinal)) + ChangeBackgroundColour(ColourInfo.SingleColour(Colour4.DarkOliveGreen)); + + if (Environment.CommandLine.Contains("osu://", StringComparison.Ordinal)) + ChangeBackgroundColour(ColourInfo.SingleColour(Colour4.DarkBlue)); + + if (Environment.CommandLine.Contains("osump://", StringComparison.Ordinal)) + ChangeBackgroundColour(ColourInfo.SingleColour(Colour4.DarkRed)); + } + + [Test] + public void TestInstall() + { + AddStep("install", () => associationManager.InstallAssociations()); + } + + [Test] + public void TestOpenBeatmap() + { + string beatmapPath = null!; + AddStep("create temp beatmap", () => beatmapPath = TestResources.GetTestBeatmapForImport()); + AddAssert("beatmap path ends with .osz", () => beatmapPath, () => Does.EndWith(".osz")); + AddStep("open beatmap", () => host.OpenFileExternally(beatmapPath)); + AddUntilStep("wait for focus", () => host.IsActive.Value); + AddStep("delete temp beatmap", () => File.Delete(beatmapPath)); + } + + /// + /// To check that the icon is correct + /// + [Test] + public void TestPresentBeatmap() + { + string beatmapPath = null!; + AddStep("create temp beatmap", () => beatmapPath = TestResources.GetTestBeatmapForImport()); + AddAssert("beatmap path ends with .osz", () => beatmapPath, () => Does.EndWith(".osz")); + AddStep("show beatmap in explorer", () => host.PresentFileExternally(beatmapPath)); + AddUntilStep("wait for focus", () => host.IsActive.Value); + AddStep("delete temp beatmap", () => File.Delete(beatmapPath)); + } + + [TestCase("osu://s/1")] + [TestCase("osump://123")] + public void TestUrl(string url) + { + AddStep($"open {url}", () => Process.Start(new ProcessStartInfo(url) { UseShellExecute = true })); + } + + [Test] + public void TestUninstall() + { + AddStep("uninstall", () => associationManager.UninstallAssociations()); + } + + /// + /// Useful when testing things out and manually changing the registry. + /// + [Test] + public void TestNotifyShell() + { + AddStep("notify shell of changes", () => associationManager.NotifyShellUpdate()); + } + } +} diff --git a/osu.Game/Localisation/WindowsAssociationManagerStrings.cs b/osu.Game/Localisation/WindowsAssociationManagerStrings.cs new file mode 100644 index 0000000000..95a6decdd6 --- /dev/null +++ b/osu.Game/Localisation/WindowsAssociationManagerStrings.cs @@ -0,0 +1,39 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Localisation; + +namespace osu.Game.Localisation +{ + public static class WindowsAssociationManagerStrings + { + private const string prefix = @"osu.Game.Resources.Localisation.WindowsAssociationManager"; + + /// + /// "osu! Beatmap" + /// + public static LocalisableString OsuBeatmap => new TranslatableString(getKey(@"osu_beatmap"), @"osu! Beatmap"); + + /// + /// "osu! Replay" + /// + public static LocalisableString OsuReplay => new TranslatableString(getKey(@"osu_replay"), @"osu! Replay"); + + /// + /// "osu! Skin" + /// + public static LocalisableString OsuSkin => new TranslatableString(getKey(@"osu_skin"), @"osu! Skin"); + + /// + /// "osu!" + /// + public static LocalisableString OsuProtocol => new TranslatableString(getKey(@"osu_protocol"), @"osu!"); + + /// + /// "osu! Multiplayer" + /// + public static LocalisableString OsuMultiplayer => new TranslatableString(getKey(@"osu_multiplayer"), @"osu! Multiplayer"); + + private static string getKey(string key) => $@"{prefix}:{key}"; + } +} \ No newline at end of file diff --git a/osu.Game/Updater/WindowsAssociationManager.cs b/osu.Game/Updater/WindowsAssociationManager.cs new file mode 100644 index 0000000000..8949d88362 --- /dev/null +++ b/osu.Game/Updater/WindowsAssociationManager.cs @@ -0,0 +1,268 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; +using Microsoft.Win32; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Localisation; +using osu.Framework.Logging; +using osu.Game.Resources.Icons; +using osu.Game.Localisation; + +namespace osu.Game.Updater +{ + [SupportedOSPlatform("windows")] + public partial class WindowsAssociationManager : Component + { + public const string SOFTWARE_CLASSES = @"Software\Classes"; + + /// + /// Sub key for setting the icon. + /// https://learn.microsoft.com/en-us/windows/win32/com/defaulticon + /// + public const string DEFAULT_ICON = @"DefaultIcon"; + + /// + /// Sub key for setting the command line that the shell invokes. + /// https://learn.microsoft.com/en-us/windows/win32/com/shell + /// + public const string SHELL_OPEN_COMMAND = @"Shell\Open\Command"; + + private static readonly FileAssociation[] file_associations = + { + new FileAssociation(@".osz", WindowsAssociationManagerStrings.OsuBeatmap, Icons.Lazer), + new FileAssociation(@".olz", WindowsAssociationManagerStrings.OsuBeatmap, Icons.Lazer), + new FileAssociation(@".osr", WindowsAssociationManagerStrings.OsuReplay, Icons.Lazer), + new FileAssociation(@".osk", WindowsAssociationManagerStrings.OsuSkin, Icons.Lazer), + }; + + private static readonly UriAssociation[] uri_associations = + { + new UriAssociation(@"osu", WindowsAssociationManagerStrings.OsuProtocol, Icons.Lazer), + new UriAssociation(@"osump", WindowsAssociationManagerStrings.OsuMultiplayer, Icons.Lazer), + }; + + [Resolved] + private LocalisationManager localisation { get; set; } = null!; + + private IBindable localisationParameters = null!; + + private readonly string exePath; + private readonly string programIdPrefix; + + /// Path to the executable to register. + /// + /// Program ID prefix used for file associations. Should be relatively short since the full program ID has a 39 character limit, + /// see https://learn.microsoft.com/en-us/windows/win32/com/-progid--key. + /// + public WindowsAssociationManager(string exePath, string programIdPrefix) + { + this.exePath = exePath; + this.programIdPrefix = programIdPrefix; + } + + [BackgroundDependencyLoader] + private void load() + { + localisationParameters = localisation.CurrentParameters.GetBoundCopy(); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + localisationParameters.ValueChanged += _ => updateDescriptions(); + } + + internal void InstallAssociations() + { + try + { + using (var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, writable: true)) + { + if (classes == null) + return; + + foreach (var association in file_associations) + association.Install(classes, exePath, programIdPrefix); + + foreach (var association in uri_associations) + association.Install(classes, exePath); + } + + updateDescriptions(); + } + catch (Exception e) + { + Logger.Log(@$"Failed to install file and URI associations: {e.Message}"); + } + } + + private void updateDescriptions() + { + try + { + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) + return; + + foreach (var association in file_associations) + { + var b = localisation.GetLocalisedBindableString(association.Description); + association.UpdateDescription(classes, programIdPrefix, b.Value); + b.UnbindAll(); + } + + foreach (var association in uri_associations) + { + var b = localisation.GetLocalisedBindableString(association.Description); + association.UpdateDescription(classes, b.Value); + b.UnbindAll(); + } + + NotifyShellUpdate(); + } + catch (Exception e) + { + Logger.Log($@"Failed to update file and URI associations: {e.Message}"); + } + } + + internal void UninstallAssociations() + { + try + { + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) + return; + + foreach (var association in file_associations) + association.Uninstall(classes, programIdPrefix); + + foreach (var association in uri_associations) + association.Uninstall(classes); + + NotifyShellUpdate(); + } + catch (Exception e) + { + Logger.Log($@"Failed to uninstall file and URI associations: {e.Message}"); + } + } + + internal void NotifyShellUpdate() => SHChangeNotify(EventId.SHCNE_ASSOCCHANGED, Flags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); + + #region Native interop + + [DllImport("Shell32.dll")] + private static extern void SHChangeNotify(EventId wEventId, Flags uFlags, IntPtr dwItem1, IntPtr dwItem2); + + private enum EventId + { + /// + /// A file type association has changed. must be specified in the uFlags parameter. + /// dwItem1 and dwItem2 are not used and must be . This event should also be sent for registered protocols. + /// + SHCNE_ASSOCCHANGED = 0x08000000 + } + + private enum Flags : uint + { + SHCNF_IDLIST = 0x0000 + } + + #endregion + + private record FileAssociation(string Extension, LocalisableString Description, Win32Icon Icon) + { + private string getProgramId(string prefix) => $@"{prefix}.File{Extension}"; + + /// + /// Installs a file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/com/-progid--key + /// + public void Install(RegistryKey classes, string exePath, string programIdPrefix) + { + string programId = getProgramId(programIdPrefix); + + // register a program id for the given extension + using (var programKey = classes.CreateSubKey(programId)) + { + using (var defaultIconKey = programKey.CreateSubKey(DEFAULT_ICON)) + defaultIconKey.SetValue(null, Icon.RegistryString); + + using (var openCommandKey = programKey.CreateSubKey(SHELL_OPEN_COMMAND)) + openCommandKey.SetValue(null, $@"""{exePath}"" ""%1"""); + } + + using (var extensionKey = classes.CreateSubKey(Extension)) + { + // set ourselves as the default program + extensionKey.SetValue(null, programId); + + // add to the open with dialog + // https://learn.microsoft.com/en-us/windows/win32/shell/how-to-include-an-application-on-the-open-with-dialog-box + using (var openWithKey = extensionKey.CreateSubKey(@"OpenWithProgIds")) + openWithKey.SetValue(programId, string.Empty); + } + } + + public void UpdateDescription(RegistryKey classes, string programIdPrefix, string description) + { + using (var programKey = classes.OpenSubKey(getProgramId(programIdPrefix), true)) + programKey?.SetValue(null, description); + } + + public void Uninstall(RegistryKey classes, string programIdPrefix) + { + string programId = getProgramId(programIdPrefix); + + // importantly, we don't delete the default program entry because some other program could have taken it. + + using (var extensionKey = classes.OpenSubKey($@"{Extension}\OpenWithProgIds", true)) + extensionKey?.DeleteValue(programId, throwOnMissingValue: false); + + classes.DeleteSubKeyTree(programId, throwOnMissingSubKey: false); + } + } + + private record UriAssociation(string Protocol, LocalisableString Description, Win32Icon Icon) + { + /// + /// "The URL Protocol string value indicates that this key declares a custom pluggable protocol handler." + /// See https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85). + /// + public const string URL_PROTOCOL = @"URL Protocol"; + + /// + /// Registers an URI protocol handler in accordance with https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85). + /// + public void Install(RegistryKey classes, string exePath) + { + using (var protocolKey = classes.CreateSubKey(Protocol)) + { + protocolKey.SetValue(URL_PROTOCOL, string.Empty); + + using (var defaultIconKey = protocolKey.CreateSubKey(DEFAULT_ICON)) + defaultIconKey.SetValue(null, Icon.RegistryString); + + using (var openCommandKey = protocolKey.CreateSubKey(SHELL_OPEN_COMMAND)) + openCommandKey.SetValue(null, $@"""{exePath}"" ""%1"""); + } + } + + public void UpdateDescription(RegistryKey classes, string description) + { + using (var protocolKey = classes.OpenSubKey(Protocol, true)) + protocolKey?.SetValue(null, $@"URL:{description}"); + } + + public void Uninstall(RegistryKey classes) + { + classes.DeleteSubKeyTree(Protocol, throwOnMissingSubKey: false); + } + } + } +} diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 1bf8aa7b0b..e2e28c38ec 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -1005,6 +1005,7 @@ private void load() True True True + True True True True From 03578821c0c2c9fc4b4832208e7c10751f8b28af Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sat, 3 Feb 2024 17:04:06 +0100 Subject: [PATCH 034/508] Associate on startup --- osu.Desktop/OsuGameDesktop.cs | 7 ++++++- osu.Game/Updater/WindowsAssociationManager.cs | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index a0db896f46..a048deddb3 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -134,9 +134,14 @@ namespace osu.Desktop LoadComponentAsync(new DiscordRichPresence(), Add); - if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows) + if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows && OperatingSystem.IsWindows()) + { LoadComponentAsync(new GameplayWinKeyBlocker(), Add); + string? executableLocation = Path.GetDirectoryName(typeof(OsuGameDesktop).Assembly.Location); + LoadComponentAsync(new WindowsAssociationManager(Path.Join(executableLocation, @"osu!.exe"), "osu"), Add); + } + LoadComponentAsync(new ElevatedPrivilegesChecker(), Add); osuSchemeLinkIPCChannel = new OsuSchemeLinkIPCChannel(Host, this); diff --git a/osu.Game/Updater/WindowsAssociationManager.cs b/osu.Game/Updater/WindowsAssociationManager.cs index 8949d88362..104406c81b 100644 --- a/osu.Game/Updater/WindowsAssociationManager.cs +++ b/osu.Game/Updater/WindowsAssociationManager.cs @@ -69,6 +69,7 @@ namespace osu.Game.Updater private void load() { localisationParameters = localisation.CurrentParameters.GetBoundCopy(); + InstallAssociations(); } protected override void LoadComplete() From 2bac09ee00d1e809e38aca97350e4853b2ebf09f Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sat, 3 Feb 2024 17:23:59 +0100 Subject: [PATCH 035/508] Only associate on a deployed build Helps to reduce clutter when developing --- osu.Desktop/OsuGameDesktop.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index a048deddb3..c5175fd549 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -134,10 +134,11 @@ namespace osu.Desktop LoadComponentAsync(new DiscordRichPresence(), Add); - if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows && OperatingSystem.IsWindows()) - { + if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows) LoadComponentAsync(new GameplayWinKeyBlocker(), Add); + if (OperatingSystem.IsWindows() && IsDeployedBuild) + { string? executableLocation = Path.GetDirectoryName(typeof(OsuGameDesktop).Assembly.Location); LoadComponentAsync(new WindowsAssociationManager(Path.Join(executableLocation, @"osu!.exe"), "osu"), Add); } From cdcf5bddda5c15c518a810af6b68b06ab214ee52 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sat, 3 Feb 2024 17:56:14 +0100 Subject: [PATCH 036/508] Uninstall associations when uninstalling from squirrel --- osu.Desktop/Program.cs | 2 ++ .../Visual/Updater/TestSceneWindowsAssociationManager.cs | 2 +- osu.Game/Updater/WindowsAssociationManager.cs | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index a7453dc0e0..c9ce5ebf1b 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -12,6 +12,7 @@ using osu.Framework.Platform; using osu.Game; using osu.Game.IPC; using osu.Game.Tournament; +using osu.Game.Updater; using SDL2; using Squirrel; @@ -180,6 +181,7 @@ namespace osu.Desktop { tools.RemoveShortcutForThisExe(); tools.RemoveUninstallerRegistryEntry(); + WindowsAssociationManager.UninstallAssociations(@"osu"); }, onEveryRun: (_, _, _) => { // While setting the `ProcessAppUserModelId` fixes duplicate icons/shortcuts on the taskbar, it currently diff --git a/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs b/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs index 72256860fd..f3eb468334 100644 --- a/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs +++ b/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs @@ -100,7 +100,7 @@ namespace osu.Game.Tests.Visual.Updater [Test] public void TestNotifyShell() { - AddStep("notify shell of changes", () => associationManager.NotifyShellUpdate()); + AddStep("notify shell of changes", WindowsAssociationManager.NotifyShellUpdate); } } } diff --git a/osu.Game/Updater/WindowsAssociationManager.cs b/osu.Game/Updater/WindowsAssociationManager.cs index 104406c81b..bb0e37a2f4 100644 --- a/osu.Game/Updater/WindowsAssociationManager.cs +++ b/osu.Game/Updater/WindowsAssociationManager.cs @@ -78,7 +78,7 @@ namespace osu.Game.Updater localisationParameters.ValueChanged += _ => updateDescriptions(); } - internal void InstallAssociations() + public void InstallAssociations() { try { @@ -132,7 +132,9 @@ namespace osu.Game.Updater } } - internal void UninstallAssociations() + public void UninstallAssociations() => UninstallAssociations(programIdPrefix); + + public static void UninstallAssociations(string programIdPrefix) { try { @@ -154,7 +156,7 @@ namespace osu.Game.Updater } } - internal void NotifyShellUpdate() => SHChangeNotify(EventId.SHCNE_ASSOCCHANGED, Flags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); + internal static void NotifyShellUpdate() => SHChangeNotify(EventId.SHCNE_ASSOCCHANGED, Flags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); #region Native interop From 397def9ceb543ca7e6d0ada77bfde9558dae286d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 4 Feb 2024 02:58:15 +0300 Subject: [PATCH 037/508] Move layout specification outside the GradedCircles class --- .../Visual/Ranking/TestSceneGradedCircles.cs | 6 ++---- .../Ranking/Expanded/Accuracy/AccuracyCircle.cs | 14 +++++++++++++- .../Ranking/Expanded/Accuracy/GradedCircles.cs | 6 ------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneGradedCircles.cs b/osu.Game.Tests/Visual/Ranking/TestSceneGradedCircles.cs index 87fbca5c44..116386b4b5 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneGradedCircles.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneGradedCircles.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; @@ -25,12 +24,11 @@ namespace osu.Game.Tests.Visual.Ranking double accuracyB = scoreProcessor.AccuracyCutoffFromRank(ScoreRank.B); double accuracyC = scoreProcessor.AccuracyCutoffFromRank(ScoreRank.C); - Add(new Container + Add(ring = new GradedCircles(accuracyC, accuracyB, accuracyA, accuracyS, accuracyX) { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Size = new Vector2(400), - Child = ring = new GradedCircles(accuracyC, accuracyB, accuracyA, accuracyS, accuracyX) + Size = new Vector2(400) }); } diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 8304e7a542..8dc1a48f40 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -20,6 +20,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Skinning; +using osuTK; using osuTK.Graphics; namespace osu.Game.Screens.Ranking.Expanded.Accuracy @@ -156,7 +157,18 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = ColourInfo.GradientVertical(Color4Extensions.FromHex("#7CF6FF"), Color4Extensions.FromHex("#BAFFA9")), InnerRadius = accuracy_circle_radius, }, - gradedCircles = new GradedCircles(accuracyC, accuracyB, accuracyA, accuracyS, accuracyX), + new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Size = new Vector2(0.8f), + Padding = new MarginPadding(2.5f), + Child = gradedCircles = new GradedCircles(accuracyC, accuracyB, accuracyA, accuracyS, accuracyX) + { + RelativeSizeAxes = Axes.Both + } + }, badges = new Container { Name = "Rank badges", diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs index efcb848530..e60a24a310 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Scoring; -using osuTK; namespace osu.Game.Screens.Ranking.Expanded.Accuracy { @@ -39,11 +38,6 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy public GradedCircles(double accuracyC, double accuracyB, double accuracyA, double accuracyS, double accuracyX) { - Anchor = Anchor.Centre; - Origin = Anchor.Centre; - RelativeSizeAxes = Axes.Both; - Size = new Vector2(0.8f); - Padding = new MarginPadding(2.5f); InternalChildren = new Drawable[] { dProgress = new GradedCircle(0.0, accuracyC) From 4e5c9ddbfe6afad4713e9705cf4b28cd32cfd764 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 4 Feb 2024 03:02:39 +0300 Subject: [PATCH 038/508] Rename notch const to spacing --- .../Ranking/Expanded/Accuracy/AccuracyCircle.cs | 12 ++++++------ .../Ranking/Expanded/Accuracy/GradedCircles.cs | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 8dc1a48f40..7edfc00760 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -76,9 +76,9 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy public const double VIRTUAL_SS_PERCENTAGE = 0.01; /// - /// The width of a solid "notch" in terms of accuracy that appears at the ends of the rank circles to add separation. + /// The width of spacing in terms of accuracy between the grade circles. /// - public const double NOTCH_WIDTH_PERCENTAGE = 2.0 / 360; + public const double GRADE_SPACING_PERCENTAGE = 2.0 / 360; /// /// The easing for the circle filling transforms. @@ -241,10 +241,10 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy // to prevent ambiguity on what grade it's pointing at. foreach (double p in notchPercentages) { - if (Precision.AlmostEquals(p, targetAccuracy, NOTCH_WIDTH_PERCENTAGE / 2)) + if (Precision.AlmostEquals(p, targetAccuracy, GRADE_SPACING_PERCENTAGE / 2)) { int tippingDirection = targetAccuracy - p >= 0 ? 1 : -1; // We "round up" here to match rank criteria - targetAccuracy = p + tippingDirection * (NOTCH_WIDTH_PERCENTAGE / 2); + targetAccuracy = p + tippingDirection * (GRADE_SPACING_PERCENTAGE / 2); break; } } @@ -253,7 +253,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy if (score.Rank == ScoreRank.X || score.Rank == ScoreRank.XH) targetAccuracy = 1; else - targetAccuracy = Math.Min(accuracyX - VIRTUAL_SS_PERCENTAGE - NOTCH_WIDTH_PERCENTAGE / 2, targetAccuracy); + targetAccuracy = Math.Min(accuracyX - VIRTUAL_SS_PERCENTAGE - GRADE_SPACING_PERCENTAGE / 2, targetAccuracy); // The accuracy circle gauge visually fills up a bit too much. // This wouldn't normally matter but we want it to align properly with the inner graded circle in the above cases. @@ -349,7 +349,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy .FadeOut(800, Easing.Out); accuracyCircle - .FillTo(accuracyS - NOTCH_WIDTH_PERCENTAGE / 2 - visual_alignment_offset, 70, Easing.OutQuint); + .FillTo(accuracyS - GRADE_SPACING_PERCENTAGE / 2 - visual_alignment_offset, 70, Easing.OutQuint); badges.Single(b => b.Rank == getRank(ScoreRank.S)) .FadeOut(70, Easing.OutQuint); diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs index e60a24a310..57b6d8e4ac 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -79,8 +79,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy public GradedCircle(double startProgress, double endProgress) { - this.startProgress = startProgress + AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5; - this.endProgress = endProgress - AccuracyCircle.NOTCH_WIDTH_PERCENTAGE * 0.5; + this.startProgress = startProgress + AccuracyCircle.GRADE_SPACING_PERCENTAGE * 0.5; + this.endProgress = endProgress - AccuracyCircle.GRADE_SPACING_PERCENTAGE * 0.5; Anchor = Anchor.Centre; Origin = Anchor.Centre; From 2f4211249e0b3863d6058252ed55dc0e4f9d6c7f Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 5 Feb 2024 13:12:03 +0100 Subject: [PATCH 039/508] Use cleaner way to specify .exe path --- osu.Desktop/OsuGameDesktop.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index c5175fd549..a6d9ff1653 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -138,10 +138,7 @@ namespace osu.Desktop LoadComponentAsync(new GameplayWinKeyBlocker(), Add); if (OperatingSystem.IsWindows() && IsDeployedBuild) - { - string? executableLocation = Path.GetDirectoryName(typeof(OsuGameDesktop).Assembly.Location); - LoadComponentAsync(new WindowsAssociationManager(Path.Join(executableLocation, @"osu!.exe"), "osu"), Add); - } + LoadComponentAsync(new WindowsAssociationManager(Path.ChangeExtension(typeof(OsuGameDesktop).Assembly.Location, ".exe"), "osu"), Add); LoadComponentAsync(new ElevatedPrivilegesChecker(), Add); From 01efd1b353f556795f5d30eb4fe6723b7fcd6200 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 5 Feb 2024 13:34:03 +0100 Subject: [PATCH 040/508] Move `WindowsAssociationManager` to `osu.Desktop` --- osu.Desktop/Program.cs | 2 +- .../Windows}/WindowsAssociationManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename {osu.Game/Updater => osu.Desktop/Windows}/WindowsAssociationManager.cs (99%) diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index c9ce5ebf1b..edbf39a30a 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -5,6 +5,7 @@ using System; using System.IO; using System.Runtime.Versioning; using osu.Desktop.LegacyIpc; +using osu.Desktop.Windows; using osu.Framework; using osu.Framework.Development; using osu.Framework.Logging; @@ -12,7 +13,6 @@ using osu.Framework.Platform; using osu.Game; using osu.Game.IPC; using osu.Game.Tournament; -using osu.Game.Updater; using SDL2; using Squirrel; diff --git a/osu.Game/Updater/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs similarity index 99% rename from osu.Game/Updater/WindowsAssociationManager.cs rename to osu.Desktop/Windows/WindowsAssociationManager.cs index bb0e37a2f4..038788f990 100644 --- a/osu.Game/Updater/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -13,7 +13,7 @@ using osu.Framework.Logging; using osu.Game.Resources.Icons; using osu.Game.Localisation; -namespace osu.Game.Updater +namespace osu.Desktop.Windows { [SupportedOSPlatform("windows")] public partial class WindowsAssociationManager : Component From 7789cc01eb31733fa76147adecf73db186c12759 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 5 Feb 2024 14:03:16 +0100 Subject: [PATCH 041/508] Copy .ico files when publishing These icons should appear in end-user installation folder. --- osu.Desktop/Windows/Icons.cs | 10 ++++++++++ osu.Desktop/Windows/Win32Icon.cs | 16 ++++++++++++++++ osu.Desktop/Windows/WindowsAssociationManager.cs | 5 ++--- osu.Desktop/osu.Desktop.csproj | 3 +++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 osu.Desktop/Windows/Icons.cs create mode 100644 osu.Desktop/Windows/Win32Icon.cs diff --git a/osu.Desktop/Windows/Icons.cs b/osu.Desktop/Windows/Icons.cs new file mode 100644 index 0000000000..cc60f92810 --- /dev/null +++ b/osu.Desktop/Windows/Icons.cs @@ -0,0 +1,10 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Desktop.Windows +{ + public static class Icons + { + public static Win32Icon Lazer => new Win32Icon(@"lazer.ico"); + } +} diff --git a/osu.Desktop/Windows/Win32Icon.cs b/osu.Desktop/Windows/Win32Icon.cs new file mode 100644 index 0000000000..9544846c55 --- /dev/null +++ b/osu.Desktop/Windows/Win32Icon.cs @@ -0,0 +1,16 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Desktop.Windows +{ + public record Win32Icon + { + public readonly string Path; + + internal Win32Icon(string name) + { + string dir = System.IO.Path.GetDirectoryName(typeof(Win32Icon).Assembly.Location)!; + Path = System.IO.Path.Join(dir, name); + } + } +} diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 038788f990..a5f977d15d 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -10,7 +10,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Framework.Logging; -using osu.Game.Resources.Icons; using osu.Game.Localisation; namespace osu.Desktop.Windows @@ -194,7 +193,7 @@ namespace osu.Desktop.Windows using (var programKey = classes.CreateSubKey(programId)) { using (var defaultIconKey = programKey.CreateSubKey(DEFAULT_ICON)) - defaultIconKey.SetValue(null, Icon.RegistryString); + defaultIconKey.SetValue(null, Icon.Path); using (var openCommandKey = programKey.CreateSubKey(SHELL_OPEN_COMMAND)) openCommandKey.SetValue(null, $@"""{exePath}"" ""%1"""); @@ -249,7 +248,7 @@ namespace osu.Desktop.Windows protocolKey.SetValue(URL_PROTOCOL, string.Empty); using (var defaultIconKey = protocolKey.CreateSubKey(DEFAULT_ICON)) - defaultIconKey.SetValue(null, Icon.RegistryString); + defaultIconKey.SetValue(null, Icon.Path); using (var openCommandKey = protocolKey.CreateSubKey(SHELL_OPEN_COMMAND)) openCommandKey.SetValue(null, $@"""{exePath}"" ""%1"""); diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index d6a11fa924..c6a95c1623 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -31,4 +31,7 @@ + + + From 4ec9d26657167bc7310984f093837ef183cef24f Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 5 Feb 2024 14:16:35 +0100 Subject: [PATCH 042/508] Inline constants --- osu.Desktop/OsuGameDesktop.cs | 2 +- .../Windows/WindowsAssociationManager.cs | 31 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index a6d9ff1653..2e1b34fb38 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -138,7 +138,7 @@ namespace osu.Desktop LoadComponentAsync(new GameplayWinKeyBlocker(), Add); if (OperatingSystem.IsWindows() && IsDeployedBuild) - LoadComponentAsync(new WindowsAssociationManager(Path.ChangeExtension(typeof(OsuGameDesktop).Assembly.Location, ".exe"), "osu"), Add); + LoadComponentAsync(new WindowsAssociationManager(), Add); LoadComponentAsync(new ElevatedPrivilegesChecker(), Add); diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index a5f977d15d..7131067224 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.IO; using System.Runtime.InteropServices; using System.Runtime.Versioning; using Microsoft.Win32; @@ -31,6 +32,14 @@ namespace osu.Desktop.Windows /// public const string SHELL_OPEN_COMMAND = @"Shell\Open\Command"; + public static readonly string EXE_PATH = Path.ChangeExtension(typeof(WindowsAssociationManager).Assembly.Location, ".exe"); + + /// + /// Program ID prefix used for file associations. Should be relatively short since the full program ID has a 39 character limit, + /// see https://learn.microsoft.com/en-us/windows/win32/com/-progid--key. + /// + public const string PROGRAM_ID_PREFIX = "osu"; + private static readonly FileAssociation[] file_associations = { new FileAssociation(@".osz", WindowsAssociationManagerStrings.OsuBeatmap, Icons.Lazer), @@ -50,20 +59,6 @@ namespace osu.Desktop.Windows private IBindable localisationParameters = null!; - private readonly string exePath; - private readonly string programIdPrefix; - - /// Path to the executable to register. - /// - /// Program ID prefix used for file associations. Should be relatively short since the full program ID has a 39 character limit, - /// see https://learn.microsoft.com/en-us/windows/win32/com/-progid--key. - /// - public WindowsAssociationManager(string exePath, string programIdPrefix) - { - this.exePath = exePath; - this.programIdPrefix = programIdPrefix; - } - [BackgroundDependencyLoader] private void load() { @@ -87,10 +82,10 @@ namespace osu.Desktop.Windows return; foreach (var association in file_associations) - association.Install(classes, exePath, programIdPrefix); + association.Install(classes, EXE_PATH, PROGRAM_ID_PREFIX); foreach (var association in uri_associations) - association.Install(classes, exePath); + association.Install(classes, EXE_PATH); } updateDescriptions(); @@ -112,7 +107,7 @@ namespace osu.Desktop.Windows foreach (var association in file_associations) { var b = localisation.GetLocalisedBindableString(association.Description); - association.UpdateDescription(classes, programIdPrefix, b.Value); + association.UpdateDescription(classes, PROGRAM_ID_PREFIX, b.Value); b.UnbindAll(); } @@ -131,7 +126,7 @@ namespace osu.Desktop.Windows } } - public void UninstallAssociations() => UninstallAssociations(programIdPrefix); + public void UninstallAssociations() => UninstallAssociations(PROGRAM_ID_PREFIX); public static void UninstallAssociations(string programIdPrefix) { From 0168ade2e13f200f475081d54363b8b9ee835687 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 5 Feb 2024 14:19:22 +0100 Subject: [PATCH 043/508] Remove tests Can be tested with ``` dotnet publish -f net6.0 -r win-x64 osu.Desktop -o publish -c Debug publish\osu! ``` --- .../TestSceneWindowsAssociationManager.cs | 106 ------------------ 1 file changed, 106 deletions(-) delete mode 100644 osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs diff --git a/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs b/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs deleted file mode 100644 index f3eb468334..0000000000 --- a/osu.Game.Tests/Visual/Updater/TestSceneWindowsAssociationManager.cs +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.Diagnostics; -using System.IO; -using System.Runtime.Versioning; -using NUnit.Framework; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Colour; -using osu.Framework.Platform; -using osu.Game.Graphics.Sprites; -using osu.Game.Tests.Resources; -using osu.Game.Updater; - -namespace osu.Game.Tests.Visual.Updater -{ - [SupportedOSPlatform("windows")] - [Ignore("These tests modify the windows registry and open programs")] - public partial class TestSceneWindowsAssociationManager : OsuTestScene - { - private static readonly string exe_path = Path.ChangeExtension(typeof(TestSceneWindowsAssociationManager).Assembly.Location, ".exe"); - - [Resolved] - private GameHost host { get; set; } = null!; - - private readonly WindowsAssociationManager associationManager; - - public TestSceneWindowsAssociationManager() - { - Children = new Drawable[] - { - new OsuSpriteText { Text = Environment.CommandLine }, - associationManager = new WindowsAssociationManager(exe_path, "osu.Test"), - }; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - if (Environment.CommandLine.Contains(".osz", StringComparison.Ordinal)) - ChangeBackgroundColour(ColourInfo.SingleColour(Colour4.DarkOliveGreen)); - - if (Environment.CommandLine.Contains("osu://", StringComparison.Ordinal)) - ChangeBackgroundColour(ColourInfo.SingleColour(Colour4.DarkBlue)); - - if (Environment.CommandLine.Contains("osump://", StringComparison.Ordinal)) - ChangeBackgroundColour(ColourInfo.SingleColour(Colour4.DarkRed)); - } - - [Test] - public void TestInstall() - { - AddStep("install", () => associationManager.InstallAssociations()); - } - - [Test] - public void TestOpenBeatmap() - { - string beatmapPath = null!; - AddStep("create temp beatmap", () => beatmapPath = TestResources.GetTestBeatmapForImport()); - AddAssert("beatmap path ends with .osz", () => beatmapPath, () => Does.EndWith(".osz")); - AddStep("open beatmap", () => host.OpenFileExternally(beatmapPath)); - AddUntilStep("wait for focus", () => host.IsActive.Value); - AddStep("delete temp beatmap", () => File.Delete(beatmapPath)); - } - - /// - /// To check that the icon is correct - /// - [Test] - public void TestPresentBeatmap() - { - string beatmapPath = null!; - AddStep("create temp beatmap", () => beatmapPath = TestResources.GetTestBeatmapForImport()); - AddAssert("beatmap path ends with .osz", () => beatmapPath, () => Does.EndWith(".osz")); - AddStep("show beatmap in explorer", () => host.PresentFileExternally(beatmapPath)); - AddUntilStep("wait for focus", () => host.IsActive.Value); - AddStep("delete temp beatmap", () => File.Delete(beatmapPath)); - } - - [TestCase("osu://s/1")] - [TestCase("osump://123")] - public void TestUrl(string url) - { - AddStep($"open {url}", () => Process.Start(new ProcessStartInfo(url) { UseShellExecute = true })); - } - - [Test] - public void TestUninstall() - { - AddStep("uninstall", () => associationManager.UninstallAssociations()); - } - - /// - /// Useful when testing things out and manually changing the registry. - /// - [Test] - public void TestNotifyShell() - { - AddStep("notify shell of changes", WindowsAssociationManager.NotifyShellUpdate); - } - } -} From 17033e09f679f1f2c7800bdb552545967c42fa18 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 5 Feb 2024 14:29:17 +0100 Subject: [PATCH 044/508] Change to class to satisfy CFS hopefully --- osu.Desktop/Windows/Win32Icon.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/Windows/Win32Icon.cs b/osu.Desktop/Windows/Win32Icon.cs index 9544846c55..401e7a2be3 100644 --- a/osu.Desktop/Windows/Win32Icon.cs +++ b/osu.Desktop/Windows/Win32Icon.cs @@ -3,7 +3,7 @@ namespace osu.Desktop.Windows { - public record Win32Icon + public class Win32Icon { public readonly string Path; From 5850d6a57807aee271aae79532964bc85d345e1a Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 6 Feb 2024 20:06:51 +0900 Subject: [PATCH 045/508] Show near-misses on the results-screen heatmap --- osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs | 7 +- .../Objects/Drawables/DrawableHitCircle.cs | 74 +++++++++++-------- .../Statistics/AccuracyHeatmap.cs | 60 +++++++++------ 3 files changed, 81 insertions(+), 60 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs index 10d7af5e58..0e3f972d41 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModClassic.cs @@ -95,12 +95,7 @@ namespace osu.Game.Rulesets.Osu.Mods /// private static void blockInputToObjectsUnderSliderHead(DrawableSliderHead slider) { - var oldHitAction = slider.HitArea.Hit; - slider.HitArea.Hit = () => - { - oldHitAction?.Invoke(); - return !slider.DrawableSlider.AllJudged; - }; + slider.HitArea.CanBeHit = () => !slider.DrawableSlider.AllJudged; } private void applyEarlyFading(DrawableHitCircle circle) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index b1c9bef6c4..3727e78d01 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -10,7 +10,6 @@ using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Graphics.Containers; @@ -43,7 +42,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables Drawable IHasApproachCircle.ApproachCircle => ApproachCircle; private Container scaleContainer; - private InputManager inputManager; public DrawableHitCircle() : this(null) @@ -73,14 +71,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { HitArea = new HitReceptor { - Hit = () => - { - if (AllJudged) - return false; - - UpdateResult(true); - return true; - }, + CanBeHit = () => !AllJudged, + Hit = () => UpdateResult(true) }, shakeContainer = new ShakeContainer { @@ -114,13 +106,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue)); } - protected override void LoadComplete() - { - base.LoadComplete(); - - inputManager = GetContainingInputManager(); - } - public override double LifetimeStart { get => base.LifetimeStart; @@ -155,7 +140,15 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (!userTriggered) { if (!HitObject.HitWindows.CanBeHit(timeOffset)) - ApplyMinResult(); + { + ApplyResult((r, position) => + { + var circleResult = (OsuHitCircleJudgementResult)r; + + circleResult.Type = r.Judgement.MinResult; + circleResult.CursorPositionAtHit = position; + }, computeHitPosition()); + } return; } @@ -169,22 +162,21 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (result == HitResult.None || clickAction != ClickAction.Hit) return; - Vector2? hitPosition = null; - - // Todo: This should also consider misses, but they're a little more interesting to handle, since we don't necessarily know the position at the time of a miss. - if (result.IsHit()) - { - var localMousePosition = ToLocalSpace(inputManager.CurrentState.Mouse.Position); - hitPosition = HitObject.StackedPosition + (localMousePosition - DrawSize / 2); - } - ApplyResult<(HitResult result, Vector2? position)>((r, state) => { var circleResult = (OsuHitCircleJudgementResult)r; circleResult.Type = state.result; circleResult.CursorPositionAtHit = state.position; - }, (result, hitPosition)); + }, (result, computeHitPosition())); + } + + private Vector2? computeHitPosition() + { + if (HitArea.ClosestPressPosition is Vector2 screenSpaceHitPosition) + return HitObject.StackedPosition + (ToLocalSpace(screenSpaceHitPosition) - DrawSize / 2); + + return null; } /// @@ -227,6 +219,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables break; case ArmedState.Idle: + HitArea.ClosestPressPosition = null; HitArea.HitAction = null; break; @@ -247,9 +240,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables // IsHovered is used public override bool HandlePositionalInput => true; - public Func Hit; + public Func CanBeHit; + public Action Hit; public OsuAction? HitAction; + public Vector2? ClosestPressPosition; public HitReceptor() { @@ -264,12 +259,31 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public bool OnPressed(KeyBindingPressEvent e) { + if (!(CanBeHit?.Invoke() ?? false)) + return false; + switch (e.Action) { case OsuAction.LeftButton: case OsuAction.RightButton: - if (IsHovered && (Hit?.Invoke() ?? false)) + // Only update closest press position while the object hasn't been hit yet. + if (HitAction == null) { + if (ClosestPressPosition is Vector2 curClosest) + { + float oldDist = Vector2.DistanceSquared(curClosest, ScreenSpaceDrawQuad.Centre); + float newDist = Vector2.DistanceSquared(e.ScreenSpaceMousePosition, ScreenSpaceDrawQuad.Centre); + + if (newDist < oldDist) + ClosestPressPosition = e.ScreenSpaceMousePosition; + } + else + ClosestPressPosition = e.ScreenSpaceMousePosition; + } + + if (IsHovered) + { + Hit?.Invoke(); HitAction ??= e.Action; return true; } diff --git a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs index f9d4a3b325..813f3b2e7a 100644 --- a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs +++ b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs @@ -197,7 +197,9 @@ namespace osu.Game.Rulesets.Osu.Statistics var point = new HitPoint(pointType, this) { - BaseColour = pointType == HitPointType.Hit ? new Color4(102, 255, 204, 255) : new Color4(255, 102, 102, 255) + BaseColour = pointType == HitPointType.Hit + ? new Color4(102, 255, 204, 255) + : new Color4(255, 102, 102, 255) }; points[r][c] = point; @@ -250,12 +252,15 @@ namespace osu.Game.Rulesets.Osu.Statistics var rotatedCoordinate = -1 * new Vector2((float)Math.Cos(rotatedAngle), (float)Math.Sin(rotatedAngle)); Vector2 localCentre = new Vector2(points_per_dimension - 1) / 2; - float localRadius = localCentre.X * inner_portion * normalisedDistance; // The radius inside the inner portion which of the heatmap which the closest point lies. + float localRadius = localCentre.X * inner_portion * normalisedDistance; Vector2 localPoint = localCentre + localRadius * rotatedCoordinate; // Find the most relevant hit point. - int r = Math.Clamp((int)Math.Round(localPoint.Y), 0, points_per_dimension - 1); - int c = Math.Clamp((int)Math.Round(localPoint.X), 0, points_per_dimension - 1); + int r = (int)Math.Round(localPoint.Y); + int c = (int)Math.Round(localPoint.X); + + if (r < 0 || r >= points_per_dimension || c < 0 || c >= points_per_dimension) + return; PeakValue = Math.Max(PeakValue, ((HitPoint)pointGrid.Content[r][c]).Increment()); @@ -298,28 +303,35 @@ namespace osu.Game.Rulesets.Osu.Statistics { base.Update(); - // the point at which alpha is saturated and we begin to adjust colour lightness. - const float lighten_cutoff = 0.95f; - - // the amount of lightness to attribute regardless of relative value to peak point. - const float non_relative_portion = 0.2f; - - float amount = 0; - - // give some amount of alpha regardless of relative count - amount += non_relative_portion * Math.Min(1, count / 10f); - - // add relative portion - amount += (1 - non_relative_portion) * (count / heatmap.PeakValue); - - // apply easing - amount = (float)Interpolation.ApplyEasing(Easing.OutQuint, Math.Min(1, amount)); - - Debug.Assert(amount <= 1); - - Alpha = Math.Min(amount / lighten_cutoff, 1); if (pointType == HitPointType.Hit) + { + // the point at which alpha is saturated and we begin to adjust colour lightness. + const float lighten_cutoff = 0.95f; + + // the amount of lightness to attribute regardless of relative value to peak point. + const float non_relative_portion = 0.2f; + + float amount = 0; + + // give some amount of alpha regardless of relative count + amount += non_relative_portion * Math.Min(1, count / 10f); + + // add relative portion + amount += (1 - non_relative_portion) * (count / heatmap.PeakValue); + + // apply easing + amount = (float)Interpolation.ApplyEasing(Easing.OutQuint, Math.Min(1, amount)); + + Debug.Assert(amount <= 1); + + Alpha = Math.Min(amount / lighten_cutoff, 1); Colour = BaseColour.Lighten(Math.Max(0, amount - lighten_cutoff)); + } + else + { + Alpha = 0.8f; + Colour = BaseColour; + } } } From 99d716f8fc62aaaf09ca65fa7da6f8f876bd6b8a Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 6 Feb 2024 22:23:30 +0900 Subject: [PATCH 046/508] Make miss points into crosses --- .../Statistics/AccuracyHeatmap.cs | 123 ++++++++++-------- 1 file changed, 68 insertions(+), 55 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs index 813f3b2e7a..2120b929a7 100644 --- a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs +++ b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs @@ -9,6 +9,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -191,18 +192,22 @@ namespace osu.Game.Rulesets.Osu.Statistics for (int c = 0; c < points_per_dimension; c++) { - HitPointType pointType = Vector2.Distance(new Vector2(c + 0.5f, r + 0.5f), centre) <= innerRadius - ? HitPointType.Hit - : HitPointType.Miss; + bool isHit = Vector2.Distance(new Vector2(c + 0.5f, r + 0.5f), centre) <= innerRadius; - var point = new HitPoint(pointType, this) + if (isHit) { - BaseColour = pointType == HitPointType.Hit - ? new Color4(102, 255, 204, 255) - : new Color4(255, 102, 102, 255) - }; - - points[r][c] = point; + points[r][c] = new HitPoint(this) + { + BaseColour = new Color4(102, 255, 204, 255) + }; + } + else + { + points[r][c] = new MissPoint + { + BaseColour = new Color4(255, 102, 102, 255) + }; + } } } @@ -262,33 +267,21 @@ namespace osu.Game.Rulesets.Osu.Statistics if (r < 0 || r >= points_per_dimension || c < 0 || c >= points_per_dimension) return; - PeakValue = Math.Max(PeakValue, ((HitPoint)pointGrid.Content[r][c]).Increment()); + PeakValue = Math.Max(PeakValue, ((GridPoint)pointGrid.Content[r][c]).Increment()); bufferedGrid.ForceRedraw(); } - private partial class HitPoint : Circle + private abstract partial class GridPoint : CompositeDrawable { /// /// The base colour which will be lightened/darkened depending on the value of this . /// public Color4 BaseColour; - private readonly HitPointType pointType; - private readonly AccuracyHeatmap heatmap; + public override bool IsPresent => Count > 0; - public override bool IsPresent => count > 0; - - public HitPoint(HitPointType pointType, AccuracyHeatmap heatmap) - { - this.pointType = pointType; - this.heatmap = heatmap; - - RelativeSizeAxes = Axes.Both; - Alpha = 1; - } - - private int count; + protected int Count { get; private set; } /// /// Increment the value of this point by one. @@ -296,49 +289,69 @@ namespace osu.Game.Rulesets.Osu.Statistics /// The value after incrementing. public int Increment() { - return ++count; + return ++Count; + } + } + + private partial class MissPoint : GridPoint + { + public MissPoint() + { + RelativeSizeAxes = Axes.Both; + + InternalChild = new SpriteIcon + { + RelativeSizeAxes = Axes.Both, + Icon = FontAwesome.Solid.Times + }; + } + + protected override void Update() + { + Alpha = 0.8f; + Colour = BaseColour; + } + } + + private partial class HitPoint : GridPoint + { + private readonly AccuracyHeatmap heatmap; + + public HitPoint(AccuracyHeatmap heatmap) + { + this.heatmap = heatmap; + + RelativeSizeAxes = Axes.Both; + + InternalChild = new Circle { RelativeSizeAxes = Axes.Both }; } protected override void Update() { base.Update(); - if (pointType == HitPointType.Hit) - { - // the point at which alpha is saturated and we begin to adjust colour lightness. - const float lighten_cutoff = 0.95f; + // the point at which alpha is saturated and we begin to adjust colour lightness. + const float lighten_cutoff = 0.95f; - // the amount of lightness to attribute regardless of relative value to peak point. - const float non_relative_portion = 0.2f; + // the amount of lightness to attribute regardless of relative value to peak point. + const float non_relative_portion = 0.2f; - float amount = 0; + float amount = 0; - // give some amount of alpha regardless of relative count - amount += non_relative_portion * Math.Min(1, count / 10f); + // give some amount of alpha regardless of relative count + amount += non_relative_portion * Math.Min(1, Count / 10f); - // add relative portion - amount += (1 - non_relative_portion) * (count / heatmap.PeakValue); + // add relative portion + amount += (1 - non_relative_portion) * (Count / heatmap.PeakValue); - // apply easing - amount = (float)Interpolation.ApplyEasing(Easing.OutQuint, Math.Min(1, amount)); + // apply easing + amount = (float)Interpolation.ApplyEasing(Easing.OutQuint, Math.Min(1, amount)); - Debug.Assert(amount <= 1); + Debug.Assert(amount <= 1); - Alpha = Math.Min(amount / lighten_cutoff, 1); - Colour = BaseColour.Lighten(Math.Max(0, amount - lighten_cutoff)); - } - else - { - Alpha = 0.8f; - Colour = BaseColour; - } + Alpha = Math.Min(amount / lighten_cutoff, 1); + Colour = BaseColour.Lighten(Math.Max(0, amount - lighten_cutoff)); } } - - private enum HitPointType - { - Hit, - Miss - } } } From ff7cd67909d72c520ec2aabaf7ac96083d812cd3 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 6 Feb 2024 21:14:36 +0300 Subject: [PATCH 047/508] Move all the circles into their own container --- .../Expanded/Accuracy/GradedCircles.cs | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs index 57b6d8e4ac..33b71c53a7 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -20,49 +20,45 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy set { progress = value; - dProgress.RevealProgress = value; - cProgress.RevealProgress = value; - bProgress.RevealProgress = value; - aProgress.RevealProgress = value; - sProgress.RevealProgress = value; - xProgress.RevealProgress = value; + + foreach (var circle in circles) + circle.RevealProgress = value; } } - private readonly GradedCircle dProgress; - private readonly GradedCircle cProgress; - private readonly GradedCircle bProgress; - private readonly GradedCircle aProgress; - private readonly GradedCircle sProgress; - private readonly GradedCircle xProgress; + private readonly Container circles; public GradedCircles(double accuracyC, double accuracyB, double accuracyA, double accuracyS, double accuracyX) { - InternalChildren = new Drawable[] + InternalChild = circles = new Container { - dProgress = new GradedCircle(0.0, accuracyC) + RelativeSizeAxes = Axes.Both, + Children = new[] { - Colour = OsuColour.ForRank(ScoreRank.D), - }, - cProgress = new GradedCircle(accuracyC, accuracyB) - { - Colour = OsuColour.ForRank(ScoreRank.C), - }, - bProgress = new GradedCircle(accuracyB, accuracyA) - { - Colour = OsuColour.ForRank(ScoreRank.B), - }, - aProgress = new GradedCircle(accuracyA, accuracyS) - { - Colour = OsuColour.ForRank(ScoreRank.A), - }, - sProgress = new GradedCircle(accuracyS, accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE) - { - Colour = OsuColour.ForRank(ScoreRank.S), - }, - xProgress = new GradedCircle(accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE, 1.0) - { - Colour = OsuColour.ForRank(ScoreRank.X) + new GradedCircle(0.0, accuracyC) + { + Colour = OsuColour.ForRank(ScoreRank.D), + }, + new GradedCircle(accuracyC, accuracyB) + { + Colour = OsuColour.ForRank(ScoreRank.C), + }, + new GradedCircle(accuracyB, accuracyA) + { + Colour = OsuColour.ForRank(ScoreRank.B), + }, + new GradedCircle(accuracyA, accuracyS) + { + Colour = OsuColour.ForRank(ScoreRank.A), + }, + new GradedCircle(accuracyS, accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE) + { + Colour = OsuColour.ForRank(ScoreRank.S), + }, + new GradedCircle(accuracyX - AccuracyCircle.VIRTUAL_SS_PERCENTAGE, 1.0) + { + Colour = OsuColour.ForRank(ScoreRank.X) + } } }; } From 44b1515cc5395486963615d238f2f77c16b5888c Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 7 Feb 2024 03:28:40 +0900 Subject: [PATCH 048/508] Remove LangVersion redefintions --- osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj | 1 - osu.Game/osu.Game.csproj | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index 518ab362ca..7817d55f57 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -4,7 +4,6 @@ Library true click the circles. to the beat. - 10 diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 935b759e4d..9bcdebc347 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -3,7 +3,6 @@ net8.0 Library true - 10 osu! From 9b8f2064867472009e3c5c621c1fbf5823ad7592 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 7 Feb 2024 03:38:07 +0900 Subject: [PATCH 049/508] Enable NRT for DrawableHitCircle to clean up --- .../Objects/Drawables/DrawableHitCircle.cs | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 3727e78d01..b950ef4bbb 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -1,12 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using System.Diagnostics; -using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -27,34 +24,30 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { public partial class DrawableHitCircle : DrawableOsuHitObject, IHasApproachCircle { - public OsuAction? HitAction => HitArea?.HitAction; + public OsuAction? HitAction => HitArea.HitAction; protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle; - public SkinnableDrawable ApproachCircle { get; private set; } - public HitReceptor HitArea { get; private set; } - public SkinnableDrawable CirclePiece { get; private set; } + public SkinnableDrawable ApproachCircle { get; private set; } = null!; + public HitReceptor HitArea { get; private set; } = null!; + public SkinnableDrawable CirclePiece { get; private set; } = null!; - protected override IEnumerable DimmablePieces => new[] - { - CirclePiece, - }; + protected override IEnumerable DimmablePieces => new[] { CirclePiece }; Drawable IHasApproachCircle.ApproachCircle => ApproachCircle; - private Container scaleContainer; + private Container scaleContainer = null!; + private ShakeContainer shakeContainer = null!; public DrawableHitCircle() : this(null) { } - public DrawableHitCircle([CanBeNull] HitCircle h = null) + public DrawableHitCircle(HitCircle? h = null) : base(h) { } - private ShakeContainer shakeContainer; - [BackgroundDependencyLoader] private void load() { @@ -219,8 +212,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables break; case ArmedState.Idle: - HitArea.ClosestPressPosition = null; - HitArea.HitAction = null; + HitArea.Reset(); break; case ArmedState.Miss: @@ -240,11 +232,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables // IsHovered is used public override bool HandlePositionalInput => true; - public Func CanBeHit; - public Action Hit; + public required Func CanBeHit { get; set; } + public required Action Hit { get; set; } - public OsuAction? HitAction; - public Vector2? ClosestPressPosition; + public OsuAction? HitAction { get; private set; } + public Vector2? ClosestPressPosition { get; private set; } public HitReceptor() { @@ -259,7 +251,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public bool OnPressed(KeyBindingPressEvent e) { - if (!(CanBeHit?.Invoke() ?? false)) + if (CanBeHit()) return false; switch (e.Action) @@ -283,7 +275,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (IsHovered) { - Hit?.Invoke(); + Hit(); HitAction ??= e.Action; return true; } @@ -297,13 +289,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public void OnReleased(KeyBindingReleaseEvent e) { } + + public void Reset() + { + HitAction = null; + ClosestPressPosition = null; + } } private partial class ProxyableSkinnableDrawable : SkinnableDrawable { public override bool RemoveWhenNotAlive => false; - public ProxyableSkinnableDrawable(ISkinComponentLookup lookup, Func defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling) + public ProxyableSkinnableDrawable(ISkinComponentLookup lookup, Func? defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling) : base(lookup, defaultImplementation, confineMode) { } From 38f7913b31bbc64f99882668b7d8cb89de4d51fd Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 7 Feb 2024 03:50:56 +0900 Subject: [PATCH 050/508] Fix inverted condition --- osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index b950ef4bbb..c9f2983b1e 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -251,7 +251,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public bool OnPressed(KeyBindingPressEvent e) { - if (CanBeHit()) + if (!CanBeHit()) return false; switch (e.Action) From 2fc06f16b50c0112522b3c2f164de6aa2aa36608 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 7 Feb 2024 03:51:28 +0900 Subject: [PATCH 051/508] Fix inspections --- osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs index c624fbbe73..9d79cb0db4 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs @@ -91,11 +91,11 @@ namespace osu.Game.Rulesets.Osu.Tests var skinnable = firstObject.ApproachCircle; - if (skin == null && skinnable?.Drawable is DefaultApproachCircle) + if (skin == null && skinnable.Drawable is DefaultApproachCircle) // check for default skin provider return true; - var text = skinnable?.Drawable as SpriteText; + var text = skinnable.Drawable as SpriteText; return text?.Text == skin; }); From e2867986c591f042b63c6da36e1f27d40cb89341 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 7 Feb 2024 03:47:36 +0900 Subject: [PATCH 052/508] Add xmldocs --- .../Objects/Drawables/DrawableHitCircle.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index c9f2983b1e..f7237d4c03 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -232,10 +232,24 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables // IsHovered is used public override bool HandlePositionalInput => true; + /// + /// Whether the hitobject can still be hit at the current point in time. + /// public required Func CanBeHit { get; set; } + + /// + /// An action that's invoked to perform the hit. + /// public required Action Hit { get; set; } + /// + /// The with which the hit was attempted. + /// public OsuAction? HitAction { get; private set; } + + /// + /// The closest position to the hit receptor at the point where the hit was attempted. + /// public Vector2? ClosestPressPosition { get; private set; } public HitReceptor() @@ -290,6 +304,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { } + /// + /// Resets to a fresh state. + /// public void Reset() { HitAction = null; From 1f13124b3834b846281c5d63acc65275c356258e Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 7 Feb 2024 03:52:51 +0900 Subject: [PATCH 053/508] Always process position as long as it's hittable For example... If a hitobject is pressed but the result is a shake, this will stop processing hits. --- .../Objects/Drawables/DrawableHitCircle.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index f7237d4c03..c3ce6acce9 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -272,20 +272,16 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { case OsuAction.LeftButton: case OsuAction.RightButton: - // Only update closest press position while the object hasn't been hit yet. - if (HitAction == null) + if (ClosestPressPosition is Vector2 curClosest) { - if (ClosestPressPosition is Vector2 curClosest) - { - float oldDist = Vector2.DistanceSquared(curClosest, ScreenSpaceDrawQuad.Centre); - float newDist = Vector2.DistanceSquared(e.ScreenSpaceMousePosition, ScreenSpaceDrawQuad.Centre); + float oldDist = Vector2.DistanceSquared(curClosest, ScreenSpaceDrawQuad.Centre); + float newDist = Vector2.DistanceSquared(e.ScreenSpaceMousePosition, ScreenSpaceDrawQuad.Centre); - if (newDist < oldDist) - ClosestPressPosition = e.ScreenSpaceMousePosition; - } - else + if (newDist < oldDist) ClosestPressPosition = e.ScreenSpaceMousePosition; } + else + ClosestPressPosition = e.ScreenSpaceMousePosition; if (IsHovered) { From dcb195f3c813c72d2bd694d1488e0c37c67f1764 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 8 Feb 2024 02:16:08 +0900 Subject: [PATCH 054/508] Add delayed resume for taiko/catch/mania --- .../UI/DrawableCatchRuleset.cs | 3 ++ .../UI/DrawableManiaRuleset.cs | 3 ++ .../UI/DrawableTaikoRuleset.cs | 3 ++ osu.Game/Screens/Play/DelayedResumeOverlay.cs | 32 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 osu.Game/Screens/Play/DelayedResumeOverlay.cs diff --git a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs index f0a327d7ac..580c90bcb4 100644 --- a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs @@ -16,6 +16,7 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Scoring; +using osu.Game.Screens.Play; namespace osu.Game.Rulesets.Catch.UI { @@ -52,5 +53,7 @@ namespace osu.Game.Rulesets.Catch.UI protected override PassThroughInputManager CreateInputManager() => new CatchInputManager(Ruleset.RulesetInfo); public override DrawableHitObject? CreateDrawableRepresentation(CatchHitObject h) => null; + + protected override ResumeOverlay CreateResumeOverlay() => new DelayedResumeOverlay(); } } diff --git a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs index decf670c5d..275b1311de 100644 --- a/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs @@ -26,6 +26,7 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Scoring; +using osu.Game.Screens.Play; using osu.Game.Skinning; namespace osu.Game.Rulesets.Mania.UI @@ -164,6 +165,8 @@ namespace osu.Game.Rulesets.Mania.UI protected override ReplayRecorder CreateReplayRecorder(Score score) => new ManiaReplayRecorder(score); + protected override ResumeOverlay CreateResumeOverlay() => new DelayedResumeOverlay(); + protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); diff --git a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs index 77b2b06c0e..cd9ed399e6 100644 --- a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs @@ -22,6 +22,7 @@ using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Scoring; +using osu.Game.Screens.Play; using osu.Game.Skinning; using osuTK; @@ -101,5 +102,7 @@ namespace osu.Game.Rulesets.Taiko.UI protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new TaikoFramedReplayInputHandler(replay); protected override ReplayRecorder CreateReplayRecorder(Score score) => new TaikoReplayRecorder(score); + + protected override ResumeOverlay CreateResumeOverlay() => new DelayedResumeOverlay(); } } diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs new file mode 100644 index 0000000000..ef39c8eb76 --- /dev/null +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -0,0 +1,32 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Localisation; +using osu.Framework.Threading; + +namespace osu.Game.Screens.Play +{ + /// + /// Simple that resumes after 800ms. + /// + public partial class DelayedResumeOverlay : ResumeOverlay + { + protected override LocalisableString Message => string.Empty; + + private ScheduledDelegate? scheduledResume; + + protected override void PopIn() + { + base.PopIn(); + + scheduledResume?.Cancel(); + scheduledResume = Scheduler.AddDelayed(Resume, 800); + } + + protected override void PopOut() + { + base.PopOut(); + scheduledResume?.Cancel(); + } + } +} From 57d5717e6a6d4fb4007e6f42aa7bca525ea176e6 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 21:33:23 +0100 Subject: [PATCH 055/508] Remove `Win32Icon` class and use plain strings instead --- osu.Desktop/Windows/Icons.cs | 9 ++++++++- osu.Desktop/Windows/Win32Icon.cs | 16 ---------------- osu.Desktop/Windows/WindowsAssociationManager.cs | 8 ++++---- 3 files changed, 12 insertions(+), 21 deletions(-) delete mode 100644 osu.Desktop/Windows/Win32Icon.cs diff --git a/osu.Desktop/Windows/Icons.cs b/osu.Desktop/Windows/Icons.cs index cc60f92810..67915c101a 100644 --- a/osu.Desktop/Windows/Icons.cs +++ b/osu.Desktop/Windows/Icons.cs @@ -1,10 +1,17 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.IO; + namespace osu.Desktop.Windows { public static class Icons { - public static Win32Icon Lazer => new Win32Icon(@"lazer.ico"); + /// + /// Fully qualified path to the directory that contains icons (in the installation folder). + /// + private static readonly string icon_directory = Path.GetDirectoryName(typeof(Icons).Assembly.Location)!; + + public static string Lazer => Path.Join(icon_directory, "lazer.ico"); } } diff --git a/osu.Desktop/Windows/Win32Icon.cs b/osu.Desktop/Windows/Win32Icon.cs deleted file mode 100644 index 401e7a2be3..0000000000 --- a/osu.Desktop/Windows/Win32Icon.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -namespace osu.Desktop.Windows -{ - public class Win32Icon - { - public readonly string Path; - - internal Win32Icon(string name) - { - string dir = System.IO.Path.GetDirectoryName(typeof(Win32Icon).Assembly.Location)!; - Path = System.IO.Path.Join(dir, name); - } - } -} diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 7131067224..a93161ae47 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -173,7 +173,7 @@ namespace osu.Desktop.Windows #endregion - private record FileAssociation(string Extension, LocalisableString Description, Win32Icon Icon) + private record FileAssociation(string Extension, LocalisableString Description, string IconPath) { private string getProgramId(string prefix) => $@"{prefix}.File{Extension}"; @@ -188,7 +188,7 @@ namespace osu.Desktop.Windows using (var programKey = classes.CreateSubKey(programId)) { using (var defaultIconKey = programKey.CreateSubKey(DEFAULT_ICON)) - defaultIconKey.SetValue(null, Icon.Path); + defaultIconKey.SetValue(null, IconPath); using (var openCommandKey = programKey.CreateSubKey(SHELL_OPEN_COMMAND)) openCommandKey.SetValue(null, $@"""{exePath}"" ""%1"""); @@ -225,7 +225,7 @@ namespace osu.Desktop.Windows } } - private record UriAssociation(string Protocol, LocalisableString Description, Win32Icon Icon) + private record UriAssociation(string Protocol, LocalisableString Description, string IconPath) { /// /// "The URL Protocol string value indicates that this key declares a custom pluggable protocol handler." @@ -243,7 +243,7 @@ namespace osu.Desktop.Windows protocolKey.SetValue(URL_PROTOCOL, string.Empty); using (var defaultIconKey = protocolKey.CreateSubKey(DEFAULT_ICON)) - defaultIconKey.SetValue(null, Icon.Path); + defaultIconKey.SetValue(null, IconPath); using (var openCommandKey = protocolKey.CreateSubKey(SHELL_OPEN_COMMAND)) openCommandKey.SetValue(null, $@"""{exePath}"" ""%1"""); From eeba93768641b05a470aa1e8ebe18389596f5d49 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 21:45:36 +0100 Subject: [PATCH 056/508] Make `WindowsAssociationManager` `static` Usages/localisation logic TBD --- osu.Desktop/Program.cs | 2 +- .../Windows/WindowsAssociationManager.cs | 57 ++++++------------- 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index edbf39a30a..38e4110f62 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -181,7 +181,7 @@ namespace osu.Desktop { tools.RemoveShortcutForThisExe(); tools.RemoveUninstallerRegistryEntry(); - WindowsAssociationManager.UninstallAssociations(@"osu"); + WindowsAssociationManager.UninstallAssociations(); }, onEveryRun: (_, _, _) => { // While setting the `ProcessAppUserModelId` fixes duplicate icons/shortcuts on the taskbar, it currently diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index a93161ae47..f1fc98090f 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -6,9 +6,6 @@ using System.IO; using System.Runtime.InteropServices; using System.Runtime.Versioning; using Microsoft.Win32; -using osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Framework.Logging; using osu.Game.Localisation; @@ -16,7 +13,7 @@ using osu.Game.Localisation; namespace osu.Desktop.Windows { [SupportedOSPlatform("windows")] - public partial class WindowsAssociationManager : Component + public static class WindowsAssociationManager { public const string SOFTWARE_CLASSES = @"Software\Classes"; @@ -54,25 +51,7 @@ namespace osu.Desktop.Windows new UriAssociation(@"osump", WindowsAssociationManagerStrings.OsuMultiplayer, Icons.Lazer), }; - [Resolved] - private LocalisationManager localisation { get; set; } = null!; - - private IBindable localisationParameters = null!; - - [BackgroundDependencyLoader] - private void load() - { - localisationParameters = localisation.CurrentParameters.GetBoundCopy(); - InstallAssociations(); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - localisationParameters.ValueChanged += _ => updateDescriptions(); - } - - public void InstallAssociations() + public static void InstallAssociations(LocalisationManager? localisation) { try { @@ -88,7 +67,7 @@ namespace osu.Desktop.Windows association.Install(classes, EXE_PATH); } - updateDescriptions(); + updateDescriptions(localisation); } catch (Exception e) { @@ -96,7 +75,7 @@ namespace osu.Desktop.Windows } } - private void updateDescriptions() + private static void updateDescriptions(LocalisationManager? localisation) { try { @@ -105,18 +84,10 @@ namespace osu.Desktop.Windows return; foreach (var association in file_associations) - { - var b = localisation.GetLocalisedBindableString(association.Description); - association.UpdateDescription(classes, PROGRAM_ID_PREFIX, b.Value); - b.UnbindAll(); - } + association.UpdateDescription(classes, PROGRAM_ID_PREFIX, getLocalisedString(association.Description)); foreach (var association in uri_associations) - { - var b = localisation.GetLocalisedBindableString(association.Description); - association.UpdateDescription(classes, b.Value); - b.UnbindAll(); - } + association.UpdateDescription(classes, getLocalisedString(association.Description)); NotifyShellUpdate(); } @@ -124,11 +95,19 @@ namespace osu.Desktop.Windows { Logger.Log($@"Failed to update file and URI associations: {e.Message}"); } + + string getLocalisedString(LocalisableString s) + { + if (localisation == null) + return s.ToString(); + + var b = localisation.GetLocalisedBindableString(s); + b.UnbindAll(); + return b.Value; + } } - public void UninstallAssociations() => UninstallAssociations(PROGRAM_ID_PREFIX); - - public static void UninstallAssociations(string programIdPrefix) + public static void UninstallAssociations() { try { @@ -137,7 +116,7 @@ namespace osu.Desktop.Windows return; foreach (var association in file_associations) - association.Uninstall(classes, programIdPrefix); + association.Uninstall(classes, PROGRAM_ID_PREFIX); foreach (var association in uri_associations) association.Uninstall(classes); From f9d257b99ea176222671aa4594ec78c01f157db7 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 21:56:39 +0100 Subject: [PATCH 057/508] Install associations as part of initial squirrel install --- osu.Desktop/OsuGameDesktop.cs | 3 --- osu.Desktop/Program.cs | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 2e1b34fb38..a0db896f46 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -137,9 +137,6 @@ namespace osu.Desktop if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows) LoadComponentAsync(new GameplayWinKeyBlocker(), Add); - if (OperatingSystem.IsWindows() && IsDeployedBuild) - LoadComponentAsync(new WindowsAssociationManager(), Add); - LoadComponentAsync(new ElevatedPrivilegesChecker(), Add); osuSchemeLinkIPCChannel = new OsuSchemeLinkIPCChannel(Host, this); diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index 38e4110f62..65236940c6 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -174,6 +174,7 @@ namespace osu.Desktop { tools.CreateShortcutForThisExe(); tools.CreateUninstallerRegistryEntry(); + WindowsAssociationManager.InstallAssociations(null); }, onAppUpdate: (_, tools) => { tools.CreateUninstallerRegistryEntry(); From 0563507295dcf68c150cfc99949964d521f98b0e Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:03:16 +0100 Subject: [PATCH 058/508] Remove duplicate try-catch and move `NotifyShellUpdate()` to less hidden place --- .../Windows/WindowsAssociationManager.cs | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index f1fc98090f..c91ab459d6 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -68,6 +68,7 @@ namespace osu.Desktop.Windows } updateDescriptions(localisation); + NotifyShellUpdate(); } catch (Exception e) { @@ -77,24 +78,15 @@ namespace osu.Desktop.Windows private static void updateDescriptions(LocalisationManager? localisation) { - try - { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); - if (classes == null) - return; + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) + return; - foreach (var association in file_associations) - association.UpdateDescription(classes, PROGRAM_ID_PREFIX, getLocalisedString(association.Description)); + foreach (var association in file_associations) + association.UpdateDescription(classes, PROGRAM_ID_PREFIX, getLocalisedString(association.Description)); - foreach (var association in uri_associations) - association.UpdateDescription(classes, getLocalisedString(association.Description)); - - NotifyShellUpdate(); - } - catch (Exception e) - { - Logger.Log($@"Failed to update file and URI associations: {e.Message}"); - } + foreach (var association in uri_associations) + association.UpdateDescription(classes, getLocalisedString(association.Description)); string getLocalisedString(LocalisableString s) { From 6bdb07602794d7eb59e7356f9fa5a04188652ff2 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:06:09 +0100 Subject: [PATCH 059/508] Move update/install logic into helper --- .../Windows/WindowsAssociationManager.cs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index c91ab459d6..3d61ad534b 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -55,18 +55,7 @@ namespace osu.Desktop.Windows { try { - using (var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, writable: true)) - { - if (classes == null) - return; - - foreach (var association in file_associations) - association.Install(classes, EXE_PATH, PROGRAM_ID_PREFIX); - - foreach (var association in uri_associations) - association.Install(classes, EXE_PATH); - } - + updateAssociations(); updateDescriptions(localisation); NotifyShellUpdate(); } @@ -76,6 +65,24 @@ namespace osu.Desktop.Windows } } + /// + /// Installs or updates associations. + /// + private static void updateAssociations() + { + using (var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, writable: true)) + { + if (classes == null) + return; + + foreach (var association in file_associations) + association.Install(classes, EXE_PATH, PROGRAM_ID_PREFIX); + + foreach (var association in uri_associations) + association.Install(classes, EXE_PATH); + } + } + private static void updateDescriptions(LocalisationManager? localisation) { using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); From 738c28755c53fd587d7ecee0cc6e8365c6aa8a44 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:17:13 +0100 Subject: [PATCH 060/508] Refactor public methods --- osu.Desktop/Program.cs | 3 +- .../Windows/WindowsAssociationManager.cs | 42 ++++++++++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index 65236940c6..494d0df3c6 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -174,10 +174,11 @@ namespace osu.Desktop { tools.CreateShortcutForThisExe(); tools.CreateUninstallerRegistryEntry(); - WindowsAssociationManager.InstallAssociations(null); + WindowsAssociationManager.InstallAssociations(); }, onAppUpdate: (_, tools) => { tools.CreateUninstallerRegistryEntry(); + WindowsAssociationManager.UpdateAssociations(); }, onAppUninstall: (_, tools) => { tools.RemoveShortcutForThisExe(); diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 3d61ad534b..18a3c2da3d 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -51,12 +51,18 @@ namespace osu.Desktop.Windows new UriAssociation(@"osump", WindowsAssociationManagerStrings.OsuMultiplayer, Icons.Lazer), }; - public static void InstallAssociations(LocalisationManager? localisation) + /// + /// Installs file and URI associations. + /// + /// + /// Call in a timely fashion to keep descriptions up-to-date and localised. + /// + public static void InstallAssociations() { try { updateAssociations(); - updateDescriptions(localisation); + updateDescriptions(null); // write default descriptions in case `UpdateDescriptions()` is not called. NotifyShellUpdate(); } catch (Exception e) @@ -65,6 +71,38 @@ namespace osu.Desktop.Windows } } + /// + /// Updates associations with latest definitions. + /// + /// + /// Call in a timely fashion to keep descriptions up-to-date and localised. + /// + public static void UpdateAssociations() + { + try + { + updateAssociations(); + NotifyShellUpdate(); + } + catch (Exception e) + { + Logger.Log(@$"Failed to update file and URI associations: {e.Message}"); + } + } + + public static void UpdateDescriptions(LocalisationManager localisationManager) + { + try + { + updateDescriptions(localisationManager); + NotifyShellUpdate(); + } + catch (Exception e) + { + Logger.Log(@$"Failed to update file and URI association descriptions: {e.Message}"); + } + } + /// /// Installs or updates associations. /// From ffdefbc742fa1948d1e9356b438adbf319221bd3 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:18:12 +0100 Subject: [PATCH 061/508] Move public methods closer together --- .../Windows/WindowsAssociationManager.cs | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 18a3c2da3d..b7465e5ffc 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -103,6 +103,28 @@ namespace osu.Desktop.Windows } } + public static void UninstallAssociations() + { + try + { + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) + return; + + foreach (var association in file_associations) + association.Uninstall(classes, PROGRAM_ID_PREFIX); + + foreach (var association in uri_associations) + association.Uninstall(classes); + + NotifyShellUpdate(); + } + catch (Exception e) + { + Logger.Log($@"Failed to uninstall file and URI associations: {e.Message}"); + } + } + /// /// Installs or updates associations. /// @@ -144,28 +166,6 @@ namespace osu.Desktop.Windows } } - public static void UninstallAssociations() - { - try - { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); - if (classes == null) - return; - - foreach (var association in file_associations) - association.Uninstall(classes, PROGRAM_ID_PREFIX); - - foreach (var association in uri_associations) - association.Uninstall(classes); - - NotifyShellUpdate(); - } - catch (Exception e) - { - Logger.Log($@"Failed to uninstall file and URI associations: {e.Message}"); - } - } - internal static void NotifyShellUpdate() => SHChangeNotify(EventId.SHCNE_ASSOCCHANGED, Flags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); #region Native interop From da8c4541dbfe8c8c0690ca57d91b6d428e94870d Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:21:04 +0100 Subject: [PATCH 062/508] Use `Logger.Error` --- osu.Desktop/Windows/WindowsAssociationManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index b7465e5ffc..c978e46b5b 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -67,7 +67,7 @@ namespace osu.Desktop.Windows } catch (Exception e) { - Logger.Log(@$"Failed to install file and URI associations: {e.Message}"); + Logger.Error(e, @$"Failed to install file and URI associations: {e.Message}"); } } @@ -86,7 +86,7 @@ namespace osu.Desktop.Windows } catch (Exception e) { - Logger.Log(@$"Failed to update file and URI associations: {e.Message}"); + Logger.Error(e, @"Failed to update file and URI associations."); } } @@ -99,7 +99,7 @@ namespace osu.Desktop.Windows } catch (Exception e) { - Logger.Log(@$"Failed to update file and URI association descriptions: {e.Message}"); + Logger.Error(e, @"Failed to update file and URI association descriptions."); } } @@ -121,7 +121,7 @@ namespace osu.Desktop.Windows } catch (Exception e) { - Logger.Log($@"Failed to uninstall file and URI associations: {e.Message}"); + Logger.Error(e, @"Failed to uninstall file and URI associations."); } } From 7f5dedc118059189e0d2bcb77e65ed39444de765 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:23:59 +0100 Subject: [PATCH 063/508] Refactor ProgID logic so it's more visible --- osu.Desktop/Windows/WindowsAssociationManager.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index c978e46b5b..aeda1e6283 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -35,7 +35,7 @@ namespace osu.Desktop.Windows /// Program ID prefix used for file associations. Should be relatively short since the full program ID has a 39 character limit, /// see https://learn.microsoft.com/en-us/windows/win32/com/-progid--key. /// - public const string PROGRAM_ID_PREFIX = "osu"; + public const string PROGRAM_ID_PREFIX = "osu.File"; private static readonly FileAssociation[] file_associations = { @@ -136,7 +136,7 @@ namespace osu.Desktop.Windows return; foreach (var association in file_associations) - association.Install(classes, EXE_PATH, PROGRAM_ID_PREFIX); + association.Install(classes, EXE_PATH); foreach (var association in uri_associations) association.Install(classes, EXE_PATH); @@ -191,15 +191,13 @@ namespace osu.Desktop.Windows private record FileAssociation(string Extension, LocalisableString Description, string IconPath) { - private string getProgramId(string prefix) => $@"{prefix}.File{Extension}"; + private string programId => $@"{PROGRAM_ID_PREFIX}{Extension}"; /// /// Installs a file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/com/-progid--key /// - public void Install(RegistryKey classes, string exePath, string programIdPrefix) + public void Install(RegistryKey classes, string exePath) { - string programId = getProgramId(programIdPrefix); - // register a program id for the given extension using (var programKey = classes.CreateSubKey(programId)) { @@ -224,14 +222,12 @@ namespace osu.Desktop.Windows public void UpdateDescription(RegistryKey classes, string programIdPrefix, string description) { - using (var programKey = classes.OpenSubKey(getProgramId(programIdPrefix), true)) + using (var programKey = classes.OpenSubKey(programId, true)) programKey?.SetValue(null, description); } public void Uninstall(RegistryKey classes, string programIdPrefix) { - string programId = getProgramId(programIdPrefix); - // importantly, we don't delete the default program entry because some other program could have taken it. using (var extensionKey = classes.OpenSubKey($@"{Extension}\OpenWithProgIds", true)) From 3419b8ffa854b4b40daf26fe248e89a4e812e84a Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:26:21 +0100 Subject: [PATCH 064/508] Standardise using declaration --- osu.Desktop/Windows/WindowsAssociationManager.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index aeda1e6283..a786afde55 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -130,17 +130,15 @@ namespace osu.Desktop.Windows /// private static void updateAssociations() { - using (var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, writable: true)) - { - if (classes == null) - return; + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) + return; - foreach (var association in file_associations) - association.Install(classes, EXE_PATH); + foreach (var association in file_associations) + association.Install(classes, EXE_PATH); - foreach (var association in uri_associations) - association.Install(classes, EXE_PATH); - } + foreach (var association in uri_associations) + association.Install(classes, EXE_PATH); } private static void updateDescriptions(LocalisationManager? localisation) From 139072fa818a088f300fce9cfd38682c9c57dbcd Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:29:20 +0100 Subject: [PATCH 065/508] Standardise using declaration --- osu.Desktop/Windows/WindowsAssociationManager.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index a786afde55..2373cfa609 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -108,8 +109,7 @@ namespace osu.Desktop.Windows try { using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); - if (classes == null) - return; + Debug.Assert(classes != null); foreach (var association in file_associations) association.Uninstall(classes, PROGRAM_ID_PREFIX); @@ -131,8 +131,7 @@ namespace osu.Desktop.Windows private static void updateAssociations() { using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); - if (classes == null) - return; + Debug.Assert(classes != null); foreach (var association in file_associations) association.Install(classes, EXE_PATH); @@ -144,8 +143,7 @@ namespace osu.Desktop.Windows private static void updateDescriptions(LocalisationManager? localisation) { using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); - if (classes == null) - return; + Debug.Assert(classes != null); foreach (var association in file_associations) association.UpdateDescription(classes, PROGRAM_ID_PREFIX, getLocalisedString(association.Description)); From bf47221594a805530cee18ab5e2ff802bd54f232 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:42:42 +0100 Subject: [PATCH 066/508] Make things testable via 'Run static method' in Rider --- osu.Desktop/Windows/WindowsAssociationManager.cs | 2 +- osu.Desktop/osu.Desktop.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 2373cfa609..83fadfcae2 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -30,7 +30,7 @@ namespace osu.Desktop.Windows /// public const string SHELL_OPEN_COMMAND = @"Shell\Open\Command"; - public static readonly string EXE_PATH = Path.ChangeExtension(typeof(WindowsAssociationManager).Assembly.Location, ".exe"); + public static readonly string EXE_PATH = Path.ChangeExtension(typeof(WindowsAssociationManager).Assembly.Location, ".exe").Replace('/', '\\'); /// /// Program ID prefix used for file associations. Should be relatively short since the full program ID has a 39 character limit, diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index c6a95c1623..57752aa1f7 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -31,7 +31,7 @@ - + From 8049270ad2e17447a5f80446a7e39e73dc5e52e2 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 7 Feb 2024 22:45:58 +0100 Subject: [PATCH 067/508] Remove unused param --- osu.Desktop/Windows/WindowsAssociationManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 83fadfcae2..83c2a97b56 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -112,7 +112,7 @@ namespace osu.Desktop.Windows Debug.Assert(classes != null); foreach (var association in file_associations) - association.Uninstall(classes, PROGRAM_ID_PREFIX); + association.Uninstall(classes); foreach (var association in uri_associations) association.Uninstall(classes); @@ -146,7 +146,7 @@ namespace osu.Desktop.Windows Debug.Assert(classes != null); foreach (var association in file_associations) - association.UpdateDescription(classes, PROGRAM_ID_PREFIX, getLocalisedString(association.Description)); + association.UpdateDescription(classes, getLocalisedString(association.Description)); foreach (var association in uri_associations) association.UpdateDescription(classes, getLocalisedString(association.Description)); @@ -216,13 +216,13 @@ namespace osu.Desktop.Windows } } - public void UpdateDescription(RegistryKey classes, string programIdPrefix, string description) + public void UpdateDescription(RegistryKey classes, string description) { using (var programKey = classes.OpenSubKey(programId, true)) programKey?.SetValue(null, description); } - public void Uninstall(RegistryKey classes, string programIdPrefix) + public void Uninstall(RegistryKey classes) { // importantly, we don't delete the default program entry because some other program could have taken it. From dfa0c51bc8b1067a08811f221da52109a6806c94 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Thu, 8 Feb 2024 00:23:46 +0100 Subject: [PATCH 068/508] Copy icons to nuget and install package Don't ask me why this uses the folder for .NET Framework 4.5 --- osu.Desktop/osu.nuspec | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Desktop/osu.nuspec b/osu.Desktop/osu.nuspec index f85698680e..66b3970351 100644 --- a/osu.Desktop/osu.nuspec +++ b/osu.Desktop/osu.nuspec @@ -20,6 +20,7 @@ + From 1dc54d6f25d030db88936ecbfec7dd8f55c71d3e Mon Sep 17 00:00:00 2001 From: Susko3 Date: Thu, 8 Feb 2024 00:54:48 +0100 Subject: [PATCH 069/508] Fix stable install path lookup `osu` is the `osu://` protocol handler, which gets overriden by lazer. Instead, use `osu!` which is the stable file handler. --- osu.Desktop/OsuGameDesktop.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index a0db896f46..5ac6ac7322 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -86,8 +86,8 @@ namespace osu.Desktop [SupportedOSPlatform("windows")] private string? getStableInstallPathFromRegistry() { - using (RegistryKey? key = Registry.ClassesRoot.OpenSubKey("osu")) - return key?.OpenSubKey(@"shell\open\command")?.GetValue(string.Empty)?.ToString()?.Split('"')[1].Replace("osu!.exe", ""); + using (RegistryKey? key = Registry.ClassesRoot.OpenSubKey("osu!")) + return key?.OpenSubKey(WindowsAssociationManager.SHELL_OPEN_COMMAND)?.GetValue(string.Empty)?.ToString()?.Split('"')[1].Replace("osu!.exe", ""); } protected override UpdateManager CreateUpdateManager() From 6ded79cf0728010aedfb367cf48f3fd3f84abe6c Mon Sep 17 00:00:00 2001 From: Susko3 Date: Thu, 8 Feb 2024 01:15:37 +0100 Subject: [PATCH 070/508] Make `NotifyShellUpdate()` `public` to ease testing --- osu.Desktop/Windows/WindowsAssociationManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 83c2a97b56..4bb8e57c9d 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -125,6 +125,8 @@ namespace osu.Desktop.Windows } } + public static void NotifyShellUpdate() => SHChangeNotify(EventId.SHCNE_ASSOCCHANGED, Flags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); + /// /// Installs or updates associations. /// @@ -162,8 +164,6 @@ namespace osu.Desktop.Windows } } - internal static void NotifyShellUpdate() => SHChangeNotify(EventId.SHCNE_ASSOCCHANGED, Flags.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); - #region Native interop [DllImport("Shell32.dll")] From c9c39ecb2f616b27b088bb455d5c122323127b10 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 9 Feb 2024 15:15:27 -0800 Subject: [PATCH 071/508] Add `RankHighest` to `APIUser` --- .../Visual/Online/TestSceneUserProfileOverlay.cs | 5 +++++ osu.Game/Online/API/Requests/Responses/APIUser.cs | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs index bc8f75d4ce..020e020b10 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs @@ -137,6 +137,11 @@ namespace osu.Game.Tests.Visual.Online @"top_ranks", @"medals" }, + RankHighest = new APIUser.UserRankHighest + { + Rank = 1, + UpdatedAt = DateTimeOffset.Now, + }, Statistics = new UserStatistics { IsRanked = true, diff --git a/osu.Game/Online/API/Requests/Responses/APIUser.cs b/osu.Game/Online/API/Requests/Responses/APIUser.cs index 56eec19fa1..4a31718f28 100644 --- a/osu.Game/Online/API/Requests/Responses/APIUser.cs +++ b/osu.Game/Online/API/Requests/Responses/APIUser.cs @@ -34,6 +34,19 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty(@"previous_usernames")] public string[] PreviousUsernames; + [JsonProperty(@"rank_highest")] + [CanBeNull] + public UserRankHighest RankHighest; + + public class UserRankHighest + { + [JsonProperty(@"rank")] + public int Rank; + + [JsonProperty(@"updated_at")] + public DateTimeOffset UpdatedAt; + } + [JsonProperty(@"country_code")] private string countryCodeString; From 8d1d65a469c717f29115743ab231ce791930668d Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 9 Feb 2024 15:17:34 -0800 Subject: [PATCH 072/508] Add `ContentTooltipText` to `ProfileValueDisplay` --- .../Header/Components/ProfileValueDisplay.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileValueDisplay.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileValueDisplay.cs index 4b1a0409a3..b2c23458b1 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileValueDisplay.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileValueDisplay.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; @@ -13,7 +14,7 @@ namespace osu.Game.Overlays.Profile.Header.Components public partial class ProfileValueDisplay : CompositeDrawable { private readonly OsuSpriteText title; - private readonly OsuSpriteText content; + private readonly ContentText content; public LocalisableString Title { @@ -25,6 +26,11 @@ namespace osu.Game.Overlays.Profile.Header.Components set => content.Text = value; } + public LocalisableString ContentTooltipText + { + set => content.TooltipText = value; + } + public ProfileValueDisplay(bool big = false, int minimumWidth = 60) { AutoSizeAxes = Axes.Both; @@ -38,9 +44,9 @@ namespace osu.Game.Overlays.Profile.Header.Components { Font = OsuFont.GetFont(size: 12) }, - content = new OsuSpriteText + content = new ContentText { - Font = OsuFont.GetFont(size: big ? 30 : 20, weight: FontWeight.Light) + Font = OsuFont.GetFont(size: big ? 30 : 20, weight: FontWeight.Light), }, new Container // Add a minimum size to the FillFlowContainer { @@ -56,5 +62,10 @@ namespace osu.Game.Overlays.Profile.Header.Components title.Colour = colourProvider.Content1; content.Colour = colourProvider.Content2; } + + private partial class ContentText : OsuSpriteText, IHasTooltip + { + public LocalisableString TooltipText { get; set; } + } } } From ae89b89928af680dc921cfc4880241aa787e44ce Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 9 Feb 2024 15:33:49 -0800 Subject: [PATCH 073/508] Centralise global rank display logic to new class --- .../Header/Components/GlobalRankDisplay.cs | 32 +++++++++++++++++++ .../Profile/Header/Components/MainDetails.cs | 9 ++---- osu.Game/Users/UserRankPanel.cs | 6 ++-- 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs diff --git a/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs b/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs new file mode 100644 index 0000000000..290b052e27 --- /dev/null +++ b/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs @@ -0,0 +1,32 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Bindables; +using osu.Framework.Extensions.LocalisationExtensions; +using osu.Framework.Localisation; +using osu.Game.Resources.Localisation.Web; +using osu.Game.Users; + +namespace osu.Game.Overlays.Profile.Header.Components +{ + public partial class GlobalRankDisplay : ProfileValueDisplay + { + public readonly Bindable UserStatistics = new Bindable(); + + public GlobalRankDisplay() + : base(true) + { + Title = UsersStrings.ShowRankGlobalSimple; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + UserStatistics.BindValueChanged(s => + { + Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; + }, true); + } + } +} diff --git a/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs b/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs index b89973c5e5..2aea897451 100644 --- a/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs +++ b/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs @@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Profile.Header.Components private readonly Dictionary scoreRankInfos = new Dictionary(); private ProfileValueDisplay medalInfo = null!; private ProfileValueDisplay ppInfo = null!; - private ProfileValueDisplay detailGlobalRank = null!; + private GlobalRankDisplay detailGlobalRank = null!; private ProfileValueDisplay detailCountryRank = null!; private RankGraph rankGraph = null!; @@ -52,10 +52,7 @@ namespace osu.Game.Overlays.Profile.Header.Components Spacing = new Vector2(20), Children = new Drawable[] { - detailGlobalRank = new ProfileValueDisplay(true) - { - Title = UsersStrings.ShowRankGlobalSimple, - }, + detailGlobalRank = new GlobalRankDisplay(), detailCountryRank = new ProfileValueDisplay(true) { Title = UsersStrings.ShowRankCountrySimple, @@ -142,7 +139,7 @@ namespace osu.Game.Overlays.Profile.Header.Components foreach (var scoreRankInfo in scoreRankInfos) scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0; - detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; + detailGlobalRank.UserStatistics.Value = user?.Statistics; detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; rankGraph.Statistics.Value = user?.Statistics; diff --git a/osu.Game/Users/UserRankPanel.cs b/osu.Game/Users/UserRankPanel.cs index 84ff3114fc..ba9ef1eee4 100644 --- a/osu.Game/Users/UserRankPanel.cs +++ b/osu.Game/Users/UserRankPanel.cs @@ -27,7 +27,6 @@ namespace osu.Game.Users [Resolved] private IAPIProvider api { get; set; } = null!; - private ProfileValueDisplay globalRankDisplay = null!; private ProfileValueDisplay countryRankDisplay = null!; private readonly IBindable statistics = new Bindable(); @@ -47,7 +46,6 @@ namespace osu.Game.Users statistics.BindTo(api.Statistics); statistics.BindValueChanged(stats => { - globalRankDisplay.Content = stats.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? "-"; countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-"; }, true); } @@ -163,9 +161,9 @@ namespace osu.Game.Users { new Drawable[] { - globalRankDisplay = new ProfileValueDisplay(true) + new GlobalRankDisplay { - Title = UsersStrings.ShowRankGlobalSimple, + UserStatistics = { BindTarget = statistics }, }, countryRankDisplay = new ProfileValueDisplay(true) { From ffd0d9bb3994f7471746921f63a3594efc16c49d Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 9 Feb 2024 15:36:15 -0800 Subject: [PATCH 074/508] Add highest rank tooltip to global rank display --- .../Profile/Header/Components/GlobalRankDisplay.cs | 12 ++++++++++++ .../Profile/Header/Components/MainDetails.cs | 1 + osu.Game/Users/UserRankPanel.cs | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs b/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs index 290b052e27..dcd4129b45 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs @@ -4,6 +4,7 @@ using osu.Framework.Bindables; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Localisation; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Resources.Localisation.Web; using osu.Game.Users; @@ -12,6 +13,7 @@ namespace osu.Game.Overlays.Profile.Header.Components public partial class GlobalRankDisplay : ProfileValueDisplay { public readonly Bindable UserStatistics = new Bindable(); + public readonly Bindable User = new Bindable(); public GlobalRankDisplay() : base(true) @@ -27,6 +29,16 @@ namespace osu.Game.Overlays.Profile.Header.Components { Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; }, true); + + // needed as statistics doesn't populate User + User.BindValueChanged(u => + { + var rankHighest = u.NewValue?.RankHighest; + + ContentTooltipText = rankHighest != null + ? UsersStrings.ShowRankHighest(rankHighest.Rank.ToLocalisableString("\\##,##0"), rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy")) + : string.Empty; + }, true); } } } diff --git a/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs b/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs index 2aea897451..ffdf8edc21 100644 --- a/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs +++ b/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs @@ -140,6 +140,7 @@ namespace osu.Game.Overlays.Profile.Header.Components scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0; detailGlobalRank.UserStatistics.Value = user?.Statistics; + detailGlobalRank.User.Value = user; detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; rankGraph.Statistics.Value = user?.Statistics; diff --git a/osu.Game/Users/UserRankPanel.cs b/osu.Game/Users/UserRankPanel.cs index ba9ef1eee4..4a00583094 100644 --- a/osu.Game/Users/UserRankPanel.cs +++ b/osu.Game/Users/UserRankPanel.cs @@ -30,6 +30,7 @@ namespace osu.Game.Users private ProfileValueDisplay countryRankDisplay = null!; private readonly IBindable statistics = new Bindable(); + private readonly IBindable user = new Bindable(); public UserRankPanel(APIUser user) : base(user) @@ -48,6 +49,8 @@ namespace osu.Game.Users { countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-"; }, true); + + user.BindTo(api.LocalUser!); } protected override Drawable CreateLayout() @@ -164,6 +167,9 @@ namespace osu.Game.Users new GlobalRankDisplay { UserStatistics = { BindTarget = statistics }, + // TODO: make highest rank update, as api.LocalUser doesn't update + // maybe move to statistics in api, so `SoloStatisticsWatcher` can update the value + User = { BindTarget = user }, }, countryRankDisplay = new ProfileValueDisplay(true) { From 7b0b39dbaa515e5d2455de0da7e9884d222fc601 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 9 Feb 2024 15:46:14 -0800 Subject: [PATCH 075/508] Fix total play time tooltip area including label --- .../Profile/Header/Components/TotalPlayTime.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/TotalPlayTime.cs b/osu.Game/Overlays/Profile/Header/Components/TotalPlayTime.cs index 08ca59d89b..a3c22d61d2 100644 --- a/osu.Game/Overlays/Profile/Header/Components/TotalPlayTime.cs +++ b/osu.Game/Overlays/Profile/Header/Components/TotalPlayTime.cs @@ -5,25 +5,19 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; -using osu.Framework.Localisation; using osu.Game.Resources.Localisation.Web; namespace osu.Game.Overlays.Profile.Header.Components { - public partial class TotalPlayTime : CompositeDrawable, IHasTooltip + public partial class TotalPlayTime : CompositeDrawable { public readonly Bindable User = new Bindable(); - public LocalisableString TooltipText { get; set; } - private ProfileValueDisplay info = null!; public TotalPlayTime() { AutoSizeAxes = Axes.Both; - - TooltipText = "0 hours"; } [BackgroundDependencyLoader] @@ -32,6 +26,7 @@ namespace osu.Game.Overlays.Profile.Header.Components InternalChild = info = new ProfileValueDisplay(minimumWidth: 140) { Title = UsersStrings.ShowStatsPlayTime, + ContentTooltipText = "0 hours", }; User.BindValueChanged(updateTime, true); @@ -40,7 +35,7 @@ namespace osu.Game.Overlays.Profile.Header.Components private void updateTime(ValueChangedEvent user) { int? playTime = user.NewValue?.User.Statistics?.PlayTime; - TooltipText = (playTime ?? 0) / 3600 + " hours"; + info.ContentTooltipText = (playTime ?? 0) / 3600 + " hours"; info.Content = formatTime(playTime); } From 1944a12634817ea43888e8ffec7b6359e6499f44 Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Mon, 12 Feb 2024 21:18:31 +0900 Subject: [PATCH 076/508] allow `ModMuted` to ranked when setting adjusted --- osu.Game/Rulesets/Mods/ModMuted.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Mods/ModMuted.cs b/osu.Game/Rulesets/Mods/ModMuted.cs index 3ecd9aa6a1..7aefefc58d 100644 --- a/osu.Game/Rulesets/Mods/ModMuted.cs +++ b/osu.Game/Rulesets/Mods/ModMuted.cs @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Mods public override LocalisableString Description => "Can you still feel the rhythm without music?"; public override ModType Type => ModType.Fun; public override double ScoreMultiplier => 1; - public override bool Ranked => UsesDefaultConfiguration; + public override bool Ranked => true; } public abstract class ModMuted : ModMuted, IApplicableToDrawableRuleset, IApplicableToTrack, IApplicableToScoreProcessor From 1eb04c5190220e97b901ab989985709f1553fa22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 13 Feb 2024 11:24:31 +0100 Subject: [PATCH 077/508] Add failing test coverage for catch --- .../CatchHealthProcessorTest.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs diff --git a/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs new file mode 100644 index 0000000000..8c2d1a91ab --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs @@ -0,0 +1,58 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Rulesets.Catch.Beatmaps; +using osu.Game.Rulesets.Catch.Judgements; +using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Catch.Scoring; + +namespace osu.Game.Rulesets.Catch.Tests +{ + [TestFixture] + public class CatchHealthProcessorTest + { + private static readonly object[][] test_cases = + [ + // hitobject, starting HP, fail expected after miss + [new Fruit(), 0.01, true], + [new Droplet(), 0.01, true], + [new TinyDroplet(), 0, true], + [new Banana(), 0, false], + ]; + + [TestCaseSource(nameof(test_cases))] + public void TestFailAfterMinResult(CatchHitObject hitObject, double startingHealth, bool failExpected) + { + var healthProcessor = new CatchHealthProcessor(0); + healthProcessor.ApplyBeatmap(new CatchBeatmap + { + HitObjects = { hitObject } + }); + healthProcessor.Health.Value = startingHealth; + + var result = new CatchJudgementResult(hitObject, hitObject.CreateJudgement()); + result.Type = result.Judgement.MinResult; + healthProcessor.ApplyResult(result); + + Assert.That(healthProcessor.HasFailed, Is.EqualTo(failExpected)); + } + + [TestCaseSource(nameof(test_cases))] + public void TestNoFailAfterMaxResult(CatchHitObject hitObject, double startingHealth, bool _) + { + var healthProcessor = new CatchHealthProcessor(0); + healthProcessor.ApplyBeatmap(new CatchBeatmap + { + HitObjects = { hitObject } + }); + healthProcessor.Health.Value = startingHealth; + + var result = new CatchJudgementResult(hitObject, hitObject.CreateJudgement()); + result.Type = result.Judgement.MaxResult; + healthProcessor.ApplyResult(result); + + Assert.That(healthProcessor.HasFailed, Is.False); + } + } +} From 86801aa51d9716228f24fb4728607f95f2ed8f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 13 Feb 2024 11:57:42 +0100 Subject: [PATCH 078/508] Add failing test coverage for osu! --- .../OsuHealthProcessorTest.cs | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 osu.Game.Rulesets.Osu.Tests/OsuHealthProcessorTest.cs diff --git a/osu.Game.Rulesets.Osu.Tests/OsuHealthProcessorTest.cs b/osu.Game.Rulesets.Osu.Tests/OsuHealthProcessorTest.cs new file mode 100644 index 0000000000..cf93e0ce7b --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/OsuHealthProcessorTest.cs @@ -0,0 +1,66 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Rulesets.Osu.Beatmaps; +using osu.Game.Rulesets.Osu.Judgements; +using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Scoring; + +namespace osu.Game.Rulesets.Osu.Tests +{ + [TestFixture] + public class OsuHealthProcessorTest + { + private static readonly object[][] test_cases = + [ + // hitobject, starting HP, fail expected after miss + [new HitCircle(), 0.01, true], + [new SliderHeadCircle(), 0.01, true], + [new SliderHeadCircle { ClassicSliderBehaviour = true }, 0.01, true], + [new SliderTick(), 0.01, true], + [new SliderRepeat(new Slider()), 0.01, true], + [new SliderTailCircle(new Slider()), 0, true], + [new SliderTailCircle(new Slider()) { ClassicSliderBehaviour = true }, 0.01, true], + [new Slider(), 0, true], + [new Slider { ClassicSliderBehaviour = true }, 0.01, true], + [new SpinnerTick(), 0, false], + [new SpinnerBonusTick(), 0, false], + [new Spinner(), 0.01, true], + ]; + + [TestCaseSource(nameof(test_cases))] + public void TestFailAfterMinResult(OsuHitObject hitObject, double startingHealth, bool failExpected) + { + var healthProcessor = new OsuHealthProcessor(0); + healthProcessor.ApplyBeatmap(new OsuBeatmap + { + HitObjects = { hitObject } + }); + healthProcessor.Health.Value = startingHealth; + + var result = new OsuJudgementResult(hitObject, hitObject.CreateJudgement()); + result.Type = result.Judgement.MinResult; + healthProcessor.ApplyResult(result); + + Assert.That(healthProcessor.HasFailed, Is.EqualTo(failExpected)); + } + + [TestCaseSource(nameof(test_cases))] + public void TestNoFailAfterMaxResult(OsuHitObject hitObject, double startingHealth, bool _) + { + var healthProcessor = new OsuHealthProcessor(0); + healthProcessor.ApplyBeatmap(new OsuBeatmap + { + HitObjects = { hitObject } + }); + healthProcessor.Health.Value = startingHealth; + + var result = new OsuJudgementResult(hitObject, hitObject.CreateJudgement()); + result.Type = result.Judgement.MaxResult; + healthProcessor.ApplyResult(result); + + Assert.That(healthProcessor.HasFailed, Is.False); + } + } +} From 441a7b3c2ff68fc13fefb439698e4605f9adacc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 13 Feb 2024 12:07:40 +0100 Subject: [PATCH 079/508] Add precautionary taiko test coverage --- .../TaikoHealthProcessorTest.cs | 82 ++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko.Tests/TaikoHealthProcessorTest.cs b/osu.Game.Rulesets.Taiko.Tests/TaikoHealthProcessorTest.cs index f4a1e888c9..aba967cdd6 100644 --- a/osu.Game.Rulesets.Taiko.Tests/TaikoHealthProcessorTest.cs +++ b/osu.Game.Rulesets.Taiko.Tests/TaikoHealthProcessorTest.cs @@ -147,7 +147,7 @@ namespace osu.Game.Rulesets.Taiko.Tests { HitObjects = { - new DrumRoll { Duration = 2000 } + new Swell { Duration = 2000 } } }; @@ -172,5 +172,85 @@ namespace osu.Game.Rulesets.Taiko.Tests Assert.That(healthProcessor.HasFailed, Is.False); }); } + + [Test] + public void TestMissHitAndHitSwell() + { + var beatmap = new TaikoBeatmap + { + HitObjects = + { + new Hit(), + new Swell { Duration = 2000 } + } + }; + + foreach (var ho in beatmap.HitObjects) + ho.ApplyDefaults(beatmap.ControlPointInfo, beatmap.Difficulty); + + var healthProcessor = new TaikoHealthProcessor(); + healthProcessor.ApplyBeatmap(beatmap); + + healthProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[0], new TaikoJudgement()) { Type = HitResult.Miss }); + + foreach (var nested in beatmap.HitObjects[1].NestedHitObjects) + { + var nestedJudgement = nested.CreateJudgement(); + healthProcessor.ApplyResult(new JudgementResult(nested, nestedJudgement) { Type = nestedJudgement.MaxResult }); + } + + var judgement = beatmap.HitObjects[1].CreateJudgement(); + healthProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[1], judgement) { Type = judgement.MaxResult }); + + Assert.Multiple(() => + { + Assert.That(healthProcessor.Health.Value, Is.EqualTo(0)); + Assert.That(healthProcessor.HasFailed, Is.True); + }); + } + + private static readonly object[][] test_cases = + [ + // hitobject, fail expected after miss + [new Hit(), true], + [new Hit.StrongNestedHit(new Hit()), false], + [new DrumRollTick(new DrumRoll()), false], + [new DrumRollTick.StrongNestedHit(new DrumRollTick(new DrumRoll())), false], + [new DrumRoll(), false], + [new SwellTick(), false], + [new Swell(), false] + ]; + + [TestCaseSource(nameof(test_cases))] + public void TestFailAfterMinResult(TaikoHitObject hitObject, bool failExpected) + { + var healthProcessor = new TaikoHealthProcessor(); + healthProcessor.ApplyBeatmap(new TaikoBeatmap + { + HitObjects = { hitObject } + }); + + var result = new JudgementResult(hitObject, hitObject.CreateJudgement()); + result.Type = result.Judgement.MinResult; + healthProcessor.ApplyResult(result); + + Assert.That(healthProcessor.HasFailed, Is.EqualTo(failExpected)); + } + + [TestCaseSource(nameof(test_cases))] + public void TestNoFailAfterMaxResult(TaikoHitObject hitObject, bool _) + { + var healthProcessor = new TaikoHealthProcessor(); + healthProcessor.ApplyBeatmap(new TaikoBeatmap + { + HitObjects = { hitObject } + }); + + var result = new JudgementResult(hitObject, hitObject.CreateJudgement()); + result.Type = result.Judgement.MaxResult; + healthProcessor.ApplyResult(result); + + Assert.That(healthProcessor.HasFailed, Is.False); + } } } From d07ea8f5b12886883a60cf9c477fa9d632404ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 13 Feb 2024 12:17:38 +0100 Subject: [PATCH 080/508] Add failing test coverage for mania --- .../ManiaHealthProcessorTest.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/osu.Game.Rulesets.Mania.Tests/ManiaHealthProcessorTest.cs b/osu.Game.Rulesets.Mania.Tests/ManiaHealthProcessorTest.cs index 315849f7de..a9771a46f3 100644 --- a/osu.Game.Rulesets.Mania.Tests/ManiaHealthProcessorTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/ManiaHealthProcessorTest.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Scoring; @@ -27,5 +28,49 @@ namespace osu.Game.Rulesets.Mania.Tests // No matter what, mania doesn't have passive HP drain. Assert.That(processor.DrainRate, Is.Zero); } + + private static readonly object[][] test_cases = + [ + // hitobject, starting HP, fail expected after miss + [new Note(), 0.01, true], + [new HeadNote(), 0.01, true], + [new TailNote(), 0.01, true], + [new HoldNoteBody(), 0, true], // hold note break + [new HoldNote(), 0, true], + ]; + + [TestCaseSource(nameof(test_cases))] + public void TestFailAfterMinResult(ManiaHitObject hitObject, double startingHealth, bool failExpected) + { + var healthProcessor = new ManiaHealthProcessor(0); + healthProcessor.ApplyBeatmap(new ManiaBeatmap(new StageDefinition(4)) + { + HitObjects = { hitObject } + }); + healthProcessor.Health.Value = startingHealth; + + var result = new JudgementResult(hitObject, hitObject.CreateJudgement()); + result.Type = result.Judgement.MinResult; + healthProcessor.ApplyResult(result); + + Assert.That(healthProcessor.HasFailed, Is.EqualTo(failExpected)); + } + + [TestCaseSource(nameof(test_cases))] + public void TestNoFailAfterMaxResult(ManiaHitObject hitObject, double startingHealth, bool _) + { + var healthProcessor = new ManiaHealthProcessor(0); + healthProcessor.ApplyBeatmap(new ManiaBeatmap(new StageDefinition(4)) + { + HitObjects = { hitObject } + }); + healthProcessor.Health.Value = startingHealth; + + var result = new JudgementResult(hitObject, hitObject.CreateJudgement()); + result.Type = result.Judgement.MaxResult; + healthProcessor.ApplyResult(result); + + Assert.That(healthProcessor.HasFailed, Is.False); + } } } From 16d893d40c10542a2502884df95d54773044ffb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 13 Feb 2024 12:26:37 +0100 Subject: [PATCH 081/508] Fix draining processor failing gameplay on bonus misses and ignore hits --- osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs | 5 +++++ osu.Game/Rulesets/Scoring/HealthProcessor.cs | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs b/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs index 629a84ea62..92a064385b 100644 --- a/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs @@ -142,6 +142,11 @@ namespace osu.Game.Rulesets.Scoring } } + protected override bool CanFailOn(JudgementResult result) + { + return !result.Judgement.MaxResult.IsBonus() && result.Type != HitResult.IgnoreHit; + } + protected override void Reset(bool storeResults) { base.Reset(storeResults); diff --git a/osu.Game/Rulesets/Scoring/HealthProcessor.cs b/osu.Game/Rulesets/Scoring/HealthProcessor.cs index b5eb755650..ccf53f075a 100644 --- a/osu.Game/Rulesets/Scoring/HealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/HealthProcessor.cs @@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Scoring Health.Value += GetHealthIncreaseFor(result); - if (meetsAnyFailCondition(result)) + if (CanFailOn(result) && meetsAnyFailCondition(result)) TriggerFailure(); } @@ -68,6 +68,13 @@ namespace osu.Game.Rulesets.Scoring /// The health increase. protected virtual double GetHealthIncreaseFor(JudgementResult result) => result.HealthIncrease; + /// + /// Whether a failure can occur on a given . + /// If the return value of this method is , neither nor will be checked + /// after this . + /// + protected virtual bool CanFailOn(JudgementResult result) => true; + /// /// The default conditions for failing. /// From 3d8d0f8430487c4c30e8964f11e52e1a6522f098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 14 Feb 2024 08:37:20 +0100 Subject: [PATCH 082/508] Update test expectations for catch --- osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs index 8c2d1a91ab..d0a8ce4bbc 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Catch.Tests // hitobject, starting HP, fail expected after miss [new Fruit(), 0.01, true], [new Droplet(), 0.01, true], - [new TinyDroplet(), 0, true], + [new TinyDroplet(), 0, false], [new Banana(), 0, false], ]; From f53bce8ff785a1c52bcd1bffb365e43287ec8bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 14 Feb 2024 08:38:39 +0100 Subject: [PATCH 083/508] Fix catch health processor allowing fail on tiny droplet Closes https://github.com/ppy/osu/issues/27159. In today's episode of "just stable things"... --- .../Scoring/CatchHealthProcessor.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs b/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs index c3cc488941..2e1aec0803 100644 --- a/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs +++ b/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; @@ -21,6 +22,19 @@ namespace osu.Game.Rulesets.Catch.Scoring protected override IEnumerable EnumerateNestedHitObjects(HitObject hitObject) => Enumerable.Empty(); + protected override bool CanFailOn(JudgementResult result) + { + // matches stable. + // see: https://github.com/peppy/osu-stable-reference/blob/46cd3a10af7cc6cc96f4eba92ef1812dc8c3a27e/osu!/GameModes/Play/Rulesets/Ruleset.cs#L967 + // the above early-return skips the failure check at the end of the same method: + // https://github.com/peppy/osu-stable-reference/blob/46cd3a10af7cc6cc96f4eba92ef1812dc8c3a27e/osu!/GameModes/Play/Rulesets/Ruleset.cs#L1232 + // making it impossible to fail on a tiny droplet regardless of result. + if (result.Type == HitResult.SmallTickMiss) + return false; + + return base.CanFailOn(result); + } + protected override double GetHealthIncreaseFor(HitObject hitObject, HitResult result) { double increase = 0; From 2c0a5b7ef54169412c805ad4b05ea47cf131c012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 14 Feb 2024 14:21:48 +0100 Subject: [PATCH 084/508] Fix missing tiny droplet not triggering fail with perfect on Stable does this: https://github.com/peppy/osu-stable-reference/blob/46cd3a10af7cc6cc96f4eba92ef1812dc8c3a27e/osu!/GameplayElements/HitObjectManagerFruits.cs#L98-L102 I'd rather not say what I think about it doing that, since it's likely to be unpublishable, but to approximate that, just make it so that only the "default fail condition" is beholden to the weird ebbs and flows of what the ruleset wants. This appears to fix the problem case and I'm hoping it doesn't break something else but I'm like 50/50 on it happening anyway at this point. Just gotta add tests add nauseam. --- .../Scoring/CatchHealthProcessor.cs | 4 ++-- .../Scoring/AccumulatingHealthProcessor.cs | 4 +++- .../Scoring/DrainingHealthProcessor.cs | 7 +++++-- osu.Game/Rulesets/Scoring/HealthProcessor.cs | 18 ++++++------------ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs b/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs index 2e1aec0803..2f55f9a85f 100644 --- a/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs +++ b/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs @@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Catch.Scoring protected override IEnumerable EnumerateNestedHitObjects(HitObject hitObject) => Enumerable.Empty(); - protected override bool CanFailOn(JudgementResult result) + protected override bool CheckDefaultFailCondition(JudgementResult result) { // matches stable. // see: https://github.com/peppy/osu-stable-reference/blob/46cd3a10af7cc6cc96f4eba92ef1812dc8c3a27e/osu!/GameModes/Play/Rulesets/Ruleset.cs#L967 @@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Catch.Scoring if (result.Type == HitResult.SmallTickMiss) return false; - return base.CanFailOn(result); + return base.CheckDefaultFailCondition(result); } protected override double GetHealthIncreaseFor(HitObject hitObject, HitResult result) diff --git a/osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs b/osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs index 422bf8ea79..bb4c2463a7 100644 --- a/osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/AccumulatingHealthProcessor.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Game.Rulesets.Judgements; + namespace osu.Game.Rulesets.Scoring { /// @@ -9,7 +11,7 @@ namespace osu.Game.Rulesets.Scoring /// public partial class AccumulatingHealthProcessor : HealthProcessor { - protected override bool DefaultFailCondition => JudgedHits == MaxHits && Health.Value < requiredHealth; + protected override bool CheckDefaultFailCondition(JudgementResult _) => JudgedHits == MaxHits && Health.Value < requiredHealth; private readonly double requiredHealth; diff --git a/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs b/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs index 92a064385b..e72a8aaf67 100644 --- a/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/DrainingHealthProcessor.cs @@ -142,9 +142,12 @@ namespace osu.Game.Rulesets.Scoring } } - protected override bool CanFailOn(JudgementResult result) + protected override bool CheckDefaultFailCondition(JudgementResult result) { - return !result.Judgement.MaxResult.IsBonus() && result.Type != HitResult.IgnoreHit; + if (result.Judgement.MaxResult.IsBonus() || result.Type == HitResult.IgnoreHit) + return false; + + return base.CheckDefaultFailCondition(result); } protected override void Reset(bool storeResults) diff --git a/osu.Game/Rulesets/Scoring/HealthProcessor.cs b/osu.Game/Rulesets/Scoring/HealthProcessor.cs index ccf53f075a..9e4c06b783 100644 --- a/osu.Game/Rulesets/Scoring/HealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/HealthProcessor.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Scoring public event Func? Failed; /// - /// Additional conditions on top of that cause a failing state. + /// Additional conditions on top of that cause a failing state. /// public event Func? FailConditions; @@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Scoring Health.Value += GetHealthIncreaseFor(result); - if (CanFailOn(result) && meetsAnyFailCondition(result)) + if (meetsAnyFailCondition(result)) TriggerFailure(); } @@ -69,16 +69,10 @@ namespace osu.Game.Rulesets.Scoring protected virtual double GetHealthIncreaseFor(JudgementResult result) => result.HealthIncrease; /// - /// Whether a failure can occur on a given . - /// If the return value of this method is , neither nor will be checked - /// after this . + /// Checks whether the default conditions for failing are met. /// - protected virtual bool CanFailOn(JudgementResult result) => true; - - /// - /// The default conditions for failing. - /// - protected virtual bool DefaultFailCondition => Precision.AlmostBigger(Health.MinValue, Health.Value); + /// if failure should be invoked. + protected virtual bool CheckDefaultFailCondition(JudgementResult result) => Precision.AlmostBigger(Health.MinValue, Health.Value); /// /// Whether the current state of or the provided meets any fail condition. @@ -86,7 +80,7 @@ namespace osu.Game.Rulesets.Scoring /// The judgement result. private bool meetsAnyFailCondition(JudgementResult result) { - if (DefaultFailCondition) + if (CheckDefaultFailCondition(result)) return true; if (FailConditions != null) From a03835bf1c472a477dc992b7c2d05357e1b07da4 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 14 Feb 2024 20:13:27 -0800 Subject: [PATCH 085/508] Improve comments --- .../Overlays/Profile/Header/Components/GlobalRankDisplay.cs | 2 +- osu.Game/Users/UserRankPanel.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs b/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs index dcd4129b45..d32f56ab1b 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Profile.Header.Components Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; }, true); - // needed as statistics doesn't populate User + // needed as `UserStatistics` doesn't populate `User` User.BindValueChanged(u => { var rankHighest = u.NewValue?.RankHighest; diff --git a/osu.Game/Users/UserRankPanel.cs b/osu.Game/Users/UserRankPanel.cs index 4a00583094..0b8a5166e6 100644 --- a/osu.Game/Users/UserRankPanel.cs +++ b/osu.Game/Users/UserRankPanel.cs @@ -167,8 +167,8 @@ namespace osu.Game.Users new GlobalRankDisplay { UserStatistics = { BindTarget = statistics }, - // TODO: make highest rank update, as api.LocalUser doesn't update - // maybe move to statistics in api, so `SoloStatisticsWatcher` can update the value + // TODO: make highest rank update, as `api.LocalUser` doesn't update + // maybe move to `UserStatistics` in api, so `SoloStatisticsWatcher` can update the value User = { BindTarget = user }, }, countryRankDisplay = new ProfileValueDisplay(true) From 0fff9d49378ce8acc9aa0e612b6215ed831eea9b Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 16 Feb 2024 19:17:41 +0900 Subject: [PATCH 086/508] Add non-whitespace search term for mods --- osu.Game/Overlays/Mods/ModPanel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Mods/ModPanel.cs b/osu.Game/Overlays/Mods/ModPanel.cs index f294b1892d..2d8d01d8c8 100644 --- a/osu.Game/Overlays/Mods/ModPanel.cs +++ b/osu.Game/Overlays/Mods/ModPanel.cs @@ -80,6 +80,7 @@ namespace osu.Game.Overlays.Mods public override IEnumerable FilterTerms => new[] { Mod.Name, + Mod.Name.Replace(" ", string.Empty), Mod.Acronym, Mod.Description }; From cd8ac6a722124e7827f2a8ee0ef39ef2ab41a932 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sat, 17 Feb 2024 22:12:15 +0200 Subject: [PATCH 087/508] Update BeatmapAttributesDisplay.cs --- .../Overlays/Mods/BeatmapAttributesDisplay.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index b9e4896b21..9312940001 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -19,6 +19,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; +using osu.Game.Online.Rooms; using osuTK; namespace osu.Game.Overlays.Mods @@ -42,6 +43,9 @@ namespace osu.Game.Overlays.Mods [Resolved] private Bindable> mods { get; set; } = null!; + [Resolved(CanBeNull = true)] + private IBindable? selectedItem { get; set; } + public BindableBool Collapsed { get; } = new BindableBool(true); private ModSettingChangeTracker? modSettingChangeTracker; @@ -108,6 +112,8 @@ namespace osu.Game.Overlays.Mods updateValues(); }, true); + selectedItem?.BindValueChanged(_ => mods.TriggerChange()); + BeatmapInfo.BindValueChanged(_ => updateValues(), true); Collapsed.BindValueChanged(_ => @@ -164,10 +170,20 @@ namespace osu.Game.Overlays.Mods starRatingDisplay.FinishTransforms(true); }); + Ruleset ruleset = gameRuleset.Value.CreateInstance(); + double rate = 1; foreach (var mod in mods.Value.OfType()) rate = mod.ApplyToRate(0, rate); + if (selectedItem != null && selectedItem.Value != null) + { + var globalMods = selectedItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + + foreach (var mod in globalMods.OfType()) + rate = mod.ApplyToRate(0, rate); + } + bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty); @@ -175,7 +191,6 @@ namespace osu.Game.Overlays.Mods foreach (var mod in mods.Value.OfType()) mod.ApplyToDifficulty(originalDifficulty); - Ruleset ruleset = gameRuleset.Value.CreateInstance(); BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty); From ed819fde1589bc0cc6167b4610c5a115e49fc844 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sat, 17 Feb 2024 23:01:31 +0200 Subject: [PATCH 088/508] Fixed bugs and added ranked status update --- .../Overlays/Mods/BeatmapAttributesDisplay.cs | 32 ++++++++++++------- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 32 +++++++++++++++++-- .../Screens/OnlinePlay/Match/RoomSubScreen.cs | 3 +- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 9312940001..da14382175 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -40,11 +40,16 @@ namespace osu.Game.Overlays.Mods public Bindable BeatmapInfo { get; } = new Bindable(); + /// + /// Should attribute display account for the multiplayer room global mods. + /// + public bool AccountForMultiplayerMods = false; + [Resolved] private Bindable> mods { get; set; } = null!; [Resolved(CanBeNull = true)] - private IBindable? selectedItem { get; set; } + private IBindable? multiplayerRoomItem { get; set; } public BindableBool Collapsed { get; } = new BindableBool(true); @@ -112,7 +117,7 @@ namespace osu.Game.Overlays.Mods updateValues(); }, true); - selectedItem?.BindValueChanged(_ => mods.TriggerChange()); + multiplayerRoomItem?.BindValueChanged(_ => mods.TriggerChange()); BeatmapInfo.BindValueChanged(_ => updateValues(), true); @@ -176,23 +181,26 @@ namespace osu.Game.Overlays.Mods foreach (var mod in mods.Value.OfType()) rate = mod.ApplyToRate(0, rate); - if (selectedItem != null && selectedItem.Value != null) - { - var globalMods = selectedItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - - foreach (var mod in globalMods.OfType()) - rate = mod.ApplyToRate(0, rate); - } - - bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; - BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty); foreach (var mod in mods.Value.OfType()) mod.ApplyToDifficulty(originalDifficulty); + if (AccountForMultiplayerMods && multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + { + var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + + foreach (var mod in multiplayerRoomMods.OfType()) + rate = mod.ApplyToRate(0, rate); + + foreach (var mod in multiplayerRoomMods.OfType()) + mod.ApplyToDifficulty(originalDifficulty); + } + BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); + bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; + TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty); approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.ApproachRate, adjustedDifficulty.ApproachRate); diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index ddf96c1cb3..0804624ed8 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -25,7 +25,9 @@ using osu.Game.Graphics.Cursor; using osu.Game.Graphics.UserInterface; using osu.Game.Input.Bindings; using osu.Game.Localisation; +using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; +using osu.Game.Online.Rooms; using osu.Game.Utils; using osuTK; using osuTK.Input; @@ -42,6 +44,12 @@ namespace osu.Game.Overlays.Mods [Cached] public Bindable> SelectedMods { get; private set; } = new Bindable>(Array.Empty()); + [Resolved(CanBeNull = true)] + private IBindable? multiplayerRoomItem { get; set; } + + [Resolved] + private OsuGameBase game { get; set; } = null!; + /// /// Contains a dictionary with the current of all mods applicable for the current ruleset. /// @@ -92,6 +100,11 @@ namespace osu.Game.Overlays.Mods /// protected virtual bool ShowPresets => false; + /// + /// Should overlay account for the multiplayer room global mods. + /// + public bool AccountForMultiplayerMods = false; + protected virtual ModColumn CreateModColumn(ModType modType) => new ModColumn(modType, false); protected virtual IReadOnlyList ComputeNewModsFromSelection(IReadOnlyList oldSelection, IReadOnlyList newSelection) => newSelection; @@ -278,7 +291,8 @@ namespace osu.Game.Overlays.Mods { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, - BeatmapInfo = { Value = beatmap?.BeatmapInfo } + BeatmapInfo = { Value = beatmap?.BeatmapInfo }, + AccountForMultiplayerMods = AccountForMultiplayerMods }, } }); @@ -332,6 +346,8 @@ namespace osu.Game.Overlays.Mods } }, true); + multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange()); + customisationVisible.BindValueChanged(_ => updateCustomisationVisualState(), true); SearchTextBox.Current.BindValueChanged(query => @@ -460,8 +476,20 @@ namespace osu.Game.Overlays.Mods foreach (var mod in SelectedMods.Value) multiplier *= mod.ScoreMultiplier; - rankingInformationDisplay.ModMultiplier.Value = multiplier; rankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked); + + if (AccountForMultiplayerMods && multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + { + Ruleset ruleset = game.Ruleset.Value.CreateInstance(); + var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + + foreach (var mod in multiplayerRoomMods) + multiplier *= mod.ScoreMultiplier; + + rankingInformationDisplay.Ranked.Value = rankingInformationDisplay.Ranked.Value && multiplayerRoomMods.All(m => m.Ranked); + } + + rankingInformationDisplay.ModMultiplier.Value = multiplier; } private void updateCustomisation() diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs index 4c0219eff5..71f8bfa0f4 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs @@ -244,7 +244,8 @@ namespace osu.Game.Screens.OnlinePlay.Match LoadComponent(UserModsSelectOverlay = new UserModSelectOverlay(OverlayColourScheme.Plum) { SelectedMods = { BindTarget = UserMods }, - IsValidMod = _ => false + IsValidMod = _ => false, + AccountForMultiplayerMods = true }); } From 414e55c90e33d492988914f992f0684284209145 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 18 Feb 2024 01:38:50 +0300 Subject: [PATCH 089/508] Add visual test case --- .../Visual/Online/TestSceneDrawableComment.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneDrawableComment.cs b/osu.Game.Tests/Visual/Online/TestSceneDrawableComment.cs index 6f09e4c1f6..5cdf79160c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDrawableComment.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDrawableComment.cs @@ -81,16 +81,17 @@ namespace osu.Game.Tests.Visual.Online }, // Taken from https://github.com/ppy/osu/issues/13993#issuecomment-885994077 + new[] { "Problematic", @"My tablet doesn't work :( It's a Huion 420 and it's apparently incompatible with OpenTablet Driver. The warning I get is: ""DeviceInUseException: Device is currently in use by another kernel module. To fix this issue, please follow the instructions from https://github.com/OpenTabletDriver/OpenTabletDriver/wiki/Linux-FAQ#arg umentoutofrangeexception-value-0-15"" and it repeats 4 times on the notification before logging subsequent warnings. Checking the logs, it looks for other Huion tablets before sending the notification (e.g. ""2021-07-23 03:52:33 [verbose]: Detect: Searching for tablet 'Huion WH1409 V2' 20 2021-07-23 03:52:33 [error]: DeviceInUseException: Device is currently in use by another kernel module. To fix this issue, please follow the instructions from https://github.com/OpenTabletDriver/OpenTabletDriver/wiki/Linux-FAQ#arg umentoutofrangeexception-value-0-15"") I use an Arch based installation of Linux and the tablet runs perfectly with Digimend kernel driver, with area configuration, pen pressure, etc. On osu!lazer the cursor disappears until I set it to ""Borderless"" instead of ""Fullscreen"" and even after it shows up, it goes to the bottom left corner as soon as a map starts. I have honestly 0 idea of whats going on at this point.", }, new[] { - "Problematic", @"My tablet doesn't work :( -It's a Huion 420 and it's apparently incompatible with OpenTablet Driver. The warning I get is: ""DeviceInUseException: Device is currently in use by another kernel module. To fix this issue, please follow the instructions from https://github.com/OpenTabletDriver/OpenTabletDriver/wiki/Linux-FAQ#arg umentoutofrangeexception-value-0-15"" and it repeats 4 times on the notification before logging subsequent warnings. -Checking the logs, it looks for other Huion tablets before sending the notification (e.g. - ""2021-07-23 03:52:33 [verbose]: Detect: Searching for tablet 'Huion WH1409 V2' - 20 2021-07-23 03:52:33 [error]: DeviceInUseException: Device is currently in use by another kernel module. To fix this issue, please follow the instructions from https://github.com/OpenTabletDriver/OpenTabletDriver/wiki/Linux-FAQ#arg umentoutofrangeexception-value-0-15"") -I use an Arch based installation of Linux and the tablet runs perfectly with Digimend kernel driver, with area configuration, pen pressure, etc. On osu!lazer the cursor disappears until I set it to ""Borderless"" instead of ""Fullscreen"" and even after it shows up, it goes to the bottom left corner as soon as a map starts. -I have honestly 0 idea of whats going on at this point." - } + "Code Block", @"User not found! ;_; + +There are a few possible reasons for this: + + They may have changed their username. + The account may be temporarily unavailable due to security or abuse issues. + You may have made a typo!" + }, }; } } From 91675e097033c249cf7b6947e1023ee2c719ef5f Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 18 Feb 2024 02:00:55 +0300 Subject: [PATCH 090/508] Update markdown code block implementation in line with framework changes --- ...suMarkdownFencedCodeBlock.cs => OsuMarkdownCodeBlock.cs} | 6 +++--- .../Graphics/Containers/Markdown/OsuMarkdownContainer.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename osu.Game/Graphics/Containers/Markdown/{OsuMarkdownFencedCodeBlock.cs => OsuMarkdownCodeBlock.cs} (87%) diff --git a/osu.Game/Graphics/Containers/Markdown/OsuMarkdownFencedCodeBlock.cs b/osu.Game/Graphics/Containers/Markdown/OsuMarkdownCodeBlock.cs similarity index 87% rename from osu.Game/Graphics/Containers/Markdown/OsuMarkdownFencedCodeBlock.cs rename to osu.Game/Graphics/Containers/Markdown/OsuMarkdownCodeBlock.cs index 7d84d368ad..27802f4c0e 100644 --- a/osu.Game/Graphics/Containers/Markdown/OsuMarkdownFencedCodeBlock.cs +++ b/osu.Game/Graphics/Containers/Markdown/OsuMarkdownCodeBlock.cs @@ -10,11 +10,11 @@ using osu.Game.Overlays; namespace osu.Game.Graphics.Containers.Markdown { - public partial class OsuMarkdownFencedCodeBlock : MarkdownFencedCodeBlock + public partial class OsuMarkdownCodeBlock : MarkdownCodeBlock { // TODO : change to monospace font for this component - public OsuMarkdownFencedCodeBlock(FencedCodeBlock fencedCodeBlock) - : base(fencedCodeBlock) + public OsuMarkdownCodeBlock(CodeBlock codeBlock) + : base(codeBlock) { } diff --git a/osu.Game/Graphics/Containers/Markdown/OsuMarkdownContainer.cs b/osu.Game/Graphics/Containers/Markdown/OsuMarkdownContainer.cs index b4031752db..d465e53432 100644 --- a/osu.Game/Graphics/Containers/Markdown/OsuMarkdownContainer.cs +++ b/osu.Game/Graphics/Containers/Markdown/OsuMarkdownContainer.cs @@ -67,7 +67,7 @@ namespace osu.Game.Graphics.Containers.Markdown protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new OsuMarkdownHeading(headingBlock); - protected override MarkdownFencedCodeBlock CreateFencedCodeBlock(FencedCodeBlock fencedCodeBlock) => new OsuMarkdownFencedCodeBlock(fencedCodeBlock); + protected override MarkdownCodeBlock CreateCodeBlock(CodeBlock codeBlock) => new OsuMarkdownCodeBlock(codeBlock); protected override MarkdownSeparator CreateSeparator(ThematicBreakBlock thematicBlock) => new OsuMarkdownSeparator(); From 2df5787dc7e46ea573bbbd4c1608cf18564029d0 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sun, 18 Feb 2024 03:13:57 +0200 Subject: [PATCH 091/508] Packed changes into separate class --- .../Overlays/Mods/BeatmapAttributesDisplay.cs | 58 ++++----- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 66 +++------- .../Mods/MultiplayerModSelectOverlay.cs | 118 ++++++++++++++++++ .../Screens/OnlinePlay/Match/RoomSubScreen.cs | 5 +- 4 files changed, 166 insertions(+), 81 deletions(-) create mode 100644 osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index da14382175..93e7e0ae9c 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -46,10 +46,7 @@ namespace osu.Game.Overlays.Mods public bool AccountForMultiplayerMods = false; [Resolved] - private Bindable> mods { get; set; } = null!; - - [Resolved(CanBeNull = true)] - private IBindable? multiplayerRoomItem { get; set; } + protected Bindable> Mods { get; private set; } = null!; public BindableBool Collapsed { get; } = new BindableBool(true); @@ -61,7 +58,7 @@ namespace osu.Game.Overlays.Mods [Resolved] private OsuGameBase game { get; set; } = null!; - private IBindable gameRuleset = null!; + protected IBindable GameRuleset = null!; private CancellationTokenSource? cancellationSource; private IBindable starDifficulty = null!; @@ -109,16 +106,14 @@ namespace osu.Game.Overlays.Mods { base.LoadComplete(); - mods.BindValueChanged(_ => + Mods.BindValueChanged(_ => { modSettingChangeTracker?.Dispose(); - modSettingChangeTracker = new ModSettingChangeTracker(mods.Value); + modSettingChangeTracker = new ModSettingChangeTracker(Mods.Value); modSettingChangeTracker.SettingChanged += _ => updateValues(); updateValues(); }, true); - multiplayerRoomItem?.BindValueChanged(_ => mods.TriggerChange()); - BeatmapInfo.BindValueChanged(_ => updateValues(), true); Collapsed.BindValueChanged(_ => @@ -128,8 +123,8 @@ namespace osu.Game.Overlays.Mods updateCollapsedState(); }); - gameRuleset = game.Ruleset.GetBoundCopy(); - gameRuleset.BindValueChanged(_ => updateValues()); + GameRuleset = game.Ruleset.GetBoundCopy(); + GameRuleset.BindValueChanged(_ => updateValues()); BeatmapInfo.BindValueChanged(_ => updateValues(), true); @@ -159,6 +154,23 @@ namespace osu.Game.Overlays.Mods LeftContent.AutoSizeDuration = Content.AutoSizeDuration = transition_duration; } + protected virtual double GetRate() + { + double rate = 1; + foreach (var mod in Mods.Value.OfType()) + rate = mod.ApplyToRate(0, rate); + return rate; + } + + protected virtual BeatmapDifficulty GetDifficulty() + { + BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value!.Difficulty); + + foreach (var mod in Mods.Value.OfType()) + mod.ApplyToDifficulty(originalDifficulty); + + return originalDifficulty; + } private void updateValues() => Scheduler.AddOnce(() => { if (BeatmapInfo.Value == null) @@ -175,28 +187,10 @@ namespace osu.Game.Overlays.Mods starRatingDisplay.FinishTransforms(true); }); - Ruleset ruleset = gameRuleset.Value.CreateInstance(); - - double rate = 1; - foreach (var mod in mods.Value.OfType()) - rate = mod.ApplyToRate(0, rate); - - BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty); - - foreach (var mod in mods.Value.OfType()) - mod.ApplyToDifficulty(originalDifficulty); - - if (AccountForMultiplayerMods && multiplayerRoomItem != null && multiplayerRoomItem.Value != null) - { - var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - - foreach (var mod in multiplayerRoomMods.OfType()) - rate = mod.ApplyToRate(0, rate); - - foreach (var mod in multiplayerRoomMods.OfType()) - mod.ApplyToDifficulty(originalDifficulty); - } + double rate = GetRate(); + BeatmapDifficulty originalDifficulty = GetDifficulty(); + Ruleset ruleset = GameRuleset.Value.CreateInstance(); BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 0804624ed8..12719475a8 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -25,9 +25,7 @@ using osu.Game.Graphics.Cursor; using osu.Game.Graphics.UserInterface; using osu.Game.Input.Bindings; using osu.Game.Localisation; -using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; -using osu.Game.Online.Rooms; using osu.Game.Utils; using osuTK; using osuTK.Input; @@ -44,11 +42,6 @@ namespace osu.Game.Overlays.Mods [Cached] public Bindable> SelectedMods { get; private set; } = new Bindable>(Array.Empty()); - [Resolved(CanBeNull = true)] - private IBindable? multiplayerRoomItem { get; set; } - - [Resolved] - private OsuGameBase game { get; set; } = null!; /// /// Contains a dictionary with the current of all mods applicable for the current ruleset. @@ -100,11 +93,6 @@ namespace osu.Game.Overlays.Mods /// protected virtual bool ShowPresets => false; - /// - /// Should overlay account for the multiplayer room global mods. - /// - public bool AccountForMultiplayerMods = false; - protected virtual ModColumn CreateModColumn(ModType modType) => new ModColumn(modType, false); protected virtual IReadOnlyList ComputeNewModsFromSelection(IReadOnlyList oldSelection, IReadOnlyList newSelection) => newSelection; @@ -138,8 +126,14 @@ namespace osu.Game.Overlays.Mods private DeselectAllModsButton deselectAllModsButton = null!; private Container aboveColumnsContent = null!; - private RankingInformationDisplay? rankingInformationDisplay; - private BeatmapAttributesDisplay? beatmapAttributesDisplay; + protected RankingInformationDisplay? RankingInformationDisplay; + protected BeatmapAttributesDisplay? BeatmapAttributesDisplay; + protected virtual BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new BeatmapAttributesDisplay + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + BeatmapInfo = { Value = Beatmap?.BeatmapInfo } + }; protected ShearedButton BackButton { get; private set; } = null!; protected ShearedToggleButton? CustomisationButton { get; private set; } @@ -159,8 +153,8 @@ namespace osu.Game.Overlays.Mods if (beatmap == value) return; beatmap = value; - if (IsLoaded && beatmapAttributesDisplay != null) - beatmapAttributesDisplay.BeatmapInfo.Value = beatmap?.BeatmapInfo; + if (IsLoaded && BeatmapAttributesDisplay != null) + BeatmapAttributesDisplay.BeatmapInfo.Value = beatmap?.BeatmapInfo; } } @@ -282,18 +276,12 @@ namespace osu.Game.Overlays.Mods }, Children = new Drawable[] { - rankingInformationDisplay = new RankingInformationDisplay + RankingInformationDisplay = new RankingInformationDisplay { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight }, - beatmapAttributesDisplay = new BeatmapAttributesDisplay - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - BeatmapInfo = { Value = beatmap?.BeatmapInfo }, - AccountForMultiplayerMods = AccountForMultiplayerMods - }, + BeatmapAttributesDisplay = GetBeatmapAttributesDisplay } }); } @@ -329,7 +317,7 @@ namespace osu.Game.Overlays.Mods SelectedMods.BindValueChanged(_ => { - updateRankingInformation(); + UpdateRankingInformation(); updateFromExternalSelection(); updateCustomisation(); @@ -342,12 +330,10 @@ namespace osu.Game.Overlays.Mods // // See https://github.com/ppy/osu/pull/23284#issuecomment-1529056988 modSettingChangeTracker = new ModSettingChangeTracker(SelectedMods.Value); - modSettingChangeTracker.SettingChanged += _ => updateRankingInformation(); + modSettingChangeTracker.SettingChanged += _ => UpdateRankingInformation(); } }, true); - multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange()); - customisationVisible.BindValueChanged(_ => updateCustomisationVisualState(), true); SearchTextBox.Current.BindValueChanged(query => @@ -371,7 +357,7 @@ namespace osu.Game.Overlays.Mods SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? Resources.Localisation.Web.CommonStrings.InputSearch : ModSelectOverlayStrings.TabToSearch; - if (beatmapAttributesDisplay != null) + if (BeatmapAttributesDisplay != null) { float rightEdgeOfLastButton = footerButtonFlow.Last().ScreenSpaceDrawQuad.TopRight.X; @@ -383,7 +369,7 @@ namespace osu.Game.Overlays.Mods // only update preview panel's collapsed state after we are fully visible, to ensure all the buttons are where we expect them to be. if (Alpha == 1) - beatmapAttributesDisplay.Collapsed.Value = screenIsntWideEnough; + BeatmapAttributesDisplay.Collapsed.Value = screenIsntWideEnough; footerContentFlow.LayoutDuration = 200; footerContentFlow.LayoutEasing = Easing.OutQuint; @@ -466,9 +452,9 @@ namespace osu.Game.Overlays.Mods modState.ValidForSelection.Value = modState.Mod.Type != ModType.System && modState.Mod.HasImplementation && IsValidMod.Invoke(modState.Mod); } - private void updateRankingInformation() + protected virtual void UpdateRankingInformation() { - if (rankingInformationDisplay == null) + if (RankingInformationDisplay == null) return; double multiplier = 1.0; @@ -476,20 +462,8 @@ namespace osu.Game.Overlays.Mods foreach (var mod in SelectedMods.Value) multiplier *= mod.ScoreMultiplier; - rankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked); - - if (AccountForMultiplayerMods && multiplayerRoomItem != null && multiplayerRoomItem.Value != null) - { - Ruleset ruleset = game.Ruleset.Value.CreateInstance(); - var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - - foreach (var mod in multiplayerRoomMods) - multiplier *= mod.ScoreMultiplier; - - rankingInformationDisplay.Ranked.Value = rankingInformationDisplay.Ranked.Value && multiplayerRoomMods.All(m => m.Ranked); - } - - rankingInformationDisplay.ModMultiplier.Value = multiplier; + RankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked); + RankingInformationDisplay.ModMultiplier.Value = multiplier; } private void updateCustomisation() diff --git a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs new file mode 100644 index 0000000000..ca1df31271 --- /dev/null +++ b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs @@ -0,0 +1,118 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Game.Rulesets; +using osu.Game.Online.Rooms; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mods; + +namespace osu.Game.Overlays.Mods +{ + public partial class MultiplayerModSelectOverlay : UserModSelectOverlay + { + public MultiplayerModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Plum) + : base(colourScheme) + { + } + + [Resolved(CanBeNull = true)] + private IBindable? multiplayerRoomItem { get; set; } + + [Resolved] + private OsuGameBase game { get; set; } = null!; + + protected override BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new MultiplayerBeatmapAttributesDisplay + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + BeatmapInfo = { Value = Beatmap?.BeatmapInfo }, + AccountForMultiplayerMods = true + }; + + protected override void LoadComplete() + { + base.LoadComplete(); + + multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange()); + } + + protected override void UpdateRankingInformation() + { + if (RankingInformationDisplay == null) + return; + + double multiplier = 1.0; + + foreach (var mod in SelectedMods.Value) + multiplier *= mod.ScoreMultiplier; + + RankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked); + + if (multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + { + Ruleset ruleset = game.Ruleset.Value.CreateInstance(); + var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + + foreach (var mod in multiplayerRoomMods) + multiplier *= mod.ScoreMultiplier; + + RankingInformationDisplay.Ranked.Value = RankingInformationDisplay.Ranked.Value && multiplayerRoomMods.All(m => m.Ranked); + } + + RankingInformationDisplay.ModMultiplier.Value = multiplier; + } + } + + public partial class MultiplayerBeatmapAttributesDisplay : BeatmapAttributesDisplay + { + public MultiplayerBeatmapAttributesDisplay() + : base() + { + } + + [Resolved(CanBeNull = true)] + private IBindable? multiplayerRoomItem { get; set; } + + protected override void LoadComplete() + { + base.LoadComplete(); + multiplayerRoomItem?.BindValueChanged(_ => Mods.TriggerChange()); + } + + protected override double GetRate() + { + double rate = base.GetRate(); + Ruleset ruleset = GameRuleset.Value.CreateInstance(); + + if (AccountForMultiplayerMods && multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + { + var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + + foreach (var mod in multiplayerRoomMods.OfType()) + rate = mod.ApplyToRate(0, rate); + } + + return rate; + } + + protected override BeatmapDifficulty GetDifficulty() + { + BeatmapDifficulty originalDifficulty = base.GetDifficulty(); + Ruleset ruleset = GameRuleset.Value.CreateInstance(); + + if (multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + { + var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + + foreach (var mod in multiplayerRoomMods.OfType()) + mod.ApplyToDifficulty(originalDifficulty); + } + + return originalDifficulty; + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs index 71f8bfa0f4..fbc06cce9e 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs @@ -241,11 +241,10 @@ namespace osu.Game.Screens.OnlinePlay.Match } }; - LoadComponent(UserModsSelectOverlay = new UserModSelectOverlay(OverlayColourScheme.Plum) + LoadComponent(UserModsSelectOverlay = new MultiplayerModSelectOverlay() { SelectedMods = { BindTarget = UserMods }, - IsValidMod = _ => false, - AccountForMultiplayerMods = true + IsValidMod = _ => false }); } From 6fb3192648f723af818322021ac5cd5cc5743ad7 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sun, 18 Feb 2024 03:14:36 +0200 Subject: [PATCH 092/508] Update BeatmapAttributesDisplay.cs --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 93e7e0ae9c..849444fa32 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -40,11 +40,6 @@ namespace osu.Game.Overlays.Mods public Bindable BeatmapInfo { get; } = new Bindable(); - /// - /// Should attribute display account for the multiplayer room global mods. - /// - public bool AccountForMultiplayerMods = false; - [Resolved] protected Bindable> Mods { get; private set; } = null!; From 4aaf016ee0ad4ff8eaebbbd207d7617e3d60a14b Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sun, 18 Feb 2024 03:15:53 +0200 Subject: [PATCH 093/508] quality improvements --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 2 -- osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs | 11 ++--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 849444fa32..7517a502c7 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -160,10 +160,8 @@ namespace osu.Game.Overlays.Mods protected virtual BeatmapDifficulty GetDifficulty() { BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value!.Difficulty); - foreach (var mod in Mods.Value.OfType()) mod.ApplyToDifficulty(originalDifficulty); - return originalDifficulty; } private void updateValues() => Scheduler.AddOnce(() => diff --git a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs index ca1df31271..ab20e9dc89 100644 --- a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs @@ -29,8 +29,7 @@ namespace osu.Game.Overlays.Mods { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, - BeatmapInfo = { Value = Beatmap?.BeatmapInfo }, - AccountForMultiplayerMods = true + BeatmapInfo = { Value = Beatmap?.BeatmapInfo } }; protected override void LoadComplete() @@ -87,15 +86,12 @@ namespace osu.Game.Overlays.Mods { double rate = base.GetRate(); Ruleset ruleset = GameRuleset.Value.CreateInstance(); - - if (AccountForMultiplayerMods && multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + if (multiplayerRoomItem != null && multiplayerRoomItem.Value != null) { var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - foreach (var mod in multiplayerRoomMods.OfType()) rate = mod.ApplyToRate(0, rate); } - return rate; } @@ -103,15 +99,12 @@ namespace osu.Game.Overlays.Mods { BeatmapDifficulty originalDifficulty = base.GetDifficulty(); Ruleset ruleset = GameRuleset.Value.CreateInstance(); - if (multiplayerRoomItem != null && multiplayerRoomItem.Value != null) { var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - foreach (var mod in multiplayerRoomMods.OfType()) mod.ApplyToDifficulty(originalDifficulty); } - return originalDifficulty; } } From 9070e973d3bf7a54dae89a8acd14acf16cdfe69c Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sun, 18 Feb 2024 03:16:18 +0200 Subject: [PATCH 094/508] Update BeatmapAttributesDisplay.cs --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 7517a502c7..08e124d8ac 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -19,7 +19,6 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; -using osu.Game.Online.Rooms; using osuTK; namespace osu.Game.Overlays.Mods From a6b63efe7d695354e4ddddb6a7143667fe56e646 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sun, 18 Feb 2024 03:28:24 +0200 Subject: [PATCH 095/508] Fixed NVika code quality errors --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 1 + osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 +- osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs | 8 ++++++-- osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 08e124d8ac..f010725c8b 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -163,6 +163,7 @@ namespace osu.Game.Overlays.Mods mod.ApplyToDifficulty(originalDifficulty); return originalDifficulty; } + private void updateValues() => Scheduler.AddOnce(() => { if (BeatmapInfo.Value == null) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 12719475a8..e29e685ece 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -42,7 +42,6 @@ namespace osu.Game.Overlays.Mods [Cached] public Bindable> SelectedMods { get; private set; } = new Bindable>(Array.Empty()); - /// /// Contains a dictionary with the current of all mods applicable for the current ruleset. /// @@ -128,6 +127,7 @@ namespace osu.Game.Overlays.Mods private Container aboveColumnsContent = null!; protected RankingInformationDisplay? RankingInformationDisplay; protected BeatmapAttributesDisplay? BeatmapAttributesDisplay; + protected virtual BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new BeatmapAttributesDisplay { Anchor = Anchor.BottomRight, diff --git a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs index ab20e9dc89..b399b6b878 100644 --- a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs @@ -86,12 +86,14 @@ namespace osu.Game.Overlays.Mods { double rate = base.GetRate(); Ruleset ruleset = GameRuleset.Value.CreateInstance(); - if (multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + + if (multiplayerRoomItem?.Value != null) { var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); foreach (var mod in multiplayerRoomMods.OfType()) rate = mod.ApplyToRate(0, rate); } + return rate; } @@ -99,12 +101,14 @@ namespace osu.Game.Overlays.Mods { BeatmapDifficulty originalDifficulty = base.GetDifficulty(); Ruleset ruleset = GameRuleset.Value.CreateInstance(); - if (multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + + if (multiplayerRoomItem?.Value != null) { var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); foreach (var mod in multiplayerRoomMods.OfType()) mod.ApplyToDifficulty(originalDifficulty); } + return originalDifficulty; } } diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs index fbc06cce9e..b20760b114 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs @@ -241,7 +241,7 @@ namespace osu.Game.Screens.OnlinePlay.Match } }; - LoadComponent(UserModsSelectOverlay = new MultiplayerModSelectOverlay() + LoadComponent(UserModsSelectOverlay = new MultiplayerModSelectOverlay { SelectedMods = { BindTarget = UserMods }, IsValidMod = _ => false From 24171bd02bf608fdee7b3c39dfecfba11968647e Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sun, 18 Feb 2024 03:34:02 +0200 Subject: [PATCH 096/508] Update MultiplayerModSelectOverlay.cs --- osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs index b399b6b878..78978e25e7 100644 --- a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs @@ -51,7 +51,7 @@ namespace osu.Game.Overlays.Mods RankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked); - if (multiplayerRoomItem != null && multiplayerRoomItem.Value != null) + if (multiplayerRoomItem?.Value != null) { Ruleset ruleset = game.Ruleset.Value.CreateInstance(); var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); @@ -68,11 +68,6 @@ namespace osu.Game.Overlays.Mods public partial class MultiplayerBeatmapAttributesDisplay : BeatmapAttributesDisplay { - public MultiplayerBeatmapAttributesDisplay() - : base() - { - } - [Resolved(CanBeNull = true)] private IBindable? multiplayerRoomItem { get; set; } From 3059ddf3b2638a0c6c3c1520fd1e93b32c1dc24d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 19 Feb 2024 01:08:40 +0300 Subject: [PATCH 097/508] Fix allocations in SliderInputManager --- osu.Game.Rulesets.Osu/OsuInputManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/OsuInputManager.cs b/osu.Game.Rulesets.Osu/OsuInputManager.cs index e472de1dfe..ceac1989a6 100644 --- a/osu.Game.Rulesets.Osu/OsuInputManager.cs +++ b/osu.Game.Rulesets.Osu/OsuInputManager.cs @@ -1,13 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using System.ComponentModel; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; +using osu.Framework.Lists; using osu.Game.Input.Bindings; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.UI; @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Osu { public partial class OsuInputManager : RulesetInputManager { - public IEnumerable PressedActions => KeyBindingContainer.PressedActions; + public SlimReadOnlyListWrapper PressedActions => KeyBindingContainer.PressedActions; /// /// Whether gameplay input buttons should be allowed. From 5a448ce02f5c65a40a57b4a3f51641d907a92de9 Mon Sep 17 00:00:00 2001 From: maromalo Date: Sun, 18 Feb 2024 19:59:56 -0300 Subject: [PATCH 098/508] Turn BPMDisplay to RollingCounter --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index b9e4896b21..1db02b7cf2 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -168,7 +169,7 @@ namespace osu.Game.Overlays.Mods foreach (var mod in mods.Value.OfType()) rate = mod.ApplyToRate(0, rate); - bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; + bpmDisplay.Current.Value = (int)Math.Round(Math.Round(BeatmapInfo.Value.BPM) * rate); BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty); @@ -194,11 +195,11 @@ namespace osu.Game.Overlays.Mods RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint); } - private partial class BPMDisplay : RollingCounter + private partial class BPMDisplay : RollingCounter { protected override double RollingDuration => 250; - protected override LocalisableString FormatCount(double count) => count.ToLocalisableString("0 BPM"); + protected override LocalisableString FormatCount(int count) => count.ToLocalisableString("0 BPM"); protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText { From c6ca812ea07eb9fdfc24038e05f4b485e9501775 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sun, 18 Feb 2024 21:52:23 -0800 Subject: [PATCH 099/508] Add feedback to delete button even when no-op --- osu.Game/Beatmaps/BeatmapManager.cs | 11 +++++++++-- osu.Game/Database/ModelManager.cs | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 1f551f1218..3aed15029d 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -361,13 +361,20 @@ namespace osu.Game.Beatmaps /// public void DeleteVideos(List items, bool silent = false) { - if (items.Count == 0) return; + var noVideosMessage = "No videos found to delete!"; + + if (items.Count == 0) + { + if (!silent) + PostNotification?.Invoke(new ProgressCompletionNotification { Text = noVideosMessage }); + return; + } var notification = new ProgressNotification { Progress = 0, Text = $"Preparing to delete all {HumanisedModelName} videos...", - CompletionText = "No videos found to delete!", + CompletionText = noVideosMessage, State = ProgressNotificationState.Active, }; diff --git a/osu.Game/Database/ModelManager.cs b/osu.Game/Database/ModelManager.cs index 39dae61d36..7a5fb5efbf 100644 --- a/osu.Game/Database/ModelManager.cs +++ b/osu.Game/Database/ModelManager.cs @@ -105,7 +105,12 @@ namespace osu.Game.Database /// public void Delete(List items, bool silent = false) { - if (items.Count == 0) return; + if (items.Count == 0) + { + if (!silent) + PostNotification?.Invoke(new ProgressCompletionNotification { Text = $"No {HumanisedModelName}s found to delete!" }); + return; + } var notification = new ProgressNotification { @@ -142,7 +147,12 @@ namespace osu.Game.Database /// public void Undelete(List items, bool silent = false) { - if (!items.Any()) return; + if (!items.Any()) + { + if (!silent) + PostNotification?.Invoke(new ProgressCompletionNotification { Text = $"No {HumanisedModelName}s found to restore!" }); + return; + } var notification = new ProgressNotification { From 413b7aab602bcd6b4f60265fe893bc88c23b63e8 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sun, 18 Feb 2024 22:12:03 -0800 Subject: [PATCH 100/508] Switch to const string --- osu.Game/Beatmaps/BeatmapManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 3aed15029d..0610f7f6fb 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -361,12 +361,12 @@ namespace osu.Game.Beatmaps /// public void DeleteVideos(List items, bool silent = false) { - var noVideosMessage = "No videos found to delete!"; + const string no_videos_message = "No videos found to delete!"; if (items.Count == 0) { if (!silent) - PostNotification?.Invoke(new ProgressCompletionNotification { Text = noVideosMessage }); + PostNotification?.Invoke(new ProgressCompletionNotification { Text = no_videos_message }); return; } @@ -374,7 +374,7 @@ namespace osu.Game.Beatmaps { Progress = 0, Text = $"Preparing to delete all {HumanisedModelName} videos...", - CompletionText = noVideosMessage, + CompletionText = no_videos_message, State = ProgressNotificationState.Active, }; From 24e3fe79a4554b45b9176411402928c35214e172 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 19 Feb 2024 17:02:53 +0100 Subject: [PATCH 101/508] Log `GlobalStatistics` when exporting logs from settings --- osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index fe88413e6a..82cc952e53 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -10,6 +10,7 @@ using osu.Framework.Localisation; using osu.Framework.Logging; using osu.Framework.Platform; using osu.Framework.Screens; +using osu.Framework.Statistics; using osu.Game.Configuration; using osu.Game.Localisation; using osu.Game.Overlays.Notifications; @@ -107,6 +108,9 @@ namespace osu.Game.Overlays.Settings.Sections.General try { + GlobalStatistics.OutputToLog(); + Logger.Flush(); + var logStorage = Logger.Storage; using (var outStream = storage.CreateFileSafely(archive_filename)) From 2ff8667dd2e433fd7abb832cc8bb91def14c44d1 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Mon, 19 Feb 2024 12:11:12 -0800 Subject: [PATCH 102/508] Revert "Centralise global rank display logic to new class" Also don't show on `LoginOverlay` usage for now. --- .../Header/Components/GlobalRankDisplay.cs | 44 ------------------- .../Profile/Header/Components/MainDetails.cs | 17 +++++-- osu.Game/Users/UserRankPanel.cs | 13 +++--- 3 files changed, 19 insertions(+), 55 deletions(-) delete mode 100644 osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs diff --git a/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs b/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs deleted file mode 100644 index d32f56ab1b..0000000000 --- a/osu.Game/Overlays/Profile/Header/Components/GlobalRankDisplay.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Bindables; -using osu.Framework.Extensions.LocalisationExtensions; -using osu.Framework.Localisation; -using osu.Game.Online.API.Requests.Responses; -using osu.Game.Resources.Localisation.Web; -using osu.Game.Users; - -namespace osu.Game.Overlays.Profile.Header.Components -{ - public partial class GlobalRankDisplay : ProfileValueDisplay - { - public readonly Bindable UserStatistics = new Bindable(); - public readonly Bindable User = new Bindable(); - - public GlobalRankDisplay() - : base(true) - { - Title = UsersStrings.ShowRankGlobalSimple; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - UserStatistics.BindValueChanged(s => - { - Content = s.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; - }, true); - - // needed as `UserStatistics` doesn't populate `User` - User.BindValueChanged(u => - { - var rankHighest = u.NewValue?.RankHighest; - - ContentTooltipText = rankHighest != null - ? UsersStrings.ShowRankHighest(rankHighest.Rank.ToLocalisableString("\\##,##0"), rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy")) - : string.Empty; - }, true); - } - } -} diff --git a/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs b/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs index ffdf8edc21..2505c1bc8c 100644 --- a/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs +++ b/osu.Game/Overlays/Profile/Header/Components/MainDetails.cs @@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Profile.Header.Components private readonly Dictionary scoreRankInfos = new Dictionary(); private ProfileValueDisplay medalInfo = null!; private ProfileValueDisplay ppInfo = null!; - private GlobalRankDisplay detailGlobalRank = null!; + private ProfileValueDisplay detailGlobalRank = null!; private ProfileValueDisplay detailCountryRank = null!; private RankGraph rankGraph = null!; @@ -52,7 +52,10 @@ namespace osu.Game.Overlays.Profile.Header.Components Spacing = new Vector2(20), Children = new Drawable[] { - detailGlobalRank = new GlobalRankDisplay(), + detailGlobalRank = new ProfileValueDisplay(true) + { + Title = UsersStrings.ShowRankGlobalSimple, + }, detailCountryRank = new ProfileValueDisplay(true) { Title = UsersStrings.ShowRankCountrySimple, @@ -139,8 +142,14 @@ namespace osu.Game.Overlays.Profile.Header.Components foreach (var scoreRankInfo in scoreRankInfos) scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0; - detailGlobalRank.UserStatistics.Value = user?.Statistics; - detailGlobalRank.User.Value = user; + detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; + + var rankHighest = user?.RankHighest; + + detailGlobalRank.ContentTooltipText = rankHighest != null + ? UsersStrings.ShowRankHighest(rankHighest.Rank.ToLocalisableString("\\##,##0"), rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy")) + : string.Empty; + detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; rankGraph.Statistics.Value = user?.Statistics; diff --git a/osu.Game/Users/UserRankPanel.cs b/osu.Game/Users/UserRankPanel.cs index 0b8a5166e6..b440261a4c 100644 --- a/osu.Game/Users/UserRankPanel.cs +++ b/osu.Game/Users/UserRankPanel.cs @@ -27,10 +27,10 @@ namespace osu.Game.Users [Resolved] private IAPIProvider api { get; set; } = null!; + private ProfileValueDisplay globalRankDisplay = null!; private ProfileValueDisplay countryRankDisplay = null!; private readonly IBindable statistics = new Bindable(); - private readonly IBindable user = new Bindable(); public UserRankPanel(APIUser user) : base(user) @@ -47,10 +47,9 @@ namespace osu.Game.Users statistics.BindTo(api.Statistics); statistics.BindValueChanged(stats => { + globalRankDisplay.Content = stats.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? "-"; countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-"; }, true); - - user.BindTo(api.LocalUser!); } protected override Drawable CreateLayout() @@ -164,12 +163,12 @@ namespace osu.Game.Users { new Drawable[] { - new GlobalRankDisplay + globalRankDisplay = new ProfileValueDisplay(true) { - UserStatistics = { BindTarget = statistics }, - // TODO: make highest rank update, as `api.LocalUser` doesn't update + Title = UsersStrings.ShowRankGlobalSimple, + // TODO: implement highest rank tooltip + // `RankHighest` resides in `APIUser`, but `api.LocalUser` doesn't update // maybe move to `UserStatistics` in api, so `SoloStatisticsWatcher` can update the value - User = { BindTarget = user }, }, countryRankDisplay = new ProfileValueDisplay(true) { From 40d6e8ce85cbd516a75510299c230d4048fd5b25 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 20 Feb 2024 15:13:22 +0900 Subject: [PATCH 103/508] Remove legacy OpenGL renderer option, it's now just OpenGL --- .../Sections/Graphics/RendererSettings.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs index fc5dd34971..a8b127d522 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Linq; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions; @@ -28,15 +27,16 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics var renderer = config.GetBindable(FrameworkSetting.Renderer); automaticRendererInUse = renderer.Value == RendererType.Automatic; - SettingsEnumDropdown rendererDropdown; - Children = new Drawable[] { - rendererDropdown = new RendererSettingsDropdown + new RendererSettingsDropdown { LabelText = GraphicsSettingsStrings.Renderer, Current = renderer, - Items = host.GetPreferredRenderersForCurrentPlatform().Order().Where(t => t != RendererType.Vulkan), + Items = host.GetPreferredRenderersForCurrentPlatform().Order() +#pragma warning disable CS0612 // Type or member is obsolete + .Where(t => t != RendererType.Vulkan && t != RendererType.OpenGLLegacy), +#pragma warning restore CS0612 // Type or member is obsolete Keywords = new[] { @"compatibility", @"directx" }, }, // TODO: this needs to be a custom dropdown at some point @@ -79,13 +79,6 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics })); } }); - - // TODO: remove this once we support SDL+android. - if (RuntimeInfo.OS == RuntimeInfo.Platform.Android) - { - rendererDropdown.Items = new[] { RendererType.Automatic, RendererType.OpenGLLegacy }; - rendererDropdown.SetNoticeText("New renderer support for android is coming soon!", true); - } } private partial class RendererSettingsDropdown : SettingsEnumDropdown From 54ef397d56c0499ceb568b2b867978a94b6b98bd Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Tue, 20 Feb 2024 12:57:28 +0200 Subject: [PATCH 104/508] Changed override method now it overrides mods getter instead of calculate fuctions --- .../Overlays/Mods/BeatmapAttributesDisplay.cs | 31 +++------ osu.Game/Overlays/Mods/ModSelectOverlay.cs | 12 ++-- .../Mods/MultiplayerModSelectOverlay.cs | 68 +++++++------------ 3 files changed, 41 insertions(+), 70 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index f010725c8b..21b3a7faa9 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -41,6 +41,7 @@ namespace osu.Game.Overlays.Mods [Resolved] protected Bindable> Mods { get; private set; } = null!; + protected virtual IEnumerable SelectedMods => Mods.Value; public BindableBool Collapsed { get; } = new BindableBool(true); @@ -148,22 +149,6 @@ namespace osu.Game.Overlays.Mods LeftContent.AutoSizeDuration = Content.AutoSizeDuration = transition_duration; } - protected virtual double GetRate() - { - double rate = 1; - foreach (var mod in Mods.Value.OfType()) - rate = mod.ApplyToRate(0, rate); - return rate; - } - - protected virtual BeatmapDifficulty GetDifficulty() - { - BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value!.Difficulty); - foreach (var mod in Mods.Value.OfType()) - mod.ApplyToDifficulty(originalDifficulty); - return originalDifficulty; - } - private void updateValues() => Scheduler.AddOnce(() => { if (BeatmapInfo.Value == null) @@ -180,14 +165,20 @@ namespace osu.Game.Overlays.Mods starRatingDisplay.FinishTransforms(true); }); - double rate = GetRate(); - BeatmapDifficulty originalDifficulty = GetDifficulty(); + double rate = 1; + foreach (var mod in SelectedMods.OfType()) + rate = mod.ApplyToRate(0, rate); + + bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; + + BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty); + + foreach (var mod in SelectedMods.OfType()) + mod.ApplyToDifficulty(originalDifficulty); Ruleset ruleset = GameRuleset.Value.CreateInstance(); BeatmapDifficulty adjustedDifficulty = ruleset.GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); - bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; - TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty); approachRateDisplay.AdjustType.Value = VerticalAttributeDisplay.CalculateEffect(originalDifficulty.ApproachRate, adjustedDifficulty.ApproachRate); diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index e29e685ece..f374828a4a 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -114,6 +114,8 @@ namespace osu.Game.Overlays.Mods public IEnumerable AllAvailableMods => AvailableMods.Value.SelectMany(pair => pair.Value); + protected virtual IEnumerable AllSelectedMods => SelectedMods.Value; + private readonly BindableBool customisationVisible = new BindableBool(); private Bindable textSearchStartsActive = null!; @@ -317,7 +319,7 @@ namespace osu.Game.Overlays.Mods SelectedMods.BindValueChanged(_ => { - UpdateRankingInformation(); + updateRankingInformation(); updateFromExternalSelection(); updateCustomisation(); @@ -330,7 +332,7 @@ namespace osu.Game.Overlays.Mods // // See https://github.com/ppy/osu/pull/23284#issuecomment-1529056988 modSettingChangeTracker = new ModSettingChangeTracker(SelectedMods.Value); - modSettingChangeTracker.SettingChanged += _ => UpdateRankingInformation(); + modSettingChangeTracker.SettingChanged += _ => updateRankingInformation(); } }, true); @@ -452,17 +454,17 @@ namespace osu.Game.Overlays.Mods modState.ValidForSelection.Value = modState.Mod.Type != ModType.System && modState.Mod.HasImplementation && IsValidMod.Invoke(modState.Mod); } - protected virtual void UpdateRankingInformation() + private void updateRankingInformation() { if (RankingInformationDisplay == null) return; double multiplier = 1.0; - foreach (var mod in SelectedMods.Value) + foreach (var mod in AllSelectedMods) multiplier *= mod.ScoreMultiplier; - RankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked); + RankingInformationDisplay.Ranked.Value = AllSelectedMods.All(m => m.Ranked); RankingInformationDisplay.ModMultiplier.Value = multiplier; } diff --git a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs index 78978e25e7..d546392650 100644 --- a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs @@ -1,13 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets; using osu.Game.Online.Rooms; -using osu.Game.Beatmaps; using osu.Game.Rulesets.Mods; namespace osu.Game.Overlays.Mods @@ -39,30 +39,21 @@ namespace osu.Game.Overlays.Mods multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange()); } - protected override void UpdateRankingInformation() + protected override IEnumerable AllSelectedMods { - if (RankingInformationDisplay == null) - return; - - double multiplier = 1.0; - - foreach (var mod in SelectedMods.Value) - multiplier *= mod.ScoreMultiplier; - - RankingInformationDisplay.Ranked.Value = SelectedMods.Value.All(m => m.Ranked); - - if (multiplayerRoomItem?.Value != null) + get { - Ruleset ruleset = game.Ruleset.Value.CreateInstance(); - var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + IEnumerable allMods = SelectedMods.Value; - foreach (var mod in multiplayerRoomMods) - multiplier *= mod.ScoreMultiplier; + if (multiplayerRoomItem?.Value != null) + { + Ruleset ruleset = game.Ruleset.Value.CreateInstance(); + var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + allMods = allMods.Concat(multiplayerRoomMods); + } - RankingInformationDisplay.Ranked.Value = RankingInformationDisplay.Ranked.Value && multiplayerRoomMods.All(m => m.Ranked); + return allMods; } - - RankingInformationDisplay.ModMultiplier.Value = multiplier; } } @@ -77,34 +68,21 @@ namespace osu.Game.Overlays.Mods multiplayerRoomItem?.BindValueChanged(_ => Mods.TriggerChange()); } - protected override double GetRate() + protected override IEnumerable SelectedMods { - double rate = base.GetRate(); - Ruleset ruleset = GameRuleset.Value.CreateInstance(); - - if (multiplayerRoomItem?.Value != null) + get { - var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - foreach (var mod in multiplayerRoomMods.OfType()) - rate = mod.ApplyToRate(0, rate); + IEnumerable selectedMods = Mods.Value; + + if (multiplayerRoomItem?.Value != null) + { + Ruleset ruleset = GameRuleset.Value.CreateInstance(); + var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + selectedMods = selectedMods.Concat(multiplayerRoomMods); + } + + return selectedMods; } - - return rate; - } - - protected override BeatmapDifficulty GetDifficulty() - { - BeatmapDifficulty originalDifficulty = base.GetDifficulty(); - Ruleset ruleset = GameRuleset.Value.CreateInstance(); - - if (multiplayerRoomItem?.Value != null) - { - var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - foreach (var mod in multiplayerRoomMods.OfType()) - mod.ApplyToDifficulty(originalDifficulty); - } - - return originalDifficulty; } } } From a4288e7ecc8e3b631b8f8a2d43ddbc83c787f033 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Tue, 20 Feb 2024 13:00:59 +0200 Subject: [PATCH 105/508] removed unnecessary changes --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index f374828a4a..5b3bafae45 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -127,8 +127,8 @@ namespace osu.Game.Overlays.Mods private DeselectAllModsButton deselectAllModsButton = null!; private Container aboveColumnsContent = null!; - protected RankingInformationDisplay? RankingInformationDisplay; - protected BeatmapAttributesDisplay? BeatmapAttributesDisplay; + private RankingInformationDisplay? rankingInformationDisplay; + private BeatmapAttributesDisplay? beatmapAttributesDisplay; protected virtual BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new BeatmapAttributesDisplay { @@ -155,8 +155,8 @@ namespace osu.Game.Overlays.Mods if (beatmap == value) return; beatmap = value; - if (IsLoaded && BeatmapAttributesDisplay != null) - BeatmapAttributesDisplay.BeatmapInfo.Value = beatmap?.BeatmapInfo; + if (IsLoaded && beatmapAttributesDisplay != null) + beatmapAttributesDisplay.BeatmapInfo.Value = beatmap?.BeatmapInfo; } } @@ -278,12 +278,12 @@ namespace osu.Game.Overlays.Mods }, Children = new Drawable[] { - RankingInformationDisplay = new RankingInformationDisplay + rankingInformationDisplay = new RankingInformationDisplay { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight }, - BeatmapAttributesDisplay = GetBeatmapAttributesDisplay + beatmapAttributesDisplay = GetBeatmapAttributesDisplay } }); } @@ -359,7 +359,7 @@ namespace osu.Game.Overlays.Mods SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? Resources.Localisation.Web.CommonStrings.InputSearch : ModSelectOverlayStrings.TabToSearch; - if (BeatmapAttributesDisplay != null) + if (beatmapAttributesDisplay != null) { float rightEdgeOfLastButton = footerButtonFlow.Last().ScreenSpaceDrawQuad.TopRight.X; @@ -371,7 +371,7 @@ namespace osu.Game.Overlays.Mods // only update preview panel's collapsed state after we are fully visible, to ensure all the buttons are where we expect them to be. if (Alpha == 1) - BeatmapAttributesDisplay.Collapsed.Value = screenIsntWideEnough; + beatmapAttributesDisplay.Collapsed.Value = screenIsntWideEnough; footerContentFlow.LayoutDuration = 200; footerContentFlow.LayoutEasing = Easing.OutQuint; @@ -456,7 +456,7 @@ namespace osu.Game.Overlays.Mods private void updateRankingInformation() { - if (RankingInformationDisplay == null) + if (rankingInformationDisplay == null) return; double multiplier = 1.0; @@ -464,8 +464,8 @@ namespace osu.Game.Overlays.Mods foreach (var mod in AllSelectedMods) multiplier *= mod.ScoreMultiplier; - RankingInformationDisplay.Ranked.Value = AllSelectedMods.All(m => m.Ranked); - RankingInformationDisplay.ModMultiplier.Value = multiplier; + rankingInformationDisplay.Ranked.Value = AllSelectedMods.All(m => m.Ranked); + rankingInformationDisplay.ModMultiplier.Value = multiplier; } private void updateCustomisation() From 8199a49ee23f12e729a78658a6decd95df56fbc5 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Tue, 20 Feb 2024 13:11:19 +0200 Subject: [PATCH 106/508] minor look changes --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 1 + osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 21b3a7faa9..7c3c971d76 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -41,6 +41,7 @@ namespace osu.Game.Overlays.Mods [Resolved] protected Bindable> Mods { get; private set; } = null!; + protected virtual IEnumerable SelectedMods => Mods.Value; public BindableBool Collapsed { get; } = new BindableBool(true); diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 5b3bafae45..8a3b1954ed 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -464,8 +464,8 @@ namespace osu.Game.Overlays.Mods foreach (var mod in AllSelectedMods) multiplier *= mod.ScoreMultiplier; - rankingInformationDisplay.Ranked.Value = AllSelectedMods.All(m => m.Ranked); rankingInformationDisplay.ModMultiplier.Value = multiplier; + rankingInformationDisplay.Ranked.Value = AllSelectedMods.All(m => m.Ranked); } private void updateCustomisation() From ed028e8d260854fc800a3331bef952682d5e811f Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Tue, 20 Feb 2024 13:13:13 +0200 Subject: [PATCH 107/508] Update MultiplayerModSelectOverlay.cs --- osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs index d546392650..ee087bb149 100644 --- a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs @@ -35,7 +35,6 @@ namespace osu.Game.Overlays.Mods protected override void LoadComplete() { base.LoadComplete(); - multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange()); } From 4a314a8e316273ff1f23b4003ea232d413b31ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 11:17:18 +0100 Subject: [PATCH 108/508] Namespacify data structures used in websocket communications --- osu.Game/Online/Chat/WebSocketChatClient.cs | 2 ++ .../Notifications/WebSocket/{ => Events}/NewChatMessageData.cs | 2 +- .../Notifications/WebSocket/{ => Requests}/EndChatRequest.cs | 2 +- .../Notifications/WebSocket/{ => Requests}/StartChatRequest.cs | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) rename osu.Game/Online/Notifications/WebSocket/{ => Events}/NewChatMessageData.cs (94%) rename osu.Game/Online/Notifications/WebSocket/{ => Requests}/EndChatRequest.cs (89%) rename osu.Game/Online/Notifications/WebSocket/{ => Requests}/StartChatRequest.cs (89%) diff --git a/osu.Game/Online/Chat/WebSocketChatClient.cs b/osu.Game/Online/Chat/WebSocketChatClient.cs index 8e1b501b25..37774a1f5d 100644 --- a/osu.Game/Online/Chat/WebSocketChatClient.cs +++ b/osu.Game/Online/Chat/WebSocketChatClient.cs @@ -13,6 +13,8 @@ using osu.Framework.Logging; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Notifications.WebSocket; +using osu.Game.Online.Notifications.WebSocket.Events; +using osu.Game.Online.Notifications.WebSocket.Requests; namespace osu.Game.Online.Chat { diff --git a/osu.Game/Online/Notifications/WebSocket/NewChatMessageData.cs b/osu.Game/Online/Notifications/WebSocket/Events/NewChatMessageData.cs similarity index 94% rename from osu.Game/Online/Notifications/WebSocket/NewChatMessageData.cs rename to osu.Game/Online/Notifications/WebSocket/Events/NewChatMessageData.cs index 850fbd226b..ff9f5ee9f7 100644 --- a/osu.Game/Online/Notifications/WebSocket/NewChatMessageData.cs +++ b/osu.Game/Online/Notifications/WebSocket/Events/NewChatMessageData.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Chat; -namespace osu.Game.Online.Notifications.WebSocket +namespace osu.Game.Online.Notifications.WebSocket.Events { /// /// A websocket message sent from the server when new messages arrive. diff --git a/osu.Game/Online/Notifications/WebSocket/EndChatRequest.cs b/osu.Game/Online/Notifications/WebSocket/Requests/EndChatRequest.cs similarity index 89% rename from osu.Game/Online/Notifications/WebSocket/EndChatRequest.cs rename to osu.Game/Online/Notifications/WebSocket/Requests/EndChatRequest.cs index 7f67587f5d..9058fea815 100644 --- a/osu.Game/Online/Notifications/WebSocket/EndChatRequest.cs +++ b/osu.Game/Online/Notifications/WebSocket/Requests/EndChatRequest.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace osu.Game.Online.Notifications.WebSocket +namespace osu.Game.Online.Notifications.WebSocket.Requests { /// /// A websocket message notifying the server that the client no longer wants to receive chat messages. diff --git a/osu.Game/Online/Notifications/WebSocket/StartChatRequest.cs b/osu.Game/Online/Notifications/WebSocket/Requests/StartChatRequest.cs similarity index 89% rename from osu.Game/Online/Notifications/WebSocket/StartChatRequest.cs rename to osu.Game/Online/Notifications/WebSocket/Requests/StartChatRequest.cs index 9dd69a7377..bc96415642 100644 --- a/osu.Game/Online/Notifications/WebSocket/StartChatRequest.cs +++ b/osu.Game/Online/Notifications/WebSocket/Requests/StartChatRequest.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; -namespace osu.Game.Online.Notifications.WebSocket +namespace osu.Game.Online.Notifications.WebSocket.Requests { /// /// A websocket message notifying the server that the client wants to receive chat messages. From 48bf9680e135d1ca528828d411047d338cc07c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 11:29:59 +0100 Subject: [PATCH 109/508] Add new structures for receiving new medal data --- .../Events/NewPrivateNotificationEvent.cs | 39 +++++++++++++++++++ .../WebSocket/Events/UserAchievementUnlock.cs | 34 ++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 osu.Game/Online/Notifications/WebSocket/Events/NewPrivateNotificationEvent.cs create mode 100644 osu.Game/Online/Notifications/WebSocket/Events/UserAchievementUnlock.cs diff --git a/osu.Game/Online/Notifications/WebSocket/Events/NewPrivateNotificationEvent.cs b/osu.Game/Online/Notifications/WebSocket/Events/NewPrivateNotificationEvent.cs new file mode 100644 index 0000000000..1fc9636136 --- /dev/null +++ b/osu.Game/Online/Notifications/WebSocket/Events/NewPrivateNotificationEvent.cs @@ -0,0 +1,39 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace osu.Game.Online.Notifications.WebSocket.Events +{ + /// + /// Reference: https://github.com/ppy/osu-web/blob/master/app/Events/NewPrivateNotificationEvent.php + /// + public class NewPrivateNotificationEvent + { + [JsonProperty("id")] + public ulong ID { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } = string.Empty; + + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } + + [JsonProperty("object_type")] + public string ObjectType { get; set; } = string.Empty; + + [JsonProperty("object_id")] + public ulong ObjectId { get; set; } + + [JsonProperty("source_user_id")] + public uint SourceUserID { get; set; } + + [JsonProperty("is_read")] + public bool IsRead { get; set; } + + [JsonProperty("details")] + public JObject? Details { get; set; } + } +} diff --git a/osu.Game/Online/Notifications/WebSocket/Events/UserAchievementUnlock.cs b/osu.Game/Online/Notifications/WebSocket/Events/UserAchievementUnlock.cs new file mode 100644 index 0000000000..6c7c8af4f4 --- /dev/null +++ b/osu.Game/Online/Notifications/WebSocket/Events/UserAchievementUnlock.cs @@ -0,0 +1,34 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using Newtonsoft.Json; + +namespace osu.Game.Online.Notifications.WebSocket.Events +{ + /// + /// Reference: https://github.com/ppy/osu-web/blob/master/app/Jobs/Notifications/UserAchievementUnlock.php + /// + public class UserAchievementUnlock + { + [JsonProperty("achievement_id")] + public uint AchievementId { get; set; } + + [JsonProperty("achievement_mode")] + public ushort? AchievementMode { get; set; } + + [JsonProperty("cover_url")] + public string CoverUrl { get; set; } = string.Empty; + + [JsonProperty("slug")] + public string Slug { get; set; } = string.Empty; + + [JsonProperty("title")] + public string Title { get; set; } = string.Empty; + + [JsonProperty("description")] + public string Description { get; set; } = string.Empty; + + [JsonProperty("user_id")] + public uint UserId { get; set; } + } +} From 4911f5208b2ba6903aa3ec807ba246238bf501d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 12:03:12 +0100 Subject: [PATCH 110/508] Demote medal "overlay" to animation I need the actual overlay to be doing way more things (receiving the actual websocket events, queueing the medals for display, handling activation mode), so the pre-existing API design of the overlay just will not fly. --- osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs | 2 +- osu.Game/Overlays/{MedalOverlay.cs => MedalAnimation.cs} | 4 ++-- osu.Game/Overlays/MedalSplash/DrawableMedal.cs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) rename osu.Game/Overlays/{MedalOverlay.cs => MedalAnimation.cs} (99%) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs index 71ed0a14a2..afd4427629 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs @@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Gameplay { AddStep(@"display", () => { - LoadComponentAsync(new MedalOverlay(new Medal + LoadComponentAsync(new MedalAnimation(new Medal { Name = @"Animations", InternalName = @"all-intro-doubletime", diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalAnimation.cs similarity index 99% rename from osu.Game/Overlays/MedalOverlay.cs rename to osu.Game/Overlays/MedalAnimation.cs index eba35ec6f9..80c06be87c 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalAnimation.cs @@ -27,7 +27,7 @@ using osu.Framework.Utils; namespace osu.Game.Overlays { - public partial class MedalOverlay : FocusedOverlayContainer + public partial class MedalAnimation : VisibilityContainer { public const float DISC_SIZE = 400; @@ -45,7 +45,7 @@ namespace osu.Game.Overlays private readonly Container content; - public MedalOverlay(Medal medal) + public MedalAnimation(Medal medal) { this.medal = medal; RelativeSizeAxes = Axes.Both; diff --git a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs index f4f6fd2bc1..2beed6645a 100644 --- a/osu.Game/Overlays/MedalSplash/DrawableMedal.cs +++ b/osu.Game/Overlays/MedalSplash/DrawableMedal.cs @@ -38,7 +38,7 @@ namespace osu.Game.Overlays.MedalSplash public DrawableMedal(Medal medal) { this.medal = medal; - Position = new Vector2(0f, MedalOverlay.DISC_SIZE / 2); + Position = new Vector2(0f, MedalAnimation.DISC_SIZE / 2); FillFlowContainer infoFlow; Children = new Drawable[] @@ -174,7 +174,7 @@ namespace osu.Game.Overlays.MedalSplash .ScaleTo(1); this.ScaleTo(scale_when_unlocked, duration, Easing.OutExpo); - this.MoveToY(MedalOverlay.DISC_SIZE / 2 - 30, duration, Easing.OutExpo); + this.MoveToY(MedalAnimation.DISC_SIZE / 2 - 30, duration, Easing.OutExpo); unlocked.FadeInFromZero(duration); break; @@ -184,7 +184,7 @@ namespace osu.Game.Overlays.MedalSplash .ScaleTo(1); this.ScaleTo(scale_when_full, duration, Easing.OutExpo); - this.MoveToY(MedalOverlay.DISC_SIZE / 2 - 60, duration, Easing.OutExpo); + this.MoveToY(MedalAnimation.DISC_SIZE / 2 - 60, duration, Easing.OutExpo); unlocked.Show(); name.FadeInFromZero(duration + 100); description.FadeInFromZero(duration * 2); From 4f321e242bd7650c0bfe9afec4d3746188df3cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 12:05:25 +0100 Subject: [PATCH 111/508] Enable NRT in `OsuFocusedOverlayContainer` --- .../Containers/OsuFocusedOverlayContainer.cs | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 162c4b6a59..16539a812d 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -20,10 +18,10 @@ namespace osu.Game.Graphics.Containers [Cached(typeof(IPreviewTrackOwner))] public abstract partial class OsuFocusedOverlayContainer : FocusedOverlayContainer, IPreviewTrackOwner, IKeyBindingHandler { - private Sample samplePopIn; - private Sample samplePopOut; - protected virtual string PopInSampleName => "UI/overlay-pop-in"; - protected virtual string PopOutSampleName => "UI/overlay-pop-out"; + protected readonly IBindable OverlayActivationMode = new Bindable(OverlayActivation.All); + + protected virtual string PopInSampleName => @"UI/overlay-pop-in"; + protected virtual string PopOutSampleName => @"UI/overlay-pop-out"; protected virtual double PopInOutSampleBalance => 0; protected override bool BlockNonPositionalInput => true; @@ -34,19 +32,20 @@ namespace osu.Game.Graphics.Containers /// protected virtual bool DimMainContent => true; - [Resolved(CanBeNull = true)] - private IOverlayManager overlayManager { get; set; } + [Resolved] + private IOverlayManager? overlayManager { get; set; } [Resolved] - private PreviewTrackManager previewTrackManager { get; set; } + private PreviewTrackManager previewTrackManager { get; set; } = null!; - protected readonly IBindable OverlayActivationMode = new Bindable(OverlayActivation.All); + private Sample? samplePopIn; + private Sample? samplePopOut; - [BackgroundDependencyLoader(true)] - private void load(AudioManager audio) + [BackgroundDependencyLoader] + private void load(AudioManager? audio) { - samplePopIn = audio.Samples.Get(PopInSampleName); - samplePopOut = audio.Samples.Get(PopOutSampleName); + samplePopIn = audio?.Samples.Get(PopInSampleName); + samplePopOut = audio?.Samples.Get(PopOutSampleName); } protected override void LoadComplete() From 2e5b61302ab2652b09ac8fe57e48d76315b0d85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 12:53:46 +0100 Subject: [PATCH 112/508] Implement basic medal display flow --- .../Visual/Gameplay/TestSceneMedalOverlay.cs | 45 +++++-- .../Containers/OsuFocusedOverlayContainer.cs | 11 +- osu.Game/Overlays/MedalAnimation.cs | 15 +-- osu.Game/Overlays/MedalOverlay.cs | 112 ++++++++++++++++++ 4 files changed, 155 insertions(+), 28 deletions(-) create mode 100644 osu.Game/Overlays/MedalOverlay.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs index afd4427629..ead5c5b418 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs @@ -1,26 +1,51 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using Newtonsoft.Json.Linq; using NUnit.Framework; +using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; +using osu.Game.Online.API; +using osu.Game.Online.Notifications.WebSocket; +using osu.Game.Online.Notifications.WebSocket.Events; using osu.Game.Overlays; -using osu.Game.Users; +using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { [TestFixture] - public partial class TestSceneMedalOverlay : OsuTestScene + public partial class TestSceneMedalOverlay : OsuManualInputManagerTestScene { - public TestSceneMedalOverlay() + private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; + + private MedalOverlay overlay = null!; + + [SetUpSteps] + public void SetUpSteps() { - AddStep(@"display", () => + AddStep("create overlay", () => Child = overlay = new MedalOverlay()); + } + + [Test] + public void TestBasicAward() + { + AddStep("award medal", () => dummyAPI.NotificationsClient.Receive(new SocketMessage { - LoadComponentAsync(new MedalAnimation(new Medal + Event = @"new", + Data = JObject.FromObject(new NewPrivateNotificationEvent { - Name = @"Animations", - InternalName = @"all-intro-doubletime", - Description = @"More complex than you think.", - }), Add); - }); + Name = @"user_achievement_unlock", + Details = JObject.FromObject(new UserAchievementUnlock + { + Title = "Time And A Half", + Description = "Having a right ol' time. One and a half of them, almost.", + Slug = @"all-intro-doubletime" + }) + }) + })); + AddUntilStep("overlay shown", () => overlay.State.Value, () => Is.EqualTo(Visibility.Visible)); + AddRepeatStep("dismiss", () => InputManager.Key(Key.Escape), 2); + AddUntilStep("overlay hidden", () => overlay.State.Value, () => Is.EqualTo(Visibility.Hidden)); } } } diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 16539a812d..1945b2f0dd 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -20,8 +20,8 @@ namespace osu.Game.Graphics.Containers { protected readonly IBindable OverlayActivationMode = new Bindable(OverlayActivation.All); - protected virtual string PopInSampleName => @"UI/overlay-pop-in"; - protected virtual string PopOutSampleName => @"UI/overlay-pop-out"; + protected virtual string? PopInSampleName => @"UI/overlay-pop-in"; + protected virtual string? PopOutSampleName => @"UI/overlay-pop-out"; protected virtual double PopInOutSampleBalance => 0; protected override bool BlockNonPositionalInput => true; @@ -44,8 +44,11 @@ namespace osu.Game.Graphics.Containers [BackgroundDependencyLoader] private void load(AudioManager? audio) { - samplePopIn = audio?.Samples.Get(PopInSampleName); - samplePopOut = audio?.Samples.Get(PopOutSampleName); + if (!string.IsNullOrEmpty(PopInSampleName)) + samplePopIn = audio?.Samples.Get(PopInSampleName); + + if (!string.IsNullOrEmpty(PopOutSampleName)) + samplePopOut = audio?.Samples.Get(PopOutSampleName); } protected override void LoadComplete() diff --git a/osu.Game/Overlays/MedalAnimation.cs b/osu.Game/Overlays/MedalAnimation.cs index 80c06be87c..041929be67 100644 --- a/osu.Game/Overlays/MedalAnimation.cs +++ b/osu.Game/Overlays/MedalAnimation.cs @@ -18,11 +18,9 @@ using osu.Framework.Allocation; using osu.Framework.Audio.Sample; using osu.Framework.Audio; using osu.Framework.Graphics.Textures; -using osuTK.Input; using osu.Framework.Graphics.Shapes; using System; using osu.Framework.Graphics.Effects; -using osu.Framework.Input.Events; using osu.Framework.Utils; namespace osu.Game.Overlays @@ -190,17 +188,6 @@ namespace osu.Game.Overlays particleContainer.Add(new MedalParticle(RNG.Next(0, 359))); } - protected override bool OnClick(ClickEvent e) - { - dismiss(); - return true; - } - - protected override void OnFocusLost(FocusLostEvent e) - { - if (e.CurrentState.Keyboard.Keys.IsPressed(Key.Escape)) dismiss(); - } - private const double initial_duration = 400; private const double step_duration = 900; @@ -256,7 +243,7 @@ namespace osu.Game.Overlays this.FadeOut(200); } - private void dismiss() + public void Dismiss() { if (drawableMedal.State != DisplayState.Full) { diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs new file mode 100644 index 0000000000..c3d7b4b9fc --- /dev/null +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -0,0 +1,112 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Extensions.ObjectExtensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Input.Events; +using osu.Game.Graphics.Containers; +using osu.Game.Input.Bindings; +using osu.Game.Online.API; +using osu.Game.Online.Notifications.WebSocket; +using osu.Game.Online.Notifications.WebSocket.Events; +using osu.Game.Users; + +namespace osu.Game.Overlays +{ + public partial class MedalOverlay : OsuFocusedOverlayContainer + { + protected override string? PopInSampleName => null; + protected override string? PopOutSampleName => null; + + protected override void PopIn() => this.FadeIn(); + + protected override void PopOut() + { + showingMedals = false; + this.FadeOut(); + } + + [Resolved] + private IAPIProvider api { get; set; } = null!; + + private Container medalContainer = null!; + private bool showingMedals; + + [BackgroundDependencyLoader] + private void load() + { + RelativeSizeAxes = Axes.Both; + + api.NotificationsClient.MessageReceived += handleMedalMessages; + + Add(medalContainer = new Container + { + RelativeSizeAxes = Axes.Both + }); + } + + private void handleMedalMessages(SocketMessage obj) + { + if (obj.Event != @"new") + return; + + var data = obj.Data?.ToObject(); + if (data == null || data.Name != @"user_achievement_unlock") + return; + + var details = data.Details?.ToObject(); + if (details == null) + return; + + var medal = new Medal + { + Name = details.Title, + InternalName = details.Slug, + Description = details.Description, + }; + + Show(); + LoadComponentAsync(new MedalAnimation(medal), animation => + { + medalContainer.Add(animation); + showingMedals = true; + }); + } + + protected override void Update() + { + base.Update(); + + if (showingMedals && !medalContainer.Any()) + Hide(); + } + + protected override bool OnClick(ClickEvent e) + { + (medalContainer.FirstOrDefault(anim => anim.IsAlive) as MedalAnimation)?.Dismiss(); + return true; + } + + public override bool OnPressed(KeyBindingPressEvent e) + { + if (e.Action == GlobalAction.Back) + { + (medalContainer.FirstOrDefault(anim => anim.IsAlive) as MedalAnimation)?.Dismiss(); + return true; + } + + return base.OnPressed(e); + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (api.IsNotNull()) + api.NotificationsClient.MessageReceived -= handleMedalMessages; + } + } +} From e4971ae121cf6078cf7e1150cf5176e26d093250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 13:08:02 +0100 Subject: [PATCH 113/508] Add display queueing when multiple medals are granted in quick succession --- .../Visual/Gameplay/TestSceneMedalOverlay.cs | 51 ++++++++++++++----- osu.Game/Overlays/MedalOverlay.cs | 12 ++++- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs index ead5c5b418..a33c7e662f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs @@ -29,23 +29,48 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestBasicAward() { - AddStep("award medal", () => dummyAPI.NotificationsClient.Receive(new SocketMessage + awardMedal(new UserAchievementUnlock { - Event = @"new", - Data = JObject.FromObject(new NewPrivateNotificationEvent - { - Name = @"user_achievement_unlock", - Details = JObject.FromObject(new UserAchievementUnlock - { - Title = "Time And A Half", - Description = "Having a right ol' time. One and a half of them, almost.", - Slug = @"all-intro-doubletime" - }) - }) - })); + Title = "Time And A Half", + Description = "Having a right ol' time. One and a half of them, almost.", + Slug = @"all-intro-doubletime" + }); AddUntilStep("overlay shown", () => overlay.State.Value, () => Is.EqualTo(Visibility.Visible)); AddRepeatStep("dismiss", () => InputManager.Key(Key.Escape), 2); AddUntilStep("overlay hidden", () => overlay.State.Value, () => Is.EqualTo(Visibility.Hidden)); } + + [Test] + public void TestMultipleMedalsInQuickSuccession() + { + awardMedal(new UserAchievementUnlock + { + Title = "Time And A Half", + Description = "Having a right ol' time. One and a half of them, almost.", + Slug = @"all-intro-doubletime" + }); + awardMedal(new UserAchievementUnlock + { + Title = "S-Ranker", + Description = "Accuracy is really underrated.", + Slug = @"all-secret-rank-s" + }); + awardMedal(new UserAchievementUnlock + { + Title = "500 Combo", + Description = "500 big ones! You're moving up in the world!", + Slug = @"osu-combo-500" + }); + } + + private void awardMedal(UserAchievementUnlock unlock) => AddStep("award medal", () => dummyAPI.NotificationsClient.Receive(new SocketMessage + { + Event = @"new", + Data = JObject.FromObject(new NewPrivateNotificationEvent + { + Name = @"user_achievement_unlock", + Details = JObject.FromObject(unlock) + }) + })); } } diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index c3d7b4b9fc..70cde43924 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Extensions.ObjectExtensions; @@ -29,6 +30,8 @@ namespace osu.Game.Overlays this.FadeOut(); } + private readonly Queue queuedMedals = new Queue(); + [Resolved] private IAPIProvider api { get; set; } = null!; @@ -71,7 +74,7 @@ namespace osu.Game.Overlays Show(); LoadComponentAsync(new MedalAnimation(medal), animation => { - medalContainer.Add(animation); + queuedMedals.Enqueue(animation); showingMedals = true; }); } @@ -80,7 +83,12 @@ namespace osu.Game.Overlays { base.Update(); - if (showingMedals && !medalContainer.Any()) + if (!showingMedals || medalContainer.Any()) + return; + + if (queuedMedals.TryDequeue(out var nextMedal)) + medalContainer.Add(nextMedal); + else Hide(); } From b334b78b636a7d4504f3509c88fbf2542d8f4f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 13:44:25 +0100 Subject: [PATCH 114/508] Make medal overlay respect overlay disable via activation mode --- .../Visual/Gameplay/TestSceneMedalOverlay.cs | 35 ++++++++++++++++-- osu.Game/Overlays/MedalOverlay.cs | 36 +++++++++++-------- osu.Game/Properties/AssemblyInfo.cs | 3 ++ 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs index a33c7e662f..fe9c524285 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs @@ -1,8 +1,11 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using Moq; using Newtonsoft.Json.Linq; using NUnit.Framework; +using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Online.API; @@ -16,14 +19,26 @@ namespace osu.Game.Tests.Visual.Gameplay [TestFixture] public partial class TestSceneMedalOverlay : OsuManualInputManagerTestScene { - private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; + private readonly Bindable overlayActivationMode = new Bindable(OverlayActivation.All); + private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; private MedalOverlay overlay = null!; [SetUpSteps] public void SetUpSteps() { - AddStep("create overlay", () => Child = overlay = new MedalOverlay()); + var overlayManagerMock = new Mock(); + overlayManagerMock.Setup(mock => mock.OverlayActivationMode).Returns(overlayActivationMode); + + AddStep("create overlay", () => Child = new DependencyProvidingContainer + { + Child = overlay = new MedalOverlay(), + RelativeSizeAxes = Axes.Both, + CachedDependencies = + [ + (typeof(IOverlayManager), overlayManagerMock.Object) + ] + }); } [Test] @@ -63,6 +78,22 @@ namespace osu.Game.Tests.Visual.Gameplay }); } + [Test] + public void TestDelayMedalDisplayUntilActivationModeAllowsIt() + { + AddStep("disable overlay activation", () => overlayActivationMode.Value = OverlayActivation.Disabled); + awardMedal(new UserAchievementUnlock + { + Title = "Time And A Half", + Description = "Having a right ol' time. One and a half of them, almost.", + Slug = @"all-intro-doubletime" + }); + AddUntilStep("overlay hidden", () => overlay.State.Value, () => Is.EqualTo(Visibility.Hidden)); + + AddStep("re-enable overlay activation", () => overlayActivationMode.Value = OverlayActivation.All); + AddUntilStep("overlay shown", () => overlay.State.Value, () => Is.EqualTo(Visibility.Visible)); + } + private void awardMedal(UserAchievementUnlock unlock) => AddStep("award medal", () => dummyAPI.NotificationsClient.Receive(new SocketMessage { Event = @"new", diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 70cde43924..03beba2d3b 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -24,11 +24,7 @@ namespace osu.Game.Overlays protected override void PopIn() => this.FadeIn(); - protected override void PopOut() - { - showingMedals = false; - this.FadeOut(); - } + protected override void PopOut() => this.FadeOut(); private readonly Queue queuedMedals = new Queue(); @@ -36,7 +32,6 @@ namespace osu.Game.Overlays private IAPIProvider api { get; set; } = null!; private Container medalContainer = null!; - private bool showingMedals; [BackgroundDependencyLoader] private void load() @@ -51,6 +46,17 @@ namespace osu.Game.Overlays }); } + protected override void LoadComplete() + { + base.LoadComplete(); + + OverlayActivationMode.BindValueChanged(val => + { + if (val.NewValue != OverlayActivation.Disabled && queuedMedals.Any()) + Show(); + }, true); + } + private void handleMedalMessages(SocketMessage obj) { if (obj.Event != @"new") @@ -71,25 +77,25 @@ namespace osu.Game.Overlays Description = details.Description, }; + var medalAnimation = new MedalAnimation(medal); + queuedMedals.Enqueue(medalAnimation); Show(); - LoadComponentAsync(new MedalAnimation(medal), animation => - { - queuedMedals.Enqueue(animation); - showingMedals = true; - }); } protected override void Update() { base.Update(); - if (!showingMedals || medalContainer.Any()) + if (medalContainer.Any()) return; - if (queuedMedals.TryDequeue(out var nextMedal)) - medalContainer.Add(nextMedal); - else + if (!queuedMedals.TryDequeue(out var medal)) + { Hide(); + return; + } + + LoadComponentAsync(medal, medalContainer.Add); } protected override bool OnClick(ClickEvent e) diff --git a/osu.Game/Properties/AssemblyInfo.cs b/osu.Game/Properties/AssemblyInfo.cs index 1b77e45891..be430a0fe4 100644 --- a/osu.Game/Properties/AssemblyInfo.cs +++ b/osu.Game/Properties/AssemblyInfo.cs @@ -11,3 +11,6 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("osu.Game.Tests.Dynamic")] [assembly: InternalsVisibleTo("osu.Game.Tests.iOS")] [assembly: InternalsVisibleTo("osu.Game.Tests.Android")] + +// intended for Moq usage +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] From 8abcc70b938c1ba6d23c1d61ac15cf7cad31b02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 14:33:08 +0100 Subject: [PATCH 115/508] Add medal overlay to game --- .../Navigation/TestSceneScreenNavigation.cs | 25 +++++++++++++++++++ osu.Game/OsuGame.cs | 1 + 2 files changed, 26 insertions(+) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs index 7e42d4781d..0fa2fd4b0b 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs @@ -6,6 +6,7 @@ using System; using System.IO; using System.Linq; +using Newtonsoft.Json.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -24,6 +25,8 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.Leaderboards; +using osu.Game.Online.Notifications.WebSocket; +using osu.Game.Online.Notifications.WebSocket.Events; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapListing; using osu.Game.Overlays.Mods; @@ -340,6 +343,28 @@ namespace osu.Game.Tests.Visual.Navigation AddUntilStep("wait for results", () => Game.ScreenStack.CurrentScreen is ResultsScreen); } + [Test] + public void TestShowMedalAtResults() + { + playToResults(); + + AddStep("award medal", () => ((DummyAPIAccess)API).NotificationsClient.Receive(new SocketMessage + { + Event = @"new", + Data = JObject.FromObject(new NewPrivateNotificationEvent + { + Name = @"user_achievement_unlock", + Details = JObject.FromObject(new UserAchievementUnlock + { + Title = "Time And A Half", + Description = "Having a right ol' time. One and a half of them, almost.", + Slug = @"all-intro-doubletime" + }) + }) + })); + AddUntilStep("medal overlay shown", () => Game.ChildrenOfType().Single().State.Value, () => Is.EqualTo(Visibility.Visible)); + } + [Test] public void TestRetryFromResults() { diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9ffa88947b..a829758f0e 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1072,6 +1072,7 @@ namespace osu.Game loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true); loadComponentSingleFile(wikiOverlay = new WikiOverlay(), overlayContent.Add, true); loadComponentSingleFile(skinEditor = new SkinEditorOverlay(ScreenContainer), overlayContent.Add, true); + loadComponentSingleFile(new MedalOverlay(), overlayContent.Add); loadComponentSingleFile(new LoginOverlay { From 96825915f73c558265f736472e95d7e6c68fa19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 15:02:30 +0100 Subject: [PATCH 116/508] Fix threading failure Implicitly showing the medal overlay fires off some transforms, and the websocket listener runs on a TPL thread. That's a recipe for disaster, so schedule the show call. --- osu.Game/Overlays/MedalOverlay.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 03beba2d3b..76936e0f5a 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -22,6 +22,8 @@ namespace osu.Game.Overlays protected override string? PopInSampleName => null; protected override string? PopOutSampleName => null; + public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks; + protected override void PopIn() => this.FadeIn(); protected override void PopOut() => this.FadeOut(); @@ -52,7 +54,7 @@ namespace osu.Game.Overlays OverlayActivationMode.BindValueChanged(val => { - if (val.NewValue != OverlayActivation.Disabled && queuedMedals.Any()) + if (val.NewValue != OverlayActivation.Disabled && (queuedMedals.Any() || medalContainer.Any())) Show(); }, true); } @@ -79,7 +81,7 @@ namespace osu.Game.Overlays var medalAnimation = new MedalAnimation(medal); queuedMedals.Enqueue(medalAnimation); - Show(); + Scheduler.AddOnce(Show); } protected override void Update() From 611e3fe76bd0930e0ef0320c57ba23658e9b2bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 15:52:15 +0100 Subject: [PATCH 117/508] Delay medal display when wanting to show results animation --- osu.Game/Overlays/MedalOverlay.cs | 5 +++-- .../Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs | 5 +++++ osu.Game/Screens/Ranking/ResultsScreen.cs | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 76936e0f5a..3601566dda 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -54,7 +54,7 @@ namespace osu.Game.Overlays OverlayActivationMode.BindValueChanged(val => { - if (val.NewValue != OverlayActivation.Disabled && (queuedMedals.Any() || medalContainer.Any())) + if (val.NewValue == OverlayActivation.All && (queuedMedals.Any() || medalContainer.Any())) Show(); }, true); } @@ -81,7 +81,8 @@ namespace osu.Game.Overlays var medalAnimation = new MedalAnimation(medal); queuedMedals.Enqueue(medalAnimation); - Scheduler.AddOnce(Show); + if (OverlayActivationMode.Value == OverlayActivation.All) + Scheduler.AddOnce(Show); } protected override void Update() diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index d209c305fa..f807126614 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -31,6 +31,11 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy /// public partial class AccuracyCircle : CompositeDrawable { + /// + /// The total duration of the animation. + /// + public const double TOTAL_DURATION = APPEAR_DURATION + ACCURACY_TRANSFORM_DELAY + ACCURACY_TRANSFORM_DURATION; + /// /// Duration for the transforms causing this component to appear. /// diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 69cfbed8f2..93114b1d18 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -25,8 +25,10 @@ using osu.Game.Input.Bindings; using osu.Game.Localisation; using osu.Game.Online.API; using osu.Game.Online.Placeholders; +using osu.Game.Overlays; using osu.Game.Scoring; using osu.Game.Screens.Play; +using osu.Game.Screens.Ranking.Expanded.Accuracy; using osu.Game.Screens.Ranking.Statistics; using osuTK; @@ -41,6 +43,8 @@ namespace osu.Game.Screens.Ranking public override bool? AllowGlobalTrackControl => true; + protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.UserTriggered; + public readonly Bindable SelectedScore = new Bindable(); [CanBeNull] @@ -160,6 +164,10 @@ namespace osu.Game.Screens.Ranking bool shouldFlair = player != null && !Score.User.IsBot; ScorePanelList.AddScore(Score, shouldFlair); + // this is mostly for medal display. + // we don't want the medal animation to trample on the results screen animation, so we (ab)use `OverlayActivationMode` + // to give the results screen enough time to play the animation out before the medals can be shown. + Scheduler.AddDelayed(() => OverlayActivationMode.Value = OverlayActivation.All, shouldFlair ? AccuracyCircle.TOTAL_DURATION + 1000 : 0); } if (allowWatchingReplay) From 1db5cd3abadcc5f24ceada0092fcf8e2d7ece869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 16:16:30 +0100 Subject: [PATCH 118/508] Move medal overlay to topmost container --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index a829758f0e..dbdc86e016 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1072,7 +1072,6 @@ namespace osu.Game loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true); loadComponentSingleFile(wikiOverlay = new WikiOverlay(), overlayContent.Add, true); loadComponentSingleFile(skinEditor = new SkinEditorOverlay(ScreenContainer), overlayContent.Add, true); - loadComponentSingleFile(new MedalOverlay(), overlayContent.Add); loadComponentSingleFile(new LoginOverlay { @@ -1088,6 +1087,7 @@ namespace osu.Game loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true); loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true); + loadComponentSingleFile(new MedalOverlay(), topMostOverlayContent.Add); loadComponentSingleFile(CreateHighPerformanceSession(), Add); From e9aca9226a43285bded225e75465b41045965938 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 20 Feb 2024 19:10:03 +0300 Subject: [PATCH 119/508] Reduce allocations in ManiaPlayfield.TotalColumns --- osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs index 0d36f51943..b3420c49f3 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaPlayfield.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using System; using System.Collections.Generic; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics.Primitives; using osu.Game.Rulesets.Mania.Beatmaps; @@ -149,7 +148,18 @@ namespace osu.Game.Rulesets.Mania.UI /// /// Retrieves the total amount of columns across all stages in this playfield. /// - public int TotalColumns => stages.Sum(s => s.Columns.Length); + public int TotalColumns + { + get + { + int sum = 0; + + foreach (var stage in stages) + sum += stage.Columns.Length; + + return sum; + } + } private Stage getStageByColumn(int column) { From 9b938f333de39b0d497cab545f4e0719e17c9b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 17:25:11 +0100 Subject: [PATCH 120/508] Fix test failures --- osu.Game/Overlays/MedalOverlay.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 3601566dda..072d7db6c7 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -34,6 +34,7 @@ namespace osu.Game.Overlays private IAPIProvider api { get; set; } = null!; private Container medalContainer = null!; + private MedalAnimation? lastAnimation; [BackgroundDependencyLoader] private void load() @@ -54,7 +55,7 @@ namespace osu.Game.Overlays OverlayActivationMode.BindValueChanged(val => { - if (val.NewValue == OverlayActivation.All && (queuedMedals.Any() || medalContainer.Any())) + if (val.NewValue == OverlayActivation.All && (queuedMedals.Any() || medalContainer.Any() || lastAnimation?.IsLoaded == false)) Show(); }, true); } @@ -89,21 +90,21 @@ namespace osu.Game.Overlays { base.Update(); - if (medalContainer.Any()) + if (medalContainer.Any() || lastAnimation?.IsLoaded == false) return; - if (!queuedMedals.TryDequeue(out var medal)) + if (!queuedMedals.TryDequeue(out lastAnimation)) { Hide(); return; } - LoadComponentAsync(medal, medalContainer.Add); + LoadComponentAsync(lastAnimation, medalContainer.Add); } protected override bool OnClick(ClickEvent e) { - (medalContainer.FirstOrDefault(anim => anim.IsAlive) as MedalAnimation)?.Dismiss(); + lastAnimation?.Dismiss(); return true; } @@ -111,7 +112,7 @@ namespace osu.Game.Overlays { if (e.Action == GlobalAction.Back) { - (medalContainer.FirstOrDefault(anim => anim.IsAlive) as MedalAnimation)?.Dismiss(); + lastAnimation?.Dismiss(); return true; } From 6678c4783bc338287b6465f65cf7a8bb3ee2d288 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 20 Feb 2024 19:31:28 +0300 Subject: [PATCH 121/508] Fix PlaybackControl string allocations --- osu.Game/Screens/Edit/Components/PlaybackControl.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Components/PlaybackControl.cs b/osu.Game/Screens/Edit/Components/PlaybackControl.cs index 431336aa60..a5ed0d680f 100644 --- a/osu.Game/Screens/Edit/Components/PlaybackControl.cs +++ b/osu.Game/Screens/Edit/Components/PlaybackControl.cs @@ -97,11 +97,14 @@ namespace osu.Game.Screens.Edit.Components editorClock.Start(); } + private static readonly IconUsage play_icon = FontAwesome.Regular.PlayCircle; + private static readonly IconUsage pause_icon = FontAwesome.Regular.PauseCircle; + protected override void Update() { base.Update(); - playButton.Icon = editorClock.IsRunning ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle; + playButton.Icon = editorClock.IsRunning ? pause_icon : play_icon; } private partial class PlaybackTabControl : OsuTabControl From 33a0dcaf20fad0c79802367f81b9a370a9be035f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 17:59:21 +0100 Subject: [PATCH 122/508] NRT-annotate `MedalAnimation` and fix possible nullref --- osu.Game/Overlays/MedalAnimation.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/MedalAnimation.cs b/osu.Game/Overlays/MedalAnimation.cs index 041929be67..25776d50db 100644 --- a/osu.Game/Overlays/MedalAnimation.cs +++ b/osu.Game/Overlays/MedalAnimation.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osuTK; using osuTK.Graphics; using osu.Framework.Extensions.Color4Extensions; @@ -20,6 +18,7 @@ using osu.Framework.Audio; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Shapes; using System; +using System.Diagnostics; using osu.Framework.Graphics.Effects; using osu.Framework.Utils; @@ -37,9 +36,9 @@ namespace osu.Game.Overlays private readonly BackgroundStrip leftStrip, rightStrip; private readonly CircularContainer disc; private readonly Sprite innerSpin, outerSpin; - private DrawableMedal drawableMedal; - private Sample getSample; + private DrawableMedal? drawableMedal; + private Sample? getSample; private readonly Container content; @@ -197,7 +196,7 @@ namespace osu.Game.Overlays background.FlashColour(Color4.White.Opacity(0.25f), 400); - getSample.Play(); + getSample?.Play(); innerSpin.Spin(20000, RotationDirection.Clockwise); outerSpin.Spin(40000, RotationDirection.Clockwise); @@ -216,6 +215,8 @@ namespace osu.Game.Overlays leftStrip.ResizeWidthTo(1f, step_duration, Easing.OutQuint); rightStrip.ResizeWidthTo(1f, step_duration, Easing.OutQuint); + Debug.Assert(drawableMedal != null); + this.Animate().Schedule(() => { if (drawableMedal.State != DisplayState.Full) @@ -245,7 +246,7 @@ namespace osu.Game.Overlays public void Dismiss() { - if (drawableMedal.State != DisplayState.Full) + if (drawableMedal != null && drawableMedal.State != DisplayState.Full) { // if we haven't yet, play out the animation fully drawableMedal.State = DisplayState.Full; From 871bdb9cf7919088f0344cf9c9f6ca37b204b622 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 20 Feb 2024 19:38:57 +0300 Subject: [PATCH 123/508] Reduce string allocations in TimeInfoContainer --- .../Edit/Components/TimeInfoContainer.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs index 9c51258f17..4747828bca 100644 --- a/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs +++ b/osu.Game/Screens/Edit/Components/TimeInfoContainer.cs @@ -47,11 +47,26 @@ namespace osu.Game.Screens.Edit.Components }; } + private double? lastTime; + private double? lastBPM; + protected override void Update() { base.Update(); - trackTimer.Text = editorClock.CurrentTime.ToEditorFormattedString(); - bpm.Text = @$"{editorBeatmap.ControlPointInfo.TimingPointAt(editorClock.CurrentTime).BPM:0} BPM"; + + if (lastTime != editorClock.CurrentTime) + { + lastTime = editorClock.CurrentTime; + trackTimer.Text = editorClock.CurrentTime.ToEditorFormattedString(); + } + + double newBPM = editorBeatmap.ControlPointInfo.TimingPointAt(editorClock.CurrentTime).BPM; + + if (lastBPM != newBPM) + { + lastBPM = newBPM; + bpm.Text = @$"{newBPM:0} BPM"; + } } } } From e5be8838e68e10cc11c14dc11f5ee1dbfb5a69eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 20 Feb 2024 18:42:01 +0100 Subject: [PATCH 124/508] Fix yet another failure --- osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs index fe9c524285..5dc553b9df 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneMedalOverlay.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using Moq; using Newtonsoft.Json.Linq; using NUnit.Framework; @@ -51,6 +52,7 @@ namespace osu.Game.Tests.Visual.Gameplay Slug = @"all-intro-doubletime" }); AddUntilStep("overlay shown", () => overlay.State.Value, () => Is.EqualTo(Visibility.Visible)); + AddUntilStep("wait for load", () => this.ChildrenOfType().Any()); AddRepeatStep("dismiss", () => InputManager.Key(Key.Escape), 2); AddUntilStep("overlay hidden", () => overlay.State.Value, () => Is.EqualTo(Visibility.Hidden)); } From b92cff9a8ed370c59fca69dba9b9cb9923efa737 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 20 Feb 2024 20:29:35 +0300 Subject: [PATCH 125/508] Reduce allocations in ManiaSelectionBlueprint --- .../Blueprints/ManiaSelectionBlueprint.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs index 1ae65dd8c0..c645ddd98d 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Mania.Objects; @@ -17,9 +18,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints [Resolved] private Playfield playfield { get; set; } = null!; - [Resolved] - private IScrollingInfo scrollingInfo { get; set; } = null!; - protected ScrollingHitObjectContainer HitObjectContainer => ((ManiaPlayfield)playfield).GetColumn(HitObject.Column).HitObjectContainer; protected ManiaSelectionBlueprint(T hitObject) @@ -28,14 +26,31 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints RelativeSizeAxes = Axes.None; } - protected override void Update() - { - base.Update(); + private readonly IBindable directionBindable = new Bindable(); - var anchor = scrollingInfo.Direction.Value == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; + [BackgroundDependencyLoader] + private void load(IScrollingInfo scrollingInfo) + { + directionBindable.BindTo(scrollingInfo.Direction); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + directionBindable.BindValueChanged(onDirectionChanged, true); + } + + private void onDirectionChanged(ValueChangedEvent direction) + { + var anchor = direction.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; Anchor = Origin = anchor; foreach (var child in InternalChildren) child.Anchor = child.Origin = anchor; + } + + protected override void Update() + { + base.Update(); Position = Parent!.ToLocalSpace(HitObjectContainer.ScreenSpacePositionAtTime(HitObject.StartTime)) - AnchorPosition; Width = HitObjectContainer.DrawWidth; From 2543a48ac83a2983b76da3bfe5d63f55ad3b1544 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 20 Feb 2024 23:18:37 +0300 Subject: [PATCH 126/508] Apply padding to GridContainers directly --- .../Chat/ChannelList/ChannelListItem.cs | 56 ++++---- .../Profile/Header/DetailHeaderContainer.cs | 63 ++++----- osu.Game/Screens/Edit/BottomBar.cs | 46 +++---- .../Compose/Components/BeatDivisorControl.cs | 89 +++++------- .../Screens/Edit/EditorScreenWithTimeline.cs | 35 ++--- .../Screens/Edit/Timing/TapTimingControl.cs | 35 ++--- osu.Game/Screens/Edit/Verify/VerifyScreen.cs | 24 ++-- .../Components/MatchBeatmapDetailArea.cs | 52 ++++--- .../Lounge/Components/PillContainer.cs | 30 ++-- .../Playlists/PlaylistsRoomSubScreen.cs | 42 +++--- .../ContractedPanelMiddleContent.cs | 50 ++++--- osu.Game/Screens/Select/BeatmapDetails.cs | 129 +++++++++--------- 12 files changed, 292 insertions(+), 359 deletions(-) diff --git a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs index 21b6147113..87b1f4ef01 100644 --- a/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs +++ b/osu.Game/Overlays/Chat/ChannelList/ChannelListItem.cs @@ -66,41 +66,37 @@ namespace osu.Game.Overlays.Chat.ChannelList Colour = colourProvider.Background4, Alpha = 0f, }, - new Container + new GridContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = 18, Right = 10 }, - Child = new GridContainer + ColumnDimensions = new[] { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.AutoSize), - new Dimension(), - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.AutoSize), - }, - Content = new[] - { - new Drawable?[] - { - createIcon(), - text = new TruncatingSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Text = Channel.Name, - Font = OsuFont.Torus.With(size: 17, weight: FontWeight.SemiBold), - Colour = colourProvider.Light3, - Margin = new MarginPadding { Bottom = 2 }, - RelativeSizeAxes = Axes.X, - }, - createMentionPill(), - close = createCloseButton(), - } - }, + new Dimension(GridSizeMode.AutoSize), + new Dimension(), + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), }, - }, + Content = new[] + { + new Drawable?[] + { + createIcon(), + text = new TruncatingSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Text = Channel.Name, + Font = OsuFont.Torus.With(size: 17, weight: FontWeight.SemiBold), + Colour = colourProvider.Light3, + Margin = new MarginPadding { Bottom = 2 }, + RelativeSizeAxes = Axes.X, + }, + createMentionPill(), + close = createCloseButton(), + } + } + } }; Action = () => OnRequestSelect?.Invoke(Channel); diff --git a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs index 1f35f39b49..118bf9171e 100644 --- a/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/DetailHeaderContainer.cs @@ -26,47 +26,42 @@ namespace osu.Game.Overlays.Profile.Header RelativeSizeAxes = Axes.Both, Colour = colourProvider.Background5, }, - new Container + new GridContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Horizontal = WaveOverlayContainer.HORIZONTAL_PADDING, Vertical = 10 }, - Child = new GridContainer + RowDimensions = new[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - RowDimensions = new[] + new Dimension(GridSizeMode.AutoSize), + }, + ColumnDimensions = new[] + { + new Dimension(), + new Dimension(GridSizeMode.AutoSize), + new Dimension(GridSizeMode.AutoSize), + }, + Content = new[] + { + new Drawable[] { - new Dimension(GridSizeMode.AutoSize), - }, - ColumnDimensions = new[] - { - new Dimension(), - new Dimension(GridSizeMode.AutoSize), - new Dimension(GridSizeMode.AutoSize), - }, - Content = new[] - { - new Drawable[] + new MainDetails { - new MainDetails - { - RelativeSizeAxes = Axes.X, - User = { BindTarget = User } - }, - new Box - { - RelativeSizeAxes = Axes.Y, - Width = 2, - Colour = colourProvider.Background6, - Margin = new MarginPadding { Horizontal = 15 } - }, - new ExtendedDetails - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - User = { BindTarget = User } - } + RelativeSizeAxes = Axes.X, + User = { BindTarget = User } + }, + new Box + { + RelativeSizeAxes = Axes.Y, + Width = 2, + Colour = colourProvider.Background6, + Margin = new MarginPadding { Horizontal = 15 } + }, + new ExtendedDetails + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + User = { BindTarget = User } } } } diff --git a/osu.Game/Screens/Edit/BottomBar.cs b/osu.Game/Screens/Edit/BottomBar.cs index aa3c4ba0d0..bc7dfaab88 100644 --- a/osu.Game/Screens/Edit/BottomBar.cs +++ b/osu.Game/Screens/Edit/BottomBar.cs @@ -47,35 +47,31 @@ namespace osu.Game.Screens.Edit RelativeSizeAxes = Axes.Both, Colour = colourProvider.Background4, }, - new Container + new GridContainer { RelativeSizeAxes = Axes.Both, - Child = new GridContainer + ColumnDimensions = new[] { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.Absolute, 170), - new Dimension(), - new Dimension(GridSizeMode.Absolute, 220), - new Dimension(GridSizeMode.Absolute, HitObjectComposer.TOOLBOX_CONTRACTED_SIZE_RIGHT), - }, - Content = new[] - { - new Drawable[] - { - new TimeInfoContainer { RelativeSizeAxes = Axes.Both }, - new SummaryTimeline { RelativeSizeAxes = Axes.Both }, - new PlaybackControl { RelativeSizeAxes = Axes.Both }, - TestGameplayButton = new TestGameplayButton - { - RelativeSizeAxes = Axes.Both, - Size = new Vector2(1), - Action = editor.TestGameplay, - } - }, - } + new Dimension(GridSizeMode.Absolute, 170), + new Dimension(), + new Dimension(GridSizeMode.Absolute, 220), + new Dimension(GridSizeMode.Absolute, HitObjectComposer.TOOLBOX_CONTRACTED_SIZE_RIGHT), }, + Content = new[] + { + new Drawable[] + { + new TimeInfoContainer { RelativeSizeAxes = Axes.Both }, + new SummaryTimeline { RelativeSizeAxes = Axes.Both }, + new PlaybackControl { RelativeSizeAxes = Axes.Both }, + TestGameplayButton = new TestGameplayButton + { + RelativeSizeAxes = Axes.Both, + Size = new Vector2(1), + Action = editor.TestGameplay, + } + }, + } } }; } diff --git a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs index da1a37d57f..40b97d2137 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs @@ -86,35 +86,31 @@ namespace osu.Game.Screens.Edit.Compose.Components RelativeSizeAxes = Axes.Both, Colour = colourProvider.Background3 }, - new Container + new GridContainer { RelativeSizeAxes = Axes.Both, - Child = new GridContainer + Content = new[] { - RelativeSizeAxes = Axes.Both, - Content = new[] + new Drawable[] { - new Drawable[] + new ChevronButton { - new ChevronButton - { - Icon = FontAwesome.Solid.ChevronLeft, - Action = beatDivisor.SelectPrevious - }, - new DivisorDisplay { BeatDivisor = { BindTarget = beatDivisor } }, - new ChevronButton - { - Icon = FontAwesome.Solid.ChevronRight, - Action = beatDivisor.SelectNext - } + Icon = FontAwesome.Solid.ChevronLeft, + Action = beatDivisor.SelectPrevious }, + new DivisorDisplay { BeatDivisor = { BindTarget = beatDivisor } }, + new ChevronButton + { + Icon = FontAwesome.Solid.ChevronRight, + Action = beatDivisor.SelectNext + } }, - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.Absolute, 20), - new Dimension(), - new Dimension(GridSizeMode.Absolute, 20) - } + }, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 20), + new Dimension(), + new Dimension(GridSizeMode.Absolute, 20) } } } @@ -122,42 +118,31 @@ namespace osu.Game.Screens.Edit.Compose.Components }, new Drawable[] { - new Container + new GridContainer { RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + Content = new[] { - new Container + new Drawable[] { - RelativeSizeAxes = Axes.Both, - Child = new GridContainer + new ChevronButton { - RelativeSizeAxes = Axes.Both, - Content = new[] - { - new Drawable[] - { - new ChevronButton - { - Icon = FontAwesome.Solid.ChevronLeft, - Action = () => cycleDivisorType(-1) - }, - new DivisorTypeText { BeatDivisor = { BindTarget = beatDivisor } }, - new ChevronButton - { - Icon = FontAwesome.Solid.ChevronRight, - Action = () => cycleDivisorType(1) - } - }, - }, - ColumnDimensions = new[] - { - new Dimension(GridSizeMode.Absolute, 20), - new Dimension(), - new Dimension(GridSizeMode.Absolute, 20) - } + Icon = FontAwesome.Solid.ChevronLeft, + Action = () => cycleDivisorType(-1) + }, + new DivisorTypeText { BeatDivisor = { BindTarget = beatDivisor } }, + new ChevronButton + { + Icon = FontAwesome.Solid.ChevronRight, + Action = () => cycleDivisorType(1) } - } + }, + }, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.Absolute, 20), + new Dimension(), + new Dimension(GridSizeMode.Absolute, 20) } } }, diff --git a/osu.Game/Screens/Edit/EditorScreenWithTimeline.cs b/osu.Game/Screens/Edit/EditorScreenWithTimeline.cs index 575a66d421..2b97d363f1 100644 --- a/osu.Game/Screens/Edit/EditorScreenWithTimeline.cs +++ b/osu.Game/Screens/Edit/EditorScreenWithTimeline.cs @@ -57,37 +57,32 @@ namespace osu.Game.Screens.Edit RelativeSizeAxes = Axes.Both, Colour = colourProvider.Background4 }, - new Container + new GridContainer { Name = "Timeline content", RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Horizontal = PADDING, Top = PADDING }, - Child = new GridContainer + Content = new[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Content = new[] + new Drawable[] { - new Drawable[] + TimelineContent = new Container { - TimelineContent = new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - }, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, }, }, - RowDimensions = new[] - { - new Dimension(GridSizeMode.AutoSize), - }, - ColumnDimensions = new[] - { - new Dimension(), - new Dimension(GridSizeMode.Absolute, 90), - } }, + RowDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), + }, + ColumnDimensions = new[] + { + new Dimension(), + new Dimension(GridSizeMode.Absolute, 90), + } } } }, diff --git a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs index bb7a3b8be3..8cdbd97ecb 100644 --- a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs +++ b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs @@ -65,35 +65,28 @@ namespace osu.Game.Screens.Edit.Timing { new Drawable[] { - new Container + new GridContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(padding), - Children = new Drawable[] + ColumnDimensions = new[] { - new GridContainer + new Dimension(GridSizeMode.AutoSize), + new Dimension() + }, + Content = new[] + { + new Drawable[] { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] + metronome = new MetronomeDisplay { - new Dimension(GridSizeMode.AutoSize), - new Dimension() - }, - Content = new[] - { - new Drawable[] - { - metronome = new MetronomeDisplay - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - }, - new WaveformComparisonDisplay() - } + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, }, + new WaveformComparisonDisplay() } - } - }, + }, + } }, new Drawable[] { diff --git a/osu.Game/Screens/Edit/Verify/VerifyScreen.cs b/osu.Game/Screens/Edit/Verify/VerifyScreen.cs index b6e0450e23..fe508860e0 100644 --- a/osu.Game/Screens/Edit/Verify/VerifyScreen.cs +++ b/osu.Game/Screens/Edit/Verify/VerifyScreen.cs @@ -34,25 +34,21 @@ namespace osu.Game.Screens.Edit.Verify InterpretedDifficulty.Default = StarDifficulty.GetDifficultyRating(EditorBeatmap.BeatmapInfo.StarRating); InterpretedDifficulty.SetDefault(); - Child = new Container + Child = new GridContainer { RelativeSizeAxes = Axes.Both, - Child = new GridContainer + ColumnDimensions = new[] { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] + new Dimension(), + new Dimension(GridSizeMode.Absolute, 250), + }, + Content = new[] + { + new Drawable[] { - new Dimension(), - new Dimension(GridSizeMode.Absolute, 250), + IssueList = new IssueList(), + new IssueSettings(), }, - Content = new[] - { - new Drawable[] - { - IssueList = new IssueList(), - new IssueSettings(), - }, - } } }; } diff --git a/osu.Game/Screens/OnlinePlay/Components/MatchBeatmapDetailArea.cs b/osu.Game/Screens/OnlinePlay/Components/MatchBeatmapDetailArea.cs index dec91d8a37..b0ede8d9b5 100644 --- a/osu.Game/Screens/OnlinePlay/Components/MatchBeatmapDetailArea.cs +++ b/osu.Game/Screens/OnlinePlay/Components/MatchBeatmapDetailArea.cs @@ -26,48 +26,44 @@ namespace osu.Game.Screens.OnlinePlay.Components [Resolved(typeof(Room))] protected BindableList Playlist { get; private set; } - private readonly Drawable playlistArea; + private readonly GridContainer playlistArea; private readonly DrawableRoomPlaylist playlist; public MatchBeatmapDetailArea() { - Add(playlistArea = new Container + Add(playlistArea = new GridContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Vertical = 10 }, - Child = new GridContainer + Content = new[] { - RelativeSizeAxes = Axes.Both, - Content = new[] + new Drawable[] { - new Drawable[] + new Container { - new Container + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Bottom = 10 }, + Child = playlist = new PlaylistsRoomSettingsPlaylist { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Bottom = 10 }, - Child = playlist = new PlaylistsRoomSettingsPlaylist - { - RelativeSizeAxes = Axes.Both - } + RelativeSizeAxes = Axes.Both } - }, - new Drawable[] - { - new RoundedButton - { - Text = "Add new playlist entry", - RelativeSizeAxes = Axes.Both, - Size = Vector2.One, - Action = () => CreateNewItem?.Invoke() - } - }, + } }, - RowDimensions = new[] + new Drawable[] { - new Dimension(), - new Dimension(GridSizeMode.Absolute, 50), - } + new RoundedButton + { + Text = "Add new playlist entry", + RelativeSizeAxes = Axes.Both, + Size = Vector2.One, + Action = () => CreateNewItem?.Invoke() + } + }, + }, + RowDimensions = new[] + { + new Dimension(), + new Dimension(GridSizeMode.Absolute, 50), } }); } diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/PillContainer.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/PillContainer.cs index b473ea82c6..5f77742588 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/Components/PillContainer.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/PillContainer.cs @@ -40,35 +40,31 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components Colour = Color4.Black, Alpha = 0.5f }, - new Container + new GridContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = padding }, - Child = new GridContainer + ColumnDimensions = new[] { - AutoSizeAxes = Axes.Both, - ColumnDimensions = new[] + new Dimension(GridSizeMode.AutoSize, minSize: 80 - 2 * padding) + }, + Content = new[] + { + new[] { - new Dimension(GridSizeMode.AutoSize, minSize: 80 - 2 * padding) - }, - Content = new[] - { - new[] + new Container { - new Container + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Padding = new MarginPadding { Bottom = 2 }, + Child = content = new Container { AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Padding = new MarginPadding { Bottom = 2 }, - Child = content = new Container - { - AutoSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - } } } } diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs index cf5a8e1985..2460f78c96 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs @@ -95,38 +95,34 @@ namespace osu.Game.Screens.OnlinePlay.Playlists new Drawable[] { // Playlist items column - new Container + new GridContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Right = 5 }, - Child = new GridContainer + Content = new[] { - RelativeSizeAxes = Axes.Both, - Content = new[] + new Drawable[] { new OverlinedPlaylistHeader(), }, + new Drawable[] { - new Drawable[] { new OverlinedPlaylistHeader(), }, - new Drawable[] + new DrawableRoomPlaylist { - new DrawableRoomPlaylist + RelativeSizeAxes = Axes.Both, + Items = { BindTarget = Room.Playlist }, + SelectedItem = { BindTarget = SelectedItem }, + AllowSelection = true, + AllowShowingResults = true, + RequestResults = item => { - RelativeSizeAxes = Axes.Both, - Items = { BindTarget = Room.Playlist }, - SelectedItem = { BindTarget = SelectedItem }, - AllowSelection = true, - AllowShowingResults = true, - RequestResults = item => - { - Debug.Assert(RoomId.Value != null); - ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item, false)); - } + Debug.Assert(RoomId.Value != null); + ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item, false)); } - }, + } }, - RowDimensions = new[] - { - new Dimension(GridSizeMode.AutoSize), - new Dimension(), - } + }, + RowDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), + new Dimension(), } }, // Spacer diff --git a/osu.Game/Screens/Ranking/Contracted/ContractedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Contracted/ContractedPanelMiddleContent.cs index 195cd03e9b..cfb6465e62 100644 --- a/osu.Game/Screens/Ranking/Contracted/ContractedPanelMiddleContent.cs +++ b/osu.Game/Screens/Ranking/Contracted/ContractedPanelMiddleContent.cs @@ -150,44 +150,40 @@ namespace osu.Game.Screens.Ranking.Contracted }, new Drawable[] { - new Container + new GridContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Vertical = 5 }, - Child = new GridContainer + Content = new[] { - RelativeSizeAxes = Axes.Both, - Content = new[] + new Drawable[] { - new Drawable[] + new OsuSpriteText { - new OsuSpriteText + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Current = scoreManager.GetBindableTotalScoreString(score), + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, fixedWidth: true), + Spacing = new Vector2(-1, 0) + }, + }, + new Drawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = 2 }, + Child = new DrawableRank(score.Rank) { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Current = scoreManager.GetBindableTotalScoreString(score), - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, fixedWidth: true), - Spacing = new Vector2(-1, 0) - }, - }, - new Drawable[] - { - new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = 2 }, - Child = new DrawableRank(score.Rank) - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - } } - }, + } }, - RowDimensions = new[] - { - new Dimension(GridSizeMode.AutoSize), - } + }, + RowDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), } } }, diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index dec2c1c1de..2bb60716ff 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -75,99 +75,92 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.Both, Colour = Colour4.Black.Opacity(0.3f), }, - new Container + new GridContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = spacing }, - Children = new Drawable[] + RowDimensions = new[] { - new GridContainer + new Dimension(GridSizeMode.AutoSize), + new Dimension() + }, + Content = new[] + { + new Drawable[] { - RelativeSizeAxes = Axes.Both, - RowDimensions = new[] + new FillFlowContainer { - new Dimension(GridSizeMode.AutoSize), - new Dimension() - }, - Content = new[] - { - new Drawable[] + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Children = new Drawable[] { new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Direction = FillDirection.Horizontal, - Children = new Drawable[] + Width = 0.5f, + Spacing = new Vector2(spacing), + Padding = new MarginPadding { Right = spacing / 2 }, + Children = new[] { - new FillFlowContainer + new DetailBox().WithChild(new OnlineViewContainer(string.Empty) { RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Width = 0.5f, - Spacing = new Vector2(spacing), - Padding = new MarginPadding { Right = spacing / 2 }, - Children = new[] + Height = 134, + Padding = new MarginPadding { Horizontal = spacing, Top = spacing }, + Child = ratingsDisplay = new UserRatings { - new DetailBox().WithChild(new OnlineViewContainer(string.Empty) - { - RelativeSizeAxes = Axes.X, - Height = 134, - Padding = new MarginPadding { Horizontal = spacing, Top = spacing }, - Child = ratingsDisplay = new UserRatings - { - RelativeSizeAxes = Axes.Both, - }, - }), + RelativeSizeAxes = Axes.Both, }, - }, - new OsuScrollContainer + }), + }, + }, + new OsuScrollContainer + { + RelativeSizeAxes = Axes.X, + Height = 250, + Width = 0.5f, + ScrollbarVisible = false, + Padding = new MarginPadding { Left = spacing / 2 }, + Child = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + LayoutDuration = transition_duration, + LayoutEasing = Easing.OutQuad, + Children = new[] { - RelativeSizeAxes = Axes.X, - Height = 250, - Width = 0.5f, - ScrollbarVisible = false, - Padding = new MarginPadding { Left = spacing / 2 }, - Child = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - LayoutDuration = transition_duration, - LayoutEasing = Easing.OutQuad, - Children = new[] - { - description = new MetadataSectionDescription(query => songSelect?.Search(query)), - source = new MetadataSectionSource(query => songSelect?.Search(query)), - tags = new MetadataSectionTags(query => songSelect?.Search(query)), - }, - }, + description = new MetadataSectionDescription(query => songSelect?.Search(query)), + source = new MetadataSectionSource(query => songSelect?.Search(query)), + tags = new MetadataSectionTags(query => songSelect?.Search(query)), }, }, }, }, - new Drawable[] + }, + }, + new Drawable[] + { + failRetryContainer = new OnlineViewContainer("Sign in to view more details") + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - failRetryContainer = new OnlineViewContainer("Sign in to view more details") + new OsuSpriteText + { + Text = BeatmapsetsStrings.ShowInfoPointsOfFailure, + Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), + }, + failRetryGraph = new FailRetryGraph { RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - new OsuSpriteText - { - Text = BeatmapsetsStrings.ShowInfoPointsOfFailure, - Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), - }, - failRetryGraph = new FailRetryGraph - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = 14 + spacing / 2 }, - }, - }, + Padding = new MarginPadding { Top = 14 + spacing / 2 }, }, - } - } - }, - }, + }, + }, + } + } }, loading = new LoadingLayer(true) }; From 86e3b597b42e79eafdb6ea0722277b6a9882485b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 21 Feb 2024 13:18:51 +0800 Subject: [PATCH 127/508] Fix `LegacyApproachCircle` incorrectly applying scaling factor --- .../Skinning/Legacy/LegacyApproachCircle.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyApproachCircle.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyApproachCircle.cs index 0bdea0cab1..8ff85090ca 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyApproachCircle.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyApproachCircle.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Skinning; -using osuTK; using osuTK.Graphics; namespace osu.Game.Rulesets.Osu.Skinning.Legacy @@ -26,10 +25,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy var texture = skin.GetTexture(@"approachcircle"); Debug.Assert(texture != null); Texture = texture.WithMaximumSize(OsuHitObject.OBJECT_DIMENSIONS * 2); - - // account for the sprite being used for the default approach circle being taken from stable, - // when hitcircles have 5px padding on each size. this should be removed if we update the sprite. - Scale = new Vector2(128 / 118f); } protected override void LoadComplete() From a11a83ac480f86f9420ee2f78abb01a2912b858d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 21 Feb 2024 13:44:04 +0800 Subject: [PATCH 128/508] Improve comment regarding scale adjust of approach circles --- .../Skinning/Default/DefaultApproachCircle.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultApproachCircle.cs b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultApproachCircle.cs index 272f4b5658..3a4c454bf1 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultApproachCircle.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultApproachCircle.cs @@ -25,8 +25,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { Texture = textures.Get(@"Gameplay/osu/approachcircle").WithMaximumSize(OsuHitObject.OBJECT_DIMENSIONS * 2); - // account for the sprite being used for the default approach circle being taken from stable, - // when hitcircles have 5px padding on each size. this should be removed if we update the sprite. + // In triangles and argon skins, we expanded hitcircles to take up the full 128 px which are clickable, + // but still use the old approach circle sprite. To make it feel correct (ie. disappear as it collides + // with the hitcircle, *not when it overlaps the border*) we need to expand it slightly. Scale = new Vector2(128 / 118f); } From a137fa548080cf6c5ff5b6d79b427cf23a677d2b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 21 Feb 2024 15:43:53 +0800 Subject: [PATCH 129/508] Fix classic skin follow circles animating from incorrect starting point --- osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyFollowCircle.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyFollowCircle.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyFollowCircle.cs index fa2bb9b2ad..4a8b737206 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyFollowCircle.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyFollowCircle.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy // Note that the scale adjust here is 2 instead of DrawableSliderBall.FOLLOW_AREA to match legacy behaviour. // This means the actual tracking area for gameplay purposes is larger than the sprite (but skins may be accounting for this). - this.ScaleTo(0.5f).ScaleTo(2f, Math.Min(180f, remainingTime), Easing.Out) + this.ScaleTo(1f).ScaleTo(2f, Math.Min(180f, remainingTime), Easing.Out) .FadeTo(0).FadeTo(1f, Math.Min(60f, remainingTime)); } From 259be976e870db1fcc6f64f1382a23be02919ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 21 Feb 2024 11:42:34 +0100 Subject: [PATCH 130/508] Adjust test to fail --- .../SongSelect/TestSceneBeatmapCarousel.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index aa4c879468..de2ae3708f 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -629,7 +629,8 @@ namespace osu.Game.Tests.Visual.SongSelect { var sets = new List(); - const string zzz_string = "zzzzz"; + const string zzz_lowercase = "zzzzz"; + const string zzz_uppercase = "ZZZZZ"; AddStep("Populuate beatmap sets", () => { @@ -640,10 +641,16 @@ namespace osu.Game.Tests.Visual.SongSelect var set = TestResources.CreateTestBeatmapSetInfo(); if (i == 4) - set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_string); + set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_uppercase); + + if (i == 8) + set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_lowercase); + + if (i == 12) + set.Beatmaps.ForEach(b => b.Metadata.Author.Username = zzz_uppercase); if (i == 16) - set.Beatmaps.ForEach(b => b.Metadata.Author.Username = zzz_string); + set.Beatmaps.ForEach(b => b.Metadata.Author.Username = zzz_lowercase); sets.Add(set); } @@ -652,9 +659,11 @@ namespace osu.Game.Tests.Visual.SongSelect loadBeatmaps(sets); AddStep("Sort by author", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Author }, false)); - AddAssert($"Check {zzz_string} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Author.Username == zzz_string); + AddAssert($"Check {zzz_uppercase} is last", () => carousel.BeatmapSets.Last().Metadata.Author.Username == zzz_uppercase); + AddAssert($"Check {zzz_lowercase} is second last", () => carousel.BeatmapSets.SkipLast(1).Last().Metadata.Author.Username == zzz_lowercase); AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false)); - AddAssert($"Check {zzz_string} is at bottom", () => carousel.BeatmapSets.Last().Metadata.Artist == zzz_string); + AddAssert($"Check {zzz_uppercase} is last", () => carousel.BeatmapSets.Last().Metadata.Artist == zzz_uppercase); + AddAssert($"Check {zzz_lowercase} is second last", () => carousel.BeatmapSets.SkipLast(1).Last().Metadata.Artist == zzz_lowercase); } /// From 59235d6c50a796469bb29440745eec9e13d0e926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 21 Feb 2024 12:07:18 +0100 Subject: [PATCH 131/508] Implement custom comparer for expected carousel sort behaviour Co-authored-by: Salman Ahmed --- .../Utils/OrdinalSortByCaseStringComparer.cs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 osu.Game/Utils/OrdinalSortByCaseStringComparer.cs diff --git a/osu.Game/Utils/OrdinalSortByCaseStringComparer.cs b/osu.Game/Utils/OrdinalSortByCaseStringComparer.cs new file mode 100644 index 0000000000..99d73f644f --- /dev/null +++ b/osu.Game/Utils/OrdinalSortByCaseStringComparer.cs @@ -0,0 +1,49 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; + +namespace osu.Game.Utils +{ + /// + /// This string comparer is something of a cross-over between and . + /// is used first, but is used as a tie-breaker. + /// + /// + /// This comparer's behaviour somewhat emulates , + /// but non-ordinal comparers - both culture-aware and culture-invariant - have huge performance overheads due to i18n factors (up to 5x slower). + /// + /// + /// Given the following strings to sort: [A, B, C, D, a, b, c, d, A] and a stable sorting algorithm: + /// + /// + /// would return [A, A, B, C, D, a, b, c, d]. + /// This is undesirable as letters are interleaved. + /// + /// + /// would return [A, a, A, B, b, C, c, D, d]. + /// Different letters are not interleaved, but because case is ignored, the As are left in arbitrary order. + /// + /// + /// + /// would return [a, A, A, b, B, c, C, d, D], which is the expected behaviour. + /// + /// + public class OrdinalSortByCaseStringComparer : IComparer + { + public static readonly OrdinalSortByCaseStringComparer INSTANCE = new OrdinalSortByCaseStringComparer(); + + private OrdinalSortByCaseStringComparer() + { + } + + public int Compare(string? a, string? b) + { + int result = StringComparer.OrdinalIgnoreCase.Compare(a, b); + if (result == 0) + result = -StringComparer.Ordinal.Compare(a, b); // negative to place lowercase letters before uppercase. + return result; + } + } +} From 04a2ac3df332fda91ae41c2ee9bc5e1300a60d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 21 Feb 2024 12:07:28 +0100 Subject: [PATCH 132/508] Add benchmarking for custom string comparer --- .../BenchmarkStringComparison.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 osu.Game.Benchmarks/BenchmarkStringComparison.cs diff --git a/osu.Game.Benchmarks/BenchmarkStringComparison.cs b/osu.Game.Benchmarks/BenchmarkStringComparison.cs new file mode 100644 index 0000000000..78e4130abe --- /dev/null +++ b/osu.Game.Benchmarks/BenchmarkStringComparison.cs @@ -0,0 +1,48 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using BenchmarkDotNet.Attributes; +using osu.Game.Utils; + +namespace osu.Game.Benchmarks +{ + public class BenchmarkStringComparison + { + private string[] strings = null!; + + [GlobalSetup] + public void GlobalSetUp() + { + strings = new string[10000]; + + for (int i = 0; i < strings.Length; ++i) + strings[i] = Guid.NewGuid().ToString(); + + for (int i = 0; i < strings.Length; ++i) + { + if (i % 2 == 0) + strings[i] = strings[i].ToUpperInvariant(); + } + } + + [Benchmark] + public void OrdinalIgnoreCase() => compare(StringComparer.OrdinalIgnoreCase); + + [Benchmark] + public void OrdinalSortByCase() => compare(OrdinalSortByCaseStringComparer.INSTANCE); + + [Benchmark] + public void InvariantCulture() => compare(StringComparer.InvariantCulture); + + private void compare(IComparer comparer) + { + for (int i = 0; i < strings.Length; ++i) + { + for (int j = i + 1; j < strings.Length; ++j) + _ = comparer.Compare(strings[i], strings[j]); + } + } + } +} From 929858226ad208e29746f1b22b80399623f07d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 21 Feb 2024 12:09:37 +0100 Subject: [PATCH 133/508] Use custom comparer in beatmap carousel for expected sort behaviour --- osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs index 6c41bc3805..bf0d7dcbde 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs @@ -7,6 +7,7 @@ using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Beatmaps; using osu.Game.Screens.Select.Filter; +using osu.Game.Utils; namespace osu.Game.Screens.Select.Carousel { @@ -67,19 +68,19 @@ namespace osu.Game.Screens.Select.Carousel { default: case SortMode.Artist: - comparison = string.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist, StringComparison.Ordinal); + comparison = OrdinalSortByCaseStringComparer.INSTANCE.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist); break; case SortMode.Title: - comparison = string.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title, StringComparison.Ordinal); + comparison = OrdinalSortByCaseStringComparer.INSTANCE.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title); break; case SortMode.Author: - comparison = string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.Ordinal); + comparison = OrdinalSortByCaseStringComparer.INSTANCE.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username); break; case SortMode.Source: - comparison = string.Compare(BeatmapSet.Metadata.Source, otherSet.BeatmapSet.Metadata.Source, StringComparison.Ordinal); + comparison = OrdinalSortByCaseStringComparer.INSTANCE.Compare(BeatmapSet.Metadata.Source, otherSet.BeatmapSet.Metadata.Source); break; case SortMode.DateAdded: From fb593470d553c68b77e7ec129c47cfd9a21097d0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 21 Feb 2024 21:02:20 +0800 Subject: [PATCH 134/508] Use `DEFAULT` instead of `INSTANCE` or static field Matches other similar comparers. --- osu.Game.Benchmarks/BenchmarkStringComparison.cs | 2 +- osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs | 8 ++++---- osu.Game/Utils/OrdinalSortByCaseStringComparer.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game.Benchmarks/BenchmarkStringComparison.cs b/osu.Game.Benchmarks/BenchmarkStringComparison.cs index 78e4130abe..d40b92db5f 100644 --- a/osu.Game.Benchmarks/BenchmarkStringComparison.cs +++ b/osu.Game.Benchmarks/BenchmarkStringComparison.cs @@ -31,7 +31,7 @@ namespace osu.Game.Benchmarks public void OrdinalIgnoreCase() => compare(StringComparer.OrdinalIgnoreCase); [Benchmark] - public void OrdinalSortByCase() => compare(OrdinalSortByCaseStringComparer.INSTANCE); + public void OrdinalSortByCase() => compare(OrdinalSortByCaseStringComparer.DEFAULT); [Benchmark] public void InvariantCulture() => compare(StringComparer.InvariantCulture); diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs index bf0d7dcbde..43c9c621e8 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs @@ -68,19 +68,19 @@ namespace osu.Game.Screens.Select.Carousel { default: case SortMode.Artist: - comparison = OrdinalSortByCaseStringComparer.INSTANCE.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist); + comparison = OrdinalSortByCaseStringComparer.DEFAULT.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist); break; case SortMode.Title: - comparison = OrdinalSortByCaseStringComparer.INSTANCE.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title); + comparison = OrdinalSortByCaseStringComparer.DEFAULT.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title); break; case SortMode.Author: - comparison = OrdinalSortByCaseStringComparer.INSTANCE.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username); + comparison = OrdinalSortByCaseStringComparer.DEFAULT.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username); break; case SortMode.Source: - comparison = OrdinalSortByCaseStringComparer.INSTANCE.Compare(BeatmapSet.Metadata.Source, otherSet.BeatmapSet.Metadata.Source); + comparison = OrdinalSortByCaseStringComparer.DEFAULT.Compare(BeatmapSet.Metadata.Source, otherSet.BeatmapSet.Metadata.Source); break; case SortMode.DateAdded: diff --git a/osu.Game/Utils/OrdinalSortByCaseStringComparer.cs b/osu.Game/Utils/OrdinalSortByCaseStringComparer.cs index 99d73f644f..6c1532eef5 100644 --- a/osu.Game/Utils/OrdinalSortByCaseStringComparer.cs +++ b/osu.Game/Utils/OrdinalSortByCaseStringComparer.cs @@ -32,7 +32,7 @@ namespace osu.Game.Utils /// public class OrdinalSortByCaseStringComparer : IComparer { - public static readonly OrdinalSortByCaseStringComparer INSTANCE = new OrdinalSortByCaseStringComparer(); + public static readonly OrdinalSortByCaseStringComparer DEFAULT = new OrdinalSortByCaseStringComparer(); private OrdinalSortByCaseStringComparer() { From 6d32cfb7ee7c466a6a8b673ea6b9cac3c66d6ffd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 21 Feb 2024 21:39:33 +0800 Subject: [PATCH 135/508] Update framework --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 85171cc0fa..30037c868c 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -10,7 +10,7 @@ true - + diff --git a/osu.iOS.props b/osu.iOS.props index f23debd38f..463a726856 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -23,6 +23,6 @@ iossimulator-x64 - + From 805f0b6a296aa2507d97fdeec1f14fe78e8c8854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 21 Feb 2024 14:55:10 +0100 Subject: [PATCH 136/508] Remove unused using directive --- osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs index 25fe8170b1..5bf7c0326a 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Diagnostics; -using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; From 4cefa8bb8d256228266d204449610f443c6c37d6 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 21 Feb 2024 22:47:49 +0300 Subject: [PATCH 137/508] Reduce allocations in TimelineBlueprintContainer --- .../Components/Timeline/TimelineBlueprintContainer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs index b60e04afc1..6ebd1961a2 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs @@ -116,6 +116,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline updateStacking(); } + private readonly Stack currentConcurrentObjects = new Stack(); + private void updateStacking() { // because only blueprints of objects which are alive (via pooling) are displayed in the timeline, it's feasible to do this every-update. @@ -125,10 +127,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline // after the stack gets this tall, we can presume there is space underneath to draw subsequent blueprints. const int stack_reset_count = 3; - Stack currentConcurrentObjects = new Stack(); + currentConcurrentObjects.Clear(); - foreach (var b in SelectionBlueprints.Reverse()) + for (int i = SelectionBlueprints.Count - 1; i >= 0; i--) { + var b = SelectionBlueprints[i]; + // remove objects from the stack as long as their end time is in the past. while (currentConcurrentObjects.TryPeek(out HitObject hitObject)) { From d01421b951bc308583caa0c687f0715ab55f34de Mon Sep 17 00:00:00 2001 From: Boudewijn Popkema Date: Wed, 21 Feb 2024 23:15:37 +0100 Subject: [PATCH 138/508] clear remembered username when checkbox is unticked --- osu.Game/Overlays/Login/LoginForm.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginForm.cs b/osu.Game/Overlays/Login/LoginForm.cs index 80dfca93d2..a77baa3186 100644 --- a/osu.Game/Overlays/Login/LoginForm.cs +++ b/osu.Game/Overlays/Login/LoginForm.cs @@ -13,11 +13,11 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Localisation; using osu.Game.Online.API; using osu.Game.Overlays.Settings; using osu.Game.Resources.Localisation.Web; using osuTK; -using osu.Game.Localisation; namespace osu.Game.Overlays.Login { @@ -26,6 +26,7 @@ namespace osu.Game.Overlays.Login private TextBox username = null!; private TextBox password = null!; private ShakeContainer shakeSignIn = null!; + private SettingsCheckbox rememberUsername = null!; [Resolved] private IAPIProvider api { get; set; } = null!; @@ -82,7 +83,7 @@ namespace osu.Game.Overlays.Login }, }, }, - new SettingsCheckbox + rememberUsername = new SettingsCheckbox { LabelText = LoginPanelStrings.RememberUsername, Current = config.GetBindable(OsuSetting.SaveUsername), @@ -130,6 +131,7 @@ namespace osu.Game.Overlays.Login forgottenPasswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"{api.WebsiteRootUrl}/home/password-reset"); password.OnCommit += (_, _) => performLogin(); + rememberUsername.SettingChanged += () => onRememberUsernameChanged(config); if (api.LastLoginError?.Message is string error) { @@ -146,6 +148,12 @@ namespace osu.Game.Overlays.Login shakeSignIn.Shake(); } + private void onRememberUsernameChanged(OsuConfigManager config) + { + if (rememberUsername.Current.Value == false) + config.SetValue(OsuSetting.Username, string.Empty); + } + protected override bool OnClick(ClickEvent e) => true; protected override void OnFocus(FocusEvent e) From 2831ff60e1a361874f0285f1db74be7fa621300a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 09:39:49 +0100 Subject: [PATCH 139/508] Add test coverage --- .../Visual/Menus/TestSceneLoginOverlay.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs index 5fc075ed99..e603f72bb8 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs @@ -8,11 +8,13 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Testing; +using osu.Game.Configuration; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Overlays; using osu.Game.Overlays.Login; +using osu.Game.Overlays.Settings; using osu.Game.Users.Drawables; using osuTK.Input; @@ -25,6 +27,9 @@ namespace osu.Game.Tests.Visual.Menus private LoginOverlay loginOverlay = null!; + [Resolved] + private OsuConfigManager configManager { get; set; } = null!; + [BackgroundDependencyLoader] private void load() { @@ -156,5 +161,36 @@ namespace osu.Game.Tests.Visual.Menus }); AddAssert("login overlay is hidden", () => loginOverlay.State.Value == Visibility.Hidden); } + + [Test] + public void TestUncheckingRememberUsernameClearsIt() + { + AddStep("logout", () => API.Logout()); + AddStep("set username", () => configManager.SetValue(OsuSetting.Username, "test_user")); + AddStep("set remember password", () => configManager.SetValue(OsuSetting.SavePassword, true)); + AddStep("uncheck remember username", () => + { + InputManager.MoveMouseTo(loginOverlay.ChildrenOfType().First()); + InputManager.Click(MouseButton.Left); + }); + AddAssert("remember username off", () => configManager.Get(OsuSetting.SaveUsername), () => Is.False); + AddAssert("remember password off", () => configManager.Get(OsuSetting.SavePassword), () => Is.False); + AddAssert("username cleared", () => configManager.Get(OsuSetting.Username), () => Is.Empty); + } + + [Test] + public void TestUncheckingRememberPasswordClearsToken() + { + AddStep("logout", () => API.Logout()); + AddStep("set token", () => configManager.SetValue(OsuSetting.Token, "test_token")); + AddStep("set remember password", () => configManager.SetValue(OsuSetting.SavePassword, true)); + AddStep("uncheck remember token", () => + { + InputManager.MoveMouseTo(loginOverlay.ChildrenOfType().Last()); + InputManager.Click(MouseButton.Left); + }); + AddAssert("remember password off", () => configManager.Get(OsuSetting.SavePassword), () => Is.False); + AddAssert("token cleared", () => configManager.Get(OsuSetting.Token), () => Is.Empty); + } } } From a1046f0a865641e5b7ffea225d3ad32b45ae4177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 09:40:27 +0100 Subject: [PATCH 140/508] Revert "clear remembered username when checkbox is unticked" This reverts commit d01421b951bc308583caa0c687f0715ab55f34de. --- osu.Game/Overlays/Login/LoginForm.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginForm.cs b/osu.Game/Overlays/Login/LoginForm.cs index a77baa3186..80dfca93d2 100644 --- a/osu.Game/Overlays/Login/LoginForm.cs +++ b/osu.Game/Overlays/Login/LoginForm.cs @@ -13,11 +13,11 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Localisation; using osu.Game.Online.API; using osu.Game.Overlays.Settings; using osu.Game.Resources.Localisation.Web; using osuTK; +using osu.Game.Localisation; namespace osu.Game.Overlays.Login { @@ -26,7 +26,6 @@ namespace osu.Game.Overlays.Login private TextBox username = null!; private TextBox password = null!; private ShakeContainer shakeSignIn = null!; - private SettingsCheckbox rememberUsername = null!; [Resolved] private IAPIProvider api { get; set; } = null!; @@ -83,7 +82,7 @@ namespace osu.Game.Overlays.Login }, }, }, - rememberUsername = new SettingsCheckbox + new SettingsCheckbox { LabelText = LoginPanelStrings.RememberUsername, Current = config.GetBindable(OsuSetting.SaveUsername), @@ -131,7 +130,6 @@ namespace osu.Game.Overlays.Login forgottenPasswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"{api.WebsiteRootUrl}/home/password-reset"); password.OnCommit += (_, _) => performLogin(); - rememberUsername.SettingChanged += () => onRememberUsernameChanged(config); if (api.LastLoginError?.Message is string error) { @@ -148,12 +146,6 @@ namespace osu.Game.Overlays.Login shakeSignIn.Shake(); } - private void onRememberUsernameChanged(OsuConfigManager config) - { - if (rememberUsername.Current.Value == false) - config.SetValue(OsuSetting.Username, string.Empty); - } - protected override bool OnClick(ClickEvent e) => true; protected override void OnFocus(FocusEvent e) From 01f6ab0336a630a588b0938576660a02150bdeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 09:44:59 +0100 Subject: [PATCH 141/508] Use more correct implementation --- osu.Game/Configuration/OsuConfigManager.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 6b2cb4ee74..a71460ded7 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -77,12 +77,19 @@ namespace osu.Game.Configuration SetDefault(OsuSetting.SavePassword, false).ValueChanged += enabled => { - if (enabled.NewValue) SetValue(OsuSetting.SaveUsername, true); + if (enabled.NewValue) + SetValue(OsuSetting.SaveUsername, true); + else + GetBindable(OsuSetting.Token).SetDefault(); }; SetDefault(OsuSetting.SaveUsername, true).ValueChanged += enabled => { - if (!enabled.NewValue) SetValue(OsuSetting.SavePassword, false); + if (!enabled.NewValue) + { + GetBindable(OsuSetting.Username).SetDefault(); + SetValue(OsuSetting.SavePassword, false); + } }; SetDefault(OsuSetting.ExternalLinkWarning, true); From 81a9908c60012bde9ee9135c254ab2b891be5ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 10:27:37 +0100 Subject: [PATCH 142/508] Extract common helper for BPM rounding --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 4 ++-- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 7 ++++--- osu.Game/Utils/FormatUtils.cs | 10 ++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 1db02b7cf2..2f0b39bfbd 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -20,6 +19,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; +using osu.Game.Utils; using osuTK; namespace osu.Game.Overlays.Mods @@ -169,7 +169,7 @@ namespace osu.Game.Overlays.Mods foreach (var mod in mods.Value.OfType()) rate = mod.ApplyToRate(0, rate); - bpmDisplay.Current.Value = (int)Math.Round(Math.Round(BeatmapInfo.Value.BPM) * rate); + bpmDisplay.Current.Value = FormatUtils.RoundBPM(BeatmapInfo.Value.BPM, rate); BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty); diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index c69cd6ead6..3cab4b67b6 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -31,6 +31,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using osu.Game.Graphics.Containers; using osu.Game.Resources.Localisation.Web; +using osu.Game.Utils; namespace osu.Game.Screens.Select { @@ -405,9 +406,9 @@ namespace osu.Game.Screens.Select foreach (var mod in mods.Value.OfType()) rate = mod.ApplyToRate(0, rate); - int bpmMax = (int)Math.Round(Math.Round(beatmap.ControlPointInfo.BPMMaximum) * rate); - int bpmMin = (int)Math.Round(Math.Round(beatmap.ControlPointInfo.BPMMinimum) * rate); - int mostCommonBPM = (int)Math.Round(Math.Round(60000 / beatmap.GetMostCommonBeatLength()) * rate); + int bpmMax = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMaximum, rate); + int bpmMin = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMinimum, rate); + int mostCommonBPM = FormatUtils.RoundBPM(60000 / beatmap.GetMostCommonBeatLength(), rate); string labelText = bpmMin == bpmMax ? $"{bpmMin}" diff --git a/osu.Game/Utils/FormatUtils.cs b/osu.Game/Utils/FormatUtils.cs index 799dc75ca9..cccad3711c 100644 --- a/osu.Game/Utils/FormatUtils.cs +++ b/osu.Game/Utils/FormatUtils.cs @@ -49,5 +49,15 @@ namespace osu.Game.Utils return precision; } + + /// + /// Applies rounding to the given BPM value. + /// + /// + /// Double-rounding is applied intentionally (see https://github.com/ppy/osu/pull/18345#issue-1243311382 for rationale). + /// + /// The base BPM to round. + /// Rate adjustment, if applicable. + public static int RoundBPM(double baseBpm, double rate = 1) => (int)Math.Round(Math.Round(baseBpm) * rate); } } From 84fdcd24ef17194422a3aab9f3d6653955cda3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 10:56:50 +0100 Subject: [PATCH 143/508] Remove description from mod search terms Closes https://github.com/ppy/osu/issues/27111. --- osu.Game/Overlays/Mods/ModPanel.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModPanel.cs b/osu.Game/Overlays/Mods/ModPanel.cs index 2d8d01d8c8..cf173b0d6a 100644 --- a/osu.Game/Overlays/Mods/ModPanel.cs +++ b/osu.Game/Overlays/Mods/ModPanel.cs @@ -77,12 +77,11 @@ namespace osu.Game.Overlays.Mods /// public bool Visible => modState.Visible; - public override IEnumerable FilterTerms => new[] + public override IEnumerable FilterTerms => new LocalisableString[] { Mod.Name, Mod.Name.Replace(" ", string.Empty), Mod.Acronym, - Mod.Description }; public override bool MatchingFilter From b08fcbd4e953af0051bf9560eba57006763ded43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 10:56:13 +0100 Subject: [PATCH 144/508] Adjust tests to new behaviour --- .../Visual/UserInterface/TestSceneModSelectOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index 99a5897dff..b26e126249 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -788,7 +788,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddAssert("all columns visible", () => this.ChildrenOfType().All(col => col.IsPresent)); AddStep("set search", () => modSelectOverlay.SearchTerm = "HD"); - AddAssert("one column visible", () => this.ChildrenOfType().Count(col => col.IsPresent) == 1); + AddAssert("two columns visible", () => this.ChildrenOfType().Count(col => col.IsPresent) == 2); AddStep("filter out everything", () => modSelectOverlay.SearchTerm = "Some long search term with no matches"); AddAssert("no columns visible", () => this.ChildrenOfType().All(col => !col.IsPresent)); @@ -812,7 +812,7 @@ namespace osu.Game.Tests.Visual.UserInterface AddAssert("all columns visible", () => this.ChildrenOfType().All(col => col.IsPresent)); AddStep("set search", () => modSelectOverlay.SearchTerm = "fail"); - AddAssert("one column visible", () => this.ChildrenOfType().Count(col => col.IsPresent) == 2); + AddAssert("one column visible", () => this.ChildrenOfType().Count(col => col.IsPresent) == 1); AddStep("hide", () => modSelectOverlay.Hide()); AddStep("show", () => modSelectOverlay.Show()); From 47db317df84862a68947c20e71dcfe87c552830f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 11:45:57 +0100 Subject: [PATCH 145/508] Enable NRT in `TestSceneDifficultyIcon` --- osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs index 80320c138b..e544177d50 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -16,7 +14,7 @@ namespace osu.Game.Tests.Visual.Beatmaps { public partial class TestSceneDifficultyIcon : OsuTestScene { - private FillFlowContainer fill; + private FillFlowContainer fill = null!; protected override void LoadComplete() { @@ -35,7 +33,7 @@ namespace osu.Game.Tests.Visual.Beatmaps [Test] public void CreateDifficultyIcon() { - DifficultyIcon difficultyIcon = null; + DifficultyIcon difficultyIcon = null!; AddRepeatStep("create difficulty icon", () => { From d06c67ad8f921b02990b954256c95c22c5e70f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 11:57:40 +0100 Subject: [PATCH 146/508] Substitute two jank interdependent bool flags for single tri-state enums --- .../Beatmaps/TestSceneDifficultyIcon.cs | 12 ++------ osu.Game/Beatmaps/Drawables/DifficultyIcon.cs | 29 ++++++++++++++----- .../Drawables/DifficultyIconTooltip.cs | 11 ++++--- osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs | 2 +- .../OnlinePlay/DrawableRoomPlaylistItem.cs | 2 +- .../Carousel/DrawableCarouselBeatmap.cs | 2 +- 6 files changed, 34 insertions(+), 24 deletions(-) diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs index e544177d50..6a226c2b8c 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs @@ -50,18 +50,12 @@ namespace osu.Game.Tests.Visual.Beatmaps fill.Add(difficultyIcon = new DifficultyIcon(beatmapInfo, rulesetInfo) { Scale = new Vector2(2), - ShowTooltip = true, - ShowExtendedTooltip = true }); }, 10); - AddStep("hide extended tooltip", () => difficultyIcon.ShowExtendedTooltip = false); - - AddStep("hide tooltip", () => difficultyIcon.ShowTooltip = false); - - AddStep("show tooltip", () => difficultyIcon.ShowTooltip = true); - - AddStep("show extended tooltip", () => difficultyIcon.ShowExtendedTooltip = true); + AddStep("no tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.None); + AddStep("basic tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.StarRating); + AddStep("extended tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.Extended); } } } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 73073a8286..2e7f894d12 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -32,14 +32,9 @@ namespace osu.Game.Beatmaps.Drawables } /// - /// Whether to display a tooltip on hover. Only works if a beatmap was provided at construction time. + /// Which type of tooltip to show. Only works if a beatmap was provided at construction time. /// - public bool ShowTooltip { get; set; } = true; - - /// - /// Whether to include the difficulty stats in the tooltip or not. Defaults to false. Has no effect if is false. - /// - public bool ShowExtendedTooltip { get; set; } + public DifficultyIconTooltipType TooltipType { get; set; } = DifficultyIconTooltipType.StarRating; private readonly IBeatmapInfo? beatmap; @@ -138,6 +133,24 @@ namespace osu.Game.Beatmaps.Drawables GetCustomTooltip() => new DifficultyIconTooltip(); DifficultyIconTooltipContent IHasCustomTooltip. - TooltipContent => (ShowTooltip && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, ShowExtendedTooltip) : null)!; + TooltipContent => (TooltipType != DifficultyIconTooltipType.None && beatmap != null ? new DifficultyIconTooltipContent(beatmap, Current, ruleset, mods, TooltipType) : null)!; + } + + public enum DifficultyIconTooltipType + { + /// + /// No tooltip. + /// + None, + + /// + /// Star rating only. + /// + StarRating, + + /// + /// Star rating, OD, HP, CS, AR, length, BPM, and max combo. + /// + Extended, } } diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index 71366de654..952f71332f 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -113,7 +113,7 @@ namespace osu.Game.Beatmaps.Drawables starRating.Current.BindTarget = displayedContent.Difficulty; difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; - if (!displayedContent.ShowExtendedTooltip) + if (displayedContent.TooltipType == DifficultyIconTooltipType.StarRating) { difficultyFillFlowContainer.Hide(); miscFillFlowContainer.Hide(); @@ -166,15 +166,18 @@ namespace osu.Game.Beatmaps.Drawables public readonly IBindable Difficulty; public readonly IRulesetInfo Ruleset; public readonly Mod[]? Mods; - public readonly bool ShowExtendedTooltip; + public readonly DifficultyIconTooltipType TooltipType; - public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[]? mods, bool showExtendedTooltip = false) + public DifficultyIconTooltipContent(IBeatmapInfo beatmapInfo, IBindable difficulty, IRulesetInfo rulesetInfo, Mod[]? mods, DifficultyIconTooltipType tooltipType) { + if (tooltipType == DifficultyIconTooltipType.None) + throw new ArgumentOutOfRangeException(nameof(tooltipType), tooltipType, "Cannot instantiate a tooltip without a type"); + BeatmapInfo = beatmapInfo; Difficulty = difficulty; Ruleset = rulesetInfo; Mods = mods; - ShowExtendedTooltip = showExtendedTooltip; + TooltipType = tooltipType; } } } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs index 1f38e2ed6c..5f021803b0 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapPicker.cs @@ -297,7 +297,7 @@ namespace osu.Game.Overlays.BeatmapSet }, icon = new DifficultyIcon(beatmapInfo, ruleset) { - ShowTooltip = false, + TooltipType = DifficultyIconTooltipType.None, Current = { Value = new StarDifficulty(beatmapInfo.StarRating, 0) }, Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs index 44e91c6975..1b8e2d8be6 100644 --- a/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs +++ b/osu.Game/Screens/OnlinePlay/DrawableRoomPlaylistItem.cs @@ -285,7 +285,7 @@ namespace osu.Game.Screens.OnlinePlay difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods) { Size = new Vector2(icon_height), - ShowExtendedTooltip = true + TooltipType = DifficultyIconTooltipType.Extended, }; } else diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs index baf0a14062..01e58d4ab2 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs @@ -122,7 +122,7 @@ namespace osu.Game.Screens.Select.Carousel { difficultyIcon = new DifficultyIcon(beatmapInfo) { - ShowTooltip = false, + TooltipType = DifficultyIconTooltipType.None, Scale = new Vector2(1.8f), }, new FillFlowContainer From 37400643605426647eb80097401002828ff0d7ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 11:59:55 +0100 Subject: [PATCH 147/508] Fix test scene not properly setting tooltip type on all icons --- .../Visual/Beatmaps/TestSceneDifficultyIcon.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs index 6a226c2b8c..fb6bebe50d 100644 --- a/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs +++ b/osu.Game.Tests/Visual/Beatmaps/TestSceneDifficultyIcon.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Utils; @@ -14,13 +15,13 @@ namespace osu.Game.Tests.Visual.Beatmaps { public partial class TestSceneDifficultyIcon : OsuTestScene { - private FillFlowContainer fill = null!; + private FillFlowContainer fill = null!; protected override void LoadComplete() { base.LoadComplete(); - Child = fill = new FillFlowContainer + Child = fill = new FillFlowContainer { AutoSizeAxes = Axes.Y, Width = 300, @@ -33,8 +34,6 @@ namespace osu.Game.Tests.Visual.Beatmaps [Test] public void CreateDifficultyIcon() { - DifficultyIcon difficultyIcon = null!; - AddRepeatStep("create difficulty icon", () => { var rulesetInfo = new OsuRuleset().RulesetInfo; @@ -47,15 +46,15 @@ namespace osu.Game.Tests.Visual.Beatmaps beatmapInfo.StarRating = RNG.NextSingle(0, 10); beatmapInfo.BPM = RNG.Next(60, 300); - fill.Add(difficultyIcon = new DifficultyIcon(beatmapInfo, rulesetInfo) + fill.Add(new DifficultyIcon(beatmapInfo, rulesetInfo) { Scale = new Vector2(2), }); }, 10); - AddStep("no tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.None); - AddStep("basic tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.StarRating); - AddStep("extended tooltip", () => difficultyIcon.TooltipType = DifficultyIconTooltipType.Extended); + AddStep("no tooltip", () => fill.ForEach(icon => icon.TooltipType = DifficultyIconTooltipType.None)); + AddStep("basic tooltip", () => fill.ForEach(icon => icon.TooltipType = DifficultyIconTooltipType.StarRating)); + AddStep("extended tooltip", () => fill.ForEach(icon => icon.TooltipType = DifficultyIconTooltipType.Extended)); } } } From 7861125e7ac1dcd48c06f5ab005870b5c111c31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 12:11:49 +0100 Subject: [PATCH 148/508] Swap AR and OD on tooltips Matches everything else. --- osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index 952f71332f..1f3dcfee8c 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -78,8 +78,8 @@ namespace osu.Game.Beatmaps.Drawables { circleSize = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, drainRate = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, + overallDifficulty = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, approachRate = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) }, - overallDifficulty = new OsuSpriteText { Font = OsuFont.GetFont(size: 14) } } }, miscFillFlowContainer = new FillFlowContainer From bbf3f6b56ca29f367b40fb5cc5414aab349820c2 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 22 Feb 2024 16:31:13 +0300 Subject: [PATCH 149/508] Fix old-style legacy spinner fade in not matching stable --- .../Skinning/Legacy/LegacyOldStyleSpinner.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyOldStyleSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyOldStyleSpinner.cs index c57487cf75..c75983f3d2 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyOldStyleSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyOldStyleSpinner.cs @@ -92,8 +92,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimePreempt)) this.FadeOut(); - using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimeFadeIn / 2)) - this.FadeInFromZero(spinner.TimeFadeIn / 2); + using (BeginAbsoluteSequence(spinner.StartTime - spinner.TimeFadeIn)) + this.FadeInFromZero(spinner.TimeFadeIn); } protected override void Update() From 99bbbf810bfcdbe2d1ee8fea5cecbc86e46ce667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 16:58:21 +0100 Subject: [PATCH 150/508] Update github actions to resolve most node deprecation warnings As is github tradition, workflows started yelling about running on a node version that was getting sunset, so here we go again. Relevant bumps: - https://github.com/actions/checkout/releases/tag/v4.0.0 - https://github.com/actions/setup-dotnet/releases/tag/v4.0.0 - https://github.com/actions/cache/releases/tag/v4.0.0 - https://github.com/actions/setup-java/releases/tag/v4.0.0 - https://github.com/peter-evans/create-pull-request/releases/tag/v6.0.0 - https://github.com/dorny/test-reporter/releases/tag/v1.8.0 Notably, `actions/upload-artifact` is _not_ bumped to v4, although it should be to resolve the node deprecation warnings, because it has more breaking changes and bumping would break `dorny/test-reporter` (see https://github.com/dorny/test-reporter/issues/363). --- .github/workflows/ci.yml | 20 +++++++++---------- .github/workflows/diffcalc.yml | 2 +- .github/workflows/report-nunit.yml | 2 +- .github/workflows/sentry-release.yml | 2 +- .../workflows/update-web-mod-definitions.yml | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de902df93f..1ea4654563 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install .NET 8.0.x - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: "8.0.x" @@ -27,7 +27,7 @@ jobs: run: dotnet restore osu.Desktop.slnf - name: Restore inspectcode cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ github.workspace }}/inspectcode key: inspectcode-${{ hashFiles('.config/dotnet-tools.json', '.github/workflows/ci.yml', 'osu.sln*', 'osu*.slnf', '.editorconfig', '.globalconfig', 'CodeAnalysis/*', '**/*.csproj', '**/*.props') }} @@ -70,10 +70,10 @@ jobs: timeout-minutes: 60 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install .NET 8.0.x - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: "8.0.x" @@ -99,16 +99,16 @@ jobs: timeout-minutes: 60 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup JDK 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: microsoft java-version: 11 - name: Install .NET 8.0.x - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: "8.0.x" @@ -126,10 +126,10 @@ jobs: timeout-minutes: 60 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install .NET 8.0.x - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: "8.0.x" diff --git a/.github/workflows/diffcalc.yml b/.github/workflows/diffcalc.yml index 5f16e09040..7a2dcecb9c 100644 --- a/.github/workflows/diffcalc.yml +++ b/.github/workflows/diffcalc.yml @@ -140,7 +140,7 @@ jobs: GOOGLE_CREDS_FILE: ${{ steps.set-outputs.outputs.GOOGLE_CREDS_FILE }} steps: - name: Checkout diffcalc-sheet-generator - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: ${{ env.EXECUTION_ID }} repository: 'smoogipoo/diffcalc-sheet-generator' diff --git a/.github/workflows/report-nunit.yml b/.github/workflows/report-nunit.yml index 99e39f6f56..c44f46d70a 100644 --- a/.github/workflows/report-nunit.yml +++ b/.github/workflows/report-nunit.yml @@ -28,7 +28,7 @@ jobs: timeout-minutes: 5 steps: - name: Annotate CI run with test results - uses: dorny/test-reporter@v1.6.0 + uses: dorny/test-reporter@v1.8.0 with: artifact: osu-test-results-${{matrix.os.prettyname}}-${{matrix.threadingMode}} name: Test Results (${{matrix.os.prettyname}}, ${{matrix.threadingMode}}) diff --git a/.github/workflows/sentry-release.yml b/.github/workflows/sentry-release.yml index ff4165c414..be104d0fd3 100644 --- a/.github/workflows/sentry-release.yml +++ b/.github/workflows/sentry-release.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/update-web-mod-definitions.yml b/.github/workflows/update-web-mod-definitions.yml index 5827a6cdbf..b19f03ad7d 100644 --- a/.github/workflows/update-web-mod-definitions.yml +++ b/.github/workflows/update-web-mod-definitions.yml @@ -13,23 +13,23 @@ jobs: runs-on: ubuntu-latest steps: - name: Install .NET 8.0.x - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: "8.0.x" - name: Checkout ppy/osu - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: osu - name: Checkout ppy/osu-tools - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ppy/osu-tools path: osu-tools - name: Checkout ppy/osu-web - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: ppy/osu-web path: osu-web @@ -43,7 +43,7 @@ jobs: working-directory: ./osu-tools - name: Create pull request with changes - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: title: Update mod definitions body: "This PR has been auto-generated to update the mod definitions to match ppy/osu@${{ github.ref_name }}." From e1ceb8a5fa9abb9512c5e1639ae1132b64a9d272 Mon Sep 17 00:00:00 2001 From: SupDos <6813986+SupDos@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:54:28 +0100 Subject: [PATCH 151/508] Add missing .olz association to iOS --- osu.iOS/Info.plist | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/osu.iOS/Info.plist b/osu.iOS/Info.plist index cf51fe995b..1330e29bc1 100644 --- a/osu.iOS/Info.plist +++ b/osu.iOS/Info.plist @@ -102,6 +102,19 @@ osz + + UTTypeConformsTo + + sh.ppy.osu.items + + UTTypeIdentifier + sh.ppy.osu.olz + UTTypeTagSpecification + + public.filename-extension + olz + + CFBundleDocumentTypes From 0074bdc5a17be66df7dd656106973829e0909bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 19:15:02 +0100 Subject: [PATCH 152/508] Change `ResultsScreen` constructor boolean params to init-only properties --- .../Background/TestSceneUserDimBackgrounds.cs | 3 ++- .../TestScenePlaylistsResultsScreen.cs | 5 +++-- .../Visual/Ranking/TestSceneResultsScreen.cs | 6 ++++-- osu.Game/OsuGame.cs | 2 +- .../Multiplayer/MultiplayerResultsScreen.cs | 2 +- .../OnlinePlay/Playlists/PlaylistsPlayer.cs | 5 ++++- .../Playlists/PlaylistsResultsScreen.cs | 4 ++-- .../Playlists/PlaylistsRoomSubScreen.cs | 2 +- osu.Game/Screens/Play/Player.cs | 5 +++-- osu.Game/Screens/Play/ReplayPlayer.cs | 2 +- .../Screens/Play/SpectatorResultsScreen.cs | 2 +- osu.Game/Screens/Ranking/ResultsScreen.cs | 19 ++++++++++++------- osu.Game/Screens/Ranking/SoloResultsScreen.cs | 4 ++-- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 14 files changed, 38 insertions(+), 25 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index 566ccd6bd5..204dea39b2 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -349,8 +349,9 @@ namespace osu.Game.Tests.Visual.Background private partial class FadeAccessibleResults : ResultsScreen { public FadeAccessibleResults(ScoreInfo score) - : base(score, true) + : base(score) { + AllowRetry = true; } protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs index 25ee20b089..fca965052f 100644 --- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs +++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs @@ -420,9 +420,10 @@ namespace osu.Game.Tests.Visual.Playlists public new LoadingSpinner RightSpinner => base.RightSpinner; public new ScorePanelList ScorePanelList => base.ScorePanelList; - public TestResultsScreen([CanBeNull] ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true) - : base(score, roomId, playlistItem, allowRetry) + public TestResultsScreen([CanBeNull] ScoreInfo score, int roomId, PlaylistItem playlistItem) + : base(score, roomId, playlistItem) { + AllowRetry = true; } } } diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs index cf4bec54ff..ffc5dbc8fb 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs @@ -399,8 +399,9 @@ namespace osu.Game.Tests.Visual.Ranking public HotkeyRetryOverlay RetryOverlay; public TestResultsScreen(ScoreInfo score) - : base(score, true) + : base(score) { + AllowRetry = true; ShowUserStatistics = true; } @@ -470,8 +471,9 @@ namespace osu.Game.Tests.Visual.Ranking public HotkeyRetryOverlay RetryOverlay; public UnrankedSoloResultsScreen(ScoreInfo score) - : base(score, true) + : base(score) { + AllowRetry = true; Score!.BeatmapInfo!.OnlineID = 0; Score.BeatmapInfo.Status = BeatmapOnlineStatus.Pending; } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9ffa88947b..ec44076520 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -768,7 +768,7 @@ namespace osu.Game break; case ScorePresentType.Results: - screen.Push(new SoloResultsScreen(databasedScore.ScoreInfo, false)); + screen.Push(new SoloResultsScreen(databasedScore.ScoreInfo)); break; } }, validScreens: validScreens); diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerResultsScreen.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerResultsScreen.cs index f665ed2d41..6ed75508dc 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerResultsScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerResultsScreen.cs @@ -10,7 +10,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer public partial class MultiplayerResultsScreen : PlaylistsResultsScreen { public MultiplayerResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem) - : base(score, roomId, playlistItem, false) + : base(score, roomId, playlistItem) { } } diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs index b0e4585986..74454959a1 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs @@ -58,7 +58,10 @@ namespace osu.Game.Screens.OnlinePlay.Playlists protected override ResultsScreen CreateResults(ScoreInfo score) { Debug.Assert(Room.RoomID.Value != null); - return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, true); + return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem) + { + AllowRetry = true, + }; } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsResultsScreen.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsResultsScreen.cs index 6a1924dea2..add7aee8cd 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsResultsScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsResultsScreen.cs @@ -41,8 +41,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists [Resolved] private RulesetStore rulesets { get; set; } - public PlaylistsResultsScreen([CanBeNull] ScoreInfo score, long roomId, PlaylistItem playlistItem, bool allowRetry, bool allowWatchingReplay = true) - : base(score, allowRetry, allowWatchingReplay) + public PlaylistsResultsScreen([CanBeNull] ScoreInfo score, long roomId, PlaylistItem playlistItem) + : base(score) { this.roomId = roomId; this.playlistItem = playlistItem; diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs index 2460f78c96..3fb9de428a 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomSubScreen.cs @@ -114,7 +114,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists RequestResults = item => { Debug.Assert(RoomId.Value != null); - ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item, false)); + ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item)); } } }, diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 11ff5fdbef..8383936f7c 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -1224,9 +1224,10 @@ namespace osu.Game.Screens.Play /// /// The to be displayed in the results screen. /// The . - protected virtual ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, true) + protected virtual ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score) { - ShowUserStatistics = true + AllowRetry = true, + ShowUserStatistics = true, }; private void fadeOut(bool instant = false) diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index 3c5b85662a..ff60dbc0d0 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -92,7 +92,7 @@ namespace osu.Game.Screens.Play Scores = { BindTarget = LeaderboardScores } }; - protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false); + protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score); public bool OnPressed(KeyBindingPressEvent e) { diff --git a/osu.Game/Screens/Play/SpectatorResultsScreen.cs b/osu.Game/Screens/Play/SpectatorResultsScreen.cs index 393cbddb34..5ee2a5ce0e 100644 --- a/osu.Game/Screens/Play/SpectatorResultsScreen.cs +++ b/osu.Game/Screens/Play/SpectatorResultsScreen.cs @@ -13,7 +13,7 @@ namespace osu.Game.Screens.Play public partial class SpectatorResultsScreen : SoloResultsScreen { public SpectatorResultsScreen(ScoreInfo score) - : base(score, false) + : base(score) { } diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 69cfbed8f2..6beb4d7401 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -63,16 +63,21 @@ namespace osu.Game.Screens.Ranking private bool lastFetchCompleted; - private readonly bool allowRetry; - private readonly bool allowWatchingReplay; + /// + /// Whether the user can retry the beatmap from the results screen. + /// + public bool AllowRetry { get; init; } + + /// + /// Whether the user can watch the replay of the completed play from the results screen. + /// + public bool AllowWatchingReplay { get; init; } = true; private Sample popInSample; - protected ResultsScreen([CanBeNull] ScoreInfo score, bool allowRetry, bool allowWatchingReplay = true) + protected ResultsScreen([CanBeNull] ScoreInfo score) { Score = score; - this.allowRetry = allowRetry; - this.allowWatchingReplay = allowWatchingReplay; SelectedScore.Value = score; } @@ -162,7 +167,7 @@ namespace osu.Game.Screens.Ranking ScorePanelList.AddScore(Score, shouldFlair); } - if (allowWatchingReplay) + if (AllowWatchingReplay) { buttons.Add(new ReplayDownloadButton(SelectedScore.Value) { @@ -171,7 +176,7 @@ namespace osu.Game.Screens.Ranking }); } - if (player != null && allowRetry) + if (player != null && AllowRetry) { buttons.Add(new RetryButton { Width = 300 }); diff --git a/osu.Game/Screens/Ranking/SoloResultsScreen.cs b/osu.Game/Screens/Ranking/SoloResultsScreen.cs index 866440bbd6..38bc13ffb9 100644 --- a/osu.Game/Screens/Ranking/SoloResultsScreen.cs +++ b/osu.Game/Screens/Ranking/SoloResultsScreen.cs @@ -34,8 +34,8 @@ namespace osu.Game.Screens.Ranking private IBindable latestUpdate = null!; private readonly Bindable statisticsUpdate = new Bindable(); - public SoloResultsScreen(ScoreInfo score, bool allowRetry) - : base(score, allowRetry) + public SoloResultsScreen(ScoreInfo score) + : base(score) { } diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 7b7b8857f3..52f49ba56a 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Select } protected void PresentScore(ScoreInfo score) => - FinaliseSelection(score.BeatmapInfo, score.Ruleset, () => this.Push(new SoloResultsScreen(score, false))); + FinaliseSelection(score.BeatmapInfo, score.Ruleset, () => this.Push(new SoloResultsScreen(score))); protected override BeatmapDetailArea CreateBeatmapDetailArea() { From 1e53503608aa683a97e3f7f3ca1e9855929c9f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 19:49:14 +0100 Subject: [PATCH 153/508] Show user statistics after completing a playlists / multiplayer score --- .../Ranking/TestSceneStatisticsPanel.cs | 4 +- .../Multiplayer/MultiplayerPlayer.cs | 8 +++- .../OnlinePlay/Playlists/PlaylistsPlayer.cs | 1 + osu.Game/Screens/Ranking/ResultsScreen.cs | 16 ++++++- osu.Game/Screens/Ranking/SoloResultsScreen.cs | 43 ------------------- ...tisticsPanel.cs => UserStatisticsPanel.cs} | 26 +++++++++-- 6 files changed, 46 insertions(+), 52 deletions(-) rename osu.Game/Screens/Ranking/Statistics/{SoloStatisticsPanel.cs => UserStatisticsPanel.cs} (55%) diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs b/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs index d0a45856b2..c7bd52ce8e 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs @@ -82,12 +82,12 @@ namespace osu.Game.Tests.Visual.Ranking private void loadPanel(ScoreInfo score) => AddStep("load panel", () => { - Child = new SoloStatisticsPanel(score) + Child = new UserStatisticsPanel(score) { RelativeSizeAxes = Axes.Both, State = { Value = Visibility.Visible }, Score = { Value = score }, - StatisticsUpdate = + DisplayedUserStatisticsUpdate = { Value = new SoloStatisticsUpdate(score, new UserStatistics { diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs index c5c536eae6..e560c5ca5d 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs @@ -200,7 +200,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer return multiplayerLeaderboard.TeamScores.Count == 2 ? new MultiplayerTeamResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, multiplayerLeaderboard.TeamScores) - : new MultiplayerResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem); + { + ShowUserStatistics = true, + } + : new MultiplayerResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem) + { + ShowUserStatistics = true + }; } protected override void Dispose(bool isDisposing) diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs index 74454959a1..48f63731e1 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs @@ -61,6 +61,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem) { AllowRetry = true, + ShowUserStatistics = true, }; } diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 6beb4d7401..b63c753721 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -73,6 +73,13 @@ namespace osu.Game.Screens.Ranking /// public bool AllowWatchingReplay { get; init; } = true; + /// + /// Whether the user's personal statistics should be shown on the extended statistics panel + /// after clicking the score panel associated with the being presented. + /// Requires to be present. + /// + public bool ShowUserStatistics { get; init; } + private Sample popInSample; protected ResultsScreen([CanBeNull] ScoreInfo score) @@ -105,7 +112,7 @@ namespace osu.Game.Screens.Ranking RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - StatisticsPanel = CreateStatisticsPanel().With(panel => + StatisticsPanel = createStatisticsPanel().With(panel => { panel.RelativeSizeAxes = Axes.Both; panel.Score.BindTarget = SelectedScore; @@ -243,7 +250,12 @@ namespace osu.Game.Screens.Ranking /// /// Creates the to be used to display extended information about scores. /// - protected virtual StatisticsPanel CreateStatisticsPanel() => new StatisticsPanel(); + private StatisticsPanel createStatisticsPanel() + { + return ShowUserStatistics && Score != null + ? new UserStatisticsPanel(Score) + : new StatisticsPanel(); + } private void fetchScoresCallback(IEnumerable scores) => Schedule(() => { diff --git a/osu.Game/Screens/Ranking/SoloResultsScreen.cs b/osu.Game/Screens/Ranking/SoloResultsScreen.cs index 38bc13ffb9..ee0251b5ac 100644 --- a/osu.Game/Screens/Ranking/SoloResultsScreen.cs +++ b/osu.Game/Screens/Ranking/SoloResultsScreen.cs @@ -6,70 +6,27 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Extensions; using osu.Game.Online.API; using osu.Game.Online.API.Requests; -using osu.Game.Online.Solo; using osu.Game.Rulesets; using osu.Game.Scoring; -using osu.Game.Screens.Ranking.Statistics; namespace osu.Game.Screens.Ranking { public partial class SoloResultsScreen : ResultsScreen { - /// - /// Whether the user's personal statistics should be shown on the extended statistics panel - /// after clicking the score panel associated with the being presented. - /// - public bool ShowUserStatistics { get; init; } - private GetScoresRequest? getScoreRequest; [Resolved] private RulesetStore rulesets { get; set; } = null!; - private IBindable latestUpdate = null!; - private readonly Bindable statisticsUpdate = new Bindable(); - public SoloResultsScreen(ScoreInfo score) : base(score) { } - [BackgroundDependencyLoader] - private void load(SoloStatisticsWatcher? soloStatisticsWatcher) - { - if (ShowUserStatistics && soloStatisticsWatcher != null) - { - Debug.Assert(Score != null); - - latestUpdate = soloStatisticsWatcher.LatestUpdate.GetBoundCopy(); - latestUpdate.BindValueChanged(update => - { - if (update.NewValue?.Score.MatchesOnlineID(Score) == true) - statisticsUpdate.Value = update.NewValue; - }); - } - } - - protected override StatisticsPanel CreateStatisticsPanel() - { - Debug.Assert(Score != null); - - if (ShowUserStatistics) - { - return new SoloStatisticsPanel(Score) - { - StatisticsUpdate = { BindTarget = statisticsUpdate } - }; - } - - return base.CreateStatisticsPanel(); - } - protected override APIRequest? FetchScores(Action>? scoresCallback) { Debug.Assert(Score != null); diff --git a/osu.Game/Screens/Ranking/Statistics/SoloStatisticsPanel.cs b/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs similarity index 55% rename from osu.Game/Screens/Ranking/Statistics/SoloStatisticsPanel.cs rename to osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs index 762be61853..280e5ec90f 100644 --- a/osu.Game/Screens/Ranking/Statistics/SoloStatisticsPanel.cs +++ b/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs @@ -3,25 +3,43 @@ using System.Collections.Generic; using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Beatmaps; +using osu.Game.Extensions; using osu.Game.Online.Solo; using osu.Game.Scoring; using osu.Game.Screens.Ranking.Statistics.User; namespace osu.Game.Screens.Ranking.Statistics { - public partial class SoloStatisticsPanel : StatisticsPanel + public partial class UserStatisticsPanel : StatisticsPanel { private readonly ScoreInfo achievedScore; - public SoloStatisticsPanel(ScoreInfo achievedScore) + internal readonly Bindable DisplayedUserStatisticsUpdate = new Bindable(); + + private IBindable latestGlobalStatisticsUpdate = null!; + + public UserStatisticsPanel(ScoreInfo achievedScore) { this.achievedScore = achievedScore; } - public Bindable StatisticsUpdate { get; } = new Bindable(); + [BackgroundDependencyLoader] + private void load(SoloStatisticsWatcher? soloStatisticsWatcher) + { + if (soloStatisticsWatcher != null) + { + latestGlobalStatisticsUpdate = soloStatisticsWatcher.LatestUpdate.GetBoundCopy(); + latestGlobalStatisticsUpdate.BindValueChanged(update => + { + if (update.NewValue?.Score.MatchesOnlineID(achievedScore) == true) + DisplayedUserStatisticsUpdate.Value = update.NewValue; + }); + } + } protected override ICollection CreateStatisticItems(ScoreInfo newScore, IBeatmap playableBeatmap) { @@ -37,7 +55,7 @@ namespace osu.Game.Screens.Ranking.Statistics RelativeSizeAxes = Axes.X, Anchor = Anchor.Centre, Origin = Anchor.Centre, - StatisticsUpdate = { BindTarget = StatisticsUpdate } + StatisticsUpdate = { BindTarget = DisplayedUserStatisticsUpdate } })).ToArray(); } From eac4c5f69d6a201ced50c19fd826d8d618c9b7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 22 Feb 2024 19:50:46 +0100 Subject: [PATCH 154/508] Rename `{Solo -> User}StatisticsWatcher` et al. The "solo" prefix is a bit unbecoming now. The updates are not only for solo. --- .../Menus/TestSceneToolbarUserButton.cs | 10 +++++----- .../Online/TestSceneSoloStatisticsWatcher.cs | 20 +++++++++---------- .../Visual/Ranking/TestSceneOverallRanking.cs | 2 +- .../Ranking/TestSceneStatisticsPanel.cs | 2 +- ...sticsUpdate.cs => UserStatisticsUpdate.cs} | 6 +++--- ...icsWatcher.cs => UserStatisticsWatcher.cs} | 8 ++++---- osu.Game/OsuGame.cs | 2 +- .../TransientUserStatisticsUpdateDisplay.cs | 6 +++--- osu.Game/Screens/Play/SubmittingPlayer.cs | 4 ++-- .../Ranking/Statistics/User/OverallRanking.cs | 4 ++-- .../Statistics/User/RankingChangeRow.cs | 4 ++-- .../Ranking/Statistics/UserStatisticsPanel.cs | 6 +++--- 12 files changed, 37 insertions(+), 37 deletions(-) rename osu.Game/Online/Solo/{SoloStatisticsUpdate.cs => UserStatisticsUpdate.cs} (88%) rename osu.Game/Online/Solo/{SoloStatisticsWatcher.cs => UserStatisticsWatcher.cs} (93%) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs b/osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs index 69fedf4a3a..41ce739c2f 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs @@ -100,7 +100,7 @@ namespace osu.Game.Tests.Visual.Menus AddStep("Gain", () => { var transientUpdateDisplay = this.ChildrenOfType().Single(); - transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate( + transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate( new ScoreInfo(), new UserStatistics { @@ -116,7 +116,7 @@ namespace osu.Game.Tests.Visual.Menus AddStep("Loss", () => { var transientUpdateDisplay = this.ChildrenOfType().Single(); - transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate( + transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate( new ScoreInfo(), new UserStatistics { @@ -132,7 +132,7 @@ namespace osu.Game.Tests.Visual.Menus AddStep("No change", () => { var transientUpdateDisplay = this.ChildrenOfType().Single(); - transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate( + transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate( new ScoreInfo(), new UserStatistics { @@ -148,7 +148,7 @@ namespace osu.Game.Tests.Visual.Menus AddStep("Was null", () => { var transientUpdateDisplay = this.ChildrenOfType().Single(); - transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate( + transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate( new ScoreInfo(), new UserStatistics { @@ -164,7 +164,7 @@ namespace osu.Game.Tests.Visual.Menus AddStep("Became null", () => { var transientUpdateDisplay = this.ChildrenOfType().Single(); - transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate( + transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate( new ScoreInfo(), new UserStatistics { diff --git a/osu.Game.Tests/Visual/Online/TestSceneSoloStatisticsWatcher.cs b/osu.Game.Tests/Visual/Online/TestSceneSoloStatisticsWatcher.cs index 19121b7f58..733769b9f3 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneSoloStatisticsWatcher.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneSoloStatisticsWatcher.cs @@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.Online { protected override bool UseOnlineAPI => false; - private SoloStatisticsWatcher watcher = null!; + private UserStatisticsWatcher watcher = null!; [Resolved] private SpectatorClient spectatorClient { get; set; } = null!; @@ -107,7 +107,7 @@ namespace osu.Game.Tests.Visual.Online AddStep("create watcher", () => { - Child = watcher = new SoloStatisticsWatcher(); + Child = watcher = new UserStatisticsWatcher(); }); } @@ -123,7 +123,7 @@ namespace osu.Game.Tests.Visual.Online var ruleset = new OsuRuleset().RulesetInfo; - SoloStatisticsUpdate? update = null; + UserStatisticsUpdate? update = null; registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate); feignScoreProcessing(userId, ruleset, 5_000_000); @@ -146,7 +146,7 @@ namespace osu.Game.Tests.Visual.Online // note ordering - in this test processing completes *before* the registration is added. feignScoreProcessing(userId, ruleset, 5_000_000); - SoloStatisticsUpdate? update = null; + UserStatisticsUpdate? update = null; registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate); AddStep("signal score processed", () => ((ISpectatorClient)spectatorClient).UserScoreProcessed(userId, scoreId)); @@ -164,7 +164,7 @@ namespace osu.Game.Tests.Visual.Online long scoreId = getScoreId(); var ruleset = new OsuRuleset().RulesetInfo; - SoloStatisticsUpdate? update = null; + UserStatisticsUpdate? update = null; registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate); feignScoreProcessing(userId, ruleset, 5_000_000); @@ -191,7 +191,7 @@ namespace osu.Game.Tests.Visual.Online long scoreId = getScoreId(); var ruleset = new OsuRuleset().RulesetInfo; - SoloStatisticsUpdate? update = null; + UserStatisticsUpdate? update = null; registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate); feignScoreProcessing(userId, ruleset, 5_000_000); @@ -212,7 +212,7 @@ namespace osu.Game.Tests.Visual.Online long scoreId = getScoreId(); var ruleset = new OsuRuleset().RulesetInfo; - SoloStatisticsUpdate? update = null; + UserStatisticsUpdate? update = null; registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate); feignScoreProcessing(userId, ruleset, 5_000_000); @@ -241,7 +241,7 @@ namespace osu.Game.Tests.Visual.Online feignScoreProcessing(userId, ruleset, 6_000_000); - SoloStatisticsUpdate? update = null; + UserStatisticsUpdate? update = null; registerForUpdates(secondScoreId, ruleset, receivedUpdate => update = receivedUpdate); AddStep("signal score processed", () => ((ISpectatorClient)spectatorClient).UserScoreProcessed(userId, secondScoreId)); @@ -259,7 +259,7 @@ namespace osu.Game.Tests.Visual.Online var ruleset = new OsuRuleset().RulesetInfo; - SoloStatisticsUpdate? update = null; + UserStatisticsUpdate? update = null; registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate); feignScoreProcessing(userId, ruleset, 5_000_000); @@ -289,7 +289,7 @@ namespace osu.Game.Tests.Visual.Online }); } - private void registerForUpdates(long scoreId, RulesetInfo rulesetInfo, Action onUpdateReady) => + private void registerForUpdates(long scoreId, RulesetInfo rulesetInfo, Action onUpdateReady) => AddStep("register for updates", () => { watcher.RegisterForStatisticsUpdateAfter( diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs b/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs index 355a572f95..ee0ab0c880 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs @@ -112,6 +112,6 @@ namespace osu.Game.Tests.Visual.Ranking }); private void displayUpdate(UserStatistics before, UserStatistics after) => - AddStep("display update", () => overallRanking.StatisticsUpdate.Value = new SoloStatisticsUpdate(new ScoreInfo(), before, after)); + AddStep("display update", () => overallRanking.StatisticsUpdate.Value = new UserStatisticsUpdate(new ScoreInfo(), before, after)); } } diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs b/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs index c7bd52ce8e..ecb8073a88 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs @@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.Ranking Score = { Value = score }, DisplayedUserStatisticsUpdate = { - Value = new SoloStatisticsUpdate(score, new UserStatistics + Value = new UserStatisticsUpdate(score, new UserStatistics { Level = new UserStatistics.LevelInfo { diff --git a/osu.Game/Online/Solo/SoloStatisticsUpdate.cs b/osu.Game/Online/Solo/UserStatisticsUpdate.cs similarity index 88% rename from osu.Game/Online/Solo/SoloStatisticsUpdate.cs rename to osu.Game/Online/Solo/UserStatisticsUpdate.cs index cb9dac97c7..03f3abbb66 100644 --- a/osu.Game/Online/Solo/SoloStatisticsUpdate.cs +++ b/osu.Game/Online/Solo/UserStatisticsUpdate.cs @@ -9,7 +9,7 @@ namespace osu.Game.Online.Solo /// /// Contains data about the change in a user's profile statistics after completing a score. /// - public class SoloStatisticsUpdate + public class UserStatisticsUpdate { /// /// The score set by the user that triggered the update. @@ -27,12 +27,12 @@ namespace osu.Game.Online.Solo public UserStatistics After { get; } /// - /// Creates a new . + /// Creates a new . /// /// The score set by the user that triggered the update. /// The user's profile statistics prior to the score being set. /// The user's profile statistics after the score was set. - public SoloStatisticsUpdate(ScoreInfo score, UserStatistics before, UserStatistics after) + public UserStatisticsUpdate(ScoreInfo score, UserStatistics before, UserStatistics after) { Score = score; Before = before; diff --git a/osu.Game/Online/Solo/SoloStatisticsWatcher.cs b/osu.Game/Online/Solo/UserStatisticsWatcher.cs similarity index 93% rename from osu.Game/Online/Solo/SoloStatisticsWatcher.cs rename to osu.Game/Online/Solo/UserStatisticsWatcher.cs index 2072e8633f..2fff92fe0f 100644 --- a/osu.Game/Online/Solo/SoloStatisticsWatcher.cs +++ b/osu.Game/Online/Solo/UserStatisticsWatcher.cs @@ -20,10 +20,10 @@ namespace osu.Game.Online.Solo /// /// A persistent component that binds to the spectator server and API in order to deliver updates about the logged in user's gameplay statistics. /// - public partial class SoloStatisticsWatcher : Component + public partial class UserStatisticsWatcher : Component { - public IBindable LatestUpdate => latestUpdate; - private readonly Bindable latestUpdate = new Bindable(); + public IBindable LatestUpdate => latestUpdate; + private readonly Bindable latestUpdate = new Bindable(); [Resolved] private SpectatorClient spectatorClient { get; set; } = null!; @@ -120,7 +120,7 @@ namespace osu.Game.Online.Solo latestStatistics.TryGetValue(rulesetName, out UserStatistics? latestRulesetStatistics); latestRulesetStatistics ??= new UserStatistics(); - latestUpdate.Value = new SoloStatisticsUpdate(scoreInfo, latestRulesetStatistics, updatedStatistics); + latestUpdate.Value = new UserStatisticsUpdate(scoreInfo, latestRulesetStatistics, updatedStatistics); latestStatistics[rulesetName] = updatedStatistics; } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index ec44076520..419e31bacd 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1022,7 +1022,7 @@ namespace osu.Game ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both)); }); - loadComponentSingleFile(new SoloStatisticsWatcher(), Add, true); + loadComponentSingleFile(new UserStatisticsWatcher(), Add, true); loadComponentSingleFile(Toolbar = new Toolbar { OnHome = delegate diff --git a/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs b/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs index f56a1a3dd2..e7a78f8b80 100644 --- a/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs +++ b/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs @@ -21,13 +21,13 @@ namespace osu.Game.Overlays.Toolbar { public partial class TransientUserStatisticsUpdateDisplay : CompositeDrawable { - public Bindable LatestUpdate { get; } = new Bindable(); + public Bindable LatestUpdate { get; } = new Bindable(); private Statistic globalRank = null!; private Statistic pp = null!; [BackgroundDependencyLoader] - private void load(SoloStatisticsWatcher? soloStatisticsWatcher) + private void load(UserStatisticsWatcher? soloStatisticsWatcher) { RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; @@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Toolbar }; if (soloStatisticsWatcher != null) - ((IBindable)LatestUpdate).BindTo(soloStatisticsWatcher.LatestUpdate); + ((IBindable)LatestUpdate).BindTo(soloStatisticsWatcher.LatestUpdate); } protected override void LoadComplete() diff --git a/osu.Game/Screens/Play/SubmittingPlayer.cs b/osu.Game/Screens/Play/SubmittingPlayer.cs index ecb507f382..ee88171789 100644 --- a/osu.Game/Screens/Play/SubmittingPlayer.cs +++ b/osu.Game/Screens/Play/SubmittingPlayer.cs @@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play [Resolved(canBeNull: true)] [CanBeNull] - private SoloStatisticsWatcher soloStatisticsWatcher { get; set; } + private UserStatisticsWatcher userStatisticsWatcher { get; set; } private readonly object scoreSubmissionLock = new object(); private TaskCompletionSource scoreSubmissionSource; @@ -189,7 +189,7 @@ namespace osu.Game.Screens.Play await submitScore(score).ConfigureAwait(false); spectatorClient.EndPlaying(GameplayState); - soloStatisticsWatcher?.RegisterForStatisticsUpdateAfter(score.ScoreInfo); + userStatisticsWatcher?.RegisterForStatisticsUpdateAfter(score.ScoreInfo); } [Resolved] diff --git a/osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs b/osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs index d08a654e99..5c96a2b6c3 100644 --- a/osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs +++ b/osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs @@ -14,7 +14,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User { private const float transition_duration = 300; - public Bindable StatisticsUpdate { get; } = new Bindable(); + public Bindable StatisticsUpdate { get; } = new Bindable(); private LoadingLayer loadingLayer = null!; private GridContainer content = null!; @@ -86,7 +86,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User FinishTransforms(true); } - private void onUpdateReceived(ValueChangedEvent update) + private void onUpdateReceived(ValueChangedEvent update) { if (update.NewValue == null) { diff --git a/osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs b/osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs index 906bf8d5ca..a477f38cd1 100644 --- a/osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs +++ b/osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User { public abstract partial class RankingChangeRow : CompositeDrawable { - public Bindable StatisticsUpdate { get; } = new Bindable(); + public Bindable StatisticsUpdate { get; } = new Bindable(); private readonly Func accessor; @@ -113,7 +113,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User StatisticsUpdate.BindValueChanged(onStatisticsUpdate, true); } - private void onStatisticsUpdate(ValueChangedEvent statisticsUpdate) + private void onStatisticsUpdate(ValueChangedEvent statisticsUpdate) { var update = statisticsUpdate.NewValue; diff --git a/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs b/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs index 280e5ec90f..7f8c12ddab 100644 --- a/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs +++ b/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs @@ -18,9 +18,9 @@ namespace osu.Game.Screens.Ranking.Statistics { private readonly ScoreInfo achievedScore; - internal readonly Bindable DisplayedUserStatisticsUpdate = new Bindable(); + internal readonly Bindable DisplayedUserStatisticsUpdate = new Bindable(); - private IBindable latestGlobalStatisticsUpdate = null!; + private IBindable latestGlobalStatisticsUpdate = null!; public UserStatisticsPanel(ScoreInfo achievedScore) { @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Ranking.Statistics } [BackgroundDependencyLoader] - private void load(SoloStatisticsWatcher? soloStatisticsWatcher) + private void load(UserStatisticsWatcher? soloStatisticsWatcher) { if (soloStatisticsWatcher != null) { From d6beae2ce1d34d0efb17eaf9ccc531a72a757ecf Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 22 Feb 2024 19:10:15 -0800 Subject: [PATCH 155/508] Update delete/restore mod presets message when none --- .../MaintenanceSettingsStrings.cs | 10 +++++++ .../Sections/Maintenance/ModPresetSettings.cs | 27 ++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/osu.Game/Localisation/MaintenanceSettingsStrings.cs b/osu.Game/Localisation/MaintenanceSettingsStrings.cs index 469f565f1e..2511e7aecc 100644 --- a/osu.Game/Localisation/MaintenanceSettingsStrings.cs +++ b/osu.Game/Localisation/MaintenanceSettingsStrings.cs @@ -109,11 +109,21 @@ namespace osu.Game.Localisation /// public static LocalisableString DeletedAllModPresets => new TranslatableString(getKey(@"deleted_all_mod_presets"), @"Deleted all mod presets!"); + /// + /// "No mod presets found to delete!" + /// + public static LocalisableString NoModPresetsFoundToDelete => new TranslatableString(getKey(@"no_mod_presets_found_to_delete"), @"No mod presets found to delete!"); + /// /// "Restored all deleted mod presets!" /// public static LocalisableString RestoredAllDeletedModPresets => new TranslatableString(getKey(@"restored_all_deleted_mod_presets"), @"Restored all deleted mod presets!"); + /// + /// "No mod presets found to restore!" + /// + public static LocalisableString NoModPresetsFoundToRestore => new TranslatableString(getKey(@"no_mod_presets_found_to_restore"), @"No mod presets found to restore!"); + /// /// "Please select your osu!stable install location" /// diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/ModPresetSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/ModPresetSettings.cs index ba45d9c896..f0d6d10e51 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/ModPresetSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/ModPresetSettings.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Framework.Logging; @@ -52,36 +53,50 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance }); } - private void deleteAllModPresets() => + private bool deleteAllModPresets() => realm.Write(r => { + bool anyDeleted = false; + foreach (var preset in r.All()) + { + anyDeleted |= !preset.DeletePending; preset.DeletePending = true; + } + + return anyDeleted; }); - private void onAllModPresetsDeleted(Task deletionTask) + private void onAllModPresetsDeleted(Task deletionTask) { deleteAllButton.Enabled.Value = true; if (deletionTask.IsCompletedSuccessfully) - notificationOverlay?.Post(new ProgressCompletionNotification { Text = MaintenanceSettingsStrings.DeletedAllModPresets }); + notificationOverlay?.Post(new ProgressCompletionNotification { Text = deletionTask.GetResultSafely() ? MaintenanceSettingsStrings.DeletedAllModPresets : MaintenanceSettingsStrings.NoModPresetsFoundToDelete }); else if (deletionTask.IsFaulted) Logger.Error(deletionTask.Exception, "Failed to delete all mod presets"); } - private void undeleteModPresets() => + private bool undeleteModPresets() => realm.Write(r => { + bool anyRestored = false; + foreach (var preset in r.All().Where(preset => preset.DeletePending)) + { + anyRestored |= preset.DeletePending; preset.DeletePending = false; + } + + return anyRestored; }); - private void onModPresetsUndeleted(Task undeletionTask) + private void onModPresetsUndeleted(Task undeletionTask) { undeleteButton.Enabled.Value = true; if (undeletionTask.IsCompletedSuccessfully) - notificationOverlay?.Post(new ProgressCompletionNotification { Text = MaintenanceSettingsStrings.RestoredAllDeletedModPresets }); + notificationOverlay?.Post(new ProgressCompletionNotification { Text = undeletionTask.GetResultSafely() ? MaintenanceSettingsStrings.RestoredAllDeletedModPresets : MaintenanceSettingsStrings.NoModPresetsFoundToRestore }); else if (undeletionTask.IsFaulted) Logger.Error(undeletionTask.Exception, "Failed to restore mod presets"); } From 6c8204f9a35cfcc11b4a6fc9003b50dd30e37960 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 22 Feb 2024 19:40:02 -0800 Subject: [PATCH 156/508] Update delete collections message when none --- .../Localisation/MaintenanceSettingsStrings.cs | 5 +++++ .../Sections/Maintenance/CollectionsSettings.cs | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/osu.Game/Localisation/MaintenanceSettingsStrings.cs b/osu.Game/Localisation/MaintenanceSettingsStrings.cs index 2511e7aecc..2e5f1d29df 100644 --- a/osu.Game/Localisation/MaintenanceSettingsStrings.cs +++ b/osu.Game/Localisation/MaintenanceSettingsStrings.cs @@ -104,6 +104,11 @@ namespace osu.Game.Localisation /// public static LocalisableString DeletedAllCollections => new TranslatableString(getKey(@"deleted_all_collections"), @"Deleted all collections!"); + /// + /// "No collections found to delete!" + /// + public static LocalisableString NoCollectionsFoundToDelete => new TranslatableString(getKey(@"no_collections_found_to_delete"), @"No collections found to delete!"); + /// /// "Deleted all mod presets!" /// diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/CollectionsSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/CollectionsSettings.cs index 09acc22c25..b373535a8b 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/CollectionsSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/CollectionsSettings.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Localisation; using osu.Game.Collections; @@ -35,8 +36,20 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance private void deleteAllCollections() { - realm.Write(r => r.RemoveAll()); - notificationOverlay?.Post(new ProgressCompletionNotification { Text = MaintenanceSettingsStrings.DeletedAllCollections }); + bool anyDeleted = realm.Write(r => + { + if (r.All().Any()) + { + r.RemoveAll(); + return true; + } + else + { + return false; + } + }); + + notificationOverlay?.Post(new ProgressCompletionNotification { Text = anyDeleted ? MaintenanceSettingsStrings.DeletedAllCollections : MaintenanceSettingsStrings.NoCollectionsFoundToDelete }); } } } From 157819c19931b581abf36cbcf3538f70637d970c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Feb 2024 11:23:11 +0800 Subject: [PATCH 157/508] Materialise realm collection hashes during song select search process Without this, there's a large overhead to do a realm-live `Contains` search when a collection is selected. This may also help considerably alleviate https://github.com/ppy/osu/discussions/27298#discussioncomment-8552508 as we will be performing the native realm search much less. --- osu.Game/Screens/Select/FilterControl.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 1827eb58ca..6fd22364f6 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -4,6 +4,7 @@ #nullable disable using System; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -64,7 +65,7 @@ namespace osu.Game.Screens.Select Sort = sortMode.Value, AllowConvertedBeatmaps = showConverted.Value, Ruleset = ruleset.Value, - CollectionBeatmapMD5Hashes = collectionDropdown.Current.Value?.Collection?.PerformRead(c => c.BeatmapMD5Hashes) + CollectionBeatmapMD5Hashes = collectionDropdown.Current.Value?.Collection?.PerformRead(c => c.BeatmapMD5Hashes).ToList() }; if (!minimumStars.IsDefault) From d1d32fc16cf6474ec8661c83dbd6bd282cff172b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 23 Feb 2024 14:49:46 +0100 Subject: [PATCH 158/508] Fix editor displaying combo colours in effectively incorrect order Addresses https://github.com/ppy/osu/discussions/27316. Stable lies about the first combo colour being first; in the `.osu` file it is actually second. It does a thing in editor itself to correct for this. https://github.com/peppy/osu-stable-reference/blob/master/osu!/GameModes/Edit/Forms/SongSetup.cs#L233-L234 --- osu.Game/Screens/Edit/EditorBeatmapSkin.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs index 80239504d8..71530ee5bc 100644 --- a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs +++ b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs @@ -4,7 +4,7 @@ #nullable disable using System; -using System.Linq; +using System.Collections.Generic; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -38,8 +38,17 @@ namespace osu.Game.Screens.Edit Skin = skin; ComboColours = new BindableList(); - if (Skin.Configuration.ComboColours != null) - ComboColours.AddRange(Skin.Configuration.ComboColours.Select(c => (Colour4)c)); + + if (Skin.Configuration.ComboColours is IReadOnlyList comboColours) + { + // due to the foibles of how `IHasComboInformation` / `ComboIndexWithOffsets` work, + // the actual effective first combo colour that will be used on the beatmap is the one with index 1, not 0. + // see also: `IHasComboInformation.UpdateComboInformation`, + // https://github.com/peppy/osu-stable-reference/blob/46cd3a10af7cc6cc96f4eba92ef1812dc8c3a27e/osu!/GameModes/Edit/Forms/SongSetup.cs#L233-L234. + for (int i = 0; i < comboColours.Count; ++i) + ComboColours.Add(comboColours[(i + 1) % comboColours.Count]); + } + ComboColours.BindCollectionChanged((_, _) => updateColours()); } @@ -47,7 +56,10 @@ namespace osu.Game.Screens.Edit private void updateColours() { - Skin.Configuration.CustomComboColours = ComboColours.Select(c => (Color4)c).ToList(); + // performs the inverse of the index rotation operation described in the ctor. + Skin.Configuration.CustomComboColours.Clear(); + for (int i = 0; i < ComboColours.Count; ++i) + Skin.Configuration.CustomComboColours.Add(ComboColours[(ComboColours.Count + i - 1) % ComboColours.Count]); invokeSkinChanged(); } From ae9c58be3030cb5c0b3c0148446afbf8edf452ac Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 16:42:58 +0300 Subject: [PATCH 159/508] Remove "multiplayer" references from subclass and move to appropriate place --- .../OnlinePlay/Match/RoomModSelectOverlay.cs} | 24 ++++++++++--------- .../Screens/OnlinePlay/Match/RoomSubScreen.cs | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) rename osu.Game/{Overlays/Mods/MultiplayerModSelectOverlay.cs => Screens/OnlinePlay/Match/RoomModSelectOverlay.cs} (72%) diff --git a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs similarity index 72% rename from osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs rename to osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs index ee087bb149..00704b7ec7 100644 --- a/osu.Game/Overlays/Mods/MultiplayerModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; @@ -6,26 +6,28 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Game.Rulesets; using osu.Game.Online.Rooms; +using osu.Game.Overlays; +using osu.Game.Overlays.Mods; +using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; -namespace osu.Game.Overlays.Mods +namespace osu.Game.Screens.OnlinePlay.Match { - public partial class MultiplayerModSelectOverlay : UserModSelectOverlay + public partial class RoomModSelectOverlay : UserModSelectOverlay { - public MultiplayerModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Plum) + public RoomModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Plum) : base(colourScheme) { } [Resolved(CanBeNull = true)] - private IBindable? multiplayerRoomItem { get; set; } + private IBindable? selectedItem { get; set; } [Resolved] private OsuGameBase game { get; set; } = null!; - protected override BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new MultiplayerBeatmapAttributesDisplay + protected override BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new RoomBeatmapAttributesDisplay { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, @@ -35,7 +37,7 @@ namespace osu.Game.Overlays.Mods protected override void LoadComplete() { base.LoadComplete(); - multiplayerRoomItem?.BindValueChanged(_ => SelectedMods.TriggerChange()); + selectedItem?.BindValueChanged(_ => SelectedMods.TriggerChange()); } protected override IEnumerable AllSelectedMods @@ -44,10 +46,10 @@ namespace osu.Game.Overlays.Mods { IEnumerable allMods = SelectedMods.Value; - if (multiplayerRoomItem?.Value != null) + if (selectedItem?.Value != null) { Ruleset ruleset = game.Ruleset.Value.CreateInstance(); - var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); + var multiplayerRoomMods = selectedItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); allMods = allMods.Concat(multiplayerRoomMods); } @@ -56,7 +58,7 @@ namespace osu.Game.Overlays.Mods } } - public partial class MultiplayerBeatmapAttributesDisplay : BeatmapAttributesDisplay + public partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay { [Resolved(CanBeNull = true)] private IBindable? multiplayerRoomItem { get; set; } diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs index b20760b114..97fbb83992 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs @@ -241,7 +241,7 @@ namespace osu.Game.Screens.OnlinePlay.Match } }; - LoadComponent(UserModsSelectOverlay = new MultiplayerModSelectOverlay + LoadComponent(UserModsSelectOverlay = new RoomModSelectOverlay { SelectedMods = { BindTarget = UserMods }, IsValidMod = _ => false From f94cd4483cb4f4b0a4b8cd189975ccca92f54720 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 16:47:37 +0300 Subject: [PATCH 160/508] Avoid relying on game-wide ruleset bindable --- .../OnlinePlay/Match/RoomModSelectOverlay.cs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs index 00704b7ec7..e6ff2260e9 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -25,7 +26,7 @@ namespace osu.Game.Screens.OnlinePlay.Match private IBindable? selectedItem { get; set; } [Resolved] - private OsuGameBase game { get; set; } = null!; + private RulesetStore rulesets { get; set; } = null!; protected override BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new RoomBeatmapAttributesDisplay { @@ -48,9 +49,9 @@ namespace osu.Game.Screens.OnlinePlay.Match if (selectedItem?.Value != null) { - Ruleset ruleset = game.Ruleset.Value.CreateInstance(); - var multiplayerRoomMods = selectedItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - allMods = allMods.Concat(multiplayerRoomMods); + var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance(); + Debug.Assert(rulesetInstance != null); + allMods = allMods.Concat(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); } return allMods; @@ -61,12 +62,15 @@ namespace osu.Game.Screens.OnlinePlay.Match public partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay { [Resolved(CanBeNull = true)] - private IBindable? multiplayerRoomItem { get; set; } + private IBindable? selectedItem { get; set; } + + [Resolved] + private RulesetStore rulesets { get; set; } = null!; protected override void LoadComplete() { base.LoadComplete(); - multiplayerRoomItem?.BindValueChanged(_ => Mods.TriggerChange()); + selectedItem?.BindValueChanged(_ => Mods.TriggerChange()); } protected override IEnumerable SelectedMods @@ -75,11 +79,11 @@ namespace osu.Game.Screens.OnlinePlay.Match { IEnumerable selectedMods = Mods.Value; - if (multiplayerRoomItem?.Value != null) + if (selectedItem?.Value != null) { - Ruleset ruleset = GameRuleset.Value.CreateInstance(); - var multiplayerRoomMods = multiplayerRoomItem.Value.RequiredMods.Select(m => m.ToMod(ruleset)); - selectedMods = selectedMods.Concat(multiplayerRoomMods); + var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance(); + Debug.Assert(rulesetInstance != null); + selectedMods = selectedMods.Concat(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); } return selectedMods; From f86b7f0702790bd21522f86501ca9a19e771d018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 23 Feb 2024 14:52:44 +0100 Subject: [PATCH 161/508] Enable NRT in `EditorBeatmapSkin` --- osu.Game/Screens/Edit/EditorBeatmapSkin.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs index 71530ee5bc..07fa1cb49c 100644 --- a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs +++ b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using osu.Framework.Audio.Sample; @@ -20,7 +18,7 @@ namespace osu.Game.Screens.Edit /// public class EditorBeatmapSkin : ISkin { - public event Action BeatmapSkinChanged; + public event Action? BeatmapSkinChanged; /// /// The underlying beatmap skin. @@ -65,10 +63,14 @@ namespace osu.Game.Screens.Edit #region Delegated ISkin implementation - public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup); - public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT); - public ISample GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo); - public IBindable GetConfig(TLookup lookup) => Skin.GetConfig(lookup); + public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup); + public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT); + public ISample? GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo); + + public IBindable? GetConfig(TLookup lookup) + where TLookup : notnull + where TValue : notnull + => Skin.GetConfig(lookup); #endregion } From 918577d530c0fa27fc58f2677a731df23b20d230 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 16:51:52 +0300 Subject: [PATCH 162/508] Compute required mods list once per update --- .../OnlinePlay/Match/RoomModSelectOverlay.cs | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs index e6ff2260e9..5406912f49 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs @@ -35,28 +35,28 @@ namespace osu.Game.Screens.OnlinePlay.Match BeatmapInfo = { Value = Beatmap?.BeatmapInfo } }; + private readonly List roomMods = new List(); + protected override void LoadComplete() { base.LoadComplete(); - selectedItem?.BindValueChanged(_ => SelectedMods.TriggerChange()); - } - protected override IEnumerable AllSelectedMods - { - get + selectedItem?.BindValueChanged(_ => { - IEnumerable allMods = SelectedMods.Value; + roomMods.Clear(); if (selectedItem?.Value != null) { var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance(); Debug.Assert(rulesetInstance != null); - allMods = allMods.Concat(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); + roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); } - return allMods; - } + SelectedMods.TriggerChange(); + }); } + + protected override IEnumerable AllSelectedMods => roomMods.Concat(base.AllSelectedMods); } public partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay @@ -67,27 +67,27 @@ namespace osu.Game.Screens.OnlinePlay.Match [Resolved] private RulesetStore rulesets { get; set; } = null!; + private readonly List roomMods = new List(); + protected override void LoadComplete() { base.LoadComplete(); - selectedItem?.BindValueChanged(_ => Mods.TriggerChange()); - } - protected override IEnumerable SelectedMods - { - get + selectedItem?.BindValueChanged(_ => { - IEnumerable selectedMods = Mods.Value; + roomMods.Clear(); if (selectedItem?.Value != null) { var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance(); Debug.Assert(rulesetInstance != null); - selectedMods = selectedMods.Concat(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); + roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); } - return selectedMods; - } + Mods.TriggerChange(); + }); } + + protected override IEnumerable SelectedMods => roomMods.Concat(base.SelectedMods); } } From 323d7f8e2dabbd090c29b51926338cece1a94f64 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 16:59:08 +0300 Subject: [PATCH 163/508] Change `BeatmapAttributesDisplay` retrieval to proper method --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 16 +++--- .../OnlinePlay/Match/RoomModSelectOverlay.cs | 56 +++++++++---------- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 8a3b1954ed..99981c28d5 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -130,13 +130,6 @@ namespace osu.Game.Overlays.Mods private RankingInformationDisplay? rankingInformationDisplay; private BeatmapAttributesDisplay? beatmapAttributesDisplay; - protected virtual BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new BeatmapAttributesDisplay - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - BeatmapInfo = { Value = Beatmap?.BeatmapInfo } - }; - protected ShearedButton BackButton { get; private set; } = null!; protected ShearedToggleButton? CustomisationButton { get; private set; } protected SelectAllModsButton? SelectAllModsButton { get; set; } @@ -283,7 +276,12 @@ namespace osu.Game.Overlays.Mods Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight }, - beatmapAttributesDisplay = GetBeatmapAttributesDisplay + beatmapAttributesDisplay = CreateBeatmapAttributesDisplay().With(b => + { + b.Anchor = Anchor.BottomRight; + b.Origin = Anchor.BottomRight; + b.BeatmapInfo.Value = Beatmap?.BeatmapInfo; + }), } }); } @@ -293,6 +291,8 @@ namespace osu.Game.Overlays.Mods textSearchStartsActive = configManager.GetBindable(OsuSetting.ModSelectTextSearchStartsActive); } + protected virtual BeatmapAttributesDisplay CreateBeatmapAttributesDisplay() => new BeatmapAttributesDisplay(); + public override void Hide() { base.Hide(); diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs index 5406912f49..4bf8e22d4e 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Graphics; using osu.Game.Online.Rooms; using osu.Game.Overlays; using osu.Game.Overlays.Mods; @@ -28,13 +27,6 @@ namespace osu.Game.Screens.OnlinePlay.Match [Resolved] private RulesetStore rulesets { get; set; } = null!; - protected override BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new RoomBeatmapAttributesDisplay - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - BeatmapInfo = { Value = Beatmap?.BeatmapInfo } - }; - private readonly List roomMods = new List(); protected override void LoadComplete() @@ -57,37 +49,39 @@ namespace osu.Game.Screens.OnlinePlay.Match } protected override IEnumerable AllSelectedMods => roomMods.Concat(base.AllSelectedMods); - } - public partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay - { - [Resolved(CanBeNull = true)] - private IBindable? selectedItem { get; set; } + protected override BeatmapAttributesDisplay CreateBeatmapAttributesDisplay() => new RoomBeatmapAttributesDisplay(); - [Resolved] - private RulesetStore rulesets { get; set; } = null!; - - private readonly List roomMods = new List(); - - protected override void LoadComplete() + private partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay { - base.LoadComplete(); + [Resolved(CanBeNull = true)] + private IBindable? selectedItem { get; set; } - selectedItem?.BindValueChanged(_ => + [Resolved] + private RulesetStore rulesets { get; set; } = null!; + + private readonly List roomMods = new List(); + + protected override void LoadComplete() { - roomMods.Clear(); + base.LoadComplete(); - if (selectedItem?.Value != null) + selectedItem?.BindValueChanged(_ => { - var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance(); - Debug.Assert(rulesetInstance != null); - roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); - } + roomMods.Clear(); - Mods.TriggerChange(); - }); + if (selectedItem?.Value != null) + { + var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance(); + Debug.Assert(rulesetInstance != null); + roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); + } + + Mods.TriggerChange(); + }); + } + + protected override IEnumerable SelectedMods => roomMods.Concat(base.SelectedMods); } - - protected override IEnumerable SelectedMods => roomMods.Concat(base.SelectedMods); } } From 9ce07a96b2f98358050eacb4d72767fc1dede2cc Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 17:28:54 +0300 Subject: [PATCH 164/508] Rewrite mods flow and remove `RoomBeatmapAttributesDisplay` --- .../Overlays/Mods/BeatmapAttributesDisplay.cs | 26 ++++--------- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 34 +++++++++++------ .../OnlinePlay/Match/RoomModSelectOverlay.cs | 37 +------------------ 3 files changed, 31 insertions(+), 66 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 7c3c971d76..8f84b51127 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -13,7 +13,6 @@ using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; -using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -39,15 +38,10 @@ namespace osu.Game.Overlays.Mods public Bindable BeatmapInfo { get; } = new Bindable(); - [Resolved] - protected Bindable> Mods { get; private set; } = null!; - - protected virtual IEnumerable SelectedMods => Mods.Value; + public Bindable> Mods { get; } = new Bindable>(); public BindableBool Collapsed { get; } = new BindableBool(true); - private ModSettingChangeTracker? modSettingChangeTracker; - [Resolved] private BeatmapDifficultyCache difficultyCache { get; set; } = null!; @@ -102,15 +96,8 @@ namespace osu.Game.Overlays.Mods { base.LoadComplete(); - Mods.BindValueChanged(_ => - { - modSettingChangeTracker?.Dispose(); - modSettingChangeTracker = new ModSettingChangeTracker(Mods.Value); - modSettingChangeTracker.SettingChanged += _ => updateValues(); - updateValues(); - }, true); - - BeatmapInfo.BindValueChanged(_ => updateValues(), true); + Mods.BindValueChanged(_ => updateValues()); + BeatmapInfo.BindValueChanged(_ => updateValues()); Collapsed.BindValueChanged(_ => { @@ -122,8 +109,9 @@ namespace osu.Game.Overlays.Mods GameRuleset = game.Ruleset.GetBoundCopy(); GameRuleset.BindValueChanged(_ => updateValues()); - BeatmapInfo.BindValueChanged(_ => updateValues(), true); + BeatmapInfo.BindValueChanged(_ => updateValues()); + updateValues(); updateCollapsedState(); } @@ -167,14 +155,14 @@ namespace osu.Game.Overlays.Mods }); double rate = 1; - foreach (var mod in SelectedMods.OfType()) + foreach (var mod in Mods.Value.OfType()) rate = mod.ApplyToRate(0, rate); bpmDisplay.Current.Value = BeatmapInfo.Value.BPM * rate; BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(BeatmapInfo.Value.Difficulty); - foreach (var mod in SelectedMods.OfType()) + foreach (var mod in Mods.Value.OfType()) mod.ApplyToDifficulty(originalDifficulty); Ruleset ruleset = GameRuleset.Value.CreateInstance(); diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 99981c28d5..fa87b0aa0d 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -114,8 +114,6 @@ namespace osu.Game.Overlays.Mods public IEnumerable AllAvailableMods => AvailableMods.Value.SelectMany(pair => pair.Value); - protected virtual IEnumerable AllSelectedMods => SelectedMods.Value; - private readonly BindableBool customisationVisible = new BindableBool(); private Bindable textSearchStartsActive = null!; @@ -319,7 +317,7 @@ namespace osu.Game.Overlays.Mods SelectedMods.BindValueChanged(_ => { - updateRankingInformation(); + UpdateOverlayInformation(SelectedMods.Value); updateFromExternalSelection(); updateCustomisation(); @@ -332,7 +330,7 @@ namespace osu.Game.Overlays.Mods // // See https://github.com/ppy/osu/pull/23284#issuecomment-1529056988 modSettingChangeTracker = new ModSettingChangeTracker(SelectedMods.Value); - modSettingChangeTracker.SettingChanged += _ => updateRankingInformation(); + modSettingChangeTracker.SettingChanged += _ => UpdateOverlayInformation(SelectedMods.Value); } }, true); @@ -454,18 +452,30 @@ namespace osu.Game.Overlays.Mods modState.ValidForSelection.Value = modState.Mod.Type != ModType.System && modState.Mod.HasImplementation && IsValidMod.Invoke(modState.Mod); } - private void updateRankingInformation() + /// + /// Updates any information displayed on the overlay regarding the effects of the selected mods. + /// + /// The list of mods to show effect from. This can be overriden to include effect of mods that are not part of the bindable (e.g. room mods in multiplayer/playlists). + protected virtual void UpdateOverlayInformation(IReadOnlyList mods) { - if (rankingInformationDisplay == null) - return; + if (rankingInformationDisplay != null) + { + double multiplier = 1.0; - double multiplier = 1.0; + foreach (var mod in mods) + multiplier *= mod.ScoreMultiplier; - foreach (var mod in AllSelectedMods) - multiplier *= mod.ScoreMultiplier; + rankingInformationDisplay.ModMultiplier.Value = multiplier; + rankingInformationDisplay.Ranked.Value = mods.All(m => m.Ranked); + } - rankingInformationDisplay.ModMultiplier.Value = multiplier; - rankingInformationDisplay.Ranked.Value = AllSelectedMods.All(m => m.Ranked); + if (beatmapAttributesDisplay != null) + { + if (!ReferenceEquals(beatmapAttributesDisplay.Mods.Value, mods)) + beatmapAttributesDisplay.Mods.Value = mods; + else + beatmapAttributesDisplay.Mods.TriggerChange(); // mods list may be same but a mod setting has changed, trigger change in that case. + } } private void updateCustomisation() diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs index 4bf8e22d4e..dd0ecbad90 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs @@ -48,40 +48,7 @@ namespace osu.Game.Screens.OnlinePlay.Match }); } - protected override IEnumerable AllSelectedMods => roomMods.Concat(base.AllSelectedMods); - - protected override BeatmapAttributesDisplay CreateBeatmapAttributesDisplay() => new RoomBeatmapAttributesDisplay(); - - private partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay - { - [Resolved(CanBeNull = true)] - private IBindable? selectedItem { get; set; } - - [Resolved] - private RulesetStore rulesets { get; set; } = null!; - - private readonly List roomMods = new List(); - - protected override void LoadComplete() - { - base.LoadComplete(); - - selectedItem?.BindValueChanged(_ => - { - roomMods.Clear(); - - if (selectedItem?.Value != null) - { - var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance(); - Debug.Assert(rulesetInstance != null); - roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); - } - - Mods.TriggerChange(); - }); - } - - protected override IEnumerable SelectedMods => roomMods.Concat(base.SelectedMods); - } + protected override void UpdateOverlayInformation(IReadOnlyList mods) + => base.UpdateOverlayInformation(roomMods.Concat(mods).ToList()); } } From fdc0636554ca83daf3762c229feee047f34966b5 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 17:30:31 +0300 Subject: [PATCH 165/508] General code cleanup --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 12 +++++----- .../OnlinePlay/Match/RoomModSelectOverlay.cs | 22 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index fa87b0aa0d..bf43dc3d9c 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -274,12 +274,12 @@ namespace osu.Game.Overlays.Mods Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight }, - beatmapAttributesDisplay = CreateBeatmapAttributesDisplay().With(b => + beatmapAttributesDisplay = new BeatmapAttributesDisplay { - b.Anchor = Anchor.BottomRight; - b.Origin = Anchor.BottomRight; - b.BeatmapInfo.Value = Beatmap?.BeatmapInfo; - }), + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + BeatmapInfo = { Value = Beatmap?.BeatmapInfo }, + }, } }); } @@ -289,8 +289,6 @@ namespace osu.Game.Overlays.Mods textSearchStartsActive = configManager.GetBindable(OsuSetting.ModSelectTextSearchStartsActive); } - protected virtual BeatmapAttributesDisplay CreateBeatmapAttributesDisplay() => new BeatmapAttributesDisplay(); - public override void Hide() { base.Hide(); diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs index dd0ecbad90..db7cfe980c 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs @@ -16,32 +16,32 @@ namespace osu.Game.Screens.OnlinePlay.Match { public partial class RoomModSelectOverlay : UserModSelectOverlay { - public RoomModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Plum) - : base(colourScheme) - { - } - - [Resolved(CanBeNull = true)] - private IBindable? selectedItem { get; set; } + [Resolved] + private IBindable selectedItem { get; set; } = null!; [Resolved] private RulesetStore rulesets { get; set; } = null!; private readonly List roomMods = new List(); + public RoomModSelectOverlay() + : base(OverlayColourScheme.Plum) + { + } + protected override void LoadComplete() { base.LoadComplete(); - selectedItem?.BindValueChanged(_ => + selectedItem.BindValueChanged(_ => { roomMods.Clear(); - if (selectedItem?.Value != null) + if (selectedItem.Value is PlaylistItem item) { - var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance(); + var rulesetInstance = rulesets.GetRuleset(item.RulesetID)?.CreateInstance(); Debug.Assert(rulesetInstance != null); - roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))); + roomMods.AddRange(item.RequiredMods.Select(m => m.ToMod(rulesetInstance))); } SelectedMods.TriggerChange(); From 869f0a82de4272806eda4350944c7fd989f52e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 23 Feb 2024 15:38:52 +0100 Subject: [PATCH 166/508] Use hashset for faster lookup --- osu.Game/Screens/Select/FilterControl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 6fd22364f6..17297c9ebf 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -4,7 +4,7 @@ #nullable disable using System; -using System.Linq; +using System.Collections.Immutable; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Select Sort = sortMode.Value, AllowConvertedBeatmaps = showConverted.Value, Ruleset = ruleset.Value, - CollectionBeatmapMD5Hashes = collectionDropdown.Current.Value?.Collection?.PerformRead(c => c.BeatmapMD5Hashes).ToList() + CollectionBeatmapMD5Hashes = collectionDropdown.Current.Value?.Collection?.PerformRead(c => c.BeatmapMD5Hashes).ToImmutableHashSet() }; if (!minimumStars.IsDefault) From c1db9d7819496e52db88223134d642d6cba6f0d3 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 18:16:35 +0300 Subject: [PATCH 167/508] Add test coverage --- .../TestSceneMultiplayerMatchSubScreen.cs | 30 +++++++++++++++++++ .../Overlays/Mods/BeatmapAttributesDisplay.cs | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs index a41eff067b..4bedc31f38 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs @@ -286,6 +286,36 @@ namespace osu.Game.Tests.Visual.Multiplayer }); } + [Test] + [FlakyTest] // See above + public void TestModSelectOverlay() + { + AddStep("add playlist item", () => + { + SelectedRoom.Value.Playlist.Add(new PlaylistItem(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo) + { + RulesetID = new OsuRuleset().RulesetInfo.OnlineID, + RequiredMods = new[] + { + new APIMod(new OsuModDoubleTime { SpeedChange = { Value = 2.0 } }), + new APIMod(new OsuModStrictTracking()), + }, + AllowedMods = new[] + { + new APIMod(new OsuModFlashlight()), + new APIMod(new OsuModHardRock()), + } + }); + }); + ClickButtonWhenEnabled(); + + AddUntilStep("wait for join", () => RoomJoined); + + ClickButtonWhenEnabled(); + AddAssert("mod select shows unranked", () => this.ChildrenOfType().Single().Ranked.Value == false); + AddAssert("mod select shows different multiplier", () => !this.ChildrenOfType().Single().ModMultiplier.IsDefault); + } + private partial class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen { [Resolved(canBeNull: true)] diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 8f84b51127..472fe6f476 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -184,7 +184,7 @@ namespace osu.Game.Overlays.Mods RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint); } - private partial class BPMDisplay : RollingCounter + public partial class BPMDisplay : RollingCounter { protected override double RollingDuration => 250; From 31dabaefaa95dfb04cebe69a25b3965ae549201d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Fri, 23 Feb 2024 18:21:11 +0300 Subject: [PATCH 168/508] Reduce smoke allocations --- osu.Game.Rulesets.Osu/Skinning/SmokeSegment.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/SmokeSegment.cs b/osu.Game.Rulesets.Osu/Skinning/SmokeSegment.cs index 9838cb2c37..f4fe42b8de 100644 --- a/osu.Game.Rulesets.Osu/Skinning/SmokeSegment.cs +++ b/osu.Game.Rulesets.Osu/Skinning/SmokeSegment.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -228,7 +227,9 @@ namespace osu.Game.Rulesets.Osu.Skinning int futurePointIndex = ~Source.SmokePoints.BinarySearch(new SmokePoint { Time = CurrentTime }, new SmokePoint.UpperBoundComparer()); points.Clear(); - points.AddRange(Source.SmokePoints.Skip(firstVisiblePointIndex).Take(futurePointIndex - firstVisiblePointIndex)); + + for (int i = firstVisiblePointIndex; i < futurePointIndex; i++) + points.Add(Source.SmokePoints[i]); } protected sealed override void Draw(IRenderer renderer) From 771cdf9cd6eb12de88691ec9cddfecd52e586c88 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 18:30:14 +0300 Subject: [PATCH 169/508] Fix `TestSceneModEffectPreviewPanel` --- .../Visual/UserInterface/TestSceneModEffectPreviewPanel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModEffectPreviewPanel.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModEffectPreviewPanel.cs index b3ad5a499e..cdb6900f06 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModEffectPreviewPanel.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModEffectPreviewPanel.cs @@ -57,6 +57,7 @@ namespace osu.Game.Tests.Visual.UserInterface { Anchor = Anchor.Centre, Origin = Anchor.Centre, + Mods = { BindTarget = SelectedMods }, }); AddStep("set beatmap", () => From d4bc3090e7fd680f0f3452a1e242fa29b09f0178 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Feb 2024 18:42:07 +0300 Subject: [PATCH 170/508] Fix incorrect conflict resolution --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 3432529976..7035af1594 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -185,7 +185,7 @@ namespace osu.Game.Overlays.Mods RightContent.FadeTo(Collapsed.Value && !IsHovered ? 0 : 1, transition_duration, Easing.OutQuint); } - public partial class BPMDisplay : RollingCounter + public partial class BPMDisplay : RollingCounter { protected override double RollingDuration => 250; From 8934cf33f069d211511097861696c8af3019bb3d Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 23 Feb 2024 22:07:47 -0500 Subject: [PATCH 171/508] Apply Discord RPC changes regardless of user's status --- osu.Desktop/DiscordRichPresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index f990fd55fc..1944a73c0a 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -92,7 +92,7 @@ namespace osu.Desktop return; } - if (status.Value == UserStatus.Online && activity.Value != null) + if (activity.Value != null) { bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited; presence.State = truncate(activity.Value.GetStatus(hideIdentifiableInformation)); From e80b08c46fe45da19ffa6fba4862329333a6f112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 24 Feb 2024 09:55:51 +0100 Subject: [PATCH 172/508] Fix incorrect standardised score estimation on selected beatmaps --- osu.Game/Database/StandardisedScoreMigrationTools.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Game/Database/StandardisedScoreMigrationTools.cs b/osu.Game/Database/StandardisedScoreMigrationTools.cs index 403e73ab77..0594c80390 100644 --- a/osu.Game/Database/StandardisedScoreMigrationTools.cs +++ b/osu.Game/Database/StandardisedScoreMigrationTools.cs @@ -365,6 +365,17 @@ namespace osu.Game.Database + bonusProportion) * modMultiplier); } + // see similar check above. + // if there is no legacy combo score, all combo conversion operations below + // are either pointless or wildly wrong. + if (maximumLegacyComboScore + maximumLegacyBonusScore == 0) + { + return (long)Math.Round(( + 500000 * comboProportion // as above, zero if mods result in zero multiplier, one otherwise + + 500000 * Math.Pow(score.Accuracy, 5) + + bonusProportion) * modMultiplier); + } + // Assumptions: // - sliders and slider ticks are uniformly distributed in the beatmap, and thus can be ignored without losing much precision. // We thus consider a map of hit-circles only, which gives objectCount == maximumCombo. From e7d8ca3292e4213b248914c7a0416b48b84b2f18 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 24 Feb 2024 14:22:34 +0300 Subject: [PATCH 173/508] Fix Argon and Trianles spinner stutter --- osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs | 2 +- osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs index ee9f228137..7ed6d2dce7 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs @@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon { base.Update(); - if (!spmContainer.IsPresent && drawableSpinner.Result?.TimeStarted != null) + if (spmContainer.Alpha != 0 && drawableSpinner.Result?.TimeStarted != null) fadeCounterOnTimeStart(); } diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs index 4a76a1aec4..a5973ad444 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs @@ -126,7 +126,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { base.Update(); - if (!spmContainer.IsPresent && drawableSpinner.Result?.TimeStarted != null) + if (spmContainer.Alpha != 0 && drawableSpinner.Result?.TimeStarted != null) fadeCounterOnTimeStart(); } From 4bc92a263f9c95eece33fe97dadc40eeddc897d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 24 Feb 2024 13:20:42 +0100 Subject: [PATCH 174/508] Bump score version --- osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs index c74980abb6..775d87f3f2 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs @@ -44,9 +44,10 @@ namespace osu.Game.Scoring.Legacy /// method. Reconvert all scores. /// /// 30000013: All local scores will use lazer definitions of ranks for consistency. Recalculates the rank of all scores. + /// 30000014: Fix edge cases in conversion for osu! scores on selected beatmaps. Reconvert all scores. /// /// - public const int LATEST_VERSION = 30000013; + public const int LATEST_VERSION = 30000014; /// /// The first stable-compatible YYYYMMDD format version given to lazer usage of replays. From f6ceedc7a6dfd727c4ea29c14bca6c63575c6dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 24 Feb 2024 13:55:44 +0100 Subject: [PATCH 175/508] Inline last version which touched ranks when checking for upgrade --- osu.Game/Database/BackgroundDataStoreProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/BackgroundDataStoreProcessor.cs b/osu.Game/Database/BackgroundDataStoreProcessor.cs index be0c83bdb3..872194aa1d 100644 --- a/osu.Game/Database/BackgroundDataStoreProcessor.cs +++ b/osu.Game/Database/BackgroundDataStoreProcessor.cs @@ -382,7 +382,7 @@ namespace osu.Game.Database HashSet scoreIds = realmAccess.Run(r => new HashSet( r.All() - .Where(s => s.TotalScoreVersion < LegacyScoreEncoder.LATEST_VERSION) + .Where(s => s.TotalScoreVersion < 30000013) // last total score version with a significant change to ranks .AsEnumerable() // must be done after materialisation, as realm doesn't support // filtering on nested property predicates or projection via `.Select()` From 9b526912e9f58f9b9250ca4df8f104a988a9644b Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 24 Feb 2024 16:41:53 +0300 Subject: [PATCH 176/508] Fix incorrect operator --- osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs | 2 +- osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs index 7ed6d2dce7..e168e14858 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs @@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon { base.Update(); - if (spmContainer.Alpha != 0 && drawableSpinner.Result?.TimeStarted != null) + if (spmContainer.Alpha == 0 && drawableSpinner.Result?.TimeStarted != null) fadeCounterOnTimeStart(); } diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs index a5973ad444..2088839e82 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs @@ -126,7 +126,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { base.Update(); - if (spmContainer.Alpha != 0 && drawableSpinner.Result?.TimeStarted != null) + if (spmContainer.Alpha == 0 && drawableSpinner.Result?.TimeStarted != null) fadeCounterOnTimeStart(); } From 4bba0eaf4b5b996ff6b053e1b88cb2b86bcd477c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 24 Feb 2024 16:42:44 +0300 Subject: [PATCH 177/508] Remove repeated TimeStarted check --- osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs | 2 +- osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs index e168e14858..25ce92d1c5 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs @@ -120,7 +120,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon { base.Update(); - if (spmContainer.Alpha == 0 && drawableSpinner.Result?.TimeStarted != null) + if (spmContainer.Alpha == 0) fadeCounterOnTimeStart(); } diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs index 2088839e82..5c4d7ae47b 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs @@ -126,7 +126,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { base.Update(); - if (spmContainer.Alpha == 0 && drawableSpinner.Result?.TimeStarted != null) + if (spmContainer.Alpha == 0) fadeCounterOnTimeStart(); } From 2696620d12078432f749f02103c7a7774740f90a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 24 Feb 2024 17:09:21 +0300 Subject: [PATCH 178/508] Completely remove transform flow for spm counter --- .../Skinning/Argon/ArgonSpinner.cs | 33 +++++-------------- .../Skinning/Default/DefaultSpinner.cs | 33 +++++-------------- 2 files changed, 16 insertions(+), 50 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs index 25ce92d1c5..f2bbd7373e 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs @@ -5,7 +5,6 @@ using System; using System.Globalization; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -111,42 +110,26 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon { spmCounter.Text = Math.Truncate(spm.NewValue).ToString(@"#0"); }, true); - - drawableSpinner.ApplyCustomUpdateState += updateStateTransforms; - updateStateTransforms(drawableSpinner, drawableSpinner.State.Value); } protected override void Update() { base.Update(); - if (spmContainer.Alpha == 0) - fadeCounterOnTimeStart(); + updateSpmAlpha(); } - private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state) - { - if (!(drawableHitObject is DrawableSpinner)) - return; - - fadeCounterOnTimeStart(); - } - - private void fadeCounterOnTimeStart() + private void updateSpmAlpha() { if (drawableSpinner.Result?.TimeStarted is double startTime) { - using (BeginAbsoluteSequence(startTime)) - spmContainer.FadeIn(drawableSpinner.HitObject.TimeFadeIn); + double timeOffset = Math.Clamp(Clock.CurrentTime, startTime, startTime + drawableSpinner.HitObject.TimeFadeIn) - startTime; + spmContainer.Alpha = (float)(timeOffset / drawableSpinner.HitObject.TimeFadeIn); + } + else + { + spmContainer.Alpha = 0; } - } - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - - if (drawableSpinner.IsNotNull()) - drawableSpinner.ApplyCustomUpdateState -= updateStateTransforms; } } } diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs index 5c4d7ae47b..0bd877b902 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs @@ -5,7 +5,6 @@ using System; using System.Globalization; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; @@ -117,42 +116,26 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { spmCounter.Text = Math.Truncate(spm.NewValue).ToString(@"#0"); }, true); - - drawableSpinner.ApplyCustomUpdateState += updateStateTransforms; - updateStateTransforms(drawableSpinner, drawableSpinner.State.Value); } protected override void Update() { base.Update(); - if (spmContainer.Alpha == 0) - fadeCounterOnTimeStart(); + updateSpmAlpha(); } - private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state) - { - if (!(drawableHitObject is DrawableSpinner)) - return; - - fadeCounterOnTimeStart(); - } - - private void fadeCounterOnTimeStart() + private void updateSpmAlpha() { if (drawableSpinner.Result?.TimeStarted is double startTime) { - using (BeginAbsoluteSequence(startTime)) - spmContainer.FadeIn(drawableSpinner.HitObject.TimeFadeIn); + double timeOffset = Math.Clamp(Clock.CurrentTime, startTime, startTime + drawableSpinner.HitObject.TimeFadeIn) - startTime; + spmContainer.Alpha = (float)(timeOffset / drawableSpinner.HitObject.TimeFadeIn); + } + else + { + spmContainer.Alpha = 0; } - } - - protected override void Dispose(bool isDisposing) - { - base.Dispose(isDisposing); - - if (drawableSpinner.IsNotNull()) - drawableSpinner.ApplyCustomUpdateState -= updateStateTransforms; } } } From 824d671cce71eded91dee5ade2868da18a5f8e4b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 25 Feb 2024 00:12:20 +0800 Subject: [PATCH 179/508] Simplify implementation --- osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs | 7 +------ osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs index f2bbd7373e..3b48d36bb5 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs @@ -122,14 +122,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon private void updateSpmAlpha() { if (drawableSpinner.Result?.TimeStarted is double startTime) - { - double timeOffset = Math.Clamp(Clock.CurrentTime, startTime, startTime + drawableSpinner.HitObject.TimeFadeIn) - startTime; - spmContainer.Alpha = (float)(timeOffset / drawableSpinner.HitObject.TimeFadeIn); - } + spmContainer.Alpha = (float)Math.Clamp((Clock.CurrentTime - startTime) / drawableSpinner.HitObject.TimeFadeIn, 0, 1); else - { spmContainer.Alpha = 0; - } } } } diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs index 0bd877b902..ac56b45b69 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs @@ -128,14 +128,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default private void updateSpmAlpha() { if (drawableSpinner.Result?.TimeStarted is double startTime) - { - double timeOffset = Math.Clamp(Clock.CurrentTime, startTime, startTime + drawableSpinner.HitObject.TimeFadeIn) - startTime; - spmContainer.Alpha = (float)(timeOffset / drawableSpinner.HitObject.TimeFadeIn); - } + spmContainer.Alpha = (float)Math.Clamp((Clock.CurrentTime - startTime) / drawableSpinner.HitObject.TimeFadeIn, 0, 1); else - { spmContainer.Alpha = 0; - } } } } From 1fb19e712922871adca31db706afd27ebb0a247f Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 24 Feb 2024 20:18:30 +0300 Subject: [PATCH 180/508] Reduce allocations in DrawableSpinner --- .../Objects/Drawables/DrawableSpinner.cs | 32 ++++++++++++++++--- .../Objects/Drawables/DrawableHitObject.cs | 4 ++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 11120e49b5..8c21e6a6bc 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -279,10 +279,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (HandleUserInput) { bool isValidSpinningTime = Time.Current >= HitObject.StartTime && Time.Current <= HitObject.EndTime; - bool correctButtonPressed = (OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false); RotationTracker.Tracking = !Result.HasResult - && correctButtonPressed + && correctButtonPressed() && isValidSpinningTime; } @@ -292,11 +291,34 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables // Ticks can theoretically be judged at any point in the spinner's duration. // A tick must be alive to correctly play back samples, // but for performance reasons, we only want to keep the next tick alive. - var next = NestedHitObjects.FirstOrDefault(h => !h.Judged); + DrawableHitObject nextTick = null; + + foreach (var nested in NestedHitObjects) + { + if (!nested.Judged) + { + nextTick = nested; + break; + } + } // See default `LifetimeStart` as set in `DrawableSpinnerTick`. - if (next?.LifetimeStart == double.MaxValue) - next.LifetimeStart = HitObject.StartTime; + if (nextTick?.LifetimeStart == double.MaxValue) + nextTick.LifetimeStart = HitObject.StartTime; + } + + private bool correctButtonPressed() + { + if (OsuActionInputManager == null) + return false; + + foreach (var action in OsuActionInputManager.PressedActions) + { + if (action == OsuAction.LeftButton || action == OsuAction.RightButton) + return true; + } + + return false; } protected override void UpdateAfterChildren() diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 16bd4b565c..de05219212 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -11,10 +11,12 @@ using System.Linq; using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.ListExtensions; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; +using osu.Framework.Lists; using osu.Framework.Threading; using osu.Framework.Utils; using osu.Game.Audio; @@ -65,7 +67,7 @@ namespace osu.Game.Rulesets.Objects.Drawables public virtual IEnumerable GetSamples() => HitObject.Samples; private readonly List nestedHitObjects = new List(); - public IReadOnlyList NestedHitObjects => nestedHitObjects; + public SlimReadOnlyListWrapper NestedHitObjects => nestedHitObjects.AsSlimReadOnly(); /// /// Whether this object should handle any user input events. From 9e90f7fb0d731e06d36bce8e5bc269f362f307cd Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 24 Feb 2024 20:36:06 +0300 Subject: [PATCH 181/508] Store last enqueued RotationRecord in SpinnerSpmCalculator --- .../Skinning/Default/SpinnerSpmCalculator.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs index 44962c8548..7986108fbd 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.ObjectExtensions; @@ -33,14 +32,16 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default drawableSpinner.HitObjectApplied += resetState; } + private RotationRecord lastRecord; + public void SetRotation(float currentRotation) { // If we've gone back in time, it's fine to work with a fresh set of records for now - if (records.Count > 0 && Time.Current < records.Last().Time) + if (records.Count > 0 && Time.Current < lastRecord.Time) records.Clear(); // Never calculate SPM by same time of record to avoid 0 / 0 = NaN or X / 0 = Infinity result. - if (records.Count > 0 && Precision.AlmostEquals(Time.Current, records.Last().Time)) + if (records.Count > 0 && Precision.AlmostEquals(Time.Current, lastRecord.Time)) return; if (records.Count > 0) @@ -52,7 +53,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default result.Value = (currentRotation - record.Rotation) / (Time.Current - record.Time) * 1000 * 60 / 360; } - records.Enqueue(new RotationRecord { Rotation = currentRotation, Time = Time.Current }); + records.Enqueue(lastRecord = new RotationRecord { Rotation = currentRotation, Time = Time.Current }); } private void resetState(DrawableHitObject hitObject) From 3b53ed3c3aae40476d7f061a2796186a9f70c8b7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 24 Feb 2024 22:44:58 +0300 Subject: [PATCH 182/508] Reduce allocations in ModColumn --- osu.Game/Overlays/Mods/ModColumn.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModColumn.cs b/osu.Game/Overlays/Mods/ModColumn.cs index d65c94d14d..df33c78ea4 100644 --- a/osu.Game/Overlays/Mods/ModColumn.cs +++ b/osu.Game/Overlays/Mods/ModColumn.cs @@ -67,8 +67,25 @@ namespace osu.Game.Overlays.Mods private IModHotkeyHandler hotkeyHandler = null!; private Task? latestLoadTask; - private ICollection? latestLoadedPanels; - internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && latestLoadedPanels?.All(panel => panel.Parent != null) == true; + private ModPanel[]? latestLoadedPanels; + internal bool ItemsLoaded => latestLoadTask?.IsCompleted == true && allPanelsLoaded; + + private bool allPanelsLoaded + { + get + { + if (latestLoadedPanels == null) + return false; + + foreach (var panel in latestLoadedPanels) + { + if (panel.Parent == null) + return false; + } + + return true; + } + } public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks; From 6d2187e079c278d36ca628b128223bafc31e5e4d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 24 Feb 2024 22:58:23 +0300 Subject: [PATCH 183/508] Reduce allocations in ModSelectOverlay --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index ddf96c1cb3..3009297741 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -15,6 +15,7 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; +using osu.Framework.Localisation; using osu.Framework.Utils; using osu.Game.Audio; using osu.Game.Beatmaps; @@ -349,15 +350,23 @@ namespace osu.Game.Overlays.Mods }); } + private static readonly LocalisableString input_search_placeholder = Resources.Localisation.Web.CommonStrings.InputSearch; + private static readonly LocalisableString tab_to_search_placeholder = ModSelectOverlayStrings.TabToSearch; + protected override void Update() { base.Update(); - SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? Resources.Localisation.Web.CommonStrings.InputSearch : ModSelectOverlayStrings.TabToSearch; + SearchTextBox.PlaceholderText = SearchTextBox.HasFocus ? input_search_placeholder : tab_to_search_placeholder; if (beatmapAttributesDisplay != null) { - float rightEdgeOfLastButton = footerButtonFlow.Last().ScreenSpaceDrawQuad.TopRight.X; + ShearedButton lastFooterButton = null!; + + foreach (var b in footerButtonFlow) + lastFooterButton = b; + + float rightEdgeOfLastButton = lastFooterButton.ScreenSpaceDrawQuad.TopRight.X; // this is cheating a bit; the 640 value is hardcoded based on how wide the expanded panel _generally_ is. // due to the transition applied, the raw screenspace quad of the panel cannot be used, as it will trigger an ugly feedback cycle of expanding and collapsing. From 91d7bd10265a806946ba0e528da8aa6c07cdcd8e Mon Sep 17 00:00:00 2001 From: Detze <92268414+Detze@users.noreply.github.com> Date: Sat, 24 Feb 2024 21:56:44 +0100 Subject: [PATCH 184/508] Don't dim slider head in `DrawableSlider` --- osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index 6d492e7b08..b7ce712e2c 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override IEnumerable DimmablePieces => new Drawable[] { - HeadCircle, + // HeadCircle should not be added to this list, as it handles dimming itself TailCircle, repeatContainer, Body, From e12f8c03eef09478b8c8f3823b60632d37713192 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 25 Feb 2024 08:18:19 +0800 Subject: [PATCH 185/508] Reset `lastRecord` on `resetState` for good measure --- osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs index 7986108fbd..3383989367 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerSpmCalculator.cs @@ -58,6 +58,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default private void resetState(DrawableHitObject hitObject) { + lastRecord = default; result.Value = 0; records.Clear(); } From 081aa84718233618bd1d9fc81468e99023dbc705 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 25 Feb 2024 10:36:15 +0300 Subject: [PATCH 186/508] Simplify last footer button selection --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 3009297741..ce1d0d27a3 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -361,12 +361,7 @@ namespace osu.Game.Overlays.Mods if (beatmapAttributesDisplay != null) { - ShearedButton lastFooterButton = null!; - - foreach (var b in footerButtonFlow) - lastFooterButton = b; - - float rightEdgeOfLastButton = lastFooterButton.ScreenSpaceDrawQuad.TopRight.X; + float rightEdgeOfLastButton = footerButtonFlow[^1].ScreenSpaceDrawQuad.TopRight.X; // this is cheating a bit; the 640 value is hardcoded based on how wide the expanded panel _generally_ is. // due to the transition applied, the raw screenspace quad of the panel cannot be used, as it will trigger an ugly feedback cycle of expanding and collapsing. From f948f8ee5c49498ea58fe2a2e5817ef7fbb027c7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 25 Feb 2024 17:59:20 +0300 Subject: [PATCH 187/508] Fix HUDOverlay allocations --- osu.Game/Screens/Play/HUDOverlay.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index 32ebb82f15..f965d3392a 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -258,13 +258,13 @@ namespace osu.Game.Screens.Play Vector2? highestBottomScreenSpace = null; - foreach (var element in mainComponents.Components) - processDrawable(element); + for (int i = 0; i < mainComponents.Components.Count; i++) + processDrawable(mainComponents.Components[i]); if (rulesetComponents != null) { - foreach (var element in rulesetComponents.Components) - processDrawable(element); + for (int i = 0; i < rulesetComponents.Components.Count; i++) + processDrawable(rulesetComponents.Components[i]); } if (lowestTopScreenSpaceRight.HasValue) From c3fa97d062c370c4d5c60b2cee66e7b8298a79b7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 25 Feb 2024 18:02:42 +0300 Subject: [PATCH 188/508] Reduce allocations in HitObjectLifetimeEntry --- .../Rulesets/Objects/HitObjectLifetimeEntry.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs b/osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs index 4450f026b4..9f2720b7ca 100644 --- a/osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs +++ b/osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs @@ -41,7 +41,22 @@ namespace osu.Game.Rulesets.Objects /// /// Whether and all of its nested objects have been judged. /// - public bool AllJudged => Judged && NestedEntries.All(h => h.AllJudged); + public bool AllJudged + { + get + { + if (!Judged) + return false; + + foreach (var entry in NestedEntries) + { + if (!entry.AllJudged) + return false; + } + + return true; + } + } private readonly IBindable startTimeBindable = new BindableDouble(); From 9e3defebda1d446f815cb0cae6618f822ba482d2 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 25 Feb 2024 19:05:40 +0300 Subject: [PATCH 189/508] Remove unused using --- osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs b/osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs index 9f2720b7ca..4962ac13b5 100644 --- a/osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs +++ b/osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using osu.Framework.Bindables; using osu.Framework.Graphics.Performance; using osu.Game.Rulesets.Judgements; From 5c049feca1e855daca7499b2e6bfb6482c99fe8a Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 25 Feb 2024 21:18:15 +0300 Subject: [PATCH 190/508] Fix advanced stats in beatmap info overlay showing "key count" on non-mania beatmaps --- osu.Game/Overlays/BeatmapSet/Details.cs | 30 ++++++++++++------- .../Screens/Select/Details/AdvancedStats.cs | 29 ++++++------------ osu.Game/Screens/Select/SongSelect.cs | 7 ++++- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Details.cs b/osu.Game/Overlays/BeatmapSet/Details.cs index cf78f605aa..d656a6b14b 100644 --- a/osu.Game/Overlays/BeatmapSet/Details.cs +++ b/osu.Game/Overlays/BeatmapSet/Details.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.BeatmapSet.Buttons; +using osu.Game.Rulesets; using osu.Game.Screens.Select.Details; using osuTK; @@ -33,10 +34,10 @@ namespace osu.Game.Overlays.BeatmapSet { if (value == beatmapSet) return; - beatmapSet = value; + basic.BeatmapSet = preview.BeatmapSet = beatmapSet = value; - basic.BeatmapSet = preview.BeatmapSet = BeatmapSet; - updateDisplay(); + if (IsLoaded) + updateDisplay(); } } @@ -50,13 +51,10 @@ namespace osu.Game.Overlays.BeatmapSet if (value == beatmapInfo) return; basic.BeatmapInfo = advanced.BeatmapInfo = beatmapInfo = value; - } - } - private void updateDisplay() - { - Ratings.Ratings = BeatmapSet?.Ratings; - ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0; + if (IsLoaded) + updateDisplay(); + } } public Details() @@ -101,12 +99,22 @@ namespace osu.Game.Overlays.BeatmapSet }; } - [BackgroundDependencyLoader] - private void load() + [Resolved] + private RulesetStore rulesets { get; set; } + + protected override void LoadComplete() { + base.LoadComplete(); updateDisplay(); } + private void updateDisplay() + { + Ratings.Ratings = BeatmapSet?.Ratings; + ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0; + advanced.Ruleset.Value = rulesets.GetRuleset(beatmapInfo?.Ruleset.OnlineID ?? 0); + } + private partial class DetailBox : Container { private readonly Container content; diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index 0d68a0ec3c..74276795d2 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -38,11 +38,6 @@ namespace osu.Game.Screens.Select.Details [Resolved] private IBindable> mods { get; set; } - [Resolved] - private OsuGameBase game { get; set; } - - private IBindable gameRuleset; - protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate; private readonly StatisticRow starDifficulty; @@ -64,6 +59,8 @@ namespace osu.Game.Screens.Select.Details } } + public Bindable Ruleset { get; } = new Bindable(); + public AdvancedStats(int columns = 1) { switch (columns) @@ -137,12 +134,7 @@ namespace osu.Game.Screens.Select.Details { base.LoadComplete(); - // the cached ruleset bindable might be a decoupled bindable provided by SongSelect, - // which we can't rely on in combination with the game-wide selected mods list, - // since mods could be updated to the new ruleset instances while the decoupled bindable is held behind, - // therefore resulting in performing difficulty calculation with invalid states. - gameRuleset = game.Ruleset.GetBoundCopy(); - gameRuleset.BindValueChanged(_ => updateStatistics()); + Ruleset.BindValueChanged(_ => updateStatistics()); mods.BindValueChanged(modsChanged, true); } @@ -169,8 +161,6 @@ namespace osu.Game.Screens.Select.Details IBeatmapDifficultyInfo baseDifficulty = BeatmapInfo?.Difficulty; BeatmapDifficulty adjustedDifficulty = null; - IRulesetInfo ruleset = gameRuleset?.Value ?? beatmapInfo.Ruleset; - if (baseDifficulty != null) { BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(baseDifficulty); @@ -180,24 +170,24 @@ namespace osu.Game.Screens.Select.Details adjustedDifficulty = originalDifficulty; - if (gameRuleset != null) + if (Ruleset.Value != null) { double rate = 1; foreach (var mod in mods.Value.OfType()) rate = mod.ApplyToRate(0, rate); - adjustedDifficulty = ruleset.CreateInstance().GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); + adjustedDifficulty = Ruleset.Value.CreateInstance().GetRateAdjustedDisplayDifficulty(originalDifficulty, rate); TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty); } } - switch (ruleset.OnlineID) + switch (Ruleset.Value?.OnlineID) { case 3: // Account for mania differences locally for now. // Eventually this should be handled in a more modular way, allowing rulesets to return arbitrary difficulty attributes. - ILegacyRuleset legacyRuleset = (ILegacyRuleset)ruleset.CreateInstance(); + ILegacyRuleset legacyRuleset = (ILegacyRuleset)Ruleset.Value.CreateInstance(); // For the time being, the key count is static no matter what, because: // a) The method doesn't have knowledge of the active keymods. Doing so may require considerations for filtering. @@ -206,7 +196,6 @@ namespace osu.Game.Screens.Select.Details FirstValue.Title = BeatmapsetsStrings.ShowStatsCsMania; FirstValue.Value = (keyCount, keyCount); - break; default: @@ -240,8 +229,8 @@ namespace osu.Game.Screens.Select.Details starDifficultyCancellationSource = new CancellationTokenSource(); - var normalStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, gameRuleset.Value, null, starDifficultyCancellationSource.Token); - var moddedStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, gameRuleset.Value, mods.Value, starDifficultyCancellationSource.Token); + var normalStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, Ruleset.Value, null, starDifficultyCancellationSource.Token); + var moddedStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, Ruleset.Value, mods.Value, starDifficultyCancellationSource.Token); Task.WhenAll(normalStarDifficultyTask, moddedStarDifficultyTask).ContinueWith(_ => Schedule(() => { diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index a603934a9d..15469fad5b 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -286,7 +286,7 @@ namespace osu.Game.Screens.Select AutoSizeAxes = Axes.Y, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Padding = new MarginPadding(10) + Padding = new MarginPadding(10), }, } }, @@ -585,6 +585,11 @@ namespace osu.Game.Screens.Select beatmapInfoPrevious = beatmap; } + // we can't run this in the debounced run due to the selected mods bindable not being debounced, + // since mods could be updated to the new ruleset instances while the decoupled bindable is held behind, + // therefore resulting in performing difficulty calculation with invalid states. + advancedStats.Ruleset.Value = ruleset; + void run() { // clear pending task immediately to track any potential nested debounce operation. From b30a6d522462331e20043f0bada10186a3315196 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 25 Feb 2024 21:23:09 +0300 Subject: [PATCH 191/508] Adjust existing test coverage --- .../SongSelect/TestSceneAdvancedStats.cs | 49 ++----------------- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs index 4bb2b557ff..3b89c70a63 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneAdvancedStats.cs @@ -37,15 +37,9 @@ namespace osu.Game.Tests.Visual.SongSelect [SetUp] public void Setup() => Schedule(() => Child = advancedStats = new TestAdvancedStats { - Width = 500 + Width = 500, }); - [SetUpSteps] - public void SetUpSteps() - { - AddStep("reset game ruleset", () => Ruleset.Value = new OsuRuleset().RulesetInfo); - } - private BeatmapInfo exampleBeatmapInfo => new BeatmapInfo { Ruleset = rulesets.AvailableRulesets.First(), @@ -74,45 +68,12 @@ namespace osu.Game.Tests.Visual.SongSelect } [Test] - public void TestManiaFirstBarTextManiaBeatmap() + public void TestFirstBarText() { - AddStep("set game ruleset to mania", () => Ruleset.Value = new ManiaRuleset().RulesetInfo); - - AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo - { - Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException("osu!mania ruleset not found"), - Difficulty = new BeatmapDifficulty - { - CircleSize = 5, - DrainRate = 4.3f, - OverallDifficulty = 4.5f, - ApproachRate = 3.1f - }, - StarRating = 8 - }); - - AddAssert("first bar text is correct", () => advancedStats.ChildrenOfType().First().Text == BeatmapsetsStrings.ShowStatsCsMania); - } - - [Test] - public void TestManiaFirstBarTextConvert() - { - AddStep("set game ruleset to mania", () => Ruleset.Value = new ManiaRuleset().RulesetInfo); - - AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo - { - Ruleset = new OsuRuleset().RulesetInfo, - Difficulty = new BeatmapDifficulty - { - CircleSize = 5, - DrainRate = 4.3f, - OverallDifficulty = 4.5f, - ApproachRate = 3.1f - }, - StarRating = 8 - }); - + AddStep("set ruleset to mania", () => advancedStats.Ruleset.Value = new ManiaRuleset().RulesetInfo); AddAssert("first bar text is correct", () => advancedStats.ChildrenOfType().First().Text == BeatmapsetsStrings.ShowStatsCsMania); + AddStep("set ruleset to osu", () => advancedStats.Ruleset.Value = new OsuRuleset().RulesetInfo); + AddAssert("first bar text is correct", () => advancedStats.ChildrenOfType().First().Text == BeatmapsetsStrings.ShowStatsCs); } [Test] From 4421ff975b330e832ee0405b9171dfeed2255577 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 09:04:39 +0800 Subject: [PATCH 192/508] Add local function to perform iteration to better explain the "why" --- osu.Game/Screens/Play/HUDOverlay.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index f965d3392a..2ec2a011a6 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -258,14 +258,10 @@ namespace osu.Game.Screens.Play Vector2? highestBottomScreenSpace = null; - for (int i = 0; i < mainComponents.Components.Count; i++) - processDrawable(mainComponents.Components[i]); + processDrawables(mainComponents); if (rulesetComponents != null) - { - for (int i = 0; i < rulesetComponents.Components.Count; i++) - processDrawable(rulesetComponents.Components[i]); - } + processDrawables(rulesetComponents); if (lowestTopScreenSpaceRight.HasValue) topRightElements.Y = MathHelper.Clamp(ToLocalSpace(new Vector2(0, lowestTopScreenSpaceRight.Value)).Y, 0, DrawHeight - topRightElements.DrawHeight); @@ -282,6 +278,14 @@ namespace osu.Game.Screens.Play else bottomRightElements.Y = 0; + void processDrawables(SkinComponentsContainer components) + { + // Avoid using foreach due to missing GetEnumerator implementation. + // See https://github.com/ppy/osu-framework/blob/e10051e6643731e393b09de40a3a3d209a545031/osu.Framework/Bindables/IBindableList.cs#L41-L44. + for (int i = 0; i < components.Components.Count; i++) + processDrawable(components.Components[i]); + } + void processDrawable(ISerialisableDrawable element) { // Cast can be removed when IDrawable interface includes Anchor / RelativeSizeAxes. From 3502ec456d0131f4f6c1c9faabf01e6197a16ee1 Mon Sep 17 00:00:00 2001 From: Detze <92268414+Detze@users.noreply.github.com> Date: Mon, 26 Feb 2024 04:36:09 +0100 Subject: [PATCH 193/508] Match stable's slider border thickness more closely --- osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs index b39092a467..6bf6776617 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy protected new float CalculatedBorderPortion // Roughly matches osu!stable's slider border portions. - => base.CalculatedBorderPortion * 0.77f; + => base.CalculatedBorderPortion * 0.84f; protected override Color4 ColourAt(float position) { From 4c744ccb698e9f41cc350fcde45159a30ec52944 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 14:11:54 +0800 Subject: [PATCH 194/508] Fix "Use current" snap not working Regressed with https://github.com/ppy/osu/pull/27249. I was suspicious of this specific operation at the time but didn't test properly. --- osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs b/osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs index b2f38662cc..8bff5fe6ac 100644 --- a/osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs +++ b/osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs @@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Edit if (objTime >= editorClock.CurrentTime) continue; - if (objTime > lastBefore?.StartTime) + if (lastBefore == null || objTime > lastBefore?.StartTime) lastBefore = entry.Value.HitObject; } @@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.Edit if (objTime < editorClock.CurrentTime) continue; - if (objTime < firstAfter?.StartTime) + if (firstAfter == null || objTime < firstAfter?.StartTime) firstAfter = entry.Value.HitObject; } From 9a46e738bdf86cb0f8495e6ef69f5cc8a6d5456c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 15:45:29 +0800 Subject: [PATCH 195/508] Fix inspections --- osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs b/osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs index 8bff5fe6ac..62ad2ce7e9 100644 --- a/osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs +++ b/osu.Game/Rulesets/Edit/ComposerDistanceSnapProvider.cs @@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Edit if (objTime >= editorClock.CurrentTime) continue; - if (lastBefore == null || objTime > lastBefore?.StartTime) + if (lastBefore == null || objTime > lastBefore.StartTime) lastBefore = entry.Value.HitObject; } @@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.Edit if (objTime < editorClock.CurrentTime) continue; - if (firstAfter == null || objTime < firstAfter?.StartTime) + if (firstAfter == null || objTime < firstAfter.StartTime) firstAfter = entry.Value.HitObject; } From 8962be2ed54f8431d29d6558aa8eacf28e467707 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 17:24:04 +0800 Subject: [PATCH 196/508] Allow better menu navigation using same hotkey to progress to destination As touched on in https://github.com/ppy/osu/discussions/27102. You can now use: - `L L L` to get to playlists - `M M M` to get to multiplayer - `S` to get to settings --- osu.Game/Screens/Menu/ButtonSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index d742d2377f..15a2740160 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -102,7 +102,7 @@ namespace osu.Game.Screens.Menu buttonArea.AddRange(new Drawable[] { - new MainMenuButton(ButtonSystemStrings.Settings, string.Empty, OsuIcon.Settings, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O), + new MainMenuButton(ButtonSystemStrings.Settings, string.Empty, OsuIcon.Settings, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O, Key.S), backButton = new MainMenuButton(ButtonSystemStrings.Back, @"back-to-top", OsuIcon.PrevCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel, -WEDGE_WIDTH) { @@ -132,11 +132,11 @@ namespace osu.Game.Screens.Menu buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Playlists, @"button-default-select", OsuIcon.Tournament, new Color4(94, 63, 186, 255), onPlaylists, 0, Key.L)); buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play); - buttonsEdit.Add(new MainMenuButton(EditorStrings.BeatmapEditor.ToLower(), @"button-default-select", OsuIcon.Beatmap, new Color4(238, 170, 0, 255), () => OnEditBeatmap?.Invoke(), WEDGE_WIDTH, Key.B)); + buttonsEdit.Add(new MainMenuButton(EditorStrings.BeatmapEditor.ToLower(), @"button-default-select", OsuIcon.Beatmap, new Color4(238, 170, 0, 255), () => OnEditBeatmap?.Invoke(), WEDGE_WIDTH, Key.B, Key.E)); buttonsEdit.Add(new MainMenuButton(SkinEditorStrings.SkinEditor.ToLower(), @"button-default-select", OsuIcon.SkinB, new Color4(220, 160, 0, 255), () => OnEditSkin?.Invoke(), 0, Key.S)); buttonsEdit.ForEach(b => b.VisibleState = ButtonSystemState.Edit); - buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Play, @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P)); + buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Play, @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P, Key.M, Key.L)); buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Edit, @"button-play-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => State = ButtonSystemState.Edit, 0, Key.E)); buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Browse, @"button-default-select", OsuIcon.Beatmap, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0, Key.B, Key.D)); From 115d82664bb0a3271e7593dacce987557a2ff098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 26 Feb 2024 10:37:03 +0100 Subject: [PATCH 197/508] Assert proportional scaling rather than assume average Because if scaling is ever actually non-proportional then this should be somewhat loud. Also use the absolute value to prevent funny things happening if/when someone does negative scale. --- osu.Game/Rulesets/Mods/ModFlashlight.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs index d714cd3c85..144842def0 100644 --- a/osu.Game/Rulesets/Mods/ModFlashlight.cs +++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Diagnostics; using System.Runtime.InteropServices; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -13,6 +14,7 @@ using osu.Framework.Graphics.Shaders; using osu.Framework.Graphics.Shaders.Types; using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; +using osu.Framework.Utils; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.OpenGL.Vertices; @@ -151,9 +153,10 @@ namespace osu.Game.Rulesets.Mods if (GetPlayfieldScale != null) { Vector2 playfieldScale = GetPlayfieldScale(); - float rulesetScaleAvg = (playfieldScale.X + playfieldScale.Y) / 2f; - size *= rulesetScaleAvg; + Debug.Assert(Precision.AlmostEquals(Math.Abs(playfieldScale.X), Math.Abs(playfieldScale.Y)), + @"Playfield has non-proportional scaling. Flashlight implementations should be revisited with regard to balance."); + size *= Math.Abs(playfieldScale.X); } if (isBreakTime.Value) From 8e336610d090b2d1f94239620c336a7e0854fc34 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 18:31:36 +0800 Subject: [PATCH 198/508] Add xmldoc explaining `Ruleset` bindable's usage --- osu.Game/Screens/Select/Details/AdvancedStats.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index 74276795d2..1aba977f44 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -59,6 +59,13 @@ namespace osu.Game.Screens.Select.Details } } + /// + /// Ruleset to be used for certain elements of display. + /// When set, this will override the set 's own ruleset. + /// + /// + /// No checks are done as to whether the ruleset specified is valid for the currently . + /// public Bindable Ruleset { get; } = new Bindable(); public AdvancedStats(int columns = 1) From 8966ea2fa3a81cd567aeacbbee60e857af7d9520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 26 Feb 2024 11:59:57 +0100 Subject: [PATCH 199/508] Add test coverage --- ...tSceneHitObjectComposerDistanceSnapping.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/osu.Game.Tests/Editing/TestSceneHitObjectComposerDistanceSnapping.cs b/osu.Game.Tests/Editing/TestSceneHitObjectComposerDistanceSnapping.cs index 463287fb35..12b7dbbf12 100644 --- a/osu.Game.Tests/Editing/TestSceneHitObjectComposerDistanceSnapping.cs +++ b/osu.Game.Tests/Editing/TestSceneHitObjectComposerDistanceSnapping.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -17,6 +18,7 @@ using osu.Game.Rulesets.Osu.Edit; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Screens.Edit; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Tests.Editing { @@ -228,6 +230,28 @@ namespace osu.Game.Tests.Editing assertSnappedDistance(400, 400); } + [Test] + public void TestUseCurrentSnap() + { + AddStep("add objects to beatmap", () => + { + editorBeatmap.Add(new HitCircle { StartTime = 1000 }); + editorBeatmap.Add(new HitCircle { Position = new Vector2(100), StartTime = 2000 }); + }); + + AddStep("hover use current snap button", () => InputManager.MoveMouseTo(composer.ChildrenOfType().Single())); + AddUntilStep("use current snap expanded", () => composer.ChildrenOfType().Single().Expanded.Value, () => Is.True); + + AddStep("seek before first object", () => EditorClock.Seek(0)); + AddUntilStep("use current snap not available", () => composer.ChildrenOfType().Single().Enabled.Value, () => Is.False); + + AddStep("seek to between objects", () => EditorClock.Seek(1500)); + AddUntilStep("use current snap available", () => composer.ChildrenOfType().Single().Enabled.Value, () => Is.True); + + AddStep("seek after last object", () => EditorClock.Seek(2500)); + AddUntilStep("use current snap not available", () => composer.ChildrenOfType().Single().Enabled.Value, () => Is.False); + } + private void assertSnapDistance(float expectedDistance, HitObject? referenceObject, bool includeSliderVelocity) => AddAssert($"distance is {expectedDistance}", () => composer.DistanceSnapProvider.GetBeatSnapDistanceAt(referenceObject ?? new HitObject(), includeSliderVelocity), () => Is.EqualTo(expectedDistance).Within(Precision.FLOAT_EPSILON)); From 6dbba705b3127757dbb36f16911790d776934527 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 26 Feb 2024 12:27:02 +0100 Subject: [PATCH 200/508] Refine uninstall logic to account for legacy windows features --- osu.Desktop/Windows/WindowsAssociationManager.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 4bb8e57c9d..490faab632 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -222,12 +222,21 @@ namespace osu.Desktop.Windows programKey?.SetValue(null, description); } + /// + /// Uninstalls the file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/shell/fa-file-types#deleting-registry-information-during-uninstallation + /// public void Uninstall(RegistryKey classes) { - // importantly, we don't delete the default program entry because some other program could have taken it. + using (var extensionKey = classes.OpenSubKey(Extension, true)) + { + // clear our default association so that Explorer doesn't show the raw programId to users + // the null/(Default) entry is used for both ProdID association and as a fallback friendly name, for legacy reasons + if (extensionKey?.GetValue(null) is string s && s == programId) + extensionKey.SetValue(null, string.Empty); - using (var extensionKey = classes.OpenSubKey($@"{Extension}\OpenWithProgIds", true)) - extensionKey?.DeleteValue(programId, throwOnMissingValue: false); + using (var openWithKey = extensionKey?.CreateSubKey(@"OpenWithProgIds")) + openWithKey?.DeleteValue(programId, throwOnMissingValue: false); + } classes.DeleteSubKeyTree(programId, throwOnMissingSubKey: false); } From f2807470efc66a560dbd09da75be2ff70bf83b1d Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 26 Feb 2024 13:03:23 +0100 Subject: [PATCH 201/508] Inline `EXE_PATH` usage --- osu.Desktop/Windows/WindowsAssociationManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 490faab632..3fd566edab 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -136,10 +136,10 @@ namespace osu.Desktop.Windows Debug.Assert(classes != null); foreach (var association in file_associations) - association.Install(classes, EXE_PATH); + association.Install(classes); foreach (var association in uri_associations) - association.Install(classes, EXE_PATH); + association.Install(classes); } private static void updateDescriptions(LocalisationManager? localisation) @@ -192,7 +192,7 @@ namespace osu.Desktop.Windows /// /// Installs a file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/com/-progid--key /// - public void Install(RegistryKey classes, string exePath) + public void Install(RegistryKey classes) { // register a program id for the given extension using (var programKey = classes.CreateSubKey(programId)) @@ -201,7 +201,7 @@ namespace osu.Desktop.Windows defaultIconKey.SetValue(null, IconPath); using (var openCommandKey = programKey.CreateSubKey(SHELL_OPEN_COMMAND)) - openCommandKey.SetValue(null, $@"""{exePath}"" ""%1"""); + openCommandKey.SetValue(null, $@"""{EXE_PATH}"" ""%1"""); } using (var extensionKey = classes.CreateSubKey(Extension)) @@ -253,7 +253,7 @@ namespace osu.Desktop.Windows /// /// Registers an URI protocol handler in accordance with https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85). /// - public void Install(RegistryKey classes, string exePath) + public void Install(RegistryKey classes) { using (var protocolKey = classes.CreateSubKey(Protocol)) { @@ -263,7 +263,7 @@ namespace osu.Desktop.Windows defaultIconKey.SetValue(null, IconPath); using (var openCommandKey = protocolKey.CreateSubKey(SHELL_OPEN_COMMAND)) - openCommandKey.SetValue(null, $@"""{exePath}"" ""%1"""); + openCommandKey.SetValue(null, $@"""{EXE_PATH}"" ""%1"""); } } From 9b3ec64f411b234391ac653fb319cbb07d1d6fea Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 26 Feb 2024 13:10:37 +0100 Subject: [PATCH 202/508] Inline `HKCU\Software\Classes` usage --- .../Windows/WindowsAssociationManager.cs | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 3fd566edab..2a1aeba7e0 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -108,14 +107,11 @@ namespace osu.Desktop.Windows { try { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); - Debug.Assert(classes != null); - foreach (var association in file_associations) - association.Uninstall(classes); + association.Uninstall(); foreach (var association in uri_associations) - association.Uninstall(classes); + association.Uninstall(); NotifyShellUpdate(); } @@ -132,26 +128,20 @@ namespace osu.Desktop.Windows /// private static void updateAssociations() { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); - Debug.Assert(classes != null); - foreach (var association in file_associations) - association.Install(classes); + association.Install(); foreach (var association in uri_associations) - association.Install(classes); + association.Install(); } private static void updateDescriptions(LocalisationManager? localisation) { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); - Debug.Assert(classes != null); - foreach (var association in file_associations) - association.UpdateDescription(classes, getLocalisedString(association.Description)); + association.UpdateDescription(getLocalisedString(association.Description)); foreach (var association in uri_associations) - association.UpdateDescription(classes, getLocalisedString(association.Description)); + association.UpdateDescription(getLocalisedString(association.Description)); string getLocalisedString(LocalisableString s) { @@ -192,8 +182,11 @@ namespace osu.Desktop.Windows /// /// Installs a file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/com/-progid--key /// - public void Install(RegistryKey classes) + public void Install() { + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) return; + // register a program id for the given extension using (var programKey = classes.CreateSubKey(programId)) { @@ -216,8 +209,11 @@ namespace osu.Desktop.Windows } } - public void UpdateDescription(RegistryKey classes, string description) + public void UpdateDescription(string description) { + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) return; + using (var programKey = classes.OpenSubKey(programId, true)) programKey?.SetValue(null, description); } @@ -225,8 +221,11 @@ namespace osu.Desktop.Windows /// /// Uninstalls the file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/shell/fa-file-types#deleting-registry-information-during-uninstallation /// - public void Uninstall(RegistryKey classes) + public void Uninstall() { + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) return; + using (var extensionKey = classes.OpenSubKey(Extension, true)) { // clear our default association so that Explorer doesn't show the raw programId to users @@ -253,8 +252,11 @@ namespace osu.Desktop.Windows /// /// Registers an URI protocol handler in accordance with https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85). /// - public void Install(RegistryKey classes) + public void Install() { + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) return; + using (var protocolKey = classes.CreateSubKey(Protocol)) { protocolKey.SetValue(URL_PROTOCOL, string.Empty); @@ -267,15 +269,19 @@ namespace osu.Desktop.Windows } } - public void UpdateDescription(RegistryKey classes, string description) + public void UpdateDescription(string description) { + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + if (classes == null) return; + using (var protocolKey = classes.OpenSubKey(Protocol, true)) protocolKey?.SetValue(null, $@"URL:{description}"); } - public void Uninstall(RegistryKey classes) + public void Uninstall() { - classes.DeleteSubKeyTree(Protocol, throwOnMissingSubKey: false); + using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + classes?.DeleteSubKeyTree(Protocol, throwOnMissingSubKey: false); } } } From 3e9425fdf2d57dbeff8819bca208a63cb947eda9 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 26 Feb 2024 22:12:04 +0900 Subject: [PATCH 203/508] Adjust API of HighPerformanceSession + rename --- osu.Game/OsuGame.cs | 4 +- .../Performance/HighPerformanceSession.cs | 42 ------------------- .../HighPerformanceSessionManager.cs | 34 +++++++++++++++ 3 files changed, 36 insertions(+), 44 deletions(-) delete mode 100644 osu.Game/Performance/HighPerformanceSession.cs create mode 100644 osu.Game/Performance/HighPerformanceSessionManager.cs diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 9ffa88947b..f23a78d2dc 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -792,7 +792,7 @@ namespace osu.Game protected virtual UpdateManager CreateUpdateManager() => new UpdateManager(); - protected virtual HighPerformanceSession CreateHighPerformanceSession() => new HighPerformanceSession(); + protected virtual HighPerformanceSessionManager CreateHighPerformanceSessionManager() => new HighPerformanceSessionManager(); protected override Container CreateScalingContainer() => new ScalingContainer(ScalingMode.Everything); @@ -1088,7 +1088,7 @@ namespace osu.Game loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true); loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true); - loadComponentSingleFile(CreateHighPerformanceSession(), Add); + loadComponentSingleFile(CreateHighPerformanceSessionManager(), Add, true); loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add); diff --git a/osu.Game/Performance/HighPerformanceSession.cs b/osu.Game/Performance/HighPerformanceSession.cs deleted file mode 100644 index 07b5e7da98..0000000000 --- a/osu.Game/Performance/HighPerformanceSession.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Allocation; -using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Game.Screens.Play; - -namespace osu.Game.Performance -{ - public partial class HighPerformanceSession : Component - { - private readonly IBindable localUserPlaying = new Bindable(); - - [BackgroundDependencyLoader] - private void load(ILocalUserPlayInfo localUserInfo) - { - localUserPlaying.BindTo(localUserInfo.IsPlaying); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - localUserPlaying.BindValueChanged(playing => - { - if (playing.NewValue) - EnableHighPerformanceSession(); - else - DisableHighPerformanceSession(); - }, true); - } - - protected virtual void EnableHighPerformanceSession() - { - } - - protected virtual void DisableHighPerformanceSession() - { - } - } -} diff --git a/osu.Game/Performance/HighPerformanceSessionManager.cs b/osu.Game/Performance/HighPerformanceSessionManager.cs new file mode 100644 index 0000000000..8a49ba0dac --- /dev/null +++ b/osu.Game/Performance/HighPerformanceSessionManager.cs @@ -0,0 +1,34 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Runtime; +using osu.Framework.Allocation; +using osu.Framework.Graphics; + +namespace osu.Game.Performance +{ + public partial class HighPerformanceSessionManager : Component + { + private GCLatencyMode originalGCMode; + + public IDisposable BeginSession() + { + EnableHighPerformanceSession(); + return new InvokeOnDisposal(this, static m => m.DisableHighPerformanceSession()); + } + + protected virtual void EnableHighPerformanceSession() + { + originalGCMode = GCSettings.LatencyMode; + GCSettings.LatencyMode = GCLatencyMode.LowLatency; + GC.Collect(0); + } + + protected virtual void DisableHighPerformanceSession() + { + if (GCSettings.LatencyMode == GCLatencyMode.LowLatency) + GCSettings.LatencyMode = originalGCMode; + } + } +} From 7a96cf12893c3e5d5d6ec2b679a07230e70efe29 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 21:15:44 +0800 Subject: [PATCH 204/508] Expose `AudioFilter.IsAttached` publicly --- osu.Game/Audio/Effects/AudioFilter.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game/Audio/Effects/AudioFilter.cs b/osu.Game/Audio/Effects/AudioFilter.cs index c8673372d7..bfa9b31242 100644 --- a/osu.Game/Audio/Effects/AudioFilter.cs +++ b/osu.Game/Audio/Effects/AudioFilter.cs @@ -17,12 +17,15 @@ namespace osu.Game.Audio.Effects /// public const int MAX_LOWPASS_CUTOFF = 22049; // nyquist - 1hz + /// + /// Whether this filter is currently attached to the audio track and thus applying an adjustment. + /// + public bool IsAttached { get; private set; } + private readonly AudioMixer mixer; private readonly BQFParameters filter; private readonly BQFType type; - private bool isAttached; - private readonly Cached filterApplication = new Cached(); private int cutoff; @@ -132,22 +135,22 @@ namespace osu.Game.Audio.Effects private void ensureAttached() { - if (isAttached) + if (IsAttached) return; Debug.Assert(!mixer.Effects.Contains(filter)); mixer.Effects.Add(filter); - isAttached = true; + IsAttached = true; } private void ensureDetached() { - if (!isAttached) + if (!IsAttached) return; Debug.Assert(mixer.Effects.Contains(filter)); mixer.Effects.Remove(filter); - isAttached = false; + IsAttached = false; } protected override void Dispose(bool isDisposing) From c686dfd36164f6eb980f0d96e64700dad95cf8f2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 21:16:15 +0800 Subject: [PATCH 205/508] Apply safeties for `AudioFilter` usage around drawables which go non-present --- .../Collections/ManageCollectionsDialog.cs | 5 +++ osu.Game/Overlays/DialogOverlay.cs | 8 +++-- osu.Game/Screens/Play/PlayerLoader.cs | 35 +++++++++++++------ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/osu.Game/Collections/ManageCollectionsDialog.cs b/osu.Game/Collections/ManageCollectionsDialog.cs index cc0f23d030..16645d6796 100644 --- a/osu.Game/Collections/ManageCollectionsDialog.cs +++ b/osu.Game/Collections/ManageCollectionsDialog.cs @@ -115,6 +115,11 @@ namespace osu.Game.Collections }; } + public override bool IsPresent => base.IsPresent + // Safety for low pass filter potentially getting stuck in applied state due to + // transforms on `this` causing children to no longer be updated. + || lowPassFilter.IsAttached; + protected override void PopIn() { lowPassFilter.CutoffTo(300, 100, Easing.OutCubic); diff --git a/osu.Game/Overlays/DialogOverlay.cs b/osu.Game/Overlays/DialogOverlay.cs index a85f1ecbcd..9ad532ae50 100644 --- a/osu.Game/Overlays/DialogOverlay.cs +++ b/osu.Game/Overlays/DialogOverlay.cs @@ -27,6 +27,12 @@ namespace osu.Game.Overlays public PopupDialog CurrentDialog { get; private set; } + public override bool IsPresent => Scheduler.HasPendingTasks + || dialogContainer.Children.Count > 0 + // Safety for low pass filter potentially getting stuck in applied state due to + // transforms on `this` causing children to no longer be updated. + || lowPassFilter.IsAttached; + public DialogOverlay() { AutoSizeAxes = Axes.Y; @@ -95,8 +101,6 @@ namespace osu.Game.Overlays } } - public override bool IsPresent => Scheduler.HasPendingTasks || dialogContainer.Children.Count > 0; - protected override bool BlockNonPositionalInput => true; protected override void PopIn() diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index aa62256348..aef7a0739e 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -78,8 +78,8 @@ namespace osu.Game.Screens.Play private readonly BindableDouble volumeAdjustment = new BindableDouble(1); - private AudioFilter lowPassFilter = null!; - private AudioFilter highPassFilter = null!; + private AudioFilter? lowPassFilter; + private AudioFilter? highPassFilter; private SkinnableSound sampleRestart = null!; @@ -158,7 +158,7 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader] - private void load(SessionStatics sessionStatics, AudioManager audio, OsuConfigManager config) + private void load(SessionStatics sessionStatics, OsuConfigManager config) { muteWarningShownOnce = sessionStatics.GetBindable(Static.MutedAudioNotificationShownOnce); batteryWarningShownOnce = sessionStatics.GetBindable(Static.LowBatteryNotificationShownOnce); @@ -205,8 +205,6 @@ namespace osu.Game.Screens.Play }, }, idleTracker = new IdleTracker(750), - lowPassFilter = new AudioFilter(audio.TrackMixer), - highPassFilter = new AudioFilter(audio.TrackMixer, BQFType.HighPass), sampleRestart = new SkinnableSound(new SampleInfo(@"Gameplay/restart", @"pause-retry-click")) }; @@ -284,8 +282,9 @@ namespace osu.Game.Screens.Play // stop the track before removing adjustment to avoid a volume spike. Beatmap.Value.Track.Stop(); Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment); - lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); - highPassFilter.CutoffTo(0); + + lowPassFilter?.RemoveAndDisposeImmediately(); + highPassFilter?.RemoveAndDisposeImmediately(); } public override bool OnExiting(ScreenExitEvent e) @@ -425,6 +424,12 @@ namespace osu.Game.Screens.Play settingsScroll.FadeInFromZero(500, Easing.Out) .MoveToX(0, 500, Easing.OutQuint); + AddRangeInternal(new[] + { + lowPassFilter = new AudioFilter(audioManager.TrackMixer), + highPassFilter = new AudioFilter(audioManager.TrackMixer, BQFType.HighPass), + }); + lowPassFilter.CutoffTo(1000, 650, Easing.OutQuint); highPassFilter.CutoffTo(300).Then().CutoffTo(0, 1250); // 1250 is to line up with the appearance of MetadataInfo (750 delay + 500 fade-in) @@ -437,13 +442,23 @@ namespace osu.Game.Screens.Play content.StopTracking(); content.ScaleTo(0.7f, CONTENT_OUT_DURATION * 2, Easing.OutQuint); - content.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint); + content.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint) + // Safety for filter potentially getting stuck in applied state due to + // transforms on `this` causing children to no longer be updated. + .OnComplete(_ => + { + highPassFilter?.RemoveAndDisposeImmediately(); + highPassFilter = null; + + lowPassFilter?.RemoveAndDisposeImmediately(); + lowPassFilter = null; + }); settingsScroll.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint) .MoveToX(settingsScroll.DrawWidth, CONTENT_OUT_DURATION * 2, Easing.OutQuint); - lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, CONTENT_OUT_DURATION); - highPassFilter.CutoffTo(0, CONTENT_OUT_DURATION); + lowPassFilter?.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF, CONTENT_OUT_DURATION); + highPassFilter?.CutoffTo(0, CONTENT_OUT_DURATION); } private void pushWhenLoaded() From bfb5098238b451fc768ae855854ac9b925b57816 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 26 Feb 2024 22:13:15 +0900 Subject: [PATCH 206/508] Use high performance session during gameplay --- .../Performance/HighPerformanceSessionManager.cs | 4 ++++ osu.Game/Screens/Play/PlayerLoader.cs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/osu.Game/Performance/HighPerformanceSessionManager.cs b/osu.Game/Performance/HighPerformanceSessionManager.cs index 8a49ba0dac..c5146933b7 100644 --- a/osu.Game/Performance/HighPerformanceSessionManager.cs +++ b/osu.Game/Performance/HighPerformanceSessionManager.cs @@ -22,6 +22,8 @@ namespace osu.Game.Performance { originalGCMode = GCSettings.LatencyMode; GCSettings.LatencyMode = GCLatencyMode.LowLatency; + + // Without doing this, the new GC mode won't kick in until the next GC, which could be at a more noticeable point in time. GC.Collect(0); } @@ -29,6 +31,8 @@ namespace osu.Game.Performance { if (GCSettings.LatencyMode == GCLatencyMode.LowLatency) GCSettings.LatencyMode = originalGCMode; + + // No GC.Collect() as we were already collecting at a higher frequency in the old mode. } } } diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index aa62256348..fe235dd56d 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -25,6 +25,7 @@ using osu.Game.Input; using osu.Game.Localisation; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; +using osu.Game.Performance; using osu.Game.Screens.Menu; using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Skinning; @@ -140,6 +141,8 @@ namespace osu.Game.Screens.Play private bool quickRestart; + private IDisposable? highPerformanceSession; + [Resolved] private INotificationOverlay? notificationOverlay { get; set; } @@ -152,6 +155,9 @@ namespace osu.Game.Screens.Play [Resolved] private BatteryInfo? batteryInfo { get; set; } + [Resolved] + private HighPerformanceSessionManager? highPerformanceSessionManager { get; set; } + public PlayerLoader(Func createPlayer) { this.createPlayer = createPlayer; @@ -264,6 +270,9 @@ namespace osu.Game.Screens.Play Debug.Assert(CurrentPlayer != null); + highPerformanceSession?.Dispose(); + highPerformanceSession = null; + // prepare for a retry. CurrentPlayer = null; playerConsumed = false; @@ -304,6 +313,9 @@ namespace osu.Game.Screens.Play BackgroundBrightnessReduction = false; Beatmap.Value.Track.RemoveAdjustment(AdjustableProperty.Volume, volumeAdjustment); + highPerformanceSession?.Dispose(); + highPerformanceSession = null; + return base.OnExiting(e); } @@ -463,6 +475,10 @@ namespace osu.Game.Screens.Play if (scheduledPushPlayer != null) return; + // Now that everything's been loaded, we can safely switch to a higher performance session without incurring too much overhead. + // Doing this prior to the game being pushed gives us a bit of time to stabilise into the high performance mode before gameplay starts. + highPerformanceSession ??= highPerformanceSessionManager?.BeginSession(); + scheduledPushPlayer = Scheduler.AddDelayed(() => { // ensure that once we have reached this "point of no return", readyForPush will be false for all future checks (until a new player instance is prepared). From d6622c1756c57569f85a1b1df25f7042e7515a8a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 22:24:35 +0800 Subject: [PATCH 207/508] Add test coverage of fast menu keypresses failing to register --- .../Navigation/TestSceneButtonSystemNavigation.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/osu.Game.Tests/Visual/Navigation/TestSceneButtonSystemNavigation.cs b/osu.Game.Tests/Visual/Navigation/TestSceneButtonSystemNavigation.cs index c6d67f2bc6..43b160250c 100644 --- a/osu.Game.Tests/Visual/Navigation/TestSceneButtonSystemNavigation.cs +++ b/osu.Game.Tests/Visual/Navigation/TestSceneButtonSystemNavigation.cs @@ -28,6 +28,21 @@ namespace osu.Game.Tests.Visual.Navigation AddAssert("state is top level", () => buttons.State == ButtonSystemState.TopLevel); } + [Test] + public void TestFastShortcutKeys() + { + AddAssert("state is initial", () => buttons.State == ButtonSystemState.Initial); + + AddStep("press P three times", () => + { + InputManager.Key(Key.P); + InputManager.Key(Key.P); + InputManager.Key(Key.P); + }); + + AddAssert("entered song select", () => Game.ScreenStack.CurrentScreen is PlaySongSelect); + } + [Test] public void TestShortcutKeys() { From 4c6e8a606fbb669c5949910bc2026435180e3eb8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Feb 2024 22:22:43 +0800 Subject: [PATCH 208/508] Fix main menu eating keys if user presses too fast --- osu.Game/Screens/Menu/MainMenuButton.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Menu/MainMenuButton.cs b/osu.Game/Screens/Menu/MainMenuButton.cs index 422599a4a8..1dc79e9b1a 100644 --- a/osu.Game/Screens/Menu/MainMenuButton.cs +++ b/osu.Game/Screens/Menu/MainMenuButton.cs @@ -64,6 +64,10 @@ namespace osu.Game.Screens.Menu private Sample? sampleHover; private SampleChannel? sampleChannel; + public override bool IsPresent => base.IsPresent + // Allow keyboard interaction based on state rather than waiting for delayed animations. + || state == ButtonState.Expanded; + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos); public MainMenuButton(LocalisableString text, string sampleName, IconUsage symbol, Color4 colour, Action? clickAction = null, float extraWidth = 0, params Key[] triggerKeys) From 8032ce9225950f5fc5d6dba911833e9b3f8afa93 Mon Sep 17 00:00:00 2001 From: Detze <92268414+Detze@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:37:27 +0100 Subject: [PATCH 209/508] Match stable's slider border thickness perfectly --- osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs index 6bf6776617..af82a81e08 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs @@ -26,8 +26,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy private const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS); protected new float CalculatedBorderPortion - // Roughly matches osu!stable's slider border portions. - => base.CalculatedBorderPortion * 0.84f; + // Matches osu!stable's slider border portions. + => 0.109375f; protected override Color4 ColourAt(float position) { From 2b73d816a70fab655cdf7a9f716d6630b333ed54 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 26 Feb 2024 21:26:35 +0300 Subject: [PATCH 210/508] Bring back mod setting tracker in `BeatmapAttributesDisplay` --- osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs | 12 +++++++++++- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 7 +------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs index 7035af1594..c58cf710bd 100644 --- a/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs +++ b/osu.Game/Overlays/Mods/BeatmapAttributesDisplay.cs @@ -13,6 +13,7 @@ using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; +using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -43,6 +44,8 @@ namespace osu.Game.Overlays.Mods public BindableBool Collapsed { get; } = new BindableBool(true); + private ModSettingChangeTracker? modSettingChangeTracker; + [Resolved] private BeatmapDifficultyCache difficultyCache { get; set; } = null!; @@ -97,7 +100,14 @@ namespace osu.Game.Overlays.Mods { base.LoadComplete(); - Mods.BindValueChanged(_ => updateValues()); + Mods.BindValueChanged(_ => + { + modSettingChangeTracker?.Dispose(); + modSettingChangeTracker = new ModSettingChangeTracker(Mods.Value); + modSettingChangeTracker.SettingChanged += _ => updateValues(); + updateValues(); + }, true); + BeatmapInfo.BindValueChanged(_ => updateValues()); Collapsed.BindValueChanged(_ => diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index bf43dc3d9c..b7e2f744fa 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -468,12 +468,7 @@ namespace osu.Game.Overlays.Mods } if (beatmapAttributesDisplay != null) - { - if (!ReferenceEquals(beatmapAttributesDisplay.Mods.Value, mods)) - beatmapAttributesDisplay.Mods.Value = mods; - else - beatmapAttributesDisplay.Mods.TriggerChange(); // mods list may be same but a mod setting has changed, trigger change in that case. - } + beatmapAttributesDisplay.Mods.Value = mods; } private void updateCustomisation() From 3f9fbb931849a5f6276de638e621a1e341149cc3 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 26 Feb 2024 22:25:04 +0300 Subject: [PATCH 211/508] Introduce the concept of `ActiveMods` in mod select overlay and rewrite once more --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 37 +++++++++++++------ .../OnlinePlay/Match/RoomModSelectOverlay.cs | 21 +++-------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index b7e2f744fa..6b80ff6e44 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -42,6 +42,14 @@ namespace osu.Game.Overlays.Mods [Cached] public Bindable> SelectedMods { get; private set; } = new Bindable>(Array.Empty()); + /// + /// Contains a list of mods which should read from to display effects on the selected beatmap. + /// + /// + /// This is different from in screens like online-play rooms, where there are required mods activated from the playlist. + /// + public Bindable> ActiveMods { get; private set; } = new Bindable>(Array.Empty()); + /// /// Contains a dictionary with the current of all mods applicable for the current ruleset. /// @@ -313,22 +321,29 @@ namespace osu.Game.Overlays.Mods if (AllowCustomisation) ((IBindable>)modSettingsArea.SelectedMods).BindTo(SelectedMods); - SelectedMods.BindValueChanged(_ => + SelectedMods.BindValueChanged(mods => { - UpdateOverlayInformation(SelectedMods.Value); + var newMods = ActiveMods.Value.Except(mods.OldValue).Concat(mods.NewValue).ToList(); + ActiveMods.Value = newMods; + updateFromExternalSelection(); updateCustomisation(); + }, true); + + ActiveMods.BindValueChanged(_ => + { + updateOverlayInformation(); modSettingChangeTracker?.Dispose(); if (AllowCustomisation) { - // Importantly, use SelectedMods.Value here (and not the ValueChanged NewValue) as the latter can + // Importantly, use ActiveMods.Value here (and not the ValueChanged NewValue) as the latter can // potentially be stale, due to complexities in the way change trackers work. // // See https://github.com/ppy/osu/pull/23284#issuecomment-1529056988 - modSettingChangeTracker = new ModSettingChangeTracker(SelectedMods.Value); - modSettingChangeTracker.SettingChanged += _ => UpdateOverlayInformation(SelectedMods.Value); + modSettingChangeTracker = new ModSettingChangeTracker(ActiveMods.Value); + modSettingChangeTracker.SettingChanged += _ => updateOverlayInformation(); } }, true); @@ -451,24 +466,24 @@ namespace osu.Game.Overlays.Mods } /// - /// Updates any information displayed on the overlay regarding the effects of the selected mods. + /// Updates any information displayed on the overlay regarding the effects of the active mods. + /// This reads from instead of . /// - /// The list of mods to show effect from. This can be overriden to include effect of mods that are not part of the bindable (e.g. room mods in multiplayer/playlists). - protected virtual void UpdateOverlayInformation(IReadOnlyList mods) + private void updateOverlayInformation() { if (rankingInformationDisplay != null) { double multiplier = 1.0; - foreach (var mod in mods) + foreach (var mod in ActiveMods.Value) multiplier *= mod.ScoreMultiplier; rankingInformationDisplay.ModMultiplier.Value = multiplier; - rankingInformationDisplay.Ranked.Value = mods.All(m => m.Ranked); + rankingInformationDisplay.Ranked.Value = ActiveMods.Value.All(m => m.Ranked); } if (beatmapAttributesDisplay != null) - beatmapAttributesDisplay.Mods.Value = mods; + beatmapAttributesDisplay.Mods.Value = ActiveMods.Value; } private void updateCustomisation() diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs index db7cfe980c..d3fd6de911 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Generic; using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; @@ -10,7 +9,6 @@ using osu.Game.Online.Rooms; using osu.Game.Overlays; using osu.Game.Overlays.Mods; using osu.Game.Rulesets; -using osu.Game.Rulesets.Mods; namespace osu.Game.Screens.OnlinePlay.Match { @@ -22,8 +20,6 @@ namespace osu.Game.Screens.OnlinePlay.Match [Resolved] private RulesetStore rulesets { get; set; } = null!; - private readonly List roomMods = new List(); - public RoomModSelectOverlay() : base(OverlayColourScheme.Plum) { @@ -33,22 +29,17 @@ namespace osu.Game.Screens.OnlinePlay.Match { base.LoadComplete(); - selectedItem.BindValueChanged(_ => + selectedItem.BindValueChanged(v => { - roomMods.Clear(); - - if (selectedItem.Value is PlaylistItem item) + if (v.NewValue is PlaylistItem item) { var rulesetInstance = rulesets.GetRuleset(item.RulesetID)?.CreateInstance(); Debug.Assert(rulesetInstance != null); - roomMods.AddRange(item.RequiredMods.Select(m => m.ToMod(rulesetInstance))); + ActiveMods.Value = item.RequiredMods.Select(m => m.ToMod(rulesetInstance)).Concat(SelectedMods.Value).ToList(); } - - SelectedMods.TriggerChange(); - }); + else + ActiveMods.Value = SelectedMods.Value; + }, true); } - - protected override void UpdateOverlayInformation(IReadOnlyList mods) - => base.UpdateOverlayInformation(roomMods.Concat(mods).ToList()); } } From 2151e0a2947e4c2cc4b5b071c2af1fce852359b5 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 26 Feb 2024 22:25:20 +0300 Subject: [PATCH 212/508] Improve test coverage --- .../TestSceneMultiplayerMatchSubScreen.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs index 4bedc31f38..bdfe01ba09 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerMatchSubScreen.cs @@ -22,6 +22,7 @@ using osu.Game.Overlays; using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Mods; using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Taiko; @@ -303,7 +304,6 @@ namespace osu.Game.Tests.Visual.Multiplayer AllowedMods = new[] { new APIMod(new OsuModFlashlight()), - new APIMod(new OsuModHardRock()), } }); }); @@ -312,8 +312,14 @@ namespace osu.Game.Tests.Visual.Multiplayer AddUntilStep("wait for join", () => RoomJoined); ClickButtonWhenEnabled(); - AddAssert("mod select shows unranked", () => this.ChildrenOfType().Single().Ranked.Value == false); - AddAssert("mod select shows different multiplier", () => !this.ChildrenOfType().Single().ModMultiplier.IsDefault); + AddAssert("mod select shows unranked", () => screen.UserModsSelectOverlay.ChildrenOfType().Single().Ranked.Value == false); + AddAssert("score multiplier = 1.20", () => screen.UserModsSelectOverlay.ChildrenOfType().Single().ModMultiplier.Value, () => Is.EqualTo(1.2).Within(0.01)); + + AddStep("select flashlight", () => screen.UserModsSelectOverlay.ChildrenOfType().Single(m => m.Mod is ModFlashlight).TriggerClick()); + AddAssert("score multiplier = 1.35", () => screen.UserModsSelectOverlay.ChildrenOfType().Single().ModMultiplier.Value, () => Is.EqualTo(1.35).Within(0.01)); + + AddStep("change flashlight setting", () => ((OsuModFlashlight)screen.UserModsSelectOverlay.SelectedMods.Value.Single()).FollowDelay.Value = 1200); + AddAssert("score multiplier = 1.20", () => screen.UserModsSelectOverlay.ChildrenOfType().Single().ModMultiplier.Value, () => Is.EqualTo(1.2).Within(0.01)); } private partial class TestMultiplayerMatchSubScreen : MultiplayerMatchSubScreen From 8363c39da86b4dde7f700ebf3c3a908a4dca945e Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 27 Feb 2024 01:30:20 +0300 Subject: [PATCH 213/508] Revert "Match stable's slider border thickness perfectly" This reverts commit 8032ce9225950f5fc5d6dba911833e9b3f8afa93. --- osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs index af82a81e08..6bf6776617 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs @@ -26,8 +26,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy private const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS); protected new float CalculatedBorderPortion - // Matches osu!stable's slider border portions. - => 0.109375f; + // Roughly matches osu!stable's slider border portions. + => base.CalculatedBorderPortion * 0.84f; protected override Color4 ColourAt(float position) { From e01722a266e887b6032b520ca3f0fcd0011df51e Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 27 Feb 2024 01:30:20 +0300 Subject: [PATCH 214/508] Revert "Match stable's slider border thickness more closely" This reverts commit 3502ec456d0131f4f6c1c9faabf01e6197a16ee1. --- osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs index 6bf6776617..b39092a467 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy protected new float CalculatedBorderPortion // Roughly matches osu!stable's slider border portions. - => base.CalculatedBorderPortion * 0.84f; + => base.CalculatedBorderPortion * 0.77f; protected override Color4 ColourAt(float position) { From 81e6a6d96a0f62f0ce015e232217ee8b207ea76f Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 27 Feb 2024 02:11:32 +0300 Subject: [PATCH 215/508] Rewrite `LegacySliderBody` rendering to perfectly match stable --- .../Skinning/Legacy/LegacySliderBody.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs index b39092a467..264bb3145d 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs @@ -23,29 +23,29 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy private partial class LegacyDrawableSliderPath : DrawableSliderPath { - private const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS); - - protected new float CalculatedBorderPortion - // Roughly matches osu!stable's slider border portions. - => base.CalculatedBorderPortion * 0.77f; - protected override Color4 ColourAt(float position) { - float realBorderPortion = shadow_portion + CalculatedBorderPortion; - float realGradientPortion = 1 - realBorderPortion; - - if (position <= shadow_portion) - return new Color4(0f, 0f, 0f, 0.25f * position / shadow_portion); - - if (position <= realBorderPortion) - return BorderColour; - - position -= realBorderPortion; + const float aa_width = 0.5f / 64f; + const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS); + const float border_portion = 0.1875f; + Color4 shadow = new Color4(0, 0, 0, 0.25f); Color4 outerColour = AccentColour.Darken(0.1f); Color4 innerColour = lighten(AccentColour, 0.5f); - return LegacyUtils.InterpolateNonLinear(position / realGradientPortion, outerColour, innerColour, 0, 1); + if (position <= shadow_portion - aa_width) + return LegacyUtils.InterpolateNonLinear(position, Color4.Black.Opacity(0f), shadow, 0, shadow_portion - aa_width); + + if (position <= shadow_portion + aa_width) + return LegacyUtils.InterpolateNonLinear(position, shadow, BorderColour, shadow_portion - aa_width, shadow_portion + aa_width); + + if (position <= border_portion - aa_width) + return BorderColour; + + if (position <= border_portion + aa_width) + return LegacyUtils.InterpolateNonLinear(position, BorderColour, outerColour, border_portion - aa_width, border_portion + aa_width); + + return LegacyUtils.InterpolateNonLinear(position, outerColour, innerColour, border_portion + aa_width, 1); } /// From 2f547751826c391b765b9f0096f7f18b5649a5d8 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 27 Feb 2024 02:16:16 +0300 Subject: [PATCH 216/508] Add stable code references --- osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs index 264bb3145d..fa2b7863db 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs @@ -25,14 +25,17 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy { protected override Color4 ColourAt(float position) { + // https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/Graphics/Renderers/MmSliderRendererGL.cs#L99 const float aa_width = 0.5f / 64f; - const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS); - const float border_portion = 0.1875f; Color4 shadow = new Color4(0, 0, 0, 0.25f); Color4 outerColour = AccentColour.Darken(0.1f); Color4 innerColour = lighten(AccentColour, 0.5f); + // https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/Graphics/Renderers/MmSliderRendererGL.cs#L59-L70 + const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS); + const float border_portion = 0.1875f; + if (position <= shadow_portion - aa_width) return LegacyUtils.InterpolateNonLinear(position, Color4.Black.Opacity(0f), shadow, 0, shadow_portion - aa_width); From 18e26e39feb2fb386b433595724a4970ac841617 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 27 Feb 2024 02:20:34 +0300 Subject: [PATCH 217/508] Remove `SliderBorderSize` for simplicity --- osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs | 1 - osu.Game.Rulesets.Osu/Skinning/OsuSkinConfiguration.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs index fb31f88d3c..bda1e6cf41 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs @@ -44,7 +44,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default SnakingOut.BindTo(configSnakingOut); - BorderSize = skin.GetConfig(OsuSkinConfiguration.SliderBorderSize)?.Value ?? 1; BorderColour = skin.GetConfig(OsuSkinColour.SliderBorder)?.Value ?? Color4.White; } diff --git a/osu.Game.Rulesets.Osu/Skinning/OsuSkinConfiguration.cs b/osu.Game.Rulesets.Osu/Skinning/OsuSkinConfiguration.cs index 77fea9d8f7..9685ab685d 100644 --- a/osu.Game.Rulesets.Osu/Skinning/OsuSkinConfiguration.cs +++ b/osu.Game.Rulesets.Osu/Skinning/OsuSkinConfiguration.cs @@ -5,7 +5,6 @@ namespace osu.Game.Rulesets.Osu.Skinning { public enum OsuSkinConfiguration { - SliderBorderSize, SliderPathRadius, CursorCentre, CursorExpand, From 83af9dfb39d222a02fa45c726f1e50d43b27867f Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 27 Feb 2024 02:43:02 +0300 Subject: [PATCH 218/508] Fix `aa_width` being incorrect --- osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs index fa2b7863db..a00014ab88 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs @@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy protected override Color4 ColourAt(float position) { // https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/Graphics/Renderers/MmSliderRendererGL.cs#L99 - const float aa_width = 0.5f / 64f; + const float aa_width = 3f / 256f; Color4 shadow = new Color4(0, 0, 0, 0.25f); Color4 outerColour = AccentColour.Darken(0.1f); From f2d52fbaa2656b1a334d32b8142b56ff44c5bbb1 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 27 Feb 2024 17:33:24 +0900 Subject: [PATCH 219/508] Make class not overrideable --- osu.Game/OsuGame.cs | 4 +--- osu.Game/Performance/HighPerformanceSessionManager.cs | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f23a78d2dc..13e80e0707 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -792,8 +792,6 @@ namespace osu.Game protected virtual UpdateManager CreateUpdateManager() => new UpdateManager(); - protected virtual HighPerformanceSessionManager CreateHighPerformanceSessionManager() => new HighPerformanceSessionManager(); - protected override Container CreateScalingContainer() => new ScalingContainer(ScalingMode.Everything); #region Beatmap progression @@ -1088,7 +1086,7 @@ namespace osu.Game loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true); loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true); - loadComponentSingleFile(CreateHighPerformanceSessionManager(), Add, true); + loadComponentSingleFile(new HighPerformanceSessionManager(), Add, true); loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add); diff --git a/osu.Game/Performance/HighPerformanceSessionManager.cs b/osu.Game/Performance/HighPerformanceSessionManager.cs index c5146933b7..22c929083c 100644 --- a/osu.Game/Performance/HighPerformanceSessionManager.cs +++ b/osu.Game/Performance/HighPerformanceSessionManager.cs @@ -14,11 +14,11 @@ namespace osu.Game.Performance public IDisposable BeginSession() { - EnableHighPerformanceSession(); - return new InvokeOnDisposal(this, static m => m.DisableHighPerformanceSession()); + enableHighPerformanceSession(); + return new InvokeOnDisposal(this, static m => m.disableHighPerformanceSession()); } - protected virtual void EnableHighPerformanceSession() + private void enableHighPerformanceSession() { originalGCMode = GCSettings.LatencyMode; GCSettings.LatencyMode = GCLatencyMode.LowLatency; @@ -27,7 +27,7 @@ namespace osu.Game.Performance GC.Collect(0); } - protected virtual void DisableHighPerformanceSession() + private void disableHighPerformanceSession() { if (GCSettings.LatencyMode == GCLatencyMode.LowLatency) GCSettings.LatencyMode = originalGCMode; From dc3b41865cbf8ebb0b31f5d6d9ae042a93a14356 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 27 Feb 2024 19:17:34 +0900 Subject: [PATCH 220/508] Add logging --- osu.Game/Performance/HighPerformanceSessionManager.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Performance/HighPerformanceSessionManager.cs b/osu.Game/Performance/HighPerformanceSessionManager.cs index 22c929083c..304ab44975 100644 --- a/osu.Game/Performance/HighPerformanceSessionManager.cs +++ b/osu.Game/Performance/HighPerformanceSessionManager.cs @@ -5,6 +5,7 @@ using System; using System.Runtime; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Logging; namespace osu.Game.Performance { @@ -20,6 +21,8 @@ namespace osu.Game.Performance private void enableHighPerformanceSession() { + Logger.Log("Starting high performance session"); + originalGCMode = GCSettings.LatencyMode; GCSettings.LatencyMode = GCLatencyMode.LowLatency; @@ -29,6 +32,8 @@ namespace osu.Game.Performance private void disableHighPerformanceSession() { + Logger.Log("Ending high performance session"); + if (GCSettings.LatencyMode == GCLatencyMode.LowLatency) GCSettings.LatencyMode = originalGCMode; From 069b400dd08e21ce8e52369e5708721680b2c1f4 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 27 Feb 2024 19:36:03 +0900 Subject: [PATCH 221/508] Move manager to desktop game --- osu.Desktop/OsuGameDesktop.cs | 6 ++++++ .../Performance/HighPerformanceSessionManager.cs | 6 +++--- osu.Game/OsuGame.cs | 3 --- .../Performance/IHighPerformanceSessionManager.cs | 12 ++++++++++++ osu.Game/Screens/Play/PlayerLoader.cs | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) rename {osu.Game => osu.Desktop}/Performance/HighPerformanceSessionManager.cs (90%) create mode 100644 osu.Game/Performance/IHighPerformanceSessionManager.cs diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index a0db896f46..5b5f5c2167 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -7,6 +7,7 @@ using System.IO; using System.Reflection; using System.Runtime.Versioning; using Microsoft.Win32; +using osu.Desktop.Performance; using osu.Desktop.Security; using osu.Framework.Platform; using osu.Game; @@ -15,9 +16,11 @@ using osu.Framework; using osu.Framework.Logging; using osu.Game.Updater; using osu.Desktop.Windows; +using osu.Framework.Allocation; using osu.Game.IO; using osu.Game.IPC; using osu.Game.Online.Multiplayer; +using osu.Game.Performance; using osu.Game.Utils; using SDL2; @@ -28,6 +31,9 @@ namespace osu.Desktop private OsuSchemeLinkIPCChannel? osuSchemeLinkIPCChannel; private ArchiveImportIPCChannel? archiveImportIPCChannel; + [Cached(typeof(IHighPerformanceSessionManager))] + private readonly HighPerformanceSessionManager highPerformanceSessionManager = new HighPerformanceSessionManager(); + public OsuGameDesktop(string[]? args = null) : base(args) { diff --git a/osu.Game/Performance/HighPerformanceSessionManager.cs b/osu.Desktop/Performance/HighPerformanceSessionManager.cs similarity index 90% rename from osu.Game/Performance/HighPerformanceSessionManager.cs rename to osu.Desktop/Performance/HighPerformanceSessionManager.cs index 304ab44975..eb2b3be5b9 100644 --- a/osu.Game/Performance/HighPerformanceSessionManager.cs +++ b/osu.Desktop/Performance/HighPerformanceSessionManager.cs @@ -4,12 +4,12 @@ using System; using System.Runtime; using osu.Framework.Allocation; -using osu.Framework.Graphics; using osu.Framework.Logging; +using osu.Game.Performance; -namespace osu.Game.Performance +namespace osu.Desktop.Performance { - public partial class HighPerformanceSessionManager : Component + public class HighPerformanceSessionManager : IHighPerformanceSessionManager { private GCLatencyMode originalGCMode; diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 13e80e0707..f65557c6bb 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -55,7 +55,6 @@ using osu.Game.Overlays.Notifications; using osu.Game.Overlays.SkinEditor; using osu.Game.Overlays.Toolbar; using osu.Game.Overlays.Volume; -using osu.Game.Performance; using osu.Game.Rulesets.Mods; using osu.Game.Scoring; using osu.Game.Screens; @@ -1086,8 +1085,6 @@ namespace osu.Game loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true); loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true); - loadComponentSingleFile(new HighPerformanceSessionManager(), Add, true); - loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add); Add(difficultyRecommender); diff --git a/osu.Game/Performance/IHighPerformanceSessionManager.cs b/osu.Game/Performance/IHighPerformanceSessionManager.cs new file mode 100644 index 0000000000..826a0a04f5 --- /dev/null +++ b/osu.Game/Performance/IHighPerformanceSessionManager.cs @@ -0,0 +1,12 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; + +namespace osu.Game.Performance +{ + public interface IHighPerformanceSessionManager + { + IDisposable BeginSession(); + } +} diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index fe235dd56d..00a4a86c71 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -156,7 +156,7 @@ namespace osu.Game.Screens.Play private BatteryInfo? batteryInfo { get; set; } [Resolved] - private HighPerformanceSessionManager? highPerformanceSessionManager { get; set; } + private IHighPerformanceSessionManager? highPerformanceSessionManager { get; set; } public PlayerLoader(Func createPlayer) { From bbdd85020cc755ee75d8227468bc27c06bb67505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 27 Feb 2024 11:45:03 +0100 Subject: [PATCH 222/508] Fix slider tails sometimes not dimming correctly Originally noticed during review of another change: https://github.com/ppy/osu/pull/27369#issuecomment-1966140198. `DrawableOsuHitObject` tries to solve the initial dimming of objects by applying transform to a list of dimmable parts. For plain drawables this is safe, but if one of the parts is a DHO, it is not safe, because drawable transforms can be cleared at will. In particular, on first use of a drawable slider, `UpdateInitialTransforms()` would fire via `LoadComplete()` on the `DrawableSlider`, but *then*, also via `LoadComplete()`, the `DrawableSliderTail` would update its own state and by doing so inadvertently clear the dim transform just added by the slider. To fix, ensure dim transforms are applied to DHOs via `ApplyCustomUpdateState`. --- .../Objects/Drawables/DrawableOsuHitObject.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index 5271c03e08..35cab6459b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -80,6 +80,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables base.UpdateInitialTransforms(); foreach (var piece in DimmablePieces) + { + // if the specified dimmable piece is a DHO, it is generally not safe to tack transforms onto it directly + // as they may be cleared via the `updateState()` DHO flow, + // so use `ApplyCustomUpdateState` instead. which does not have this pitfall. + if (piece is DrawableHitObject drawableObjectPiece) + drawableObjectPiece.ApplyCustomUpdateState += (dho, _) => applyDim(dho); + else + applyDim(piece); + } + + void applyDim(Drawable piece) { piece.FadeColour(new Color4(195, 195, 195, 255)); using (piece.BeginDelayedSequence(InitialLifetimeOffset - OsuHitWindows.MISS_WINDOW)) From 189c680555e82222bf7115305b5156cb12d3adc8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Feb 2024 20:46:25 +0800 Subject: [PATCH 223/508] Add basic xmldoc on interface type --- .../Performance/IHighPerformanceSessionManager.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Game/Performance/IHighPerformanceSessionManager.cs b/osu.Game/Performance/IHighPerformanceSessionManager.cs index 826a0a04f5..d3d1fda8fc 100644 --- a/osu.Game/Performance/IHighPerformanceSessionManager.cs +++ b/osu.Game/Performance/IHighPerformanceSessionManager.cs @@ -5,8 +5,19 @@ using System; namespace osu.Game.Performance { + /// + /// Allows creating a temporary "high performance" session, with the goal of optimising runtime + /// performance for gameplay purposes. + /// + /// On desktop platforms, this will set a low latency GC mode which collects more frequently to avoid + /// GC spikes. + /// public interface IHighPerformanceSessionManager { + /// + /// Start a new high performance session. + /// + /// An which will end the session when disposed. IDisposable BeginSession(); } } From 87509fbf6efc9e14979a97fdb14b5fc6b56bdf16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 27 Feb 2024 13:47:19 +0100 Subject: [PATCH 224/508] Privatise registry-related constants Don't see any reason for them to be public. --- .../Windows/WindowsAssociationManager.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 2a1aeba7e0..c784d52a4f 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -15,27 +15,27 @@ namespace osu.Desktop.Windows [SupportedOSPlatform("windows")] public static class WindowsAssociationManager { - public const string SOFTWARE_CLASSES = @"Software\Classes"; + private const string software_classes = @"Software\Classes"; /// /// Sub key for setting the icon. /// https://learn.microsoft.com/en-us/windows/win32/com/defaulticon /// - public const string DEFAULT_ICON = @"DefaultIcon"; + private const string default_icon = @"DefaultIcon"; /// /// Sub key for setting the command line that the shell invokes. /// https://learn.microsoft.com/en-us/windows/win32/com/shell /// - public const string SHELL_OPEN_COMMAND = @"Shell\Open\Command"; + internal const string SHELL_OPEN_COMMAND = @"Shell\Open\Command"; - public static readonly string EXE_PATH = Path.ChangeExtension(typeof(WindowsAssociationManager).Assembly.Location, ".exe").Replace('/', '\\'); + private static readonly string exe_path = Path.ChangeExtension(typeof(WindowsAssociationManager).Assembly.Location, ".exe").Replace('/', '\\'); /// /// Program ID prefix used for file associations. Should be relatively short since the full program ID has a 39 character limit, /// see https://learn.microsoft.com/en-us/windows/win32/com/-progid--key. /// - public const string PROGRAM_ID_PREFIX = "osu.File"; + private const string program_id_prefix = "osu.File"; private static readonly FileAssociation[] file_associations = { @@ -177,24 +177,24 @@ namespace osu.Desktop.Windows private record FileAssociation(string Extension, LocalisableString Description, string IconPath) { - private string programId => $@"{PROGRAM_ID_PREFIX}{Extension}"; + private string programId => $@"{program_id_prefix}{Extension}"; /// /// Installs a file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/com/-progid--key /// public void Install() { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + using var classes = Registry.CurrentUser.OpenSubKey(software_classes, true); if (classes == null) return; // register a program id for the given extension using (var programKey = classes.CreateSubKey(programId)) { - using (var defaultIconKey = programKey.CreateSubKey(DEFAULT_ICON)) + using (var defaultIconKey = programKey.CreateSubKey(default_icon)) defaultIconKey.SetValue(null, IconPath); using (var openCommandKey = programKey.CreateSubKey(SHELL_OPEN_COMMAND)) - openCommandKey.SetValue(null, $@"""{EXE_PATH}"" ""%1"""); + openCommandKey.SetValue(null, $@"""{exe_path}"" ""%1"""); } using (var extensionKey = classes.CreateSubKey(Extension)) @@ -211,7 +211,7 @@ namespace osu.Desktop.Windows public void UpdateDescription(string description) { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + using var classes = Registry.CurrentUser.OpenSubKey(software_classes, true); if (classes == null) return; using (var programKey = classes.OpenSubKey(programId, true)) @@ -223,7 +223,7 @@ namespace osu.Desktop.Windows /// public void Uninstall() { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + using var classes = Registry.CurrentUser.OpenSubKey(software_classes, true); if (classes == null) return; using (var extensionKey = classes.OpenSubKey(Extension, true)) @@ -254,24 +254,24 @@ namespace osu.Desktop.Windows /// public void Install() { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + using var classes = Registry.CurrentUser.OpenSubKey(software_classes, true); if (classes == null) return; using (var protocolKey = classes.CreateSubKey(Protocol)) { protocolKey.SetValue(URL_PROTOCOL, string.Empty); - using (var defaultIconKey = protocolKey.CreateSubKey(DEFAULT_ICON)) + using (var defaultIconKey = protocolKey.CreateSubKey(default_icon)) defaultIconKey.SetValue(null, IconPath); using (var openCommandKey = protocolKey.CreateSubKey(SHELL_OPEN_COMMAND)) - openCommandKey.SetValue(null, $@"""{EXE_PATH}"" ""%1"""); + openCommandKey.SetValue(null, $@"""{exe_path}"" ""%1"""); } } public void UpdateDescription(string description) { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + using var classes = Registry.CurrentUser.OpenSubKey(software_classes, true); if (classes == null) return; using (var protocolKey = classes.OpenSubKey(Protocol, true)) @@ -280,7 +280,7 @@ namespace osu.Desktop.Windows public void Uninstall() { - using var classes = Registry.CurrentUser.OpenSubKey(SOFTWARE_CLASSES, true); + using var classes = Registry.CurrentUser.OpenSubKey(software_classes, true); classes?.DeleteSubKeyTree(Protocol, throwOnMissingSubKey: false); } } From 09dee50372f85c38a9432edd76ef3e4f7c5ad1fa Mon Sep 17 00:00:00 2001 From: Gabriel Del Nero <43073074+Gabixel@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:35:51 +0100 Subject: [PATCH 225/508] Change initial scroll animation to mod columns Starting from the end (which should be fine with the current number of columns, even on different/wider screen resolutions), and with a custom decay value when it reaches zero offset. --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index ce1d0d27a3..a5fc75aea3 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -341,12 +341,12 @@ namespace osu.Game.Overlays.Mods column.SearchTerm = query.NewValue; }, true); - // Start scrolled slightly to the right to give the user a sense that + // Start scrolling from the end, to give the user a sense that // there is more horizontal content available. ScheduleAfterChildren(() => { - columnScroll.ScrollTo(200, false); - columnScroll.ScrollToStart(); + columnScroll.ScrollToEnd(false); + columnScroll.ScrollTo(0, true, 0.0055); }); } From b3aa9e25d2f3ca99eda2f3e0ac6d7a3dedbd1f61 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 27 Feb 2024 23:18:11 +0300 Subject: [PATCH 226/508] Disable legacy slider AA for now --- osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs index a00014ab88..b54bb44f94 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs @@ -26,7 +26,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy protected override Color4 ColourAt(float position) { // https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/Graphics/Renderers/MmSliderRendererGL.cs#L99 - const float aa_width = 3f / 256f; + // float aaWidth = Math.Min(Math.Max(0.5f / PathRadius, 3.0f / 256.0f), 1.0f / 16.0f); + // applying the aa_width constant from stable makes sliders blurry, especially on CS>5. set to zero for now. + // this might be related to SmoothPath applying AA internally, but disabling that does not seem to have much of an effect. + const float aa_width = 0f; Color4 shadow = new Color4(0, 0, 0, 0.25f); Color4 outerColour = AccentColour.Darken(0.1f); From e053c08f6b137dcf5b62850ad5c17052780c4f71 Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 27 Feb 2024 16:23:36 -0500 Subject: [PATCH 227/508] Hide social interactions while in Do Not Disturb --- osu.Desktop/DiscordRichPresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 1944a73c0a..e118b3d6c0 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -95,8 +95,10 @@ namespace osu.Desktop if (activity.Value != null) { bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited; + bool hideInteractions = status.Value == UserStatus.DoNotDisturb && activity.Value is UserActivity.InLobby; + presence.State = truncate(activity.Value.GetStatus(hideIdentifiableInformation)); - presence.Details = truncate(activity.Value.GetDetails(hideIdentifiableInformation) ?? string.Empty); + presence.Details = truncate(activity.Value.GetDetails(hideIdentifiableInformation || hideInteractions) ?? string.Empty); if (getBeatmapID(activity.Value) is int beatmapId && beatmapId > 0) { From d83aeb73e4186219e1143ba7a289b02efff1c59a Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 28 Feb 2024 01:02:34 +0300 Subject: [PATCH 228/508] Fix menu cursor tracing rotation while override by gameplay cursor --- osu.Game/Graphics/Cursor/MenuCursorContainer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs index 8cf47006ab..7e42d45191 100644 --- a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs @@ -220,12 +220,16 @@ namespace osu.Game.Graphics.Cursor { activeCursor.FadeTo(1, 250, Easing.OutQuint); activeCursor.ScaleTo(1, 400, Easing.OutQuint); + activeCursor.RotateTo(0, 400, Easing.OutQuint); + dragRotationState = DragRotationState.NotDragging; } protected override void PopOut() { activeCursor.FadeTo(0, 250, Easing.OutQuint); activeCursor.ScaleTo(0.6f, 250, Easing.In); + activeCursor.RotateTo(0, 400, Easing.OutQuint); + dragRotationState = DragRotationState.NotDragging; } private void playTapSample(double baseFrequency = 1f) From c69c881cd373175859d97ce5a536a8827e6a0ddb Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 28 Feb 2024 07:58:02 +0300 Subject: [PATCH 229/508] Combine conditionals and remove "InLobby" check --- osu.Desktop/DiscordRichPresence.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index e118b3d6c0..f0da708766 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -94,11 +94,10 @@ namespace osu.Desktop if (activity.Value != null) { - bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited; - bool hideInteractions = status.Value == UserStatus.DoNotDisturb && activity.Value is UserActivity.InLobby; + bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb; presence.State = truncate(activity.Value.GetStatus(hideIdentifiableInformation)); - presence.Details = truncate(activity.Value.GetDetails(hideIdentifiableInformation || hideInteractions) ?? string.Empty); + presence.Details = truncate(activity.Value.GetDetails(hideIdentifiableInformation) ?? string.Empty); if (getBeatmapID(activity.Value) is int beatmapId && beatmapId > 0) { From 351160f94e34712103cc7d16d2ee21ee007660a6 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Tue, 27 Feb 2024 22:41:49 -0800 Subject: [PATCH 230/508] Move back/quit button from bottom left to fail overlay when spectating --- osu.Game/Screens/Play/FailOverlay.cs | 17 +---------------- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 10 ++++++++++ osu.Game/Screens/Play/PauseOverlay.cs | 10 +--------- osu.Game/Screens/Play/Player.cs | 4 ++-- osu.Game/Screens/Play/SpectatorPlayer.cs | 2 -- 5 files changed, 14 insertions(+), 29 deletions(-) diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index 210ae5ceb6..f14cdfc213 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -6,10 +6,8 @@ using System; using System.Threading.Tasks; using osu.Game.Scoring; -using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osuTK; -using osuTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -26,22 +24,9 @@ namespace osu.Game.Screens.Play public override LocalisableString Header => GameplayMenuOverlayStrings.FailedHeader; - private readonly bool showButtons; - - public FailOverlay(bool showButtons = true) - { - this.showButtons = showButtons; - } - [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load() { - if (showButtons) - { - AddButton(GameplayMenuOverlayStrings.Retry, colours.YellowDark, () => OnRetry?.Invoke()); - AddButton(GameplayMenuOverlayStrings.Quit, new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); - } - // from #10339 maybe this is a better visual effect Add(new Container { diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index 440b8d37b9..be4b8ff9fe 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -38,6 +38,7 @@ namespace osu.Game.Screens.Play public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; + public Action? OnResume; public Action? OnRetry; public Action? OnQuit; @@ -129,6 +130,15 @@ namespace osu.Game.Screens.Play }, }; + if (OnResume != null) + AddButton(GameplayMenuOverlayStrings.Continue, colours.Green, () => OnResume.Invoke()); + + if (OnRetry != null) + AddButton(GameplayMenuOverlayStrings.Retry, colours.YellowDark, () => OnRetry.Invoke()); + + if (OnQuit != null) + AddButton(GameplayMenuOverlayStrings.Quit, new Color4(170, 27, 39, 255), () => OnQuit.Invoke()); + State.ValueChanged += _ => InternalButtons.Deselect(); updateInfoText(); diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 2aa2793fd4..c8e8275641 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -11,18 +11,14 @@ using osu.Framework.Graphics; using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Audio; -using osu.Game.Graphics; using osu.Game.Input.Bindings; using osu.Game.Localisation; using osu.Game.Skinning; -using osuTK.Graphics; namespace osu.Game.Screens.Play { public partial class PauseOverlay : GameplayMenuOverlay { - public Action OnResume; - public override bool IsPresent => base.IsPresent || pauseLoop.IsPlaying; public override LocalisableString Header => GameplayMenuOverlayStrings.PausedHeader; @@ -38,12 +34,8 @@ namespace osu.Game.Screens.Play }; [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load() { - AddButton(GameplayMenuOverlayStrings.Continue, colours.Green, () => OnResume?.Invoke()); - AddButton(GameplayMenuOverlayStrings.Retry, colours.YellowDark, () => OnRetry?.Invoke()); - AddButton(GameplayMenuOverlayStrings.Quit, new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); - AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("Gameplay/pause-loop")) { Looping = true, diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 11ff5fdbef..88f6ae9e71 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -278,10 +278,10 @@ namespace osu.Game.Screens.Play createGameplayComponents(Beatmap.Value) } }, - FailOverlay = new FailOverlay(Configuration.AllowUserInteraction) + FailOverlay = new FailOverlay { SaveReplay = async () => await prepareAndImportScoreAsync(true).ConfigureAwait(false), - OnRetry = () => Restart(), + OnRetry = Configuration.AllowUserInteraction ? () => Restart() : null, OnQuit = () => PerformExit(true), }, new HotkeyExitOverlay diff --git a/osu.Game/Screens/Play/SpectatorPlayer.cs b/osu.Game/Screens/Play/SpectatorPlayer.cs index 2faead0ee1..d1404ac184 100644 --- a/osu.Game/Screens/Play/SpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SpectatorPlayer.cs @@ -25,8 +25,6 @@ namespace osu.Game.Screens.Play private readonly Score score; - public override bool AllowBackButton => true; - protected override bool CheckModsAllowFailure() { if (!allowFail) From dee57c7e72275fb87fabacbbc802775418e95185 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Tue, 27 Feb 2024 22:42:36 -0800 Subject: [PATCH 231/508] Refactor test to only allow init of actions --- .../Gameplay/TestSceneGameplayMenuOverlay.cs | 43 ++++++------------- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 6 +-- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs index aa5e5985c3..73028e6df9 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs @@ -3,7 +3,6 @@ #nullable disable -using System; using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; @@ -26,6 +25,8 @@ namespace osu.Game.Tests.Visual.Gameplay private GlobalActionContainer globalActionContainer; + private bool triggeredRetryButton; + [BackgroundDependencyLoader] private void load(OsuGameBase game) { @@ -35,12 +36,18 @@ namespace osu.Game.Tests.Visual.Gameplay [SetUp] public void SetUp() => Schedule(() => { + triggeredRetryButton = false; + globalActionContainer.Children = new Drawable[] { pauseOverlay = new PauseOverlay { OnResume = () => Logger.Log(@"Resume"), - OnRetry = () => Logger.Log(@"Retry"), + OnRetry = () => + { + Logger.Log(@"Retry"); + triggeredRetryButton = true; + }, OnQuit = () => Logger.Log(@"Quit"), }, failOverlay = new FailOverlay @@ -224,17 +231,9 @@ namespace osu.Game.Tests.Visual.Gameplay { showOverlay(); - bool triggered = false; - AddStep("Click retry button", () => - { - var lastAction = pauseOverlay.OnRetry; - pauseOverlay.OnRetry = () => triggered = true; + AddStep("Click retry button", () => getButton(1).TriggerClick()); - getButton(1).TriggerClick(); - pauseOverlay.OnRetry = lastAction; - }); - - AddAssert("Action was triggered", () => triggered); + AddAssert("Retry was triggered", () => triggeredRetryButton); AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden); } @@ -252,25 +251,9 @@ namespace osu.Game.Tests.Visual.Gameplay InputManager.Key(Key.Down); }); - bool triggered = false; - Action lastAction = null; - AddStep("Press enter", () => - { - lastAction = pauseOverlay.OnRetry; - pauseOverlay.OnRetry = () => triggered = true; - InputManager.Key(Key.Enter); - }); + AddStep("Press enter", () => InputManager.Key(Key.Enter)); - AddAssert("Action was triggered", () => - { - if (lastAction != null) - { - pauseOverlay.OnRetry = lastAction; - lastAction = null; - } - - return triggered; - }); + AddAssert("Retry was triggered", () => triggeredRetryButton); AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden); } diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index be4b8ff9fe..da239d585e 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -38,9 +38,9 @@ namespace osu.Game.Screens.Play public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; - public Action? OnResume; - public Action? OnRetry; - public Action? OnQuit; + public Action? OnResume { get; init; } + public Action? OnRetry { get; init; } + public Action? OnQuit { get; init; } /// /// Action that is invoked when is triggered. From e8a106177771cc23112f8f42e6cc9adb725736cc Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Tue, 27 Feb 2024 23:16:20 -0800 Subject: [PATCH 232/508] Add test for spectator player exit --- osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs index 1c7ede2b19..caf3a05518 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs @@ -25,6 +25,7 @@ using osu.Game.Tests.Gameplay; using osu.Game.Tests.Visual.Multiplayer; using osu.Game.Tests.Visual.Spectator; using osuTK; +using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { @@ -214,6 +215,9 @@ namespace osu.Game.Tests.Visual.Gameplay checkPaused(false); // Should continue playing until out of frames checkPaused(true); // And eventually stop after running out of frames and fail. // Todo: Should check for + display a failed message. + + AddStep("exit player", () => InputManager.Key(Key.Escape)); + AddAssert("player exited", () => Stack.CurrentScreen is SoloSpectatorScreen); } [Test] From 8e462fbb38e4ffb41f3cf7cf9e7775978d03464b Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Tue, 27 Feb 2024 23:24:04 -0800 Subject: [PATCH 233/508] Apply NRT to touched files --- .../Gameplay/TestSceneGameplayMenuOverlay.cs | 8 +++----- .../Visual/Gameplay/TestSceneSpectator.cs | 20 +++++++++---------- osu.Game/Screens/Play/FailOverlay.cs | 4 +--- osu.Game/Screens/Play/PauseOverlay.cs | 4 +--- .../Screens/Play/SaveFailedScoreButton.cs | 17 ++++++++++------ osu.Game/Screens/Play/SoloSpectatorPlayer.cs | 3 +-- osu.Game/Screens/Play/SpectatorPlayer.cs | 11 ++++------ 7 files changed, 30 insertions(+), 37 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs index 73028e6df9..3501c1a521 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; @@ -20,10 +18,10 @@ namespace osu.Game.Tests.Visual.Gameplay [Description("player pause/fail screens")] public partial class TestSceneGameplayMenuOverlay : OsuManualInputManagerTestScene { - private FailOverlay failOverlay; - private PauseOverlay pauseOverlay; + private FailOverlay failOverlay = null!; + private PauseOverlay pauseOverlay = null!; - private GlobalActionContainer globalActionContainer; + private GlobalActionContainer globalActionContainer = null!; private bool triggeredRetryButton; diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs index caf3a05518..c8356cd191 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; @@ -40,13 +38,13 @@ namespace osu.Game.Tests.Visual.Gameplay protected override bool UseOnlineAPI => true; [Resolved] - private OsuGameBase game { get; set; } + private OsuGameBase game { get; set; } = null!; private TestSpectatorClient spectatorClient => dependenciesScreen.SpectatorClient; - private DependenciesScreen dependenciesScreen; - private SoloSpectatorScreen spectatorScreen; + private DependenciesScreen dependenciesScreen = null!; + private SoloSpectatorScreen spectatorScreen = null!; - private BeatmapSetInfo importedBeatmap; + private BeatmapSetInfo importedBeatmap = null!; private int importedBeatmapId; [SetUpSteps] @@ -189,7 +187,7 @@ namespace osu.Game.Tests.Visual.Gameplay waitForPlayerCurrent(); - Player lastPlayer = null; + Player lastPlayer = null!; AddStep("store first player", () => lastPlayer = player); start(); @@ -282,7 +280,7 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestFinalFrameInBundleHasHeader() { - FrameDataBundle lastBundle = null; + FrameDataBundle? lastBundle = null; AddStep("bind to client", () => spectatorClient.OnNewFrames += (_, bundle) => lastBundle = bundle); @@ -291,8 +289,8 @@ namespace osu.Game.Tests.Visual.Gameplay finish(); AddUntilStep("bundle received", () => lastBundle != null); - AddAssert("first frame does not have header", () => lastBundle.Frames[0].Header == null); - AddAssert("last frame has header", () => lastBundle.Frames[^1].Header != null); + AddAssert("first frame does not have header", () => lastBundle?.Frames[0].Header == null); + AddAssert("last frame has header", () => lastBundle?.Frames[^1].Header != null); } [Test] @@ -387,7 +385,7 @@ namespace osu.Game.Tests.Visual.Gameplay } private OsuFramedReplayInputHandler replayHandler => - (OsuFramedReplayInputHandler)Stack.ChildrenOfType().First().ReplayInputHandler; + (OsuFramedReplayInputHandler)Stack.ChildrenOfType().First().ReplayInputHandler!; private Player player => this.ChildrenOfType().Single(); diff --git a/osu.Game/Screens/Play/FailOverlay.cs b/osu.Game/Screens/Play/FailOverlay.cs index f14cdfc213..4a0a6f573c 100644 --- a/osu.Game/Screens/Play/FailOverlay.cs +++ b/osu.Game/Screens/Play/FailOverlay.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Threading.Tasks; using osu.Game.Scoring; @@ -20,7 +18,7 @@ namespace osu.Game.Screens.Play { public partial class FailOverlay : GameplayMenuOverlay { - public Func> SaveReplay; + public Func>? SaveReplay; public override LocalisableString Header => GameplayMenuOverlayStrings.FailedHeader; diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index c8e8275641..3a471acba4 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Linq; using osu.Framework.Allocation; @@ -23,7 +21,7 @@ namespace osu.Game.Screens.Play public override LocalisableString Header => GameplayMenuOverlayStrings.PausedHeader; - private SkinnableSound pauseLoop; + private SkinnableSound pauseLoop = null!; protected override Action BackAction => () => { diff --git a/osu.Game/Screens/Play/SaveFailedScoreButton.cs b/osu.Game/Screens/Play/SaveFailedScoreButton.cs index b97c140250..ef27aac1b9 100644 --- a/osu.Game/Screens/Play/SaveFailedScoreButton.cs +++ b/osu.Game/Screens/Play/SaveFailedScoreButton.cs @@ -30,13 +30,13 @@ namespace osu.Game.Screens.Play private readonly Bindable state = new Bindable(); - private readonly Func> importFailedScore; + private readonly Func>? importFailedScore; private ScoreInfo? importedScore; private DownloadButton button = null!; - public SaveFailedScoreButton(Func> importFailedScore) + public SaveFailedScoreButton(Func>? importFailedScore) { Size = new Vector2(50, 30); @@ -60,11 +60,16 @@ namespace osu.Game.Screens.Play case DownloadState.NotDownloaded: state.Value = DownloadState.Importing; - Task.Run(importFailedScore).ContinueWith(t => + + if (importFailedScore != null) { - importedScore = realm.Run(r => r.Find(t.GetResultSafely().ID)?.Detach()); - Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded); - }).FireAndForget(); + Task.Run(importFailedScore).ContinueWith(t => + { + importedScore = realm.Run(r => r.Find(t.GetResultSafely().ID)?.Detach()); + Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded); + }).FireAndForget(); + } + break; } } diff --git a/osu.Game/Screens/Play/SoloSpectatorPlayer.cs b/osu.Game/Screens/Play/SoloSpectatorPlayer.cs index 8d25a0148d..3dafd5f752 100644 --- a/osu.Game/Screens/Play/SoloSpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SoloSpectatorPlayer.cs @@ -50,8 +50,7 @@ namespace osu.Game.Screens.Play { base.Dispose(isDisposing); - if (SpectatorClient != null) - SpectatorClient.OnUserBeganPlaying -= userBeganPlaying; + SpectatorClient.OnUserBeganPlaying -= userBeganPlaying; } } } diff --git a/osu.Game/Screens/Play/SpectatorPlayer.cs b/osu.Game/Screens/Play/SpectatorPlayer.cs index d1404ac184..520fb43445 100644 --- a/osu.Game/Screens/Play/SpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SpectatorPlayer.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -21,7 +19,7 @@ namespace osu.Game.Screens.Play public abstract partial class SpectatorPlayer : Player { [Resolved] - protected SpectatorClient SpectatorClient { get; private set; } + protected SpectatorClient SpectatorClient { get; private set; } = null!; private readonly Score score; @@ -35,7 +33,7 @@ namespace osu.Game.Screens.Play private bool allowFail; - protected SpectatorPlayer(Score score, PlayerConfiguration configuration = null) + protected SpectatorPlayer(Score score, PlayerConfiguration? configuration = null) : base(configuration) { this.score = score; @@ -98,7 +96,7 @@ namespace osu.Game.Screens.Play foreach (var frame in bundle.Frames) { - IConvertibleReplayFrame convertibleFrame = GameplayState.Ruleset.CreateConvertibleReplayFrame(); + IConvertibleReplayFrame convertibleFrame = GameplayState.Ruleset.CreateConvertibleReplayFrame()!; Debug.Assert(convertibleFrame != null); convertibleFrame.FromLegacy(frame, GameplayState.Beatmap); @@ -134,8 +132,7 @@ namespace osu.Game.Screens.Play { base.Dispose(isDisposing); - if (SpectatorClient != null) - SpectatorClient.OnNewFrames -= userSentFrames; + SpectatorClient.OnNewFrames -= userSentFrames; } } } From 6e03384c6bffba55b403c20cb566bf88c7252b12 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 28 Feb 2024 00:01:16 -0800 Subject: [PATCH 234/508] Apply NRT to `SoloSpectatorPlayer` --- osu.Game/Screens/Play/SoloSpectatorPlayer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Screens/Play/SoloSpectatorPlayer.cs b/osu.Game/Screens/Play/SoloSpectatorPlayer.cs index 3dafd5f752..2cc1c4a368 100644 --- a/osu.Game/Screens/Play/SoloSpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SoloSpectatorPlayer.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Screens; using osu.Game.Online.Spectator; From 3fb2662d74a16bf7258d0b38777e599558d214a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 28 Feb 2024 12:05:33 +0100 Subject: [PATCH 235/508] Update framework Mainly for the sake of https://github.com/ppy/osu-framework/pull/6196. --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 30037c868c..1b395a7c83 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -10,7 +10,7 @@ true - + diff --git a/osu.iOS.props b/osu.iOS.props index 463a726856..747d6059da 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -23,6 +23,6 @@ iossimulator-x64 - + From b5ce2642aacc33cd47879d72a18e51714936e11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 28 Feb 2024 13:20:41 +0100 Subject: [PATCH 236/508] Fix subscribing to `ApplyCustomUpdateState` too much --- .../Objects/Drawables/DrawableOsuHitObject.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index 35cab6459b..5f5deca1ba 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -85,7 +85,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables // as they may be cleared via the `updateState()` DHO flow, // so use `ApplyCustomUpdateState` instead. which does not have this pitfall. if (piece is DrawableHitObject drawableObjectPiece) - drawableObjectPiece.ApplyCustomUpdateState += (dho, _) => applyDim(dho); + { + // this method can be called multiple times, and we don't want to subscribe to the event more than once, + // so this is what it is going to have to be... + drawableObjectPiece.ApplyCustomUpdateState -= applyDimToDrawableHitObject; + drawableObjectPiece.ApplyCustomUpdateState += applyDimToDrawableHitObject; + } else applyDim(piece); } @@ -96,6 +101,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables using (piece.BeginDelayedSequence(InitialLifetimeOffset - OsuHitWindows.MISS_WINDOW)) piece.FadeColour(Color4.White, 100); } + + void applyDimToDrawableHitObject(DrawableHitObject dho, ArmedState _) => applyDim(dho); } protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt; From ce994a7a733eacd1bd5b1c30aacda217b071e8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 28 Feb 2024 13:31:06 +0100 Subject: [PATCH 237/508] Fix wireframe misalignment in argon accuracy counter - Closes https://github.com/ppy/osu/issues/27385. - Supersedes / closes https://github.com/ppy/osu/pull/27392. --- osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs | 6 +++--- osu.Game/Screens/Play/HUD/ArgonComboCounter.cs | 5 ++++- .../Screens/Play/HUD/ArgonCounterTextComponent.cs | 15 ++++++++++++--- osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs | 6 ++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs b/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs index ca00ab12c7..4cc04e1485 100644 --- a/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs @@ -75,21 +75,21 @@ namespace osu.Game.Screens.Play.HUD AutoSizeAxes = Axes.Both, Child = wholePart = new ArgonCounterTextComponent(Anchor.TopRight, BeatmapsetsStrings.ShowScoreboardHeadersAccuracy.ToUpper()) { - RequiredDisplayDigits = { Value = 3 }, WireframeOpacity = { BindTarget = WireframeOpacity }, + WireframeTemplate = @"###", ShowLabel = { BindTarget = ShowLabel }, } }, fractionPart = new ArgonCounterTextComponent(Anchor.TopLeft) { - RequiredDisplayDigits = { Value = 2 }, WireframeOpacity = { BindTarget = WireframeOpacity }, + WireframeTemplate = @".##", Scale = new Vector2(0.5f), }, percentText = new ArgonCounterTextComponent(Anchor.TopLeft) { Text = @"%", - RequiredDisplayDigits = { Value = 1 }, + WireframeTemplate = @"#", WireframeOpacity = { BindTarget = WireframeOpacity } }, } diff --git a/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs b/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs index 369c753cb0..3f187650b2 100644 --- a/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs @@ -68,7 +68,10 @@ namespace osu.Game.Screens.Play.HUD private void updateWireframe() { - text.RequiredDisplayDigits.Value = getDigitsRequiredForDisplayCount(); + int digitsRequiredForDisplayCount = getDigitsRequiredForDisplayCount(); + + if (digitsRequiredForDisplayCount != text.WireframeTemplate.Length) + text.WireframeTemplate = new string('#', digitsRequiredForDisplayCount); } private int getDigitsRequiredForDisplayCount() diff --git a/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs b/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs index f8c82feddd..efb4d2108e 100644 --- a/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs +++ b/osu.Game/Screens/Play/HUD/ArgonCounterTextComponent.cs @@ -25,7 +25,6 @@ namespace osu.Game.Screens.Play.HUD private readonly OsuSpriteText labelText; public IBindable WireframeOpacity { get; } = new BindableFloat(); - public Bindable RequiredDisplayDigits { get; } = new BindableInt(); public Bindable ShowLabel { get; } = new BindableBool(); public Container NumberContainer { get; private set; } @@ -36,6 +35,18 @@ namespace osu.Game.Screens.Play.HUD set => textPart.Text = value; } + /// + /// The template for the wireframe displayed behind the . + /// Any character other than a dot is interpreted to mean a full segmented display "wireframe". + /// + public string WireframeTemplate + { + get => wireframeTemplate; + set => wireframesPart.Text = wireframeTemplate = value; + } + + private string wireframeTemplate = string.Empty; + public ArgonCounterTextComponent(Anchor anchor, LocalisableString? label = null) { Anchor = anchor; @@ -69,8 +80,6 @@ namespace osu.Game.Screens.Play.HUD } } }; - - RequiredDisplayDigits.BindValueChanged(digits => wireframesPart.Text = new string('#', digits.NewValue)); } private string textLookup(char c) diff --git a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs index 44b9fb3123..7e0dd161dc 100644 --- a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs @@ -58,8 +58,10 @@ namespace osu.Game.Screens.Play.HUD private void updateWireframe() { - scoreText.RequiredDisplayDigits.Value = - Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount()); + int digitsRequiredForDisplayCount = Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount()); + + if (digitsRequiredForDisplayCount != scoreText.WireframeTemplate.Length) + scoreText.WireframeTemplate = new string('#', Math.Max(RequiredDisplayDigits.Value, digitsRequiredForDisplayCount)); } private int getDigitsRequiredForDisplayCount() From f49aa4d8157eb6368263f919c662dd0afdaca1d0 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 28 Feb 2024 22:01:39 +0800 Subject: [PATCH 238/508] Parse points and segments for path string --- .../Objects/Legacy/ConvertHitObjectParser.cs | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index f9e32fe26f..30e4101a84 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -266,30 +266,49 @@ namespace osu.Game.Rulesets.Objects.Legacy // This code takes on the responsibility of handling explicit segments of the path ("X" & "Y" from above). Implicit segments are handled by calls to convertPoints(). string[] pointSplit = pointString.Split('|'); - var controlPoints = new List>(); - int startIndex = 0; - int endIndex = 0; - bool first = true; + Span points = stackalloc Vector2[pointSplit.Length]; + Span<(PathType Type, int StartIndex)> segments = stackalloc (PathType Type, int StartIndex)[pointSplit.Length]; + int pointsCount = 0; + int segmentsCount = 0; - while (++endIndex < pointSplit.Length) + foreach (string s in pointSplit) { - // Keep incrementing endIndex while it's not the start of a new segment (indicated by having an alpha character at position 0). - if (!char.IsLetter(pointSplit[endIndex][0])) - continue; - - // Multi-segmented sliders DON'T contain the end point as part of the current segment as it's assumed to be the start of the next segment. - // The start of the next segment is the index after the type descriptor. - string endPoint = endIndex < pointSplit.Length - 1 ? pointSplit[endIndex + 1] : null; - - controlPoints.AddRange(convertPoints(pointSplit.AsMemory().Slice(startIndex, endIndex - startIndex), endPoint, first, offset)); - startIndex = endIndex; - first = false; + if (char.IsLetter(s[0])) + { + // The start of a new segment(indicated by having an alpha character at position 0). + var pathType = convertPathType(s); + segments[segmentsCount++] = (pathType, pointsCount); + } + else + { + points[pointsCount++] = readPoint(s, offset); + } } - if (endIndex > startIndex) - controlPoints.AddRange(convertPoints(pointSplit.AsMemory().Slice(startIndex, endIndex - startIndex), null, first, offset)); + var controlPoints = new List(pointsCount); - return mergePointsLists(controlPoints); + for (int i = 0; i < segmentsCount; i++) + { + int startIndex = segments[i].StartIndex; + int endIndex = i < segmentsCount - 1 ? segments[i + 1].StartIndex : pointsCount; + Vector2? endPoint = i < segmentsCount - 1 ? points[endIndex] : null; + controlPoints.AddRange(convertPoints(segments[i].Type, points[startIndex..endIndex], endPoint)); + } + + return controlPoints.ToArray(); + + static Vector2 readPoint(string value, Vector2 startPos) + { + string[] vertexSplit = value.Split(':'); + + Vector2 pos = new Vector2((int)Parsing.ParseDouble(vertexSplit[0], Parsing.MAX_COORDINATE_VALUE), (int)Parsing.ParseDouble(vertexSplit[1], Parsing.MAX_COORDINATE_VALUE)) - startPos; + return pos; + } + } + + private IEnumerable convertPoints(PathType type, ReadOnlySpan points, Vector2? endPoint) + { + throw new NotImplementedException(); } /// From 4bff54d35dbd60aab7cd8a255977fe95e5c3bde7 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 28 Feb 2024 22:37:14 +0800 Subject: [PATCH 239/508] Add ToString on PathControlPoint for debugging --- osu.Game/Rulesets/Objects/PathControlPoint.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Rulesets/Objects/PathControlPoint.cs b/osu.Game/Rulesets/Objects/PathControlPoint.cs index ae9fa08085..1f8e63b269 100644 --- a/osu.Game/Rulesets/Objects/PathControlPoint.cs +++ b/osu.Game/Rulesets/Objects/PathControlPoint.cs @@ -76,5 +76,9 @@ namespace osu.Game.Rulesets.Objects } public bool Equals(PathControlPoint other) => Position == other?.Position && Type == other.Type; + + public override string ToString() => type is null + ? $"Position={Position}" + : $"Position={Position}, Type={type}"; } } From fe34577ee2938c45d295800405a309ad3d55ac3e Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 28 Feb 2024 22:42:08 +0800 Subject: [PATCH 240/508] Update parsing. --- .../Objects/Legacy/ConvertHitObjectParser.cs | 86 ++++++------------- 1 file changed, 24 insertions(+), 62 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index 30e4101a84..2d4d2865e6 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -278,6 +278,10 @@ namespace osu.Game.Rulesets.Objects.Legacy // The start of a new segment(indicated by having an alpha character at position 0). var pathType = convertPathType(s); segments[segmentsCount++] = (pathType, pointsCount); + + // First segment is prepended by an extra zero point + if (pointsCount == 0) + points[pointsCount++] = Vector2.Zero; } else { @@ -306,47 +310,30 @@ namespace osu.Game.Rulesets.Objects.Legacy } } - private IEnumerable convertPoints(PathType type, ReadOnlySpan points, Vector2? endPoint) - { - throw new NotImplementedException(); - } - /// /// Converts a given point list into a set of path segments. /// + /// The path type of the point list. /// The point list. /// Any extra endpoint to consider as part of the points. This will NOT be returned. - /// Whether this is the first segment in the set. If true the first of the returned segments will contain a zero point. - /// The positional offset to apply to the control points. - /// The set of points contained by as one or more segments of the path, prepended by an extra zero point if is true. - private IEnumerable> convertPoints(ReadOnlyMemory points, string endPoint, bool first, Vector2 offset) + /// The set of points contained by as one or more segments of the path. + private IEnumerable convertPoints(PathType type, ReadOnlySpan points, Vector2? endPoint) { - PathType type = convertPathType(points.Span[0]); - - int readOffset = first ? 1 : 0; // First control point is zero for the first segment. - int readablePoints = points.Length - 1; // Total points readable from the base point span. - int endPointLength = endPoint != null ? 1 : 0; // Extra length if an endpoint is given that lies outside the base point span. - - var vertices = new PathControlPoint[readOffset + readablePoints + endPointLength]; - - // Fill any non-read points. - for (int i = 0; i < readOffset; i++) - vertices[i] = new PathControlPoint(); + var vertices = new PathControlPoint[points.Length]; + var result = new List(); // Parse into control points. - for (int i = 1; i < points.Length; i++) - readPoint(points.Span[i], offset, out vertices[readOffset + i - 1]); - - // If an endpoint is given, add it to the end. - if (endPoint != null) - readPoint(endPoint, offset, out vertices[^1]); + for (int i = 0; i < points.Length; i++) + vertices[i] = new PathControlPoint { Position = points[i] }; // Edge-case rules (to match stable). if (type == PathType.PERFECT_CURVE) { - if (vertices.Length != 3) + int endPointLength = endPoint is null ? 0 : 1; + + if (vertices.Length + endPointLength != 3) type = PathType.BEZIER; - else if (isLinear(vertices)) + else if (isLinear(stackalloc[] { points[0], points[1], endPoint ?? points[2] })) { // osu-stable special-cased colinear perfect curves to a linear path type = PathType.LINEAR; @@ -365,7 +352,7 @@ namespace osu.Game.Rulesets.Objects.Legacy int startIndex = 0; int endIndex = 0; - while (++endIndex < vertices.Length - endPointLength) + while (++endIndex < vertices.Length) { // Keep incrementing while an implicit segment doesn't need to be started. if (vertices[endIndex].Position != vertices[endIndex - 1].Position) @@ -378,50 +365,25 @@ namespace osu.Game.Rulesets.Objects.Legacy continue; // The last control point of each segment is not allowed to start a new implicit segment. - if (endIndex == vertices.Length - endPointLength - 1) + if (endIndex == vertices.Length - 1) continue; // Force a type on the last point, and return the current control point set as a segment. vertices[endIndex - 1].Type = type; - yield return vertices.AsMemory().Slice(startIndex, endIndex - startIndex); + for (int i = startIndex; i < endIndex; i++) + result.Add(vertices[i]); // Skip the current control point - as it's the same as the one that's just been returned. startIndex = endIndex + 1; } - if (endIndex > startIndex) - yield return vertices.AsMemory().Slice(startIndex, endIndex - startIndex); + for (int i = startIndex; i < endIndex; i++) + result.Add(vertices[i]); - static void readPoint(string value, Vector2 startPos, out PathControlPoint point) - { - string[] vertexSplit = value.Split(':'); + return result; - Vector2 pos = new Vector2((int)Parsing.ParseDouble(vertexSplit[0], Parsing.MAX_COORDINATE_VALUE), (int)Parsing.ParseDouble(vertexSplit[1], Parsing.MAX_COORDINATE_VALUE)) - startPos; - point = new PathControlPoint { Position = pos }; - } - - static bool isLinear(PathControlPoint[] p) => Precision.AlmostEquals(0, (p[1].Position.Y - p[0].Position.Y) * (p[2].Position.X - p[0].Position.X) - - (p[1].Position.X - p[0].Position.X) * (p[2].Position.Y - p[0].Position.Y)); - } - - private PathControlPoint[] mergePointsLists(List> controlPointList) - { - int totalCount = 0; - - foreach (var arr in controlPointList) - totalCount += arr.Length; - - var mergedArray = new PathControlPoint[totalCount]; - var mergedArrayMemory = mergedArray.AsMemory(); - int copyIndex = 0; - - foreach (var arr in controlPointList) - { - arr.CopyTo(mergedArrayMemory.Slice(copyIndex)); - copyIndex += arr.Length; - } - - return mergedArray; + static bool isLinear(ReadOnlySpan p) => Precision.AlmostEquals(0, (p[1].Y - p[0].Y) * (p[2].X - p[0].X) + - (p[1].X - p[0].X) * (p[2].Y - p[0].Y)); } /// From bcb91f348d746bd4470240c23c72ec812fc54113 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Wed, 28 Feb 2024 22:51:36 +0800 Subject: [PATCH 241/508] Use ArrayPool instead of stackalloc --- .../Objects/Legacy/ConvertHitObjectParser.cs | 82 ++++++++++--------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index 2d4d2865e6..a3ca719ff9 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -18,6 +18,7 @@ using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.Legacy; using osu.Game.Skinning; using osu.Game.Utils; +using System.Buffers; namespace osu.Game.Rulesets.Objects.Legacy { @@ -266,41 +267,49 @@ namespace osu.Game.Rulesets.Objects.Legacy // This code takes on the responsibility of handling explicit segments of the path ("X" & "Y" from above). Implicit segments are handled by calls to convertPoints(). string[] pointSplit = pointString.Split('|'); - Span points = stackalloc Vector2[pointSplit.Length]; - Span<(PathType Type, int StartIndex)> segments = stackalloc (PathType Type, int StartIndex)[pointSplit.Length]; + var points = ArrayPool.Shared.Rent(pointSplit.Length); + var segments = ArrayPool<(PathType Type, int StartIndex)>.Shared.Rent(pointSplit.Length); int pointsCount = 0; int segmentsCount = 0; - - foreach (string s in pointSplit) + try { - if (char.IsLetter(s[0])) - { - // The start of a new segment(indicated by having an alpha character at position 0). - var pathType = convertPathType(s); - segments[segmentsCount++] = (pathType, pointsCount); - // First segment is prepended by an extra zero point - if (pointsCount == 0) - points[pointsCount++] = Vector2.Zero; - } - else + foreach (string s in pointSplit) { - points[pointsCount++] = readPoint(s, offset); + if (char.IsLetter(s[0])) + { + // The start of a new segment(indicated by having an alpha character at position 0). + var pathType = convertPathType(s); + segments[segmentsCount++] = (pathType, pointsCount); + + // First segment is prepended by an extra zero point + if (pointsCount == 0) + points[pointsCount++] = Vector2.Zero; + } + else + { + points[pointsCount++] = readPoint(s, offset); + } } + + var controlPoints = new List>(pointsCount); + + for (int i = 0; i < segmentsCount; i++) + { + int startIndex = segments[i].StartIndex; + int endIndex = i < segmentsCount - 1 ? segments[i + 1].StartIndex : pointsCount; + Vector2? endPoint = i < segmentsCount - 1 ? points[endIndex] : null; + controlPoints.AddRange(convertPoints(segments[i].Type, new ArraySegment(points, startIndex, endIndex - startIndex), endPoint)); + } + + return controlPoints.SelectMany(s => s).ToArray(); } - - var controlPoints = new List(pointsCount); - - for (int i = 0; i < segmentsCount; i++) + finally { - int startIndex = segments[i].StartIndex; - int endIndex = i < segmentsCount - 1 ? segments[i + 1].StartIndex : pointsCount; - Vector2? endPoint = i < segmentsCount - 1 ? points[endIndex] : null; - controlPoints.AddRange(convertPoints(segments[i].Type, points[startIndex..endIndex], endPoint)); + ArrayPool.Shared.Return(points); + ArrayPool<(PathType Type, int StartIndex)>.Shared.Return(segments); } - return controlPoints.ToArray(); - static Vector2 readPoint(string value, Vector2 startPos) { string[] vertexSplit = value.Split(':'); @@ -317,13 +326,12 @@ namespace osu.Game.Rulesets.Objects.Legacy /// The point list. /// Any extra endpoint to consider as part of the points. This will NOT be returned. /// The set of points contained by as one or more segments of the path. - private IEnumerable convertPoints(PathType type, ReadOnlySpan points, Vector2? endPoint) + private IEnumerable> convertPoints(PathType type, ArraySegment points, Vector2? endPoint) { - var vertices = new PathControlPoint[points.Length]; - var result = new List(); + var vertices = new PathControlPoint[points.Count]; // Parse into control points. - for (int i = 0; i < points.Length; i++) + for (int i = 0; i < points.Count; i++) vertices[i] = new PathControlPoint { Position = points[i] }; // Edge-case rules (to match stable). @@ -333,7 +341,7 @@ namespace osu.Game.Rulesets.Objects.Legacy if (vertices.Length + endPointLength != 3) type = PathType.BEZIER; - else if (isLinear(stackalloc[] { points[0], points[1], endPoint ?? points[2] })) + else if (isLinear(points[0], points[1], endPoint ?? points[2])) { // osu-stable special-cased colinear perfect curves to a linear path type = PathType.LINEAR; @@ -370,20 +378,18 @@ namespace osu.Game.Rulesets.Objects.Legacy // Force a type on the last point, and return the current control point set as a segment. vertices[endIndex - 1].Type = type; - for (int i = startIndex; i < endIndex; i++) - result.Add(vertices[i]); + yield return new ArraySegment(vertices, startIndex, endIndex - startIndex); // Skip the current control point - as it's the same as the one that's just been returned. startIndex = endIndex + 1; } - for (int i = startIndex; i < endIndex; i++) - result.Add(vertices[i]); + if (startIndex < endIndex) + yield return new ArraySegment(vertices, startIndex, endIndex - startIndex); - return result; - - static bool isLinear(ReadOnlySpan p) => Precision.AlmostEquals(0, (p[1].Y - p[0].Y) * (p[2].X - p[0].X) - - (p[1].X - p[0].X) * (p[2].Y - p[0].Y)); + static bool isLinear(Vector2 p0, Vector2 p1, Vector2 p2) + => Precision.AlmostEquals(0, (p1.Y - p0.Y) * (p2.X - p0.X) + - (p1.X - p0.X) * (p2.Y - p0.Y)); } /// From c10ba6ece9aea6d4325482563ae64fbc8261a65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 28 Feb 2024 15:59:22 +0100 Subject: [PATCH 242/508] Fix right mouse scroll clamping not going along well with padding Co-authored-by: Joseph Madamba --- osu.Game/Graphics/Containers/OsuScrollContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/OsuScrollContainer.cs b/osu.Game/Graphics/Containers/OsuScrollContainer.cs index 124becc35a..ffd28957ef 100644 --- a/osu.Game/Graphics/Containers/OsuScrollContainer.cs +++ b/osu.Game/Graphics/Containers/OsuScrollContainer.cs @@ -127,7 +127,7 @@ namespace osu.Game.Graphics.Containers } protected virtual void ScrollFromMouseEvent(MouseEvent e) => - ScrollTo(Clamp(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim] / DrawSize[ScrollDim]) * Content.DrawSize[ScrollDim], true, DistanceDecayOnRightMouseScrollbar); + ScrollTo(Clamp(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim] / DrawSize[ScrollDim] * Content.DrawSize[ScrollDim]), true, DistanceDecayOnRightMouseScrollbar); protected override ScrollbarContainer CreateScrollbar(Direction direction) => new OsuScrollbar(direction); From 470d2be2e1b4043953e067ef91e4c997138cc0ef Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 29 Feb 2024 00:07:00 +0800 Subject: [PATCH 243/508] The overhead of LINQ is not ignorable --- .../Objects/Legacy/ConvertHitObjectParser.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index a3ca719ff9..72053648a0 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -302,7 +302,7 @@ namespace osu.Game.Rulesets.Objects.Legacy controlPoints.AddRange(convertPoints(segments[i].Type, new ArraySegment(points, startIndex, endIndex - startIndex), endPoint)); } - return controlPoints.SelectMany(s => s).ToArray(); + return mergePointsLists(controlPoints); } finally { @@ -392,6 +392,25 @@ namespace osu.Game.Rulesets.Objects.Legacy - (p1.X - p0.X) * (p2.Y - p0.Y)); } + private PathControlPoint[] mergePointsLists(List> controlPointList) + { + int totalCount = 0; + + foreach (var arr in controlPointList) + totalCount += arr.Count; + + var mergedArray = new PathControlPoint[totalCount]; + int copyIndex = 0; + + foreach (var arr in controlPointList) + { + arr.AsSpan().CopyTo(mergedArray.AsSpan(copyIndex)); + copyIndex += arr.Count; + } + + return mergedArray; + } + /// /// Creates a legacy Hit-type hit object. /// From e86ebd6cdba85e506a771aeab0fdeb0a71d74fab Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 29 Feb 2024 00:24:24 +0800 Subject: [PATCH 244/508] Fix formatting --- osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index 72053648a0..f042e6ba26 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -271,9 +271,9 @@ namespace osu.Game.Rulesets.Objects.Legacy var segments = ArrayPool<(PathType Type, int StartIndex)>.Shared.Rent(pointSplit.Length); int pointsCount = 0; int segmentsCount = 0; + try { - foreach (string s in pointSplit) { if (char.IsLetter(s[0])) From 5ca6e8c68a54c0341fc1e0debac5c6e3ebb9739e Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 28 Feb 2024 11:03:09 -0800 Subject: [PATCH 245/508] Fix some NRT changes --- osu.Game/Screens/Play/SoloSpectatorPlayer.cs | 4 +++- osu.Game/Screens/Play/SpectatorPlayer.cs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/SoloSpectatorPlayer.cs b/osu.Game/Screens/Play/SoloSpectatorPlayer.cs index 2cc1c4a368..be83a4c6b5 100644 --- a/osu.Game/Screens/Play/SoloSpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SoloSpectatorPlayer.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Screens; using osu.Game.Online.Spectator; using osu.Game.Scoring; @@ -48,7 +49,8 @@ namespace osu.Game.Screens.Play { base.Dispose(isDisposing); - SpectatorClient.OnUserBeganPlaying -= userBeganPlaying; + if (SpectatorClient.IsNotNull()) + SpectatorClient.OnUserBeganPlaying -= userBeganPlaying; } } } diff --git a/osu.Game/Screens/Play/SpectatorPlayer.cs b/osu.Game/Screens/Play/SpectatorPlayer.cs index 520fb43445..b2ac946642 100644 --- a/osu.Game/Screens/Play/SpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SpectatorPlayer.cs @@ -1,8 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Diagnostics; using osu.Framework.Allocation; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Screens; using osu.Game.Beatmaps; @@ -97,7 +97,6 @@ namespace osu.Game.Screens.Play foreach (var frame in bundle.Frames) { IConvertibleReplayFrame convertibleFrame = GameplayState.Ruleset.CreateConvertibleReplayFrame()!; - Debug.Assert(convertibleFrame != null); convertibleFrame.FromLegacy(frame, GameplayState.Beatmap); var convertedFrame = (ReplayFrame)convertibleFrame; @@ -132,7 +131,8 @@ namespace osu.Game.Screens.Play { base.Dispose(isDisposing); - SpectatorClient.OnNewFrames -= userSentFrames; + if (SpectatorClient.IsNotNull()) + SpectatorClient.OnNewFrames -= userSentFrames; } } } From 232ca5778fc7fb86144f7bb74ee93ee2ac462549 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 00:09:48 +0300 Subject: [PATCH 246/508] Improve spectator fail test --- osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs index c8356cd191..0de2b6a980 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs @@ -10,6 +10,7 @@ using osu.Framework.Screens; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Database; +using osu.Game.Localisation; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Spectator; using osu.Game.Rulesets.Osu; @@ -23,7 +24,6 @@ using osu.Game.Tests.Gameplay; using osu.Game.Tests.Visual.Multiplayer; using osu.Game.Tests.Visual.Spectator; using osuTK; -using osuTK.Input; namespace osu.Game.Tests.Visual.Gameplay { @@ -214,7 +214,9 @@ namespace osu.Game.Tests.Visual.Gameplay checkPaused(true); // And eventually stop after running out of frames and fail. // Todo: Should check for + display a failed message. - AddStep("exit player", () => InputManager.Key(Key.Escape)); + AddAssert("fail overlay present", () => player.ChildrenOfType().Single().IsPresent); + AddAssert("overlay can only quit", () => player.ChildrenOfType().Single().Buttons.Single().Text == GameplayMenuOverlayStrings.Quit); + AddStep("press quit button", () => player.ChildrenOfType().Single().Buttons.Single().TriggerClick()); AddAssert("player exited", () => Stack.CurrentScreen is SoloSpectatorScreen); } From 4a4ef91bc96c9cab11102156c429a778237cdcbf Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 00:42:52 +0300 Subject: [PATCH 247/508] Simplify active mods computation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartłomiej Dach --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 9 +++++---- .../OnlinePlay/Match/RoomModSelectOverlay.cs | 14 +++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 6b80ff6e44..9605c0b2fe 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -104,6 +104,8 @@ namespace osu.Game.Overlays.Mods protected virtual IReadOnlyList ComputeNewModsFromSelection(IReadOnlyList oldSelection, IReadOnlyList newSelection) => newSelection; + protected virtual IReadOnlyList ComputeActiveMods() => SelectedMods.Value; + protected virtual IEnumerable CreateFooterButtons() { if (AllowCustomisation) @@ -321,13 +323,12 @@ namespace osu.Game.Overlays.Mods if (AllowCustomisation) ((IBindable>)modSettingsArea.SelectedMods).BindTo(SelectedMods); - SelectedMods.BindValueChanged(mods => + SelectedMods.BindValueChanged(_ => { - var newMods = ActiveMods.Value.Except(mods.OldValue).Concat(mods.NewValue).ToList(); - ActiveMods.Value = newMods; - updateFromExternalSelection(); updateCustomisation(); + + ActiveMods.Value = ComputeActiveMods(); }, true); ActiveMods.BindValueChanged(_ => diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs index d3fd6de911..55e077df0f 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomModSelectOverlay.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; @@ -9,6 +10,7 @@ using osu.Game.Online.Rooms; using osu.Game.Overlays; using osu.Game.Overlays.Mods; using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; namespace osu.Game.Screens.OnlinePlay.Match { @@ -20,6 +22,8 @@ namespace osu.Game.Screens.OnlinePlay.Match [Resolved] private RulesetStore rulesets { get; set; } = null!; + private readonly List roomRequiredMods = new List(); + public RoomModSelectOverlay() : base(OverlayColourScheme.Plum) { @@ -31,15 +35,19 @@ namespace osu.Game.Screens.OnlinePlay.Match selectedItem.BindValueChanged(v => { + roomRequiredMods.Clear(); + if (v.NewValue is PlaylistItem item) { var rulesetInstance = rulesets.GetRuleset(item.RulesetID)?.CreateInstance(); Debug.Assert(rulesetInstance != null); - ActiveMods.Value = item.RequiredMods.Select(m => m.ToMod(rulesetInstance)).Concat(SelectedMods.Value).ToList(); + roomRequiredMods.AddRange(item.RequiredMods.Select(m => m.ToMod(rulesetInstance))); } - else - ActiveMods.Value = SelectedMods.Value; + + ActiveMods.Value = ComputeActiveMods(); }, true); } + + protected override IReadOnlyList ComputeActiveMods() => roomRequiredMods.Concat(base.ComputeActiveMods()).ToList(); } } From c3a7e998497b136e5ca97b6729de4661cc28c2d5 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 01:01:55 +0300 Subject: [PATCH 248/508] Remove unnecessary max operation --- osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs index 7e0dd161dc..a14ab3cbcd 100644 --- a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Play.HUD int digitsRequiredForDisplayCount = Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount()); if (digitsRequiredForDisplayCount != scoreText.WireframeTemplate.Length) - scoreText.WireframeTemplate = new string('#', Math.Max(RequiredDisplayDigits.Value, digitsRequiredForDisplayCount)); + scoreText.WireframeTemplate = new string('#', digitsRequiredForDisplayCount); } private int getDigitsRequiredForDisplayCount() From de48c51715c072adb1ed75d7717a93e7af334e56 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 01:11:01 +0300 Subject: [PATCH 249/508] Apply renaming in remaining usages --- ...atisticsWatcher.cs => TestSceneUserStatisticsWatcher.cs} | 2 +- .../Toolbar/TransientUserStatisticsUpdateDisplay.cs | 6 +++--- osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs | 6 +++--- osu.Game/Users/UserRankPanel.cs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename osu.Game.Tests/Visual/Online/{TestSceneSoloStatisticsWatcher.cs => TestSceneUserStatisticsWatcher.cs} (99%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneSoloStatisticsWatcher.cs b/osu.Game.Tests/Visual/Online/TestSceneUserStatisticsWatcher.cs similarity index 99% rename from osu.Game.Tests/Visual/Online/TestSceneSoloStatisticsWatcher.cs rename to osu.Game.Tests/Visual/Online/TestSceneUserStatisticsWatcher.cs index 733769b9f3..0b1f50b66f 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneSoloStatisticsWatcher.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserStatisticsWatcher.cs @@ -21,7 +21,7 @@ using osu.Game.Users; namespace osu.Game.Tests.Visual.Online { [HeadlessTest] - public partial class TestSceneSoloStatisticsWatcher : OsuTestScene + public partial class TestSceneUserStatisticsWatcher : OsuTestScene { protected override bool UseOnlineAPI => false; diff --git a/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs b/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs index e7a78f8b80..21d91ef53f 100644 --- a/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs +++ b/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Toolbar private Statistic pp = null!; [BackgroundDependencyLoader] - private void load(UserStatisticsWatcher? soloStatisticsWatcher) + private void load(UserStatisticsWatcher? userStatisticsWatcher) { RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; @@ -47,8 +47,8 @@ namespace osu.Game.Overlays.Toolbar } }; - if (soloStatisticsWatcher != null) - ((IBindable)LatestUpdate).BindTo(soloStatisticsWatcher.LatestUpdate); + if (userStatisticsWatcher != null) + ((IBindable)LatestUpdate).BindTo(userStatisticsWatcher.LatestUpdate); } protected override void LoadComplete() diff --git a/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs b/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs index 7f8c12ddab..c37eb1914b 100644 --- a/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs +++ b/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs @@ -28,11 +28,11 @@ namespace osu.Game.Screens.Ranking.Statistics } [BackgroundDependencyLoader] - private void load(UserStatisticsWatcher? soloStatisticsWatcher) + private void load(UserStatisticsWatcher? userStatisticsWatcher) { - if (soloStatisticsWatcher != null) + if (userStatisticsWatcher != null) { - latestGlobalStatisticsUpdate = soloStatisticsWatcher.LatestUpdate.GetBoundCopy(); + latestGlobalStatisticsUpdate = userStatisticsWatcher.LatestUpdate.GetBoundCopy(); latestGlobalStatisticsUpdate.BindValueChanged(update => { if (update.NewValue?.Score.MatchesOnlineID(achievedScore) == true) diff --git a/osu.Game/Users/UserRankPanel.cs b/osu.Game/Users/UserRankPanel.cs index b440261a4c..0d57b7bb7d 100644 --- a/osu.Game/Users/UserRankPanel.cs +++ b/osu.Game/Users/UserRankPanel.cs @@ -168,7 +168,7 @@ namespace osu.Game.Users Title = UsersStrings.ShowRankGlobalSimple, // TODO: implement highest rank tooltip // `RankHighest` resides in `APIUser`, but `api.LocalUser` doesn't update - // maybe move to `UserStatistics` in api, so `SoloStatisticsWatcher` can update the value + // maybe move to `UserStatistics` in api, so `UserStatisticsWatcher` can update the value }, countryRankDisplay = new ProfileValueDisplay(true) { From 8f97f0503f1107d06576390eb014cb5dfaed4b0b Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 01:13:31 +0300 Subject: [PATCH 250/508] Move away from `Solo` namespace --- osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs | 2 +- osu.Game.Tests/Visual/Online/TestSceneUserStatisticsWatcher.cs | 2 +- osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs | 2 +- osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs | 2 +- osu.Game/Online/{Solo => }/UserStatisticsUpdate.cs | 2 +- osu.Game/Online/{Solo => }/UserStatisticsWatcher.cs | 2 +- osu.Game/OsuGame.cs | 1 - .../Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs | 2 +- osu.Game/Screens/Play/SubmittingPlayer.cs | 2 +- osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs | 2 +- osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs | 2 +- osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs | 2 +- 12 files changed, 11 insertions(+), 12 deletions(-) rename osu.Game/Online/{Solo => }/UserStatisticsUpdate.cs (97%) rename osu.Game/Online/{Solo => }/UserStatisticsWatcher.cs (99%) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs b/osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs index 41ce739c2f..1a4ca65975 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs @@ -8,8 +8,8 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Testing; +using osu.Game.Online; using osu.Game.Online.API; -using osu.Game.Online.Solo; using osu.Game.Overlays.Toolbar; using osu.Game.Scoring; using osu.Game.Users; diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserStatisticsWatcher.cs b/osu.Game.Tests/Visual/Online/TestSceneUserStatisticsWatcher.cs index 0b1f50b66f..e7ad07041c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserStatisticsWatcher.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserStatisticsWatcher.cs @@ -8,10 +8,10 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Models; +using osu.Game.Online; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; -using osu.Game.Online.Solo; using osu.Game.Online.Spectator; using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs b/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs index ee0ab0c880..ffc7d88a34 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs @@ -3,7 +3,7 @@ using NUnit.Framework; using osu.Framework.Graphics; -using osu.Game.Online.Solo; +using osu.Game.Online; using osu.Game.Scoring; using osu.Game.Screens.Ranking.Statistics.User; using osu.Game.Users; diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs b/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs index ecb8073a88..acfa519c81 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneStatisticsPanel.cs @@ -13,7 +13,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Online.Solo; +using osu.Game.Online; using osu.Game.Rulesets; using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Mods; diff --git a/osu.Game/Online/Solo/UserStatisticsUpdate.cs b/osu.Game/Online/UserStatisticsUpdate.cs similarity index 97% rename from osu.Game/Online/Solo/UserStatisticsUpdate.cs rename to osu.Game/Online/UserStatisticsUpdate.cs index 03f3abbb66..f85b219ef0 100644 --- a/osu.Game/Online/Solo/UserStatisticsUpdate.cs +++ b/osu.Game/Online/UserStatisticsUpdate.cs @@ -4,7 +4,7 @@ using osu.Game.Scoring; using osu.Game.Users; -namespace osu.Game.Online.Solo +namespace osu.Game.Online { /// /// Contains data about the change in a user's profile statistics after completing a score. diff --git a/osu.Game/Online/Solo/UserStatisticsWatcher.cs b/osu.Game/Online/UserStatisticsWatcher.cs similarity index 99% rename from osu.Game/Online/Solo/UserStatisticsWatcher.cs rename to osu.Game/Online/UserStatisticsWatcher.cs index 2fff92fe0f..af32e86ae4 100644 --- a/osu.Game/Online/Solo/UserStatisticsWatcher.cs +++ b/osu.Game/Online/UserStatisticsWatcher.cs @@ -15,7 +15,7 @@ using osu.Game.Online.Spectator; using osu.Game.Scoring; using osu.Game.Users; -namespace osu.Game.Online.Solo +namespace osu.Game.Online { /// /// A persistent component that binds to the spectator server and API in order to deliver updates about the logged in user's gameplay statistics. diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 419e31bacd..44d1e7fad6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -47,7 +47,6 @@ using osu.Game.Localisation; using osu.Game.Online; using osu.Game.Online.Chat; using osu.Game.Online.Rooms; -using osu.Game.Online.Solo; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapListing; using osu.Game.Overlays.Music; diff --git a/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs b/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs index 21d91ef53f..c6f373d55f 100644 --- a/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs +++ b/osu.Game/Overlays/Toolbar/TransientUserStatisticsUpdateDisplay.cs @@ -13,7 +13,7 @@ using osu.Framework.Threading; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Online.Solo; +using osu.Game.Online; using osu.Game.Resources.Localisation.Web; using osuTK; diff --git a/osu.Game/Screens/Play/SubmittingPlayer.cs b/osu.Game/Screens/Play/SubmittingPlayer.cs index ee88171789..62226c46dd 100644 --- a/osu.Game/Screens/Play/SubmittingPlayer.cs +++ b/osu.Game/Screens/Play/SubmittingPlayer.cs @@ -14,10 +14,10 @@ using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Database; +using osu.Game.Online; using osu.Game.Online.API; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; -using osu.Game.Online.Solo; using osu.Game.Online.Spectator; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; diff --git a/osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs b/osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs index 5c96a2b6c3..1e60e09486 100644 --- a/osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs +++ b/osu.Game/Screens/Ranking/Statistics/User/OverallRanking.cs @@ -6,7 +6,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics.UserInterface; -using osu.Game.Online.Solo; +using osu.Game.Online; namespace osu.Game.Screens.Ranking.Statistics.User { diff --git a/osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs b/osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs index a477f38cd1..e5f07d9891 100644 --- a/osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs +++ b/osu.Game/Screens/Ranking/Statistics/User/RankingChangeRow.cs @@ -11,7 +11,7 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Online.Solo; +using osu.Game.Online; using osu.Game.Users; using osuTK; diff --git a/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs b/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs index c37eb1914b..fa3bb1a375 100644 --- a/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs +++ b/osu.Game/Screens/Ranking/Statistics/UserStatisticsPanel.cs @@ -8,7 +8,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Beatmaps; using osu.Game.Extensions; -using osu.Game.Online.Solo; +using osu.Game.Online; using osu.Game.Scoring; using osu.Game.Screens.Ranking.Statistics.User; From 7f5f3804f1695e130a2ab41d5e4fda092a32ed1d Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 05:39:36 +0300 Subject: [PATCH 251/508] Expose beatmap storyboard as part of `GameplayState` --- osu.Game/Screens/Play/GameplayState.cs | 9 ++++++++- osu.Game/Screens/Play/Player.cs | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayState.cs b/osu.Game/Screens/Play/GameplayState.cs index cc399a0fbe..8b0207a340 100644 --- a/osu.Game/Screens/Play/GameplayState.cs +++ b/osu.Game/Screens/Play/GameplayState.cs @@ -10,6 +10,7 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; +using osu.Game.Storyboards; namespace osu.Game.Screens.Play { @@ -40,6 +41,11 @@ namespace osu.Game.Screens.Play public readonly ScoreProcessor ScoreProcessor; + /// + /// The storyboard associated with the beatmap. + /// + public readonly Storyboard Storyboard; + /// /// Whether gameplay completed without the user failing. /// @@ -62,7 +68,7 @@ namespace osu.Game.Screens.Play private readonly Bindable lastJudgementResult = new Bindable(); - public GameplayState(IBeatmap beatmap, Ruleset ruleset, IReadOnlyList? mods = null, Score? score = null, ScoreProcessor? scoreProcessor = null) + public GameplayState(IBeatmap beatmap, Ruleset ruleset, IReadOnlyList? mods = null, Score? score = null, ScoreProcessor? scoreProcessor = null, Storyboard? storyboard = null) { Beatmap = beatmap; Ruleset = ruleset; @@ -76,6 +82,7 @@ namespace osu.Game.Screens.Play }; Mods = mods ?? Array.Empty(); ScoreProcessor = scoreProcessor ?? ruleset.CreateScoreProcessor(); + Storyboard = storyboard ?? new Storyboard(); } /// diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 88f6ae9e71..10ada09be7 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -255,7 +255,7 @@ namespace osu.Game.Screens.Play Score.ScoreInfo.Ruleset = ruleset.RulesetInfo; Score.ScoreInfo.Mods = gameplayMods; - dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, gameplayMods, Score, ScoreProcessor)); + dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, gameplayMods, Score, ScoreProcessor, Beatmap.Value.Storyboard)); var rulesetSkinProvider = new RulesetSkinProvidingContainer(ruleset, playableBeatmap, Beatmap.Value.Skin); @@ -397,7 +397,7 @@ namespace osu.Game.Screens.Play protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart); private Drawable createUnderlayComponents() => - DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard, GameplayState.Mods) { RelativeSizeAxes = Axes.Both }; + DimmableStoryboard = new DimmableStoryboard(GameplayState.Storyboard, GameplayState.Mods) { RelativeSizeAxes = Axes.Both }; private Drawable createGameplayComponents(IWorkingBeatmap working) => new ScalingContainer(ScalingMode.Gameplay) { @@ -456,7 +456,7 @@ namespace osu.Game.Screens.Play { RequestSkip = performUserRequestedSkip }, - skipOutroOverlay = new SkipOverlay(Beatmap.Value.Storyboard.LatestEventTime ?? 0) + skipOutroOverlay = new SkipOverlay(GameplayState.Storyboard.LatestEventTime ?? 0) { RequestSkip = () => progressToResults(false), Alpha = 0 @@ -1088,7 +1088,7 @@ namespace osu.Game.Screens.Play DimmableStoryboard.IsBreakTime.BindTo(breakTracker.IsBreakTime); - storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable; + storyboardReplacesBackground.Value = GameplayState.Storyboard.ReplacesBackground && GameplayState.Storyboard.HasDrawable; foreach (var mod in GameplayState.Mods.OfType()) mod.ApplyToPlayer(this); From 847a8ead4fbdd86149b10fad884ed664a94e5352 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 05:39:59 +0300 Subject: [PATCH 252/508] Hide taiko scroller when beatmap has storyboard --- .../UI/DrawableTaikoRuleset.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs index 77b2b06c0e..ff969c3f74 100644 --- a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -22,7 +24,9 @@ using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Scoring; +using osu.Game.Screens.Play; using osu.Game.Skinning; +using osu.Game.Storyboards; using osuTK; namespace osu.Game.Rulesets.Taiko.UI @@ -39,6 +43,7 @@ namespace osu.Game.Rulesets.Taiko.UI protected override bool UserScrollSpeedAdjustment => false; + [CanBeNull] private SkinnableDrawable scroller; public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods = null) @@ -48,16 +53,24 @@ namespace osu.Game.Rulesets.Taiko.UI VisualisationMethod = ScrollVisualisationMethod.Overlapping; } - [BackgroundDependencyLoader] - private void load() + [BackgroundDependencyLoader(true)] + private void load(GameplayState gameplayState) { new BarLineGenerator(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar)); - FrameStableComponents.Add(scroller = new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Scroller), _ => Empty()) + var spriteElements = gameplayState.Storyboard.Layers.Where(l => l.Name != @"Overlay") + .SelectMany(l => l.Elements) + .OfType() + .DistinctBy(e => e.Path); + + if (spriteElements.Count() < 10) { - RelativeSizeAxes = Axes.X, - Depth = float.MaxValue - }); + FrameStableComponents.Add(scroller = new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Scroller), _ => Empty()) + { + RelativeSizeAxes = Axes.X, + Depth = float.MaxValue, + }); + } KeyBindingInputManager.Add(new DrumTouchInputArea()); } @@ -76,7 +89,9 @@ namespace osu.Game.Rulesets.Taiko.UI base.UpdateAfterChildren(); var playfieldScreen = Playfield.ScreenSpaceDrawQuad; - scroller.Height = ToLocalSpace(playfieldScreen.TopLeft + new Vector2(0, playfieldScreen.Height / 20)).Y; + + if (scroller != null) + scroller.Height = ToLocalSpace(playfieldScreen.TopLeft + new Vector2(0, playfieldScreen.Height / 20)).Y; } public MultiplierControlPoint ControlPointAt(double time) From f28f19ed7eeee1ecacc909f0f4f35edb07c7b8cb Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 29 Feb 2024 10:47:16 +0800 Subject: [PATCH 253/508] Fix method indent size Co-authored-by: Salman Ahmed --- osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index f042e6ba26..db1fbe3fa4 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -389,7 +389,7 @@ namespace osu.Game.Rulesets.Objects.Legacy static bool isLinear(Vector2 p0, Vector2 p1, Vector2 p2) => Precision.AlmostEquals(0, (p1.Y - p0.Y) * (p2.X - p0.X) - - (p1.X - p0.X) * (p2.Y - p0.Y)); + - (p1.X - p0.X) * (p2.Y - p0.Y)); } private PathControlPoint[] mergePointsLists(List> controlPointList) From 4b0b0735a81aec44fe0725eac3be8ece7b733854 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 06:03:57 +0300 Subject: [PATCH 254/508] Add test coverage --- .../TestSceneTaikoPlayerScroller.cs | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayerScroller.cs diff --git a/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayerScroller.cs b/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayerScroller.cs new file mode 100644 index 0000000000..c2aa819c3a --- /dev/null +++ b/osu.Game.Rulesets.Taiko.Tests/TestSceneTaikoPlayerScroller.cs @@ -0,0 +1,57 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Framework.Testing; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Taiko.Skinning.Legacy; +using osu.Game.Storyboards; +using osu.Game.Tests.Visual; +using osuTK; + +namespace osu.Game.Rulesets.Taiko.Tests +{ + public partial class TestSceneTaikoPlayerScroller : LegacySkinPlayerTestScene + { + private Storyboard? currentStoryboard; + + protected override bool HasCustomSteps => true; + + [Test] + public void TestForegroundSpritesHidesScroller() + { + AddStep("load storyboard", () => + { + currentStoryboard = new Storyboard(); + + for (int i = 0; i < 10; i++) + currentStoryboard.GetLayer("Foreground").Add(new StoryboardSprite($"test{i}", Anchor.Centre, Vector2.Zero)); + }); + + CreateTest(); + AddAssert("taiko scroller not present", () => !this.ChildrenOfType().Any()); + } + + [Test] + public void TestOverlaySpritesKeepsScroller() + { + AddStep("load storyboard", () => + { + currentStoryboard = new Storyboard(); + + for (int i = 0; i < 10; i++) + currentStoryboard.GetLayer("Overlay").Add(new StoryboardSprite($"test{i}", Anchor.Centre, Vector2.Zero)); + }); + + CreateTest(); + AddAssert("taiko scroller present", () => this.ChildrenOfType().Single().IsPresent); + } + + protected override Ruleset CreatePlayerRuleset() => new TaikoRuleset(); + + protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null) + => base.CreateWorkingBeatmap(beatmap, currentStoryboard ?? storyboard); + } +} From dac8f98ea6b7d6f039d5fbe9b86b17a4303969cb Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 29 Feb 2024 07:13:32 +0300 Subject: [PATCH 255/508] Fix `GameplayState` not handled as nullable --- osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs index ff969c3f74..b8e76be89e 100644 --- a/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/UI/DrawableTaikoRuleset.cs @@ -54,14 +54,14 @@ namespace osu.Game.Rulesets.Taiko.UI } [BackgroundDependencyLoader(true)] - private void load(GameplayState gameplayState) + private void load([CanBeNull] GameplayState gameplayState) { new BarLineGenerator(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar)); - var spriteElements = gameplayState.Storyboard.Layers.Where(l => l.Name != @"Overlay") + var spriteElements = gameplayState?.Storyboard.Layers.Where(l => l.Name != @"Overlay") .SelectMany(l => l.Elements) .OfType() - .DistinctBy(e => e.Path); + .DistinctBy(e => e.Path) ?? Enumerable.Empty(); if (spriteElements.Count() < 10) { From 5495c2090a76bfd6f6a5efd0fd61530395cc6a68 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Feb 2024 14:15:29 +0800 Subject: [PATCH 256/508] Add test coverage of gameplay only running forwards --- .../Visual/Gameplay/TestScenePause.cs | 66 ++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs index 73aa3be73d..030f2592ed 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePause.cs @@ -16,6 +16,7 @@ using osu.Game.Configuration; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Cursor; using osu.Game.Rulesets; +using osu.Game.Rulesets.UI; using osu.Game.Screens.Play; using osu.Game.Skinning; using osuTK; @@ -31,6 +32,9 @@ namespace osu.Game.Tests.Visual.Gameplay protected override Container Content => content; + private bool gameplayClockAlwaysGoingForward = true; + private double lastForwardCheckTime; + public TestScenePause() { base.Content.Add(content = new GlobalCursorDisplay { RelativeSizeAxes = Axes.Both }); @@ -67,12 +71,20 @@ namespace osu.Game.Tests.Visual.Gameplay confirmPausedWithNoOverlay(); } + [Test] + public void TestForwardPlaybackGuarantee() + { + hookForwardPlaybackCheck(); + + AddUntilStep("wait for forward playback", () => Player.GameplayClockContainer.CurrentTime > 1000); + AddStep("seek before gameplay", () => Player.GameplayClockContainer.Seek(-5000)); + + checkForwardPlayback(); + } + [Test] public void TestPauseWithLargeOffset() { - double lastStopTime; - bool alwaysGoingForward = true; - AddStep("force large offset", () => { var offset = (BindableDouble)LocalConfig.GetBindable(OsuSetting.AudioOffset); @@ -82,25 +94,7 @@ namespace osu.Game.Tests.Visual.Gameplay offset.Value = -5000; }); - AddStep("add time forward check hook", () => - { - lastStopTime = double.MinValue; - alwaysGoingForward = true; - - Player.OnUpdate += _ => - { - var masterClock = (MasterGameplayClockContainer)Player.GameplayClockContainer; - - double currentTime = masterClock.CurrentTime; - - bool goingForward = currentTime >= lastStopTime; - - alwaysGoingForward &= goingForward; - - if (!goingForward) - Logger.Log($"Went too far backwards (last stop: {lastStopTime:N1} current: {currentTime:N1})"); - }; - }); + hookForwardPlaybackCheck(); AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10))); @@ -108,11 +102,37 @@ namespace osu.Game.Tests.Visual.Gameplay resumeAndConfirm(); - AddAssert("time didn't go too far backwards", () => alwaysGoingForward); + checkForwardPlayback(); AddStep("reset offset", () => LocalConfig.SetValue(OsuSetting.AudioOffset, 0.0)); } + private void checkForwardPlayback() => AddAssert("time didn't go too far backwards", () => gameplayClockAlwaysGoingForward); + + private void hookForwardPlaybackCheck() + { + AddStep("add time forward check hook", () => + { + lastForwardCheckTime = double.MinValue; + gameplayClockAlwaysGoingForward = true; + + Player.OnUpdate += _ => + { + var frameStableClock = Player.ChildrenOfType().Single().Clock; + + double currentTime = frameStableClock.CurrentTime; + + bool goingForward = currentTime >= lastForwardCheckTime; + lastForwardCheckTime = currentTime; + + gameplayClockAlwaysGoingForward &= goingForward; + + if (!goingForward) + Logger.Log($"Went too far backwards (last stop: {lastForwardCheckTime:N1} current: {currentTime:N1})"); + }; + }); + } + [Test] public void TestPauseResume() { From 76e8aee9ccc13637691918de7c98d0cfaa8d1a7d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Feb 2024 13:45:46 +0800 Subject: [PATCH 257/508] Disallow backwards seeks during frame stable operation when a replay is not attached --- osu.Game/Rulesets/UI/FrameStabilityContainer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs index 8c9cb262af..4011034396 100644 --- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs +++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs @@ -150,6 +150,17 @@ namespace osu.Game.Rulesets.UI state = PlaybackState.NotValid; } + // This is a hotfix for https://github.com/ppy/osu/issues/26879 while we figure how the hell time is seeking + // backwards by 11,850 ms for some users during gameplay. + // + // It basically says that "while we're running in frame stable mode, and don't have a replay attached, + // time should never go backwards". If it does, we stop running gameplay until it returns to normal. + if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime) + { + state = PlaybackState.NotValid; + return; + } + // if the proposed time is the same as the current time, assume that the clock will continue progressing in the same direction as previously. // this avoids spurious flips in direction from -1 to 1 during rewinds. if (state == PlaybackState.Valid && proposedTime != manualClock.CurrentTime) From caad89a4ddd6b773df83e46d2da9c3ac4a81f0f8 Mon Sep 17 00:00:00 2001 From: Detze <92268414+Detze@users.noreply.github.com> Date: Thu, 29 Feb 2024 07:36:35 +0100 Subject: [PATCH 258/508] Fix test failure on leap years --- .../NonVisual/Filtering/FilterQueryParserTest.cs | 2 +- osu.Game/Screens/Select/FilterQueryParser.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs index 12d6060351..bf888348ee 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs @@ -538,7 +538,7 @@ namespace osu.Game.Tests.NonVisual.Filtering Assert.That(filterCriteria.LastPlayed.Max, Is.Not.Null); // the parser internally references `DateTimeOffset.Now`, so to not make things too annoying for tests, just assume some tolerance // (irrelevant in proportion to the actual filter proscribed). - Assert.That(filterCriteria.LastPlayed.Min, Is.EqualTo(DateTimeOffset.Now.AddYears(-1).AddMonths(-6)).Within(TimeSpan.FromSeconds(5))); + Assert.That(filterCriteria.LastPlayed.Min, Is.EqualTo(DateTimeOffset.Now.AddMonths(-6).AddYears(-1)).Within(TimeSpan.FromSeconds(5))); Assert.That(filterCriteria.LastPlayed.Max, Is.EqualTo(DateTimeOffset.Now.AddMonths(-3)).Within(TimeSpan.FromSeconds(5))); } diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index 2c4077dacf..1ee8b9bc05 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -402,19 +402,19 @@ namespace osu.Game.Screens.Select // we'll want to flip the operator, such that `>5d` means "more than five days ago", as in "*before* five days ago", // as intended by the user. case Operator.Less: - op = Operator.Greater; - break; - - case Operator.LessOrEqual: op = Operator.GreaterOrEqual; break; + case Operator.LessOrEqual: + op = Operator.Greater; + break; + case Operator.Greater: - op = Operator.Less; + op = Operator.LessOrEqual; break; case Operator.GreaterOrEqual: - op = Operator.LessOrEqual; + op = Operator.Less; break; } From 9f2ea1e936e84d092cf9d2f5733b72abb43f3553 Mon Sep 17 00:00:00 2001 From: Detze <92268414+Detze@users.noreply.github.com> Date: Thu, 29 Feb 2024 08:15:49 +0100 Subject: [PATCH 259/508] Revert incorrect change (I deserve to be shot) --- osu.Game/Screens/Select/FilterQueryParser.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index 1ee8b9bc05..2c4077dacf 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -402,19 +402,19 @@ namespace osu.Game.Screens.Select // we'll want to flip the operator, such that `>5d` means "more than five days ago", as in "*before* five days ago", // as intended by the user. case Operator.Less: - op = Operator.GreaterOrEqual; - break; - - case Operator.LessOrEqual: op = Operator.Greater; break; + case Operator.LessOrEqual: + op = Operator.GreaterOrEqual; + break; + case Operator.Greater: - op = Operator.LessOrEqual; + op = Operator.Less; break; case Operator.GreaterOrEqual: - op = Operator.Less; + op = Operator.LessOrEqual; break; } From 7b28a66fc074a869d3af3f86ca2cf5c1d5e463d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 29 Feb 2024 11:11:30 +0100 Subject: [PATCH 260/508] Add failing test case --- .../TestSceneSliderInput.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs index 12be74c4cc..286e4bd775 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSliderInput.cs @@ -457,6 +457,33 @@ namespace osu.Game.Rulesets.Osu.Tests assertMidSliderJudgementFail(); } + [Test] + public void TestRewindHandling() + { + performTest(new List + { + new OsuReplayFrame { Position = new Vector2(0), Actions = { OsuAction.LeftButton }, Time = time_slider_start }, + new OsuReplayFrame { Position = new Vector2(175, 0), Actions = { OsuAction.LeftButton }, Time = 3250 }, + new OsuReplayFrame { Position = new Vector2(175, 0), Actions = { OsuAction.LeftButton }, Time = time_slider_end }, + }, new Slider + { + StartTime = time_slider_start, + Position = new Vector2(0, 0), + Path = new SliderPath(PathType.PERFECT_CURVE, new[] + { + Vector2.Zero, + new Vector2(250, 0), + }, 250), + }); + + AddUntilStep("wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value); + AddAssert("no miss judgements recorded", () => judgementResults.All(r => r.Type.IsHit())); + + AddStep("rewind to middle of slider", () => currentPlayer.Seek(time_during_slide_4)); + AddUntilStep("wait for completion", () => currentPlayer.ScoreProcessor.HasCompleted.Value); + AddAssert("no miss judgements recorded", () => judgementResults.All(r => r.Type.IsHit())); + } + private void assertAllMaxJudgements() { AddAssert("All judgements max", () => From 3355764a68535facc627433f7c58d1040f3928e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Feb 2024 18:21:44 +0800 Subject: [PATCH 261/508] "Fix" tests --- osu.Game/Rulesets/UI/FrameStabilityContainer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs index 4011034396..487c12830f 100644 --- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs +++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; +using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Timing; @@ -155,7 +156,7 @@ namespace osu.Game.Rulesets.UI // // It basically says that "while we're running in frame stable mode, and don't have a replay attached, // time should never go backwards". If it does, we stop running gameplay until it returns to normal. - if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime) + if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !DebugUtils.IsNUnitRunning) { state = PlaybackState.NotValid; return; From 3a780e2b676eee99f0b0e845c12348977df22695 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Feb 2024 18:27:28 +0800 Subject: [PATCH 262/508] Add logging when workaround is hit --- osu.Game/Rulesets/UI/FrameStabilityContainer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs index 487c12830f..03f3b8788f 100644 --- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs +++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs @@ -9,6 +9,7 @@ using osu.Framework.Bindables; using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Logging; using osu.Framework.Timing; using osu.Game.Input.Handlers; using osu.Game.Screens.Play; @@ -158,6 +159,7 @@ namespace osu.Game.Rulesets.UI // time should never go backwards". If it does, we stop running gameplay until it returns to normal. if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !DebugUtils.IsNUnitRunning) { + Logger.Log($"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})"); state = PlaybackState.NotValid; return; } From d05b31933fabb30da23e90cad95f3ea91ac40e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 29 Feb 2024 11:44:14 +0100 Subject: [PATCH 263/508] Fix slider tracking state not restoring correctly in all cases on rewind --- .../Objects/Drawables/SliderInputManager.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs index 148cf79337..58fa04bb4c 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs @@ -5,11 +5,13 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Input; using osu.Framework.Input.Events; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; +using osu.Game.Screens.Play; using osuTK; namespace osu.Game.Rulesets.Osu.Objects.Drawables @@ -21,6 +23,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables /// public bool Tracking { get; private set; } + [Resolved] + private IGameplayClock? gameplayClock { get; set; } + + private readonly Stack<(double time, bool tracking)> trackingHistory = new Stack<(double, bool)>(); + /// /// The point in time after which we can accept any key for tracking. Before this time, we may need to restrict tracking to the key used to hit the head circle. /// @@ -208,6 +215,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables /// Whether the current mouse position is valid to begin tracking. private void updateTracking(bool isValidTrackingPosition) { + if (gameplayClock?.IsRewinding == true) + { + while (trackingHistory.TryPeek(out var historyEntry) && Time.Current < historyEntry.time) + trackingHistory.Pop(); + + Debug.Assert(trackingHistory.Count > 0); + + Tracking = trackingHistory.Peek().tracking; + return; + } + + bool wasTracking = Tracking; + // from the point at which the head circle is hit, this will be non-null. // it may be null if the head circle was missed. OsuAction? headCircleHitAction = getInitialHitAction(); @@ -247,6 +267,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables && isValidTrackingPosition // valid action && validTrackingAction; + + if (wasTracking != Tracking) + trackingHistory.Push((Time.Current, Tracking)); } private OsuAction? getInitialHitAction() => slider.HeadCircle?.HitAction; From 1d1db951f08731604676bcca3c470a8416e23dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 29 Feb 2024 11:54:42 +0100 Subject: [PATCH 264/508] Reset slider input manager state completely on new object application Kind of scary this wasn't happening already. Mirrors `SpinnerRotationTracker`. --- .../Objects/Drawables/SliderInputManager.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs index 58fa04bb4c..5daf8ed972 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics; using osu.Framework.Input; using osu.Framework.Input.Events; using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Types; using osu.Game.Screens.Play; using osuTK; @@ -56,6 +57,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public SliderInputManager(DrawableSlider slider) { this.slider = slider; + this.slider.HitObjectApplied += resetState; } /// @@ -287,5 +289,22 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables return action == OsuAction.LeftButton || action == OsuAction.RightButton; } + + private void resetState(DrawableHitObject obj) + { + Tracking = false; + trackingHistory.Clear(); + trackingHistory.Push((double.NegativeInfinity, false)); + timeToAcceptAnyKeyAfter = null; + lastPressedActions.Clear(); + screenSpaceMousePosition = null; + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + slider.HitObjectApplied -= resetState; + } } } From 876b80642357996f90e8469cc25eb1e490f1f224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 29 Feb 2024 12:11:50 +0100 Subject: [PATCH 265/508] Store tracking history to slider judgement result instead --- .../Judgements/OsuSliderJudgementResult.cs | 20 +++++++++++++++++++ .../Objects/Drawables/DrawableSlider.cs | 6 ++++++ .../Objects/Drawables/SliderInputManager.cs | 7 ++----- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Judgements/OsuSliderJudgementResult.cs diff --git a/osu.Game.Rulesets.Osu/Judgements/OsuSliderJudgementResult.cs b/osu.Game.Rulesets.Osu/Judgements/OsuSliderJudgementResult.cs new file mode 100644 index 0000000000..f52294cdd7 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Judgements/OsuSliderJudgementResult.cs @@ -0,0 +1,20 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Osu.Judgements +{ + public class OsuSliderJudgementResult : OsuJudgementResult + { + public readonly Stack<(double time, bool tracking)> TrackingHistory = new Stack<(double, bool)>(); + + public OsuSliderJudgementResult(HitObject hitObject, Judgement judgement) + : base(hitObject, judgement) + { + TrackingHistory.Push((double.NegativeInfinity, false)); + } + } +} diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index b7ce712e2c..e519e51562 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -14,8 +14,10 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Layout; using osu.Game.Audio; using osu.Game.Graphics.Containers; +using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Skinning.Default; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; @@ -27,6 +29,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { public new Slider HitObject => (Slider)base.HitObject; + public new OsuSliderJudgementResult Result => (OsuSliderJudgementResult)base.Result; + public DrawableSliderHead HeadCircle => headContainer.Child; public DrawableSliderTail TailCircle => tailContainer.Child; @@ -134,6 +138,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables }, true); } + protected override JudgementResult CreateResult(Judgement judgement) => new OsuSliderJudgementResult(HitObject, judgement); + protected override void OnApply() { base.OnApply(); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs index 5daf8ed972..c75ae35a1a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/SliderInputManager.cs @@ -27,8 +27,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables [Resolved] private IGameplayClock? gameplayClock { get; set; } - private readonly Stack<(double time, bool tracking)> trackingHistory = new Stack<(double, bool)>(); - /// /// The point in time after which we can accept any key for tracking. Before this time, we may need to restrict tracking to the key used to hit the head circle. /// @@ -219,6 +217,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { if (gameplayClock?.IsRewinding == true) { + var trackingHistory = slider.Result.TrackingHistory; while (trackingHistory.TryPeek(out var historyEntry) && Time.Current < historyEntry.time) trackingHistory.Pop(); @@ -271,7 +270,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables && validTrackingAction; if (wasTracking != Tracking) - trackingHistory.Push((Time.Current, Tracking)); + slider.Result.TrackingHistory.Push((Time.Current, Tracking)); } private OsuAction? getInitialHitAction() => slider.HeadCircle?.HitAction; @@ -293,8 +292,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private void resetState(DrawableHitObject obj) { Tracking = false; - trackingHistory.Clear(); - trackingHistory.Push((double.NegativeInfinity, false)); timeToAcceptAnyKeyAfter = null; lastPressedActions.Clear(); screenSpaceMousePosition = null; From a11e63b184acc5030e3d167f13d85a3691f0b7dc Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 29 Feb 2024 20:02:04 +0800 Subject: [PATCH 266/508] Make the code more clear --- .../Objects/Legacy/ConvertHitObjectParser.cs | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index db1fbe3fa4..2b058d5e1f 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -265,49 +265,59 @@ namespace osu.Game.Rulesets.Objects.Legacy private PathControlPoint[] convertPathString(string pointString, Vector2 offset) { // This code takes on the responsibility of handling explicit segments of the path ("X" & "Y" from above). Implicit segments are handled by calls to convertPoints(). - string[] pointSplit = pointString.Split('|'); + string[] pointStringSplit = pointString.Split('|'); - var points = ArrayPool.Shared.Rent(pointSplit.Length); - var segments = ArrayPool<(PathType Type, int StartIndex)>.Shared.Rent(pointSplit.Length); - int pointsCount = 0; - int segmentsCount = 0; + var pointsBuffer = ArrayPool.Shared.Rent(pointStringSplit.Length); + var segmentsBuffer = ArrayPool<(PathType Type, int StartIndex)>.Shared.Rent(pointStringSplit.Length); + int currentPointsIndex = 0; + int currentSegmentsIndex = 0; try { - foreach (string s in pointSplit) + foreach (string s in pointStringSplit) { if (char.IsLetter(s[0])) { // The start of a new segment(indicated by having an alpha character at position 0). var pathType = convertPathType(s); - segments[segmentsCount++] = (pathType, pointsCount); + segmentsBuffer[currentSegmentsIndex++] = (pathType, currentPointsIndex); // First segment is prepended by an extra zero point - if (pointsCount == 0) - points[pointsCount++] = Vector2.Zero; + if (currentPointsIndex == 0) + pointsBuffer[currentPointsIndex++] = Vector2.Zero; } else { - points[pointsCount++] = readPoint(s, offset); + pointsBuffer[currentPointsIndex++] = readPoint(s, offset); } } + int pointsCount = currentPointsIndex; + int segmentsCount = currentSegmentsIndex; var controlPoints = new List>(pointsCount); + var allPoints = new ArraySegment(pointsBuffer, 0, pointsCount); for (int i = 0; i < segmentsCount; i++) { - int startIndex = segments[i].StartIndex; - int endIndex = i < segmentsCount - 1 ? segments[i + 1].StartIndex : pointsCount; - Vector2? endPoint = i < segmentsCount - 1 ? points[endIndex] : null; - controlPoints.AddRange(convertPoints(segments[i].Type, new ArraySegment(points, startIndex, endIndex - startIndex), endPoint)); + if (i < segmentsCount - 1) + { + int startIndex = segmentsBuffer[i].StartIndex; + int endIndex = segmentsBuffer[i + 1].StartIndex; + controlPoints.AddRange(convertPoints(segmentsBuffer[i].Type, allPoints[startIndex..endIndex], pointsBuffer[endIndex])); + } + else + { + int startIndex = segmentsBuffer[i].StartIndex; + controlPoints.AddRange(convertPoints(segmentsBuffer[i].Type, allPoints[startIndex..], null)); + } } return mergePointsLists(controlPoints); } finally { - ArrayPool.Shared.Return(points); - ArrayPool<(PathType Type, int StartIndex)>.Shared.Return(segments); + ArrayPool.Shared.Return(pointsBuffer); + ArrayPool<(PathType, int)>.Shared.Return(segmentsBuffer); } static Vector2 readPoint(string value, Vector2 startPos) From 4184a5c1ef380318dae27492c0f68c4ba211aa0e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Feb 2024 20:34:38 +0800 Subject: [PATCH 267/508] Add flag to allow backwards seeks in tests --- .../TestSceneTimingBasedNoteColouring.cs | 21 ++++++++++++------- .../NonVisual/FirstAvailableHitWindowsTest.cs | 1 + .../TestSceneCompletionCancellation.cs | 2 ++ .../TestSceneFrameStabilityContainer.cs | 3 +++ .../TestSceneGameplaySamplePlayback.cs | 2 ++ .../TestSceneGameplaySampleTriggerSource.cs | 2 ++ .../Visual/Gameplay/TestSceneHitErrorMeter.cs | 1 + .../Gameplay/TestScenePoolingRuleset.cs | 1 + .../Gameplay/TestSceneStoryboardWithOutro.cs | 2 ++ osu.Game/Rulesets/UI/DrawableRuleset.cs | 20 ++++++++++++++++++ .../Rulesets/UI/FrameStabilityContainer.cs | 5 +++-- osu.Game/Tests/Visual/PlayerTestScene.cs | 12 ++++++++++- 12 files changed, 61 insertions(+), 11 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs b/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs index 81557c198d..b5b265792b 100644 --- a/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs +++ b/osu.Game.Rulesets.Mania.Tests/TestSceneTimingBasedNoteColouring.cs @@ -34,16 +34,21 @@ namespace osu.Game.Rulesets.Mania.Tests [SetUpSteps] public void SetUpSteps() { - AddStep("setup hierarchy", () => Child = new Container + AddStep("setup hierarchy", () => { - Clock = new FramedClock(clock = new ManualClock()), - RelativeSizeAxes = Axes.Both, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Children = new[] + Child = new Container { - drawableRuleset = (DrawableManiaRuleset)Ruleset.Value.CreateInstance().CreateDrawableRulesetWith(createTestBeatmap()) - } + Clock = new FramedClock(clock = new ManualClock()), + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Children = new[] + { + drawableRuleset = (DrawableManiaRuleset)Ruleset.Value.CreateInstance().CreateDrawableRulesetWith(createTestBeatmap()) + } + }; + + drawableRuleset.AllowBackwardsSeeks = true; }); AddStep("retrieve config bindable", () => { diff --git a/osu.Game.Tests/NonVisual/FirstAvailableHitWindowsTest.cs b/osu.Game.Tests/NonVisual/FirstAvailableHitWindowsTest.cs index 0bdd0ceae6..d4b69c1be2 100644 --- a/osu.Game.Tests/NonVisual/FirstAvailableHitWindowsTest.cs +++ b/osu.Game.Tests/NonVisual/FirstAvailableHitWindowsTest.cs @@ -100,6 +100,7 @@ namespace osu.Game.Tests.NonVisual public override Container FrameStableComponents { get; } public override IFrameStableClock FrameStableClock { get; } internal override bool FrameStablePlayback { get; set; } + public override bool AllowBackwardsSeeks { get; set; } public override IReadOnlyList Mods { get; } public override double GameplayStartTime { get; } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneCompletionCancellation.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneCompletionCancellation.cs index 434d853992..f19f4b6690 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneCompletionCancellation.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneCompletionCancellation.cs @@ -29,6 +29,8 @@ namespace osu.Game.Tests.Visual.Gameplay protected override bool AllowFail => false; + protected override bool AllowBackwardsSeeks => true; + [SetUpSteps] public override void SetUpSteps() { diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneFrameStabilityContainer.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneFrameStabilityContainer.cs index 98a97e1d23..0cff675b28 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneFrameStabilityContainer.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneFrameStabilityContainer.cs @@ -131,6 +131,9 @@ namespace osu.Game.Tests.Visual.Gameplay private void createStabilityContainer(double gameplayStartTime = double.MinValue) => AddStep("create container", () => mainContainer.Child = new FrameStabilityContainer(gameplayStartTime) + { + AllowBackwardsSeeks = true, + } .WithChild(consumer = new ClockConsumingChild())); private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs index 3d35860fef..057197e819 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs @@ -16,6 +16,8 @@ namespace osu.Game.Tests.Visual.Gameplay { public partial class TestSceneGameplaySamplePlayback : PlayerTestScene { + protected override bool AllowBackwardsSeeks => true; + [Test] public void TestAllSamplesStopDuringSeek() { diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySampleTriggerSource.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySampleTriggerSource.cs index 3cbd5eefac..6981591193 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySampleTriggerSource.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySampleTriggerSource.cs @@ -28,6 +28,8 @@ namespace osu.Game.Tests.Visual.Gameplay { public partial class TestSceneGameplaySampleTriggerSource : PlayerTestScene { + protected override bool AllowBackwardsSeeks => true; + private TestGameplaySampleTriggerSource sampleTriggerSource = null!; protected override Ruleset CreatePlayerRuleset() => new OsuRuleset(); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs index 56900a0549..e57177498d 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs @@ -288,6 +288,7 @@ namespace osu.Game.Tests.Visual.Gameplay public override Container FrameStableComponents { get; } public override IFrameStableClock FrameStableClock { get; } internal override bool FrameStablePlayback { get; set; } + public override bool AllowBackwardsSeeks { get; set; } public override IReadOnlyList Mods { get; } public override double GameplayStartTime { get; } diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePoolingRuleset.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePoolingRuleset.cs index b567e8de8d..88effb4a7b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePoolingRuleset.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePoolingRuleset.cs @@ -269,6 +269,7 @@ namespace osu.Game.Tests.Visual.Gameplay drawableRuleset = (TestDrawablePoolingRuleset)ruleset.CreateDrawableRulesetWith(CreateWorkingBeatmap(beatmap).GetPlayableBeatmap(ruleset.RulesetInfo)); drawableRuleset.FrameStablePlayback = true; + drawableRuleset.AllowBackwardsSeeks = true; drawableRuleset.PoolSize = poolSize; Child = new Container diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneStoryboardWithOutro.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneStoryboardWithOutro.cs index 98825b27d4..f532921d63 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneStoryboardWithOutro.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneStoryboardWithOutro.cs @@ -31,6 +31,8 @@ namespace osu.Game.Tests.Visual.Gameplay { protected override bool HasCustomSteps => true; + protected override bool AllowBackwardsSeeks => true; + protected new OutroPlayer Player => (OutroPlayer)base.Player; private double currentBeatmapDuration; diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs index 4aeb3d4862..13e28279e6 100644 --- a/osu.Game/Rulesets/UI/DrawableRuleset.cs +++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs @@ -81,6 +81,19 @@ namespace osu.Game.Rulesets.UI public override IFrameStableClock FrameStableClock => frameStabilityContainer; + private bool allowBackwardsSeeks; + + public override bool AllowBackwardsSeeks + { + get => allowBackwardsSeeks; + set + { + allowBackwardsSeeks = value; + if (frameStabilityContainer != null) + frameStabilityContainer.AllowBackwardsSeeks = value; + } + } + private bool frameStablePlayback = true; internal override bool FrameStablePlayback @@ -178,6 +191,7 @@ namespace osu.Game.Rulesets.UI InternalChild = frameStabilityContainer = new FrameStabilityContainer(GameplayStartTime) { FrameStablePlayback = FrameStablePlayback, + AllowBackwardsSeeks = AllowBackwardsSeeks, Children = new Drawable[] { FrameStableComponents, @@ -463,6 +477,12 @@ namespace osu.Game.Rulesets.UI /// internal abstract bool FrameStablePlayback { get; set; } + /// + /// When a replay is not attached, we usually block any backwards seeks. + /// This will bypass the check. Should only be used for tests. + /// + public abstract bool AllowBackwardsSeeks { get; set; } + /// /// The mods which are to be applied. /// diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs index 03f3b8788f..ab48711955 100644 --- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs +++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; -using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Logging; @@ -26,6 +25,8 @@ namespace osu.Game.Rulesets.UI { public ReplayInputHandler? ReplayInputHandler { get; set; } + public bool AllowBackwardsSeeks { get; set; } + /// /// The number of CPU milliseconds to spend at most during seek catch-up. /// @@ -157,7 +158,7 @@ namespace osu.Game.Rulesets.UI // // It basically says that "while we're running in frame stable mode, and don't have a replay attached, // time should never go backwards". If it does, we stop running gameplay until it returns to normal. - if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !DebugUtils.IsNUnitRunning) + if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !AllowBackwardsSeeks) { Logger.Log($"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})"); state = PlaybackState.NotValid; diff --git a/osu.Game/Tests/Visual/PlayerTestScene.cs b/osu.Game/Tests/Visual/PlayerTestScene.cs index ee184c1f35..43d779261c 100644 --- a/osu.Game/Tests/Visual/PlayerTestScene.cs +++ b/osu.Game/Tests/Visual/PlayerTestScene.cs @@ -70,10 +70,20 @@ namespace osu.Game.Tests.Visual AddStep($"Load player for {CreatePlayerRuleset().Description}", LoadPlayer); AddUntilStep("player loaded", () => Player.IsLoaded && Player.Alpha == 1); + + if (AllowBackwardsSeeks) + { + AddStep("allow backwards seeking", () => + { + Player.DrawableRuleset.AllowBackwardsSeeks = AllowBackwardsSeeks; + }); + } } protected virtual bool AllowFail => false; + protected virtual bool AllowBackwardsSeeks => false; + protected virtual bool Autoplay => false; protected void LoadPlayer() => LoadPlayer(Array.Empty()); @@ -126,6 +136,6 @@ namespace osu.Game.Tests.Visual protected sealed override Ruleset CreateRuleset() => CreatePlayerRuleset(); - protected virtual TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false); + protected virtual TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(false, false, AllowBackwardsSeeks); } } From cc8b838bd45d5df2be723b6cb1ddd82bec5622b8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Feb 2024 23:03:27 +0800 Subject: [PATCH 268/508] Add comprehensive log output to help figure out problematic clocks --- osu.Game/Beatmaps/FramedBeatmapClock.cs | 26 ++++++++++++++++++- .../Rulesets/UI/FrameStabilityContainer.cs | 7 +++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/FramedBeatmapClock.cs b/osu.Game/Beatmaps/FramedBeatmapClock.cs index 49dff96ff1..af7be235fc 100644 --- a/osu.Game/Beatmaps/FramedBeatmapClock.cs +++ b/osu.Game/Beatmaps/FramedBeatmapClock.cs @@ -38,6 +38,7 @@ namespace osu.Game.Beatmaps private IDisposable? beatmapOffsetSubscription; private readonly DecouplingFramedClock decoupledTrack; + private readonly InterpolatingFramedClock interpolatedTrack; [Resolved] private OsuConfigManager config { get; set; } = null!; @@ -58,7 +59,7 @@ namespace osu.Game.Beatmaps // An interpolating clock is used to ensure precise time values even when the host audio subsystem is not reporting // high precision times (on windows there's generally only 5-10ms reporting intervals, as an example). - var interpolatedTrack = new InterpolatingFramedClock(decoupledTrack); + interpolatedTrack = new InterpolatingFramedClock(decoupledTrack); if (applyOffsets) { @@ -190,5 +191,28 @@ namespace osu.Game.Beatmaps base.Dispose(isDisposing); beatmapOffsetSubscription?.Dispose(); } + + public string GetSnapshot() + { + return + $"originalSource: {output(Source)}\n" + + $"userGlobalOffsetClock: {output(userGlobalOffsetClock)}\n" + + $"platformOffsetClock: {output(platformOffsetClock)}\n" + + $"userBeatmapOffsetClock: {output(userBeatmapOffsetClock)}\n" + + $"interpolatedTrack: {output(interpolatedTrack)}\n" + + $"decoupledTrack: {output(decoupledTrack)}\n" + + $"finalClockSource: {output(finalClockSource)}\n"; + + string output(IClock? clock) + { + if (clock == null) + return "null"; + + if (clock is IFrameBasedClock framed) + return $"current: {clock.CurrentTime:N2} running: {clock.IsRunning} rate: {clock.Rate} elapsed: {framed.ElapsedFrameTime:N2}"; + + return $"current: {clock.CurrentTime:N2} running: {clock.IsRunning} rate: {clock.Rate}"; + } + } } } diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs index ab48711955..c09018e8ca 100644 --- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs +++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs @@ -3,13 +3,16 @@ using System; using System.Diagnostics; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Logging; +using osu.Framework.Testing; using osu.Framework.Timing; +using osu.Game.Beatmaps; using osu.Game.Input.Handlers; using osu.Game.Screens.Play; @@ -161,6 +164,10 @@ namespace osu.Game.Rulesets.UI if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !AllowBackwardsSeeks) { Logger.Log($"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})"); + + if (parentGameplayClock is GameplayClockContainer gcc) + Logger.Log($"{gcc.ChildrenOfType().Single().GetSnapshot()}"); + state = PlaybackState.NotValid; return; } From 59b9d29a79c2520cda4b1fca7d2b8373e501c71d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Feb 2024 23:29:50 +0800 Subject: [PATCH 269/508] Fix formatting? --- .../Visual/Gameplay/TestSceneFrameStabilityContainer.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneFrameStabilityContainer.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneFrameStabilityContainer.cs index 0cff675b28..c2999e3f5a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneFrameStabilityContainer.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneFrameStabilityContainer.cs @@ -130,11 +130,12 @@ namespace osu.Game.Tests.Visual.Gameplay } private void createStabilityContainer(double gameplayStartTime = double.MinValue) => AddStep("create container", () => + { mainContainer.Child = new FrameStabilityContainer(gameplayStartTime) - { - AllowBackwardsSeeks = true, - } - .WithChild(consumer = new ClockConsumingChild())); + { + AllowBackwardsSeeks = true, + }.WithChild(consumer = new ClockConsumingChild()); + }); private void seekManualTo(double time) => AddStep($"seek manual clock to {time}", () => manualClock.CurrentTime = time); From eb0933c3a5aa2de47820d020d34cabaf7552e7e6 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 29 Feb 2024 20:35:20 +0300 Subject: [PATCH 270/508] Fix allocations in EffectPointVisualisation --- .../Summary/Parts/EffectPointVisualisation.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/EffectPointVisualisation.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/EffectPointVisualisation.cs index d92beba38a..bf87470e01 100644 --- a/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/EffectPointVisualisation.cs +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/Parts/EffectPointVisualisation.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; @@ -53,7 +52,18 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts // for changes. ControlPointInfo needs a refactor to make this flow better, but it should do for now. Scheduler.AddDelayed(() => { - var next = beatmap.ControlPointInfo.EffectPoints.FirstOrDefault(c => c.Time > effect.Time); + EffectControlPoint? next = null; + + for (int i = 0; i < beatmap.ControlPointInfo.EffectPoints.Count; i++) + { + var point = beatmap.ControlPointInfo.EffectPoints[i]; + + if (point.Time > effect.Time) + { + next = point; + break; + } + } if (!ReferenceEquals(nextControlPoint, next)) { From 61cc5d6f29606c3513f6c5b699849ef155be2f1f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Mar 2024 11:24:12 +0800 Subject: [PATCH 271/508] Fix typos in xmldoc --- osu.Desktop/Windows/WindowsAssociationManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index c784d52a4f..181403d287 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -180,7 +180,7 @@ namespace osu.Desktop.Windows private string programId => $@"{program_id_prefix}{Extension}"; /// - /// Installs a file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/com/-progid--key + /// Installs a file extension association in accordance with https://learn.microsoft.com/en-us/windows/win32/com/-progid--key /// public void Install() { @@ -219,7 +219,7 @@ namespace osu.Desktop.Windows } /// - /// Uninstalls the file extenstion association in accordance with https://learn.microsoft.com/en-us/windows/win32/shell/fa-file-types#deleting-registry-information-during-uninstallation + /// Uninstalls the file extension association in accordance with https://learn.microsoft.com/en-us/windows/win32/shell/fa-file-types#deleting-registry-information-during-uninstallation /// public void Uninstall() { From 00527da27d97ceba51f6d8bd46f4ec94542916a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Mar 2024 11:42:35 +0800 Subject: [PATCH 272/508] When discord is set to privacy mode, don't show beatmap being edited --- osu.Game/Users/UserActivity.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs index 1b09666df6..404ed141b9 100644 --- a/osu.Game/Users/UserActivity.cs +++ b/osu.Game/Users/UserActivity.cs @@ -151,7 +151,11 @@ namespace osu.Game.Users public EditingBeatmap() { } public override string GetStatus(bool hideIdentifiableInformation = false) => @"Editing a beatmap"; - public override string GetDetails(bool hideIdentifiableInformation = false) => BeatmapDisplayTitle; + + public override string GetDetails(bool hideIdentifiableInformation = false) => hideIdentifiableInformation + // For now let's assume that showing the beatmap a user is editing could reveal unwanted information. + ? string.Empty + : BeatmapDisplayTitle; } [MessagePackObject] From 4ad8bbb9e2d17c6c35fb26f37004c077af87dddf Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Fri, 1 Mar 2024 13:20:37 +0900 Subject: [PATCH 273/508] remove useless DrawablePool --- osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 0f2f9dc323..8bb5ee3617 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -107,8 +107,6 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters JudgementSpacing.BindValueChanged(_ => updateMetrics(), true); } - private readonly DrawablePool judgementLinePool = new DrawablePool(50); - public void Push(HitErrorShape shape) { Add(shape); From 19ed78eef57828c1da4210e5796bd5e7b7fcdb48 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Mar 2024 12:34:21 +0800 Subject: [PATCH 274/508] Log backwards seeks to sentry --- osu.Game/OsuGame.cs | 3 +++ .../Rulesets/UI/FrameStabilityContainer.cs | 15 ++++++++++--- .../Utils/SentryOnlyDiagnosticsException.cs | 21 +++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Utils/SentryOnlyDiagnosticsException.cs diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7d128a808a..eb1219f183 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1190,6 +1190,9 @@ namespace osu.Game { if (entry.Level < LogLevel.Important || entry.Target > LoggingTarget.Database || entry.Target == null) return; + if (entry.Exception is SentryOnlyDiagnosticsException) + return; + const int short_term_display_limit = 3; if (recentLogCount < short_term_display_limit) diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs index c09018e8ca..884310e44c 100644 --- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs +++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs @@ -15,6 +15,7 @@ using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Input.Handlers; using osu.Game.Screens.Play; +using osu.Game.Utils; namespace osu.Game.Rulesets.UI { @@ -29,6 +30,7 @@ namespace osu.Game.Rulesets.UI public ReplayInputHandler? ReplayInputHandler { get; set; } public bool AllowBackwardsSeeks { get; set; } + private double? lastBackwardsSeekLogTime; /// /// The number of CPU milliseconds to spend at most during seek catch-up. @@ -163,10 +165,17 @@ namespace osu.Game.Rulesets.UI // time should never go backwards". If it does, we stop running gameplay until it returns to normal. if (!hasReplayAttached && FrameStablePlayback && proposedTime > referenceClock.CurrentTime && !AllowBackwardsSeeks) { - Logger.Log($"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})"); + if (lastBackwardsSeekLogTime == null || Math.Abs(Clock.CurrentTime - lastBackwardsSeekLogTime.Value) > 1000) + { + lastBackwardsSeekLogTime = Clock.CurrentTime; - if (parentGameplayClock is GameplayClockContainer gcc) - Logger.Log($"{gcc.ChildrenOfType().Single().GetSnapshot()}"); + string loggableContent = $"Denying backwards seek during gameplay (reference: {referenceClock.CurrentTime:N2} stable: {proposedTime:N2})"; + + if (parentGameplayClock is GameplayClockContainer gcc) + loggableContent += $"\n{gcc.ChildrenOfType().Single().GetSnapshot()}"; + + Logger.Error(new SentryOnlyDiagnosticsException("backwards seek"), loggableContent); + } state = PlaybackState.NotValid; return; diff --git a/osu.Game/Utils/SentryOnlyDiagnosticsException.cs b/osu.Game/Utils/SentryOnlyDiagnosticsException.cs new file mode 100644 index 0000000000..1659b8a213 --- /dev/null +++ b/osu.Game/Utils/SentryOnlyDiagnosticsException.cs @@ -0,0 +1,21 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; + +namespace osu.Game.Utils +{ + /// + /// Log to sentry without showing an error notification to the user. + /// + /// + /// This can be used to convey important diagnostics to us developers without + /// getting in the user's way. Should be used sparingly. + internal class SentryOnlyDiagnosticsException : Exception + { + public SentryOnlyDiagnosticsException(string message) + : base(message) + { + } + } +} From 060e17e9898256128632ab1a524ab33c87d0b9c2 Mon Sep 17 00:00:00 2001 From: jvyden Date: Thu, 29 Feb 2024 19:57:32 -0500 Subject: [PATCH 275/508] Support Discord game invites in multiplayer lobbies --- osu.Desktop/DiscordRichPresence.cs | 83 +++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index f0da708766..b85abdb4fe 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -9,10 +9,13 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Logging; +using osu.Game; using osu.Game.Configuration; using osu.Game.Extensions; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; +using osu.Game.Online.Multiplayer; +using osu.Game.Online.Rooms; using osu.Game.Rulesets; using osu.Game.Users; using LogLevel = osu.Framework.Logging.LogLevel; @@ -22,6 +25,7 @@ namespace osu.Desktop internal partial class DiscordRichPresence : Component { private const string client_id = "367827983903490050"; + public const string DISCORD_PROTOCOL = $"discord-{client_id}://"; private DiscordRpcClient client = null!; @@ -33,6 +37,12 @@ namespace osu.Desktop [Resolved] private IAPIProvider api { get; set; } = null!; + [Resolved] + private OsuGame game { get; set; } = null!; + + [Resolved] + private MultiplayerClient multiplayerClient { get; set; } = null!; + private readonly IBindable status = new Bindable(); private readonly IBindable activity = new Bindable(); @@ -40,7 +50,12 @@ namespace osu.Desktop private readonly RichPresence presence = new RichPresence { - Assets = new Assets { LargeImageKey = "osu_logo_lazer", } + Assets = new Assets { LargeImageKey = "osu_logo_lazer" }, + Secrets = new Secrets + { + JoinSecret = null, + SpectateSecret = null, + }, }; [BackgroundDependencyLoader] @@ -52,8 +67,14 @@ namespace osu.Desktop }; client.OnReady += onReady; + client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Code} {e.Message}", LoggingTarget.Network, LogLevel.Error); - client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Code} {e.Message}", LoggingTarget.Network); + // set up stuff for spectate/join + // first, we register a uri scheme for when osu! isn't running and a user clicks join/spectate + // the rpc library we use also happens to _require_ that we do this + client.RegisterUriScheme(); + client.Subscribe(EventType.Join); // we have to explicitly tell discord to send us join events. + client.OnJoin += onJoin; config.BindWith(OsuSetting.DiscordRichPresence, privacyMode); @@ -114,6 +135,28 @@ namespace osu.Desktop { presence.Buttons = null; } + + if (!hideIdentifiableInformation && multiplayerClient.Room != null) + { + MultiplayerRoom room = multiplayerClient.Room; + presence.Party = new Party + { + Privacy = string.IsNullOrEmpty(room.Settings.Password) ? Party.PrivacySetting.Public : Party.PrivacySetting.Private, + ID = room.RoomID.ToString(), + // technically lobbies can have infinite users, but Discord needs this to be set to something. + // 1024 just happens to look nice. + // https://discord.com/channels/188630481301012481/188630652340404224/1212967974793642034 + Max = 1024, + Size = room.Users.Count, + }; + + presence.Secrets.JoinSecret = $"{room.RoomID}:{room.Settings.Password}"; + } + else + { + presence.Party = null; + presence.Secrets.JoinSecret = null; + } } else { @@ -139,6 +182,22 @@ namespace osu.Desktop client.SetPresence(presence); } + private void onJoin(object sender, JoinMessage args) + { + game.Window?.Raise(); // users will expect to be brought back to osu! when joining a lobby from discord + + if (!tryParseRoomSecret(args.Secret, out long roomId, out string? password)) + Logger.Log("Failed to parse the room secret Discord gave us", LoggingTarget.Network, LogLevel.Error); + + var request = new GetRoomRequest(roomId); + request.Success += room => Schedule(() => + { + game.PresentMultiplayerMatch(room, password); + }); + request.Failure += _ => Logger.Log("Couldn't find the room Discord gave us", LoggingTarget.Network, LogLevel.Error); + api.Queue(request); + } + private static readonly int ellipsis_length = Encoding.UTF8.GetByteCount(new[] { '…' }); private string truncate(string str) @@ -160,6 +219,26 @@ namespace osu.Desktop }); } + private static bool tryParseRoomSecret(ReadOnlySpan secret, out long roomId, out string? password) + { + roomId = 0; + password = null; + + int roomSecretSplitIndex = secret.IndexOf(':'); + + if (roomSecretSplitIndex == -1) + return false; + + if (!long.TryParse(secret[..roomSecretSplitIndex], out roomId)) + return false; + + // just convert to string here, we're going to have to alloc it later anyways + password = secret[(roomSecretSplitIndex + 1)..].ToString(); + if (password.Length == 0) password = null; + + return true; + } + private int? getBeatmapID(UserActivity activity) { switch (activity) From 92235e7789271da1080f6f8f635e52f5f8490002 Mon Sep 17 00:00:00 2001 From: jvyden Date: Fri, 1 Mar 2024 00:02:20 -0500 Subject: [PATCH 276/508] Make truncate and getBeatmapID static Code quality was complaining about hidden variables so I opted for this solution. --- osu.Desktop/DiscordRichPresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index b85abdb4fe..91f7f6e1da 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -200,7 +200,7 @@ namespace osu.Desktop private static readonly int ellipsis_length = Encoding.UTF8.GetByteCount(new[] { '…' }); - private string truncate(string str) + private static string truncate(string str) { if (Encoding.UTF8.GetByteCount(str) <= 128) return str; @@ -239,7 +239,7 @@ namespace osu.Desktop return true; } - private int? getBeatmapID(UserActivity activity) + private static int? getBeatmapID(UserActivity activity) { switch (activity) { From 963c0af8143654e20910ed4f6b48ebce5845ad4e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Mar 2024 16:43:47 +0800 Subject: [PATCH 277/508] Fix beatmap information still showing when testing a beatmap --- osu.Game/Users/UserActivity.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs index 404ed141b9..a5dd2cb37c 100644 --- a/osu.Game/Users/UserActivity.cs +++ b/osu.Game/Users/UserActivity.cs @@ -119,10 +119,10 @@ namespace osu.Game.Users } [MessagePackObject] - public class TestingBeatmap : InGame + public class TestingBeatmap : EditingBeatmap { public TestingBeatmap(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset) - : base(beatmapInfo, ruleset) + : base(beatmapInfo) { } From c6201ea5de4bc0ad9943fd5e5f83783e6172205d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 1 Mar 2024 20:28:52 +0800 Subject: [PATCH 278/508] Remove unused ruleset parameter when testing beatmap in editor --- osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs | 3 +-- osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs | 2 +- osu.Game/Users/UserActivity.cs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs index 4df34e6244..91942c391a 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs @@ -14,7 +14,6 @@ using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Rulesets; -using osu.Game.Rulesets.Osu; using osu.Game.Scoring; using osu.Game.Tests.Beatmaps; using osu.Game.Users; @@ -142,7 +141,7 @@ namespace osu.Game.Tests.Visual.Online AddStep("choosing", () => activity.Value = new UserActivity.ChoosingBeatmap()); AddStep("editing beatmap", () => activity.Value = new UserActivity.EditingBeatmap(new BeatmapInfo())); AddStep("modding beatmap", () => activity.Value = new UserActivity.ModdingBeatmap(new BeatmapInfo())); - AddStep("testing beatmap", () => activity.Value = new UserActivity.TestingBeatmap(new BeatmapInfo(), new OsuRuleset().RulesetInfo)); + AddStep("testing beatmap", () => activity.Value = new UserActivity.TestingBeatmap(new BeatmapInfo())); } [Test] diff --git a/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs b/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs index 7dff05667d..55607cbb7c 100644 --- a/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs +++ b/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Edit.GameplayTest private readonly Editor editor; private readonly EditorState editorState; - protected override UserActivity InitialActivity => new UserActivity.TestingBeatmap(Beatmap.Value.BeatmapInfo, Ruleset.Value); + protected override UserActivity InitialActivity => new UserActivity.TestingBeatmap(Beatmap.Value.BeatmapInfo); [Resolved] private MusicController musicController { get; set; } = null!; diff --git a/osu.Game/Users/UserActivity.cs b/osu.Game/Users/UserActivity.cs index a5dd2cb37c..a431b204bc 100644 --- a/osu.Game/Users/UserActivity.cs +++ b/osu.Game/Users/UserActivity.cs @@ -121,7 +121,7 @@ namespace osu.Game.Users [MessagePackObject] public class TestingBeatmap : EditingBeatmap { - public TestingBeatmap(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset) + public TestingBeatmap(IBeatmapInfo beatmapInfo) : base(beatmapInfo) { } From 3df32638c2235029625d929c41ce6237c646e75c Mon Sep 17 00:00:00 2001 From: Susko3 Date: Fri, 1 Mar 2024 16:06:30 +0100 Subject: [PATCH 279/508] Fix association descriptions never being written on update --- osu.Desktop/Windows/WindowsAssociationManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Desktop/Windows/WindowsAssociationManager.cs b/osu.Desktop/Windows/WindowsAssociationManager.cs index 181403d287..11b5c19ca1 100644 --- a/osu.Desktop/Windows/WindowsAssociationManager.cs +++ b/osu.Desktop/Windows/WindowsAssociationManager.cs @@ -82,6 +82,10 @@ namespace osu.Desktop.Windows try { updateAssociations(); + + // TODO: Remove once UpdateDescriptions() is called as specified in the xmldoc. + updateDescriptions(null); // always write default descriptions, in case of updating from an older version in which file associations were not implemented/installed + NotifyShellUpdate(); } catch (Exception e) From 77b3055978bdd3b872d4297f1b70ba05f6164c05 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Thu, 29 Feb 2024 23:23:57 +0300 Subject: [PATCH 280/508] Improve sb sprite end time guessing --- osu.Game/Storyboards/CommandTimelineGroup.cs | 41 ++-------------- osu.Game/Storyboards/StoryboardSprite.cs | 50 ++++++++++++++++++-- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/osu.Game/Storyboards/CommandTimelineGroup.cs b/osu.Game/Storyboards/CommandTimelineGroup.cs index 0b96db6861..c899cf77d3 100644 --- a/osu.Game/Storyboards/CommandTimelineGroup.cs +++ b/osu.Game/Storyboards/CommandTimelineGroup.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osuTK; using osuTK.Graphics; using osu.Framework.Graphics; @@ -46,32 +45,10 @@ namespace osu.Game.Storyboards } [JsonIgnore] - public double CommandsStartTime - { - get - { - double min = double.MaxValue; - - for (int i = 0; i < timelines.Length; i++) - min = Math.Min(min, timelines[i].StartTime); - - return min; - } - } + public double CommandsStartTime => timelines.Min(static t => t.StartTime); [JsonIgnore] - public double CommandsEndTime - { - get - { - double max = double.MinValue; - - for (int i = 0; i < timelines.Length; i++) - max = Math.Max(max, timelines[i].EndTime); - - return max; - } - } + public double CommandsEndTime => timelines.Max(static t => t.EndTime); [JsonIgnore] public double CommandsDuration => CommandsEndTime - CommandsStartTime; @@ -83,19 +60,7 @@ namespace osu.Game.Storyboards public virtual double EndTime => CommandsEndTime; [JsonIgnore] - public bool HasCommands - { - get - { - for (int i = 0; i < timelines.Length; i++) - { - if (timelines[i].HasCommands) - return true; - } - - return false; - } - } + public bool HasCommands => timelines.Any(static t => t.HasCommands); public virtual IEnumerable.TypedCommand> GetCommands(CommandTimelineSelector timelineSelector, double offset = 0) { diff --git a/osu.Game/Storyboards/StoryboardSprite.cs b/osu.Game/Storyboards/StoryboardSprite.cs index 982185d51b..350438942e 100644 --- a/osu.Game/Storyboards/StoryboardSprite.cs +++ b/osu.Game/Storyboards/StoryboardSprite.cs @@ -85,12 +85,56 @@ namespace osu.Game.Storyboards { get { - double latestEndTime = TimelineGroup.EndTime; + double latestEndTime = double.MaxValue; + + // Ignore the whole setup if there are loops. In theory they can be handled here too, however the logic will be overly complex. + if (loops.Count == 0) + { + // Here we are starting from maximum value and trying to minimise the end time on each step. + // There are few solid guesses we can make using which sprite's end time can be minimised: alpha = 0, scale = 0, colour.a = 0. + double[] deathTimes = + { + double.MaxValue, // alpha + double.MaxValue, // colour alpha + double.MaxValue, // scale + double.MaxValue, // scale x + double.MaxValue, // scale y + }; + + // The loops below are following the same pattern. + // We could be using TimelineGroup.EndValue here, however it's possible to have multiple commands with 0 value in a row + // so we are saving the earliest of them. + foreach (var alphaCommand in TimelineGroup.Alpha.Commands) + { + deathTimes[0] = alphaCommand.EndValue == 0 + ? Math.Min(alphaCommand.EndTime, deathTimes[0]) // commands are ordered by the start time, however end time may vary. Save the earliest. + : double.MaxValue; // If value isn't 0 (sprite becomes visible again), revert the saved state. + } + + foreach (var colourCommand in TimelineGroup.Colour.Commands) + deathTimes[1] = colourCommand.EndValue.A == 0 ? Math.Min(colourCommand.EndTime, deathTimes[1]) : double.MaxValue; + + foreach (var scaleCommand in TimelineGroup.Scale.Commands) + deathTimes[2] = scaleCommand.EndValue == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[2]) : double.MaxValue; + + foreach (var scaleCommand in TimelineGroup.VectorScale.Commands) + { + deathTimes[3] = scaleCommand.EndValue.X == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[3]) : double.MaxValue; + deathTimes[4] = scaleCommand.EndValue.Y == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[4]) : double.MaxValue; + } + + // Take the minimum time of all the potential "death" reasons. + latestEndTime = deathTimes.Min(); + } + + // If the logic above fails to find anything or discarded by the fact that there are loops present, latestEndTime will be double.MaxValue + // and thus conservativeEndTime will be used. + double conservativeEndTime = TimelineGroup.EndTime; foreach (var l in loops) - latestEndTime = Math.Max(latestEndTime, l.StartTime + l.CommandsDuration * l.TotalIterations); + conservativeEndTime = Math.Max(conservativeEndTime, l.StartTime + l.CommandsDuration * l.TotalIterations); - return latestEndTime; + return Math.Min(latestEndTime, conservativeEndTime); } } From 37e7a4dea7f957231a4eb2aaf9e95654ab4d711e Mon Sep 17 00:00:00 2001 From: Jayden Date: Fri, 1 Mar 2024 14:32:44 -0500 Subject: [PATCH 281/508] Fix yapping Co-authored-by: Salman Ahmed --- osu.Desktop/DiscordRichPresence.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 91f7f6e1da..035add8044 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -25,7 +25,6 @@ namespace osu.Desktop internal partial class DiscordRichPresence : Component { private const string client_id = "367827983903490050"; - public const string DISCORD_PROTOCOL = $"discord-{client_id}://"; private DiscordRpcClient client = null!; @@ -69,11 +68,9 @@ namespace osu.Desktop client.OnReady += onReady; client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Code} {e.Message}", LoggingTarget.Network, LogLevel.Error); - // set up stuff for spectate/join - // first, we register a uri scheme for when osu! isn't running and a user clicks join/spectate - // the rpc library we use also happens to _require_ that we do this + // A URI scheme is required to support game invitations, as well as informing Discord of the game executable path to support launching the game when a user clicks on join/spectate. client.RegisterUriScheme(); - client.Subscribe(EventType.Join); // we have to explicitly tell discord to send us join events. + client.Subscribe(EventType.Join); client.OnJoin += onJoin; config.BindWith(OsuSetting.DiscordRichPresence, privacyMode); @@ -184,7 +181,7 @@ namespace osu.Desktop private void onJoin(object sender, JoinMessage args) { - game.Window?.Raise(); // users will expect to be brought back to osu! when joining a lobby from discord + game.Window?.Raise(); if (!tryParseRoomSecret(args.Secret, out long roomId, out string? password)) Logger.Log("Failed to parse the room secret Discord gave us", LoggingTarget.Network, LogLevel.Error); @@ -232,7 +229,6 @@ namespace osu.Desktop if (!long.TryParse(secret[..roomSecretSplitIndex], out roomId)) return false; - // just convert to string here, we're going to have to alloc it later anyways password = secret[(roomSecretSplitIndex + 1)..].ToString(); if (password.Length == 0) password = null; From e0c73eb36225b1e7e058b3af5cc553f791ae28b6 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 1 Mar 2024 22:49:12 +0300 Subject: [PATCH 282/508] Fix osu!mania key images potentially showing gaps between columns --- osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs index 48b92a8486..9fd33b9963 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs @@ -6,6 +6,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Textures; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Rulesets.Mania.UI; @@ -49,14 +50,14 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy upSprite = new Sprite { Origin = Anchor.BottomCentre, - Texture = skin.GetTexture(upImage), + Texture = skin.GetTexture(upImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge), RelativeSizeAxes = Axes.X, Width = 1 }, downSprite = new Sprite { Origin = Anchor.BottomCentre, - Texture = skin.GetTexture(downImage), + Texture = skin.GetTexture(downImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge), RelativeSizeAxes = Axes.X, Width = 1, Alpha = 0 From f1b66da469ead2105e6b3f1d83e95e04b7f4ec45 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 1 Mar 2024 22:57:13 +0300 Subject: [PATCH 283/508] Add comments --- osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs index 9fd33b9963..6ba91fbbd5 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs @@ -50,6 +50,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy upSprite = new Sprite { Origin = Anchor.BottomCentre, + // ClampToEdge is used to avoid gaps between keys, see: https://github.com/ppy/osu/issues/27431 Texture = skin.GetTexture(upImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge), RelativeSizeAxes = Axes.X, Width = 1 @@ -57,6 +58,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy downSprite = new Sprite { Origin = Anchor.BottomCentre, + // ClampToEdge is used to avoid gaps between keys, see: https://github.com/ppy/osu/issues/27431 Texture = skin.GetTexture(downImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge), RelativeSizeAxes = Axes.X, Width = 1, From 82373ff752ab9c1d961a8c5673499ddb913bec05 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 2 Mar 2024 03:18:42 +0300 Subject: [PATCH 284/508] Add failing catch beatmap --- .../CatchBeatmapConversionTest.cs | 1 + .../Beatmaps/1041052-expected-conversion.json | 1 + .../Resources/Testing/Beatmaps/1041052.osu | 210 ++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 osu.Game.Rulesets.Catch.Tests/Resources/Testing/Beatmaps/1041052-expected-conversion.json create mode 100644 osu.Game.Rulesets.Catch.Tests/Resources/Testing/Beatmaps/1041052.osu diff --git a/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs index d0ecb828df..81e0675aaa 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchBeatmapConversionTest.cs @@ -53,6 +53,7 @@ namespace osu.Game.Rulesets.Catch.Tests [TestCase("3689906", new[] { typeof(CatchModDoubleTime), typeof(CatchModEasy) })] [TestCase("3949367", new[] { typeof(CatchModDoubleTime), typeof(CatchModEasy) })] [TestCase("112643")] + [TestCase("1041052", new[] { typeof(CatchModHardRock) })] public new void Test(string name, params Type[] mods) => base.Test(name, mods); protected override IEnumerable CreateConvertValue(HitObject hitObject) diff --git a/osu.Game.Rulesets.Catch.Tests/Resources/Testing/Beatmaps/1041052-expected-conversion.json b/osu.Game.Rulesets.Catch.Tests/Resources/Testing/Beatmaps/1041052-expected-conversion.json new file mode 100644 index 0000000000..01150e701d --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/Resources/Testing/Beatmaps/1041052-expected-conversion.json @@ -0,0 +1 @@ +{"Mappings":[{"StartTime":1155.0,"Objects":[{"StartTime":1155.0,"Position":208.0,"HyperDash":false},{"StartTime":1251.0,"Position":167.675858,"HyperDash":false},{"StartTime":1348.0,"Position":157.087921,"HyperDash":false},{"StartTime":1445.0,"Position":128.5,"HyperDash":false},{"StartTime":1542.0,"Position":105.912064,"HyperDash":false},{"StartTime":1620.0,"Position":102.336205,"HyperDash":false},{"StartTime":1735.0,"Position":55.0,"HyperDash":false}]},{"StartTime":2122.0,"Objects":[{"StartTime":2122.0,"Position":275.0,"HyperDash":false}]},{"StartTime":2509.0,"Objects":[{"StartTime":2509.0,"Position":269.0,"HyperDash":false}]},{"StartTime":3284.0,"Objects":[{"StartTime":3284.0,"Position":448.0,"HyperDash":false},{"StartTime":3380.0,"Position":466.562317,"HyperDash":false},{"StartTime":3477.0,"Position":477.575867,"HyperDash":false},{"StartTime":3556.0,"Position":467.440033,"HyperDash":false},{"StartTime":3671.0,"Position":481.146881,"HyperDash":false}]},{"StartTime":4058.0,"Objects":[{"StartTime":4058.0,"Position":288.0,"HyperDash":false}]},{"StartTime":5025.0,"Objects":[{"StartTime":5025.0,"Position":128.0,"HyperDash":false},{"StartTime":5121.0,"Position":94.67586,"HyperDash":false},{"StartTime":5218.0,"Position":77.08793,"HyperDash":false},{"StartTime":5315.0,"Position":51.5,"HyperDash":false},{"StartTime":5412.0,"Position":77.08794,"HyperDash":false},{"StartTime":5490.0,"Position":111.663795,"HyperDash":false},{"StartTime":5605.0,"Position":128.0,"HyperDash":false}]},{"StartTime":5800.0,"Objects":[{"StartTime":5800.0,"Position":352.0,"HyperDash":false}]},{"StartTime":5993.0,"Objects":[{"StartTime":5993.0,"Position":240.0,"HyperDash":false}]},{"StartTime":6187.0,"Objects":[{"StartTime":6187.0,"Position":336.0,"HyperDash":false}]},{"StartTime":6574.0,"Objects":[{"StartTime":6574.0,"Position":416.0,"HyperDash":false},{"StartTime":6670.0,"Position":394.697662,"HyperDash":false},{"StartTime":6767.0,"Position":365.131775,"HyperDash":false},{"StartTime":6864.0,"Position":344.5659,"HyperDash":false},{"StartTime":6961.0,"Position":314.0,"HyperDash":false},{"StartTime":7057.0,"Position":279.6977,"HyperDash":false},{"StartTime":7154.0,"Position":263.131775,"HyperDash":false},{"StartTime":7233.0,"Position":259.310059,"HyperDash":false},{"StartTime":7348.0,"Position":212.0,"HyperDash":false}]},{"StartTime":8122.0,"Objects":[{"StartTime":8122.0,"Position":488.0,"HyperDash":false},{"StartTime":8218.0,"Position":475.697662,"HyperDash":false},{"StartTime":8315.0,"Position":437.131775,"HyperDash":false},{"StartTime":8394.0,"Position":399.3101,"HyperDash":false},{"StartTime":8509.0,"Position":386.0,"HyperDash":false}]},{"StartTime":8896.0,"Objects":[{"StartTime":8896.0,"Position":457.0,"HyperDash":false},{"StartTime":8992.0,"Position":444.675873,"HyperDash":false},{"StartTime":9089.0,"Position":406.087921,"HyperDash":false},{"StartTime":9186.0,"Position":384.5,"HyperDash":false},{"StartTime":9283.0,"Position":354.912048,"HyperDash":false},{"StartTime":9361.0,"Position":330.3362,"HyperDash":false},{"StartTime":9476.0,"Position":304.0,"HyperDash":false}]},{"StartTime":10058.0,"Objects":[{"StartTime":10058.0,"Position":400.0,"HyperDash":false}]},{"StartTime":10445.0,"Objects":[{"StartTime":10445.0,"Position":304.0,"HyperDash":false},{"StartTime":10541.0,"Position":277.697662,"HyperDash":false},{"StartTime":10638.0,"Position":253.131775,"HyperDash":false},{"StartTime":10735.0,"Position":212.565887,"HyperDash":false},{"StartTime":10832.0,"Position":202.0,"HyperDash":false},{"StartTime":10928.0,"Position":208.302322,"HyperDash":false},{"StartTime":11025.0,"Position":252.868225,"HyperDash":false},{"StartTime":11104.0,"Position":286.6899,"HyperDash":false},{"StartTime":11219.0,"Position":304.0,"HyperDash":false}]},{"StartTime":11606.0,"Objects":[{"StartTime":11606.0,"Position":400.0,"HyperDash":false}]},{"StartTime":11993.0,"Objects":[{"StartTime":11993.0,"Position":240.0,"HyperDash":false},{"StartTime":12089.0,"Position":231.675858,"HyperDash":false},{"StartTime":12186.0,"Position":189.087921,"HyperDash":false},{"StartTime":12283.0,"Position":156.5,"HyperDash":false},{"StartTime":12380.0,"Position":137.912064,"HyperDash":false},{"StartTime":12458.0,"Position":136.336212,"HyperDash":false},{"StartTime":12573.0,"Position":87.0,"HyperDash":false}]},{"StartTime":13154.0,"Objects":[{"StartTime":13154.0,"Position":0.0,"HyperDash":false}]},{"StartTime":13542.0,"Objects":[{"StartTime":13542.0,"Position":112.0,"HyperDash":false},{"StartTime":13638.0,"Position":119.913734,"HyperDash":false},{"StartTime":13735.0,"Position":144.5726,"HyperDash":false},{"StartTime":13832.0,"Position":179.8026,"HyperDash":false},{"StartTime":13929.0,"Position":191.357681,"HyperDash":false},{"StartTime":14007.0,"Position":228.85704,"HyperDash":false},{"StartTime":14122.0,"Position":241.622177,"HyperDash":false}]},{"StartTime":14316.0,"Objects":[{"StartTime":14316.0,"Position":288.0,"HyperDash":false},{"StartTime":14412.0,"Position":328.324127,"HyperDash":false},{"StartTime":14509.0,"Position":338.912079,"HyperDash":false},{"StartTime":14606.0,"Position":364.5,"HyperDash":false},{"StartTime":14703.0,"Position":338.912079,"HyperDash":false},{"StartTime":14781.0,"Position":301.3362,"HyperDash":false},{"StartTime":14896.0,"Position":288.0,"HyperDash":false}]},{"StartTime":15284.0,"Objects":[{"StartTime":15284.0,"Position":192.0,"HyperDash":false},{"StartTime":15362.0,"Position":187.7823,"HyperDash":false},{"StartTime":15477.0,"Position":169.192108,"HyperDash":false}]},{"StartTime":15864.0,"Objects":[{"StartTime":15864.0,"Position":464.0,"HyperDash":false}]},{"StartTime":16638.0,"Objects":[{"StartTime":16638.0,"Position":128.0,"HyperDash":false},{"StartTime":16734.0,"Position":90.86488,"HyperDash":false},{"StartTime":16831.0,"Position":78.3134155,"HyperDash":false},{"StartTime":16928.0,"Position":73.3517761,"HyperDash":false},{"StartTime":17025.0,"Position":34.6746674,"HyperDash":false},{"StartTime":17121.0,"Position":33.0714569,"HyperDash":false},{"StartTime":17218.0,"Position":2.65127468,"HyperDash":false},{"StartTime":17315.0,"Position":19.907608,"HyperDash":false},{"StartTime":17412.0,"Position":34.674675,"HyperDash":false},{"StartTime":17508.0,"Position":56.12827,"HyperDash":false},{"StartTime":17605.0,"Position":78.0694351,"HyperDash":false},{"StartTime":17684.0,"Position":97.97488,"HyperDash":false},{"StartTime":17799.0,"Position":128.0,"HyperDash":false}]},{"StartTime":18187.0,"Objects":[{"StartTime":18187.0,"Position":224.0,"HyperDash":false},{"StartTime":18283.0,"Position":231.165024,"HyperDash":false},{"StartTime":18380.0,"Position":273.681732,"HyperDash":false},{"StartTime":18477.0,"Position":304.374176,"HyperDash":false},{"StartTime":18574.0,"Position":316.397827,"HyperDash":false},{"StartTime":18670.0,"Position":312.8548,"HyperDash":false},{"StartTime":18767.0,"Position":345.5291,"HyperDash":false},{"StartTime":18864.0,"Position":328.007355,"HyperDash":false},{"StartTime":18961.0,"Position":316.397827,"HyperDash":false},{"StartTime":19057.0,"Position":304.594452,"HyperDash":false},{"StartTime":19154.0,"Position":273.924957,"HyperDash":false},{"StartTime":19233.0,"Position":271.063354,"HyperDash":false},{"StartTime":19348.0,"Position":224.0,"HyperDash":false}]},{"StartTime":19735.0,"Objects":[{"StartTime":19735.0,"Position":128.0,"HyperDash":false},{"StartTime":19831.0,"Position":136.324142,"HyperDash":false},{"StartTime":19928.0,"Position":178.912079,"HyperDash":false},{"StartTime":20025.0,"Position":223.5,"HyperDash":false},{"StartTime":20122.0,"Position":230.087936,"HyperDash":false},{"StartTime":20200.0,"Position":260.6638,"HyperDash":false},{"StartTime":20315.0,"Position":281.0,"HyperDash":false}]},{"StartTime":20896.0,"Objects":[{"StartTime":20896.0,"Position":432.0,"HyperDash":false}]},{"StartTime":21284.0,"Objects":[{"StartTime":21284.0,"Position":328.0,"HyperDash":false},{"StartTime":21380.0,"Position":357.324127,"HyperDash":false},{"StartTime":21477.0,"Position":378.912079,"HyperDash":false},{"StartTime":21574.0,"Position":420.5,"HyperDash":false},{"StartTime":21671.0,"Position":430.087952,"HyperDash":false},{"StartTime":21749.0,"Position":447.6638,"HyperDash":false},{"StartTime":21864.0,"Position":481.0,"HyperDash":false}]},{"StartTime":22445.0,"Objects":[{"StartTime":22445.0,"Position":328.0,"HyperDash":false}]},{"StartTime":22832.0,"Objects":[{"StartTime":22832.0,"Position":224.0,"HyperDash":false},{"StartTime":22928.0,"Position":188.675858,"HyperDash":false},{"StartTime":23025.0,"Position":173.087921,"HyperDash":false},{"StartTime":23122.0,"Position":156.5,"HyperDash":false},{"StartTime":23219.0,"Position":121.912064,"HyperDash":false},{"StartTime":23297.0,"Position":91.3362045,"HyperDash":false},{"StartTime":23412.0,"Position":71.0,"HyperDash":false}]},{"StartTime":23993.0,"Objects":[{"StartTime":23993.0,"Position":224.0,"HyperDash":false}]},{"StartTime":24380.0,"Objects":[{"StartTime":24380.0,"Position":112.0,"HyperDash":false},{"StartTime":24476.0,"Position":127.324142,"HyperDash":false},{"StartTime":24573.0,"Position":162.912079,"HyperDash":false},{"StartTime":24670.0,"Position":202.5,"HyperDash":false},{"StartTime":24767.0,"Position":214.087936,"HyperDash":false},{"StartTime":24845.0,"Position":246.663788,"HyperDash":false},{"StartTime":24960.0,"Position":265.0,"HyperDash":false}]},{"StartTime":25541.0,"Objects":[{"StartTime":25541.0,"Position":416.0,"HyperDash":false}]},{"StartTime":25929.0,"Objects":[{"StartTime":25929.0,"Position":304.0,"HyperDash":false},{"StartTime":26025.0,"Position":287.9714,"HyperDash":false},{"StartTime":26122.0,"Position":274.232758,"HyperDash":false},{"StartTime":26219.0,"Position":253.164063,"HyperDash":false},{"StartTime":26316.0,"Position":274.1704,"HyperDash":false},{"StartTime":26394.0,"Position":290.949921,"HyperDash":false},{"StartTime":26509.0,"Position":303.819763,"HyperDash":false}]},{"StartTime":27090.0,"Objects":[{"StartTime":27090.0,"Position":480.0,"HyperDash":false}]},{"StartTime":27477.0,"Objects":[{"StartTime":27477.0,"Position":384.0,"HyperDash":false},{"StartTime":27573.0,"Position":351.697662,"HyperDash":false},{"StartTime":27670.0,"Position":333.0,"HyperDash":false},{"StartTime":27749.0,"Position":356.6899,"HyperDash":false},{"StartTime":27864.0,"Position":384.0,"HyperDash":false}]},{"StartTime":28058.0,"Objects":[{"StartTime":28058.0,"Position":432.0,"HyperDash":false}]},{"StartTime":28445.0,"Objects":[{"StartTime":28445.0,"Position":333.0,"HyperDash":false},{"StartTime":28541.0,"Position":305.697662,"HyperDash":false},{"StartTime":28638.0,"Position":282.0,"HyperDash":false},{"StartTime":28717.0,"Position":319.6899,"HyperDash":false},{"StartTime":28832.0,"Position":333.0,"HyperDash":false}]},{"StartTime":29025.0,"Objects":[{"StartTime":29025.0,"Position":384.0,"HyperDash":false},{"StartTime":29121.0,"Position":341.697662,"HyperDash":false},{"StartTime":29218.0,"Position":333.131775,"HyperDash":false},{"StartTime":29297.0,"Position":293.3101,"HyperDash":false},{"StartTime":29412.0,"Position":282.0,"HyperDash":false}]},{"StartTime":29606.0,"Objects":[{"StartTime":29606.0,"Position":224.0,"HyperDash":false},{"StartTime":29702.0,"Position":206.103424,"HyperDash":false},{"StartTime":29799.0,"Position":176.49205,"HyperDash":false},{"StartTime":29896.0,"Position":149.701324,"HyperDash":false},{"StartTime":29993.0,"Position":147.519775,"HyperDash":false},{"StartTime":30071.0,"Position":144.128265,"HyperDash":false},{"StartTime":30186.0,"Position":148.650436,"HyperDash":false}]},{"StartTime":30574.0,"Objects":[{"StartTime":30574.0,"Position":272.0,"HyperDash":false},{"StartTime":30670.0,"Position":303.302338,"HyperDash":false},{"StartTime":30767.0,"Position":322.868225,"HyperDash":false},{"StartTime":30846.0,"Position":351.6899,"HyperDash":false},{"StartTime":30961.0,"Position":374.0,"HyperDash":false}]},{"StartTime":31154.0,"Objects":[{"StartTime":31154.0,"Position":424.0,"HyperDash":false},{"StartTime":31250.0,"Position":439.371674,"HyperDash":false},{"StartTime":31347.0,"Position":424.705872,"HyperDash":false},{"StartTime":31444.0,"Position":417.305573,"HyperDash":false},{"StartTime":31541.0,"Position":395.3253,"HyperDash":false},{"StartTime":31619.0,"Position":372.2993,"HyperDash":false},{"StartTime":31734.0,"Position":347.633759,"HyperDash":false}]},{"StartTime":32122.0,"Objects":[{"StartTime":32122.0,"Position":224.0,"HyperDash":false},{"StartTime":32218.0,"Position":200.129822,"HyperDash":false},{"StartTime":32315.0,"Position":176.418152,"HyperDash":false},{"StartTime":32394.0,"Position":164.275757,"HyperDash":false},{"StartTime":32509.0,"Position":146.329926,"HyperDash":false}]},{"StartTime":32703.0,"Objects":[{"StartTime":32703.0,"Position":256.0,"HyperDash":false}]},{"StartTime":33284.0,"Objects":[{"StartTime":33284.0,"Position":496.0,"HyperDash":false}]},{"StartTime":33671.0,"Objects":[{"StartTime":33671.0,"Position":304.0,"HyperDash":false},{"StartTime":33767.0,"Position":297.697662,"HyperDash":false},{"StartTime":33864.0,"Position":253.0,"HyperDash":false},{"StartTime":33943.0,"Position":270.6899,"HyperDash":false},{"StartTime":34058.0,"Position":304.0,"HyperDash":false}]},{"StartTime":34251.0,"Objects":[{"StartTime":34251.0,"Position":352.0,"HyperDash":false},{"StartTime":34347.0,"Position":374.083679,"HyperDash":false},{"StartTime":34444.0,"Position":391.360016,"HyperDash":false},{"StartTime":34541.0,"Position":387.812561,"HyperDash":false},{"StartTime":34638.0,"Position":404.369629,"HyperDash":false},{"StartTime":34716.0,"Position":417.578369,"HyperDash":false},{"StartTime":34831.0,"Position":385.75708,"HyperDash":false}]},{"StartTime":35219.0,"Objects":[{"StartTime":35219.0,"Position":280.0,"HyperDash":false},{"StartTime":35315.0,"Position":277.964783,"HyperDash":false},{"StartTime":35412.0,"Position":251.783386,"HyperDash":false},{"StartTime":35491.0,"Position":238.233582,"HyperDash":false},{"StartTime":35606.0,"Position":223.420578,"HyperDash":false}]},{"StartTime":35800.0,"Objects":[{"StartTime":35800.0,"Position":272.0,"HyperDash":false},{"StartTime":35896.0,"Position":303.035217,"HyperDash":false},{"StartTime":35993.0,"Position":300.2166,"HyperDash":false},{"StartTime":36072.0,"Position":326.766418,"HyperDash":false},{"StartTime":36187.0,"Position":328.5794,"HyperDash":false}]},{"StartTime":36380.0,"Objects":[{"StartTime":36380.0,"Position":224.0,"HyperDash":false}]},{"StartTime":36767.0,"Objects":[{"StartTime":36767.0,"Position":176.0,"HyperDash":false},{"StartTime":36863.0,"Position":148.9648,"HyperDash":false},{"StartTime":36960.0,"Position":147.783386,"HyperDash":false},{"StartTime":37039.0,"Position":140.233582,"HyperDash":false},{"StartTime":37154.0,"Position":119.420578,"HyperDash":false}]},{"StartTime":37348.0,"Objects":[{"StartTime":37348.0,"Position":168.0,"HyperDash":false},{"StartTime":37444.0,"Position":170.0352,"HyperDash":false},{"StartTime":37541.0,"Position":196.216614,"HyperDash":false},{"StartTime":37620.0,"Position":195.766418,"HyperDash":false},{"StartTime":37735.0,"Position":224.579422,"HyperDash":false}]},{"StartTime":37928.0,"Objects":[{"StartTime":37928.0,"Position":120.0,"HyperDash":false}]},{"StartTime":38316.0,"Objects":[{"StartTime":38316.0,"Position":304.0,"HyperDash":false},{"StartTime":38412.0,"Position":277.697662,"HyperDash":false},{"StartTime":38509.0,"Position":253.131775,"HyperDash":false},{"StartTime":38588.0,"Position":226.310089,"HyperDash":false},{"StartTime":38703.0,"Position":202.0,"HyperDash":false}]},{"StartTime":38896.0,"Objects":[{"StartTime":38896.0,"Position":88.0,"HyperDash":false}]},{"StartTime":39477.0,"Objects":[{"StartTime":39477.0,"Position":280.0,"HyperDash":false},{"StartTime":39555.0,"Position":292.6114,"HyperDash":false},{"StartTime":39670.0,"Position":331.0,"HyperDash":false}]},{"StartTime":39864.0,"Objects":[{"StartTime":39864.0,"Position":424.0,"HyperDash":false},{"StartTime":39960.0,"Position":428.059753,"HyperDash":false},{"StartTime":40057.0,"Position":441.062134,"HyperDash":false},{"StartTime":40136.0,"Position":432.009247,"HyperDash":false},{"StartTime":40251.0,"Position":420.508881,"HyperDash":false}]},{"StartTime":40445.0,"Objects":[{"StartTime":40445.0,"Position":288.0,"HyperDash":false}]},{"StartTime":41025.0,"Objects":[{"StartTime":41025.0,"Position":32.0,"HyperDash":false}]},{"StartTime":41413.0,"Objects":[{"StartTime":41413.0,"Position":256.0,"HyperDash":false},{"StartTime":41509.0,"Position":291.8391,"HyperDash":false},{"StartTime":41606.0,"Position":302.265045,"HyperDash":false},{"StartTime":41685.0,"Position":310.9909,"HyperDash":false},{"StartTime":41800.0,"Position":352.8495,"HyperDash":false}]},{"StartTime":41993.0,"Objects":[{"StartTime":41993.0,"Position":447.0,"HyperDash":false}]},{"StartTime":42187.0,"Objects":[{"StartTime":42187.0,"Position":440.0,"HyperDash":false},{"StartTime":42283.0,"Position":403.2554,"HyperDash":false},{"StartTime":42380.0,"Position":389.7651,"HyperDash":false},{"StartTime":42459.0,"Position":365.6506,"HyperDash":false},{"StartTime":42574.0,"Position":342.9871,"HyperDash":false}]},{"StartTime":42961.0,"Objects":[{"StartTime":42961.0,"Position":248.0,"HyperDash":false},{"StartTime":43057.0,"Position":264.94986,"HyperDash":false},{"StartTime":43154.0,"Position":281.6838,"HyperDash":false},{"StartTime":43251.0,"Position":305.2995,"HyperDash":false},{"StartTime":43348.0,"Position":330.6694,"HyperDash":false},{"StartTime":43444.0,"Position":352.264221,"HyperDash":false},{"StartTime":43541.0,"Position":377.479736,"HyperDash":false},{"StartTime":43638.0,"Position":371.509277,"HyperDash":false},{"StartTime":43735.0,"Position":330.6694,"HyperDash":false},{"StartTime":43831.0,"Position":294.557373,"HyperDash":false},{"StartTime":43928.0,"Position":281.915039,"HyperDash":false},{"StartTime":44007.0,"Position":283.462677,"HyperDash":false},{"StartTime":44122.0,"Position":248.0,"HyperDash":false}]},{"StartTime":44509.0,"Objects":[{"StartTime":44509.0,"Position":144.0,"HyperDash":false},{"StartTime":44605.0,"Position":140.034851,"HyperDash":false},{"StartTime":44702.0,"Position":110.27771,"HyperDash":false},{"StartTime":44799.0,"Position":69.63604,"HyperDash":false},{"StartTime":44896.0,"Position":61.2429733,"HyperDash":false},{"StartTime":44974.0,"Position":47.09105,"HyperDash":false},{"StartTime":45089.0,"Position":14.520277,"HyperDash":false}]},{"StartTime":45284.0,"Objects":[{"StartTime":45284.0,"Position":56.0,"HyperDash":false}]},{"StartTime":45671.0,"Objects":[{"StartTime":45671.0,"Position":264.0,"HyperDash":false}]},{"StartTime":46058.0,"Objects":[{"StartTime":46058.0,"Position":264.0,"HyperDash":false},{"StartTime":46154.0,"Position":301.302338,"HyperDash":false},{"StartTime":46251.0,"Position":314.868225,"HyperDash":false},{"StartTime":46330.0,"Position":321.6899,"HyperDash":false},{"StartTime":46445.0,"Position":366.0,"HyperDash":false}]},{"StartTime":46638.0,"Objects":[{"StartTime":46638.0,"Position":416.0,"HyperDash":false},{"StartTime":46734.0,"Position":371.675873,"HyperDash":false},{"StartTime":46831.0,"Position":365.087921,"HyperDash":false},{"StartTime":46928.0,"Position":325.5,"HyperDash":false},{"StartTime":47025.0,"Position":313.912048,"HyperDash":false},{"StartTime":47103.0,"Position":306.3362,"HyperDash":false},{"StartTime":47218.0,"Position":263.0,"HyperDash":false}]},{"StartTime":47606.0,"Objects":[{"StartTime":47606.0,"Position":360.0,"HyperDash":false},{"StartTime":47702.0,"Position":324.675873,"HyperDash":false},{"StartTime":47799.0,"Position":309.087921,"HyperDash":false},{"StartTime":47896.0,"Position":293.5,"HyperDash":false},{"StartTime":47993.0,"Position":257.912048,"HyperDash":false},{"StartTime":48071.0,"Position":244.336212,"HyperDash":false},{"StartTime":48186.0,"Position":207.0,"HyperDash":false}]},{"StartTime":48380.0,"Objects":[{"StartTime":48380.0,"Position":160.0,"HyperDash":false},{"StartTime":48476.0,"Position":166.997681,"HyperDash":false},{"StartTime":48573.0,"Position":187.484192,"HyperDash":false},{"StartTime":48652.0,"Position":200.988281,"HyperDash":false},{"StartTime":48767.0,"Position":236.72261,"HyperDash":false}]},{"StartTime":49154.0,"Objects":[{"StartTime":49154.0,"Position":32.0,"HyperDash":false}]},{"StartTime":49542.0,"Objects":[{"StartTime":49542.0,"Position":248.0,"HyperDash":false},{"StartTime":49638.0,"Position":266.302338,"HyperDash":false},{"StartTime":49735.0,"Position":298.868225,"HyperDash":false},{"StartTime":49814.0,"Position":314.6899,"HyperDash":false},{"StartTime":49929.0,"Position":350.0,"HyperDash":false}]},{"StartTime":50316.0,"Objects":[{"StartTime":50316.0,"Position":256.0,"HyperDash":false},{"StartTime":50394.0,"Position":235.3886,"HyperDash":false},{"StartTime":50509.0,"Position":205.0,"HyperDash":false}]},{"StartTime":50703.0,"Objects":[{"StartTime":50703.0,"Position":256.0,"HyperDash":false},{"StartTime":50799.0,"Position":296.302338,"HyperDash":false},{"StartTime":50896.0,"Position":306.868225,"HyperDash":false},{"StartTime":50975.0,"Position":344.6899,"HyperDash":false},{"StartTime":51090.0,"Position":358.0,"HyperDash":false}]},{"StartTime":51284.0,"Objects":[{"StartTime":51284.0,"Position":440.0,"HyperDash":false}]},{"StartTime":51477.0,"Objects":[{"StartTime":51477.0,"Position":352.0,"HyperDash":false},{"StartTime":51573.0,"Position":329.697662,"HyperDash":false},{"StartTime":51670.0,"Position":301.131775,"HyperDash":false},{"StartTime":51749.0,"Position":288.3101,"HyperDash":false},{"StartTime":51864.0,"Position":250.0,"HyperDash":false}]},{"StartTime":52251.0,"Objects":[{"StartTime":52251.0,"Position":128.0,"HyperDash":false},{"StartTime":52347.0,"Position":102.275604,"HyperDash":false},{"StartTime":52444.0,"Position":77.8078156,"HyperDash":false},{"StartTime":52541.0,"Position":41.6188354,"HyperDash":false},{"StartTime":52638.0,"Position":32.3890381,"HyperDash":false},{"StartTime":52716.0,"Position":11.4332657,"HyperDash":false},{"StartTime":52831.0,"Position":4.4833107,"HyperDash":false}]},{"StartTime":53025.0,"Objects":[{"StartTime":53025.0,"Position":88.0,"HyperDash":false}]},{"StartTime":53413.0,"Objects":[{"StartTime":53413.0,"Position":168.0,"HyperDash":false},{"StartTime":53491.0,"Position":145.000992,"HyperDash":false},{"StartTime":53606.0,"Position":155.630676,"HyperDash":false}]},{"StartTime":53800.0,"Objects":[{"StartTime":53800.0,"Position":248.0,"HyperDash":false},{"StartTime":53896.0,"Position":263.12973,"HyperDash":false},{"StartTime":53993.0,"Position":290.128967,"HyperDash":false},{"StartTime":54090.0,"Position":316.20874,"HyperDash":false},{"StartTime":54187.0,"Position":340.6195,"HyperDash":false},{"StartTime":54265.0,"Position":376.1075,"HyperDash":false},{"StartTime":54380.0,"Position":385.246277,"HyperDash":false}]},{"StartTime":54574.0,"Objects":[{"StartTime":54574.0,"Position":472.0,"HyperDash":false}]},{"StartTime":54961.0,"Objects":[{"StartTime":54961.0,"Position":328.0,"HyperDash":false}]},{"StartTime":55348.0,"Objects":[{"StartTime":55348.0,"Position":224.0,"HyperDash":false},{"StartTime":55444.0,"Position":195.951981,"HyperDash":false},{"StartTime":55541.0,"Position":173.643036,"HyperDash":false},{"StartTime":55620.0,"Position":140.030609,"HyperDash":false},{"StartTime":55735.0,"Position":123.025146,"HyperDash":false}]},{"StartTime":55929.0,"Objects":[{"StartTime":55929.0,"Position":72.0,"HyperDash":false},{"StartTime":56025.0,"Position":95.8109741,"HyperDash":false},{"StartTime":56122.0,"Position":121.880394,"HyperDash":false},{"StartTime":56201.0,"Position":145.29776,"HyperDash":false},{"StartTime":56316.0,"Position":172.019226,"HyperDash":false}]},{"StartTime":56509.0,"Objects":[{"StartTime":56509.0,"Position":256.0,"HyperDash":false}]},{"StartTime":56896.0,"Objects":[{"StartTime":56896.0,"Position":328.0,"HyperDash":false},{"StartTime":56992.0,"Position":356.5922,"HyperDash":false},{"StartTime":57089.0,"Position":368.955872,"HyperDash":false},{"StartTime":57186.0,"Position":373.612579,"HyperDash":false},{"StartTime":57283.0,"Position":419.1303,"HyperDash":false},{"StartTime":57361.0,"Position":444.262817,"HyperDash":false},{"StartTime":57476.0,"Position":466.641,"HyperDash":false}]},{"StartTime":57671.0,"Objects":[{"StartTime":57671.0,"Position":416.0,"HyperDash":false},{"StartTime":57767.0,"Position":391.6712,"HyperDash":false},{"StartTime":57864.0,"Position":367.089,"HyperDash":false},{"StartTime":57943.0,"Position":328.06842,"HyperDash":false},{"StartTime":58058.0,"Position":317.924561,"HyperDash":false}]},{"StartTime":58445.0,"Objects":[{"StartTime":58445.0,"Position":144.0,"HyperDash":false}]},{"StartTime":58832.0,"Objects":[{"StartTime":58832.0,"Position":320.0,"HyperDash":false}]},{"StartTime":59219.0,"Objects":[{"StartTime":59219.0,"Position":128.0,"HyperDash":false}]},{"StartTime":59606.0,"Objects":[{"StartTime":59606.0,"Position":112.0,"HyperDash":false}]},{"StartTime":59993.0,"Objects":[{"StartTime":59993.0,"Position":224.0,"HyperDash":false},{"StartTime":60089.0,"Position":217.725632,"HyperDash":false},{"StartTime":60186.0,"Position":227.34639,"HyperDash":false},{"StartTime":60265.0,"Position":214.703522,"HyperDash":false},{"StartTime":60380.0,"Position":206.754791,"HyperDash":false}]},{"StartTime":60767.0,"Objects":[{"StartTime":60767.0,"Position":80.0,"HyperDash":false},{"StartTime":60863.0,"Position":90.79409,"HyperDash":false},{"StartTime":60960.0,"Position":75.87808,"HyperDash":false},{"StartTime":61039.0,"Position":74.4997559,"HyperDash":false},{"StartTime":61154.0,"Position":96.53038,"HyperDash":false}]},{"StartTime":61542.0,"Objects":[{"StartTime":61542.0,"Position":200.0,"HyperDash":false},{"StartTime":61638.0,"Position":196.089508,"HyperDash":false},{"StartTime":61735.0,"Position":236.445679,"HyperDash":false},{"StartTime":61814.0,"Position":270.5239,"HyperDash":false},{"StartTime":61929.0,"Position":286.4193,"HyperDash":false}]},{"StartTime":62316.0,"Objects":[{"StartTime":62316.0,"Position":376.0,"HyperDash":false},{"StartTime":62412.0,"Position":361.9105,"HyperDash":false},{"StartTime":62509.0,"Position":339.554321,"HyperDash":false},{"StartTime":62588.0,"Position":316.4761,"HyperDash":false},{"StartTime":62703.0,"Position":289.5807,"HyperDash":false}]},{"StartTime":63090.0,"Objects":[{"StartTime":63090.0,"Position":184.0,"HyperDash":false},{"StartTime":63186.0,"Position":174.5783,"HyperDash":false},{"StartTime":63283.0,"Position":191.193848,"HyperDash":false},{"StartTime":63362.0,"Position":204.138489,"HyperDash":false},{"StartTime":63477.0,"Position":198.424973,"HyperDash":false}]},{"StartTime":63864.0,"Objects":[{"StartTime":63864.0,"Position":88.0,"HyperDash":false},{"StartTime":63960.0,"Position":45.16764,"HyperDash":false},{"StartTime":64057.0,"Position":38.0766068,"HyperDash":false},{"StartTime":64154.0,"Position":12.98558,"HyperDash":false},{"StartTime":64251.0,"Position":38.0766144,"HyperDash":false},{"StartTime":64329.0,"Position":69.2529,"HyperDash":false},{"StartTime":64444.0,"Position":88.0,"HyperDash":false}]},{"StartTime":64638.0,"Objects":[{"StartTime":64638.0,"Position":312.0,"HyperDash":false}]},{"StartTime":64832.0,"Objects":[{"StartTime":64832.0,"Position":208.0,"HyperDash":false}]},{"StartTime":65025.0,"Objects":[{"StartTime":65025.0,"Position":304.0,"HyperDash":false}]},{"StartTime":65413.0,"Objects":[{"StartTime":65413.0,"Position":360.0,"HyperDash":false},{"StartTime":65491.0,"Position":361.6114,"HyperDash":false},{"StartTime":65606.0,"Position":411.0,"HyperDash":false}]},{"StartTime":65800.0,"Objects":[{"StartTime":65800.0,"Position":462.0,"HyperDash":false},{"StartTime":65878.0,"Position":458.3886,"HyperDash":false},{"StartTime":65993.0,"Position":411.0,"HyperDash":false}]},{"StartTime":66187.0,"Objects":[{"StartTime":66187.0,"Position":344.0,"HyperDash":false},{"StartTime":66283.0,"Position":327.697662,"HyperDash":false},{"StartTime":66380.0,"Position":293.131775,"HyperDash":false},{"StartTime":66459.0,"Position":271.3101,"HyperDash":false},{"StartTime":66574.0,"Position":242.0,"HyperDash":false}]},{"StartTime":66961.0,"Objects":[{"StartTime":66961.0,"Position":152.0,"HyperDash":false},{"StartTime":67057.0,"Position":167.659241,"HyperDash":false},{"StartTime":67154.0,"Position":147.9835,"HyperDash":false},{"StartTime":67233.0,"Position":135.201309,"HyperDash":false},{"StartTime":67348.0,"Position":106.616547,"HyperDash":false}]},{"StartTime":67735.0,"Objects":[{"StartTime":67735.0,"Position":32.0,"HyperDash":false},{"StartTime":67831.0,"Position":42.2565079,"HyperDash":false},{"StartTime":67928.0,"Position":78.75527,"HyperDash":false},{"StartTime":68007.0,"Position":85.89344,"HyperDash":false},{"StartTime":68122.0,"Position":125.752792,"HyperDash":false}]},{"StartTime":68316.0,"Objects":[{"StartTime":68316.0,"Position":208.0,"HyperDash":false}]},{"StartTime":68509.0,"Objects":[{"StartTime":68509.0,"Position":224.0,"HyperDash":false},{"StartTime":68605.0,"Position":240.243561,"HyperDash":false},{"StartTime":68702.0,"Position":270.729248,"HyperDash":false},{"StartTime":68781.0,"Position":291.85675,"HyperDash":false},{"StartTime":68896.0,"Position":317.7006,"HyperDash":false}]},{"StartTime":69284.0,"Objects":[{"StartTime":69284.0,"Position":216.0,"HyperDash":false},{"StartTime":69380.0,"Position":191.846649,"HyperDash":false},{"StartTime":69477.0,"Position":185.704849,"HyperDash":false},{"StartTime":69556.0,"Position":168.950912,"HyperDash":false},{"StartTime":69671.0,"Position":193.879364,"HyperDash":false}]},{"StartTime":70058.0,"Objects":[{"StartTime":70058.0,"Position":360.0,"HyperDash":false},{"StartTime":70154.0,"Position":374.986725,"HyperDash":false},{"StartTime":70251.0,"Position":367.9918,"HyperDash":false},{"StartTime":70330.0,"Position":353.6845,"HyperDash":false},{"StartTime":70445.0,"Position":337.885529,"HyperDash":false}]},{"StartTime":70832.0,"Objects":[{"StartTime":70832.0,"Position":264.0,"HyperDash":false},{"StartTime":70928.0,"Position":225.951981,"HyperDash":false},{"StartTime":71025.0,"Position":213.643036,"HyperDash":false},{"StartTime":71104.0,"Position":187.030609,"HyperDash":false},{"StartTime":71219.0,"Position":163.025146,"HyperDash":false}]},{"StartTime":71413.0,"Objects":[{"StartTime":71413.0,"Position":112.0,"HyperDash":false},{"StartTime":71509.0,"Position":75.97218,"HyperDash":false},{"StartTime":71606.0,"Position":61.6836624,"HyperDash":false},{"StartTime":71685.0,"Position":27.0878525,"HyperDash":false},{"StartTime":71800.0,"Position":11.1066208,"HyperDash":false}]},{"StartTime":71993.0,"Objects":[{"StartTime":71993.0,"Position":40.0,"HyperDash":false},{"StartTime":72071.0,"Position":52.4331474,"HyperDash":false},{"StartTime":72186.0,"Position":68.28971,"HyperDash":false}]},{"StartTime":72380.0,"Objects":[{"StartTime":72380.0,"Position":176.0,"HyperDash":false},{"StartTime":72476.0,"Position":187.970581,"HyperDash":false},{"StartTime":72573.0,"Position":161.344147,"HyperDash":false},{"StartTime":72670.0,"Position":136.575012,"HyperDash":false},{"StartTime":72767.0,"Position":119.0057,"HyperDash":false},{"StartTime":72845.0,"Position":79.55367,"HyperDash":false},{"StartTime":72960.0,"Position":69.6823959,"HyperDash":false}]},{"StartTime":73154.0,"Objects":[{"StartTime":73154.0,"Position":120.0,"HyperDash":false},{"StartTime":73250.0,"Position":160.2306,"HyperDash":false},{"StartTime":73347.0,"Position":169.814178,"HyperDash":false},{"StartTime":73426.0,"Position":170.964127,"HyperDash":false},{"StartTime":73541.0,"Position":209.453659,"HyperDash":false}]},{"StartTime":73929.0,"Objects":[{"StartTime":73929.0,"Position":312.0,"HyperDash":false},{"StartTime":74025.0,"Position":321.048035,"HyperDash":false},{"StartTime":74122.0,"Position":362.356964,"HyperDash":false},{"StartTime":74201.0,"Position":394.9694,"HyperDash":false},{"StartTime":74316.0,"Position":412.974854,"HyperDash":false}]},{"StartTime":74703.0,"Objects":[{"StartTime":74703.0,"Position":336.0,"HyperDash":false},{"StartTime":74781.0,"Position":342.880768,"HyperDash":false},{"StartTime":74896.0,"Position":315.910126,"HyperDash":false}]},{"StartTime":75090.0,"Objects":[{"StartTime":75090.0,"Position":400.0,"HyperDash":false},{"StartTime":75168.0,"Position":399.237152,"HyperDash":false},{"StartTime":75283.0,"Position":417.9073,"HyperDash":false}]},{"StartTime":75477.0,"Objects":[{"StartTime":75477.0,"Position":328.0,"HyperDash":false},{"StartTime":75573.0,"Position":296.892883,"HyperDash":false},{"StartTime":75670.0,"Position":288.19165,"HyperDash":false},{"StartTime":75767.0,"Position":275.9188,"HyperDash":false},{"StartTime":75864.0,"Position":238.263733,"HyperDash":false},{"StartTime":75942.0,"Position":221.022842,"HyperDash":false},{"StartTime":76057.0,"Position":202.919159,"HyperDash":false}]},{"StartTime":76251.0,"Objects":[{"StartTime":76251.0,"Position":296.0,"HyperDash":false},{"StartTime":76347.0,"Position":313.798157,"HyperDash":false},{"StartTime":76444.0,"Position":346.261322,"HyperDash":false},{"StartTime":76523.0,"Position":375.263733,"HyperDash":false},{"StartTime":76638.0,"Position":392.493958,"HyperDash":false}]},{"StartTime":77219.0,"Objects":[{"StartTime":77219.0,"Position":152.0,"HyperDash":false},{"StartTime":77315.0,"Position":119.697678,"HyperDash":false},{"StartTime":77412.0,"Position":101.0,"HyperDash":false},{"StartTime":77491.0,"Position":137.689911,"HyperDash":false},{"StartTime":77606.0,"Position":152.0,"HyperDash":false}]},{"StartTime":77800.0,"Objects":[{"StartTime":77800.0,"Position":320.0,"HyperDash":false}]},{"StartTime":78187.0,"Objects":[{"StartTime":78187.0,"Position":320.0,"HyperDash":false},{"StartTime":78265.0,"Position":323.92218,"HyperDash":false},{"StartTime":78380.0,"Position":369.294647,"HyperDash":false}]},{"StartTime":78574.0,"Objects":[{"StartTime":78574.0,"Position":456.0,"HyperDash":false},{"StartTime":78670.0,"Position":443.684448,"HyperDash":false},{"StartTime":78767.0,"Position":433.251038,"HyperDash":false},{"StartTime":78846.0,"Position":411.9393,"HyperDash":false},{"StartTime":78961.0,"Position":410.384216,"HyperDash":false}]},{"StartTime":79348.0,"Objects":[{"StartTime":79348.0,"Position":288.0,"HyperDash":false},{"StartTime":79444.0,"Position":287.315552,"HyperDash":false},{"StartTime":79541.0,"Position":310.748962,"HyperDash":false},{"StartTime":79620.0,"Position":322.0607,"HyperDash":false},{"StartTime":79735.0,"Position":333.615784,"HyperDash":false}]},{"StartTime":80122.0,"Objects":[{"StartTime":80122.0,"Position":240.0,"HyperDash":false},{"StartTime":80218.0,"Position":206.699463,"HyperDash":false},{"StartTime":80315.0,"Position":192.5893,"HyperDash":false},{"StartTime":80394.0,"Position":180.9993,"HyperDash":false},{"StartTime":80509.0,"Position":144.773514,"HyperDash":false}]},{"StartTime":80703.0,"Objects":[{"StartTime":80703.0,"Position":64.0,"HyperDash":false}]},{"StartTime":80896.0,"Objects":[{"StartTime":80896.0,"Position":40.0,"HyperDash":false},{"StartTime":80992.0,"Position":52.30054,"HyperDash":false},{"StartTime":81089.0,"Position":87.4107056,"HyperDash":false},{"StartTime":81168.0,"Position":99.0006943,"HyperDash":false},{"StartTime":81283.0,"Position":135.226486,"HyperDash":false}]},{"StartTime":81671.0,"Objects":[{"StartTime":81671.0,"Position":248.0,"HyperDash":false},{"StartTime":81767.0,"Position":248.315552,"HyperDash":false},{"StartTime":81864.0,"Position":270.748962,"HyperDash":false},{"StartTime":81943.0,"Position":270.0607,"HyperDash":false},{"StartTime":82058.0,"Position":293.615784,"HyperDash":false}]},{"StartTime":82445.0,"Objects":[{"StartTime":82445.0,"Position":120.0,"HyperDash":false}]},{"StartTime":82832.0,"Objects":[{"StartTime":82832.0,"Position":312.0,"HyperDash":false}]},{"StartTime":83219.0,"Objects":[{"StartTime":83219.0,"Position":400.0,"HyperDash":false},{"StartTime":83297.0,"Position":406.999,"HyperDash":false},{"StartTime":83412.0,"Position":412.369324,"HyperDash":false}]},{"StartTime":83606.0,"Objects":[{"StartTime":83606.0,"Position":360.0,"HyperDash":false},{"StartTime":83684.0,"Position":344.762848,"HyperDash":false},{"StartTime":83799.0,"Position":342.0927,"HyperDash":false}]},{"StartTime":83993.0,"Objects":[{"StartTime":83993.0,"Position":272.0,"HyperDash":false},{"StartTime":84089.0,"Position":267.17865,"HyperDash":false},{"StartTime":84186.0,"Position":223.813,"HyperDash":false},{"StartTime":84265.0,"Position":218.85318,"HyperDash":false},{"StartTime":84380.0,"Position":179.797424,"HyperDash":false}]},{"StartTime":84767.0,"Objects":[{"StartTime":84767.0,"Position":80.0,"HyperDash":false},{"StartTime":84845.0,"Position":91.5179,"HyperDash":false},{"StartTime":84960.0,"Position":96.12762,"HyperDash":false}]},{"StartTime":85154.0,"Objects":[{"StartTime":85154.0,"Position":16.0,"HyperDash":false},{"StartTime":85232.0,"Position":0.0,"HyperDash":false},{"StartTime":85347.0,"Position":16.0,"HyperDash":false}]},{"StartTime":85542.0,"Objects":[{"StartTime":85542.0,"Position":104.0,"HyperDash":false},{"StartTime":85638.0,"Position":112.302322,"HyperDash":false},{"StartTime":85735.0,"Position":154.868225,"HyperDash":false},{"StartTime":85814.0,"Position":182.689911,"HyperDash":false},{"StartTime":85929.0,"Position":206.0,"HyperDash":false}]},{"StartTime":86316.0,"Objects":[{"StartTime":86316.0,"Position":376.0,"HyperDash":false},{"StartTime":86412.0,"Position":382.0039,"HyperDash":false},{"StartTime":86509.0,"Position":424.2578,"HyperDash":false},{"StartTime":86588.0,"Position":445.011047,"HyperDash":false},{"StartTime":86703.0,"Position":472.7657,"HyperDash":false}]},{"StartTime":87090.0,"Objects":[{"StartTime":87090.0,"Position":296.0,"HyperDash":false},{"StartTime":87186.0,"Position":311.353729,"HyperDash":false},{"StartTime":87283.0,"Position":308.602417,"HyperDash":false},{"StartTime":87362.0,"Position":307.240021,"HyperDash":false},{"StartTime":87477.0,"Position":312.385956,"HyperDash":false}]},{"StartTime":87864.0,"Objects":[{"StartTime":87864.0,"Position":24.0,"HyperDash":false}]},{"StartTime":88251.0,"Objects":[{"StartTime":88251.0,"Position":249.0,"HyperDash":false},{"StartTime":88347.0,"Position":233.0,"HyperDash":false},{"StartTime":88444.0,"Position":449.0,"HyperDash":false},{"StartTime":88541.0,"Position":411.0,"HyperDash":false},{"StartTime":88638.0,"Position":75.0,"HyperDash":false},{"StartTime":88735.0,"Position":474.0,"HyperDash":false},{"StartTime":88831.0,"Position":176.0,"HyperDash":false},{"StartTime":88928.0,"Position":1.0,"HyperDash":false},{"StartTime":89025.0,"Position":37.0,"HyperDash":false},{"StartTime":89122.0,"Position":481.0,"HyperDash":false},{"StartTime":89219.0,"Position":375.0,"HyperDash":false},{"StartTime":89315.0,"Position":407.0,"HyperDash":false},{"StartTime":89412.0,"Position":231.0,"HyperDash":false},{"StartTime":89509.0,"Position":338.0,"HyperDash":false},{"StartTime":89606.0,"Position":322.0,"HyperDash":false},{"StartTime":89703.0,"Position":347.0,"HyperDash":false},{"StartTime":89800.0,"Position":365.0,"HyperDash":false}]}]} \ No newline at end of file diff --git a/osu.Game.Rulesets.Catch.Tests/Resources/Testing/Beatmaps/1041052.osu b/osu.Game.Rulesets.Catch.Tests/Resources/Testing/Beatmaps/1041052.osu new file mode 100644 index 0000000000..a0cecc1b18 --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/Resources/Testing/Beatmaps/1041052.osu @@ -0,0 +1,210 @@ +osu file format v14 + +[General] +AudioFilename: audio.mp3 +AudioLeadIn: 0 +PreviewTime: 65316 +Countdown: 0 +SampleSet: Soft +StackLeniency: 0.7 +Mode: 2 +LetterboxInBreaks: 0 +WidescreenStoryboard: 0 + +[Editor] +DistanceSpacing: 1.4 +BeatDivisor: 4 +GridSize: 8 +TimelineZoom: 1.4 + +[Metadata] +Title:Nanairo Symphony -TV Size- +TitleUnicode:七色シンフォニー -TV Size- +Artist:Coalamode. +ArtistUnicode:コアラモード. +Creator:Ascendance +Version:Aru's Cup +Source:四月は君の嘘 +Tags:shigatsu wa kimi no uso your lie in april opening arusamour tenshichan [superstar] +BeatmapID:1041052 +BeatmapSetID:488149 + +[Difficulty] +HPDrainRate:3 +CircleSize:2.5 +OverallDifficulty:6 +ApproachRate:6 +SliderMultiplier:1.02 +SliderTickRate:2 + +[Events] +//Background and Video events +Video,500,"forty.avi" +0,0,"cropped-1366-768-647733.jpg",0,0 +//Break Periods +//Storyboard Layer 0 (Background) +//Storyboard Layer 1 (Fail) +//Storyboard Layer 2 (Pass) +//Storyboard Layer 3 (Foreground) +//Storyboard Sound Samples + +[TimingPoints] +1155,387.096774193548,4,2,1,50,1,0 +15284,-100,4,2,1,60,0,0 +16638,-100,4,2,1,50,0,0 +41413,-100,4,2,1,60,0,0 +59993,-100,4,2,1,65,0,0 +66187,-100,4,2,1,70,0,1 +87284,-100,4,2,1,60,0,1 +87864,-100,4,2,1,70,0,0 +87961,-100,4,2,1,50,0,0 +88638,-100,4,2,1,30,0,0 +89413,-100,4,2,1,10,0,0 +89800,-100,4,2,1,5,0,0 + + +[Colours] +Combo1 : 255,128,64 +Combo2 : 0,128,255 +Combo3 : 255,128,192 +Combo4 : 0,128,192 + +[HitObjects] +208,160,1155,6,0,L|45:160,1,153,2|2,0:0|0:0,0:0:0:0: +160,160,2122,1,0,0:0:0:0: +272,160,2509,1,2,0:0:0:0: +448,288,3284,6,0,P|480:240|480:192,1,102,2|0,0:0|0:0,0:0:0:0: +384,96,4058,1,2,0:0:0:0: +128,64,5025,6,0,L|32:64,2,76.5,2|0|0,0:0|0:0|0:0,0:0:0:0: +192,64,5800,1,2,0:0:0:0: +240,64,5993,1,2,0:0:0:0: +288,64,6187,1,2,0:0:0:0: +416,80,6574,6,0,L|192:80,1,204,0|2,0:0|0:0,0:0:0:0: +488,160,8122,2,0,L|376:160,1,102 +457,288,8896,2,0,L|297:288,1,153,2|2,0:0|0:0,0:0:0:0: +400,288,10058,1,0,0:0:0:0: +304,288,10445,6,0,L|192:288,2,102,2|0|2,0:0|0:0|0:0,0:0:0:0: +400,288,11606,1,0,0:0:0:0: +240,288,11993,2,0,L|80:288,1,153,2|0,0:0|0:0,0:0:0:0: +0,288,13154,1,0,0:0:0:0: +112,240,13542,6,0,P|160:288|256:288,1,153,6|2,0:0|0:0,0:0:0:0: +288,288,14316,2,0,L|368:288,2,76.5,2|0|0,0:0|0:0|0:0,0:0:0:0: +192,288,15284,2,0,L|160:224,1,51,0|12,0:0|0:0,0:0:0:0: +312,208,15864,1,6,0:0:0:0: +128,176,16638,6,0,P|64:160|0:96,2,153,6|2|0,0:0|0:0|0:0,0:0:0:0: +224,176,18187,2,0,P|288:192|352:272,2,153,2|2|0,0:0|0:0|0:0,0:0:0:0: +128,176,19735,6,0,L|288:176,1,153,2|2,0:0|0:0,0:0:0:0: +432,176,20896,1,0,0:0:0:0: +328,176,21284,2,0,L|488:176,1,153,2|2,0:0|0:0,0:0:0:0: +328,176,22445,1,0,0:0:0:0: +224,176,22832,6,0,L|64:176,1,153,2|2,0:0|0:0,0:0:0:0: +224,176,23993,1,0,0:0:0:0: +112,176,24380,2,0,L|272:176,1,153,2|2,0:0|0:0,0:0:0:0: +416,176,25541,1,0,0:0:0:0: +304,256,25929,6,0,P|272:208|312:120,1,153,2|2,0:0|0:0,0:0:0:0: +480,112,27090,1,0,0:0:0:0: +384,112,27477,6,0,L|320:112,2,51,2|2|0,0:0|0:0|0:0,0:0:0:0: +432,112,28058,1,2,0:0:0:0: +333,112,28445,2,0,L|282:112,2,51,0|0|0,0:0|0:0|0:0,0:0:0:0: +384,112,29025,6,0,L|272:112,1,102,6|0,0:0|0:0,0:0:0:0: +224,112,29606,2,0,P|160:144|160:240,1,153,2|2,0:0|0:0,0:0:0:0: +272,272,30574,2,0,L|374:272,1,102 +424,272,31154,2,0,P|414:344|348:378,1,153,0|0,0:0|0:0,0:0:0:0: +224,304,32122,6,0,P|176:320|144:368,1,102,2|0,0:0|0:0,0:0:0:0: +200,368,32703,1,2,0:0:0:0: +376,368,33284,1,0,0:0:0:0: +304,296,33671,2,0,L|240:296,2,51,2|2|0,0:0|0:0|0:0,0:0:0:0: +352,296,34251,2,0,P|400:248|384:168,1,153,2|0,0:0|0:0,0:0:0:0: +280,176,35219,6,0,L|216:80,1,102,2|0,0:0|0:0,0:0:0:0: +272,104,35800,2,0,L|336:8,1,102,2|0,0:0|0:0,0:0:0:0: +280,16,36380,1,2,0:0:0:0: +176,32,36767,6,0,L|112:128,1,102,2|0,0:0|0:0,0:0:0:0: +168,128,37348,2,0,L|232:224,1,102,2|0,0:0|0:0,0:0:0:0: +176,224,37928,1,2,0:0:0:0: +304,264,38316,6,0,L|200:264,1,102,2|0,0:0|0:0,0:0:0:0: +144,264,38896,1,2,0:0:0:0: +280,336,39477,2,0,L|336:336,1,51 +424,336,39864,2,0,P|440:304|416:240,1,102,8|0,0:3|0:3,0:3:0:0: +352,232,40445,1,4,0:1:0:0: +160,224,41025,1,8,0:3:0:0: +256,48,41413,6,0,P|302:28|353:31,1,102,6|0,0:0|0:0,0:0:0:0: +400,40,41993,1,0,0:0:0:0: +440,80,42187,2,0,P|389:76|342:96,1,102,2|8,0:0|0:0,0:0:0:0: +248,128,42961,2,0,P|312:176|392:144,2,153,2|2|8,0:0|0:0|0:3,0:0:0:0: +144,136,44509,6,0,P|80:88|0:120,1,153,2|0,0:0|0:0,0:0:0:0: +56,136,45284,1,2,0:0:0:0: +160,144,45671,1,8,0:0:0:0: +264,144,46058,2,0,L|384:144,1,102,2|0,0:0|0:0,0:0:0:0: +416,152,46638,2,0,L|264:152,1,153,2|8,0:0|0:3,0:0:0:0: +360,120,47606,6,0,L|192:120,1,153,2|0,0:0|0:0,0:0:0:0: +160,128,48380,2,0,P|208:80|256:96,1,102,2|8,0:0|0:0,0:0:0:0: +144,136,49154,1,2,0:0:0:0: +248,144,49542,2,0,L|368:144,1,102,0|2,0:0|0:0,0:0:0:0: +256,192,50316,2,0,L|200:192,1,51,10|0,0:0|0:0,0:0:0:0: +256,184,50703,6,0,L|360:184,1,102,2|0,0:0|0:0,0:0:0:0: +400,208,51284,1,0,0:0:0:0: +352,240,51477,2,0,L|240:240,1,102 +128,336,52251,6,0,P|64:336|0:256,1,153,2|2,0:0|0:0,0:0:0:0: +88,264,53025,1,2,0:0:0:0: +168,208,53413,2,0,L|152:144,1,51,8|8,0:0|0:3,0:0:0:0: +248,120,53800,6,0,P|328:152|392:120,1,153,6|0,0:0|0:0,0:0:0:0: +432,120,54574,1,2,0:0:0:0: +328,128,54961,1,8,0:0:0:0: +224,128,55348,6,0,L|112:144,1,102,2|0,0:0|0:0,0:0:0:0: +72,152,55929,2,0,L|192:176,1,102,2|0,0:0|0:0,0:0:0:0: +224,184,56509,1,8,0:3:0:0: +328,176,56896,6,0,P|376:208|472:192,1,153,2|0,0:0|0:0,0:0:0:0: +416,208,57671,2,0,L|304:240,1,102,2|8,0:0|0:0,0:0:0:0: +224,272,58445,5,2,0:0:0:0: +320,296,58832,1,0,0:0:0:0: +224,328,59219,1,2,0:0:0:0: +120,328,59606,1,8,0:3:0:0: +224,264,59993,6,0,P|224:200|192:152,1,102,6|0,0:0|0:0,0:0:0:0: +80,184,60767,2,0,P|76:133|97:87,1,102,2|8,0:0|0:0,0:0:0:0: +200,80,61542,2,0,P|232:112|296:112,1,102,2|0,0:0|0:0,0:0:0:0: +376,160,62316,2,0,P|344:192|280:192,1,102,2|8,0:0|0:0,0:0:0:0: +184,240,63090,6,0,L|200:128,1,102,2|8,0:0|0:0,0:0:0:0: +88,136,63864,2,0,L|8:152,2,76.5,6|2|2,0:0|0:0|0:0,0:0:0:0: +160,112,64638,1,8,0:0:0:0: +208,128,64832,1,8,0:0:0:0: +256,144,65025,1,8,0:0:0:0: +360,152,65413,6,0,L|424:152,1,51,8|0,0:0|0:0,0:0:0:0: +462,152,65800,2,0,L|398:152,1,51,8|8,0:0|0:3,0:0:0:0: +344,144,66187,6,0,L|232:144,1,102,12|8,0:0|0:0,0:0:0:0: +152,120,66961,2,0,P|148:169|107:196,1,102,8|8,0:0|0:0,0:0:0:0: +32,264,67735,6,0,L|144:216,1,102,8|8,0:0|0:0,0:0:0:0: +176,208,68316,1,0,0:0:0:0: +224,200,68509,2,0,L|317:240,1,102,8|8,0:0|0:0,0:0:0:0: +216,256,69284,6,0,P|184:304|200:352,1,102,8|8,0:0|0:0,0:0:0:0: +360,256,70058,2,0,P|368:207|337:167,1,102,8|8,0:0|0:0,0:0:0:0: +264,80,70832,6,0,L|152:96,1,102,8|8,0:0|0:0,0:0:0:0: +112,104,71413,2,0,L|11:89,1,102,8|0,0:0|0:0,0:0:0:0: +40,128,71993,2,0,L|72:176,1,51,8|8,0:0|0:3,0:0:0:0: +176,216,72380,6,0,P|144:280|64:280,1,153,12|0,0:0|0:0,0:0:0:0: +120,280,73154,2,0,P|191:299|216:328,1,102,8|8,0:0|0:0,0:0:0:0: +312,320,73929,6,0,L|424:304,1,102,8|8,0:0|0:0,0:0:0:0: +336,272,74703,2,0,L|312:216,1,51,8|0,0:0|0:0,0:0:0:0: +400,200,75090,2,0,L|424:136,1,51,8|0,0:0|0:0,0:0:0:0: +328,152,75477,6,0,P|280:184|200:136,1,153,12|0,0:0|0:0,0:0:0:0: +296,136,76251,2,0,P|360:136|408:168,1,102,8|8,0:0|0:0,0:0:0:0: +152,248,77219,6,0,L|96:248,2,51,0|12|0,0:0|0:0|0:0,0:0:0:0: +208,248,77800,1,8,0:0:0:0: +320,256,78187,2,0,L|369:243,1,51,8|8,0:0|0:3,0:0:0:0: +456,232,78574,6,0,L|408:136,1,102,12|8,0:0|0:0,0:0:0:0: +288,136,79348,2,0,L|336:40,1,102,8|8,0:0|0:0,0:0:0:0: +240,80,80122,6,0,P|144:80|128:64,1,102,8|8,0:0|0:0,0:0:0:0: +96,72,80703,1,0,0:0:0:0: +40,104,80896,2,0,P|136:104|152:88,1,102,8|8,0:0|0:0,0:0:0:0: +248,128,81671,6,0,L|296:224,1,102,12|8,0:0|0:0,0:0:0:0: +208,272,82445,1,10,0:0:0:0: +312,272,82832,1,8,0:0:0:0: +400,224,83219,6,0,L|416:160,1,51,8|2,0:0|0:0,0:0:0:0: +360,56,83606,2,0,L|336:120,1,51,8|0,0:0|0:0,0:0:0:0: +272,152,83993,2,0,P|192:152|176:136,1,102,0|8,0:0|0:0,0:0:0:0: +80,160,84767,6,0,L|96:208,1,51,8|0,0:0|0:0,0:0:0:0: +16,272,85154,2,0,L|16:328,1,51,8|0,0:0|0:0,0:0:0:0: +104,304,85542,2,0,L|208:304,1,102,2|8,0:0|0:0,0:0:0:0: +376,336,86316,6,0,L|472:304,1,102,4|0,0:0|0:0,0:0:0:0: +296,248,87090,2,0,P|312:168|312:136,1,102,2|8,0:0|0:3,0:0:0:0: +168,96,87864,1,4,0:0:0:0: +256,192,88251,12,0,89800,0:0:0:0: From 285adcb00e65abbcaad8d6a7cffedcc416949ab5 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 2 Mar 2024 00:19:45 +0300 Subject: [PATCH 285/508] Fix catch hit object position getting randomised when last object has pos=0 --- osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index 200018f28b..198f8f59c6 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -118,7 +118,11 @@ namespace osu.Game.Rulesets.Catch.Beatmaps float offsetPosition = hitObject.OriginalX; double startTime = hitObject.StartTime; - if (lastPosition == null) + if (lastPosition == null || + // some objects can get assigned position zero, making stable incorrectly go inside this if branch on the next object. to maintain behaviour and compatibility, do the same here. + // reference: https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/GameplayElements/HitObjects/Fruits/HitFactoryFruits.cs#L45-L50 + // todo: should be revisited and corrected later probably. + lastPosition == 0) { lastPosition = offsetPosition; lastStartTime = startTime; From 85f131d2f87f7da733c542a38ae8cd6804a43f89 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 2 Mar 2024 22:45:15 +0300 Subject: [PATCH 286/508] Fix "unranked explaination" tooltip text using incorrect translation key --- osu.Game/Localisation/ModSelectOverlayStrings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Localisation/ModSelectOverlayStrings.cs b/osu.Game/Localisation/ModSelectOverlayStrings.cs index 9513eacf02..7a9bb698d8 100644 --- a/osu.Game/Localisation/ModSelectOverlayStrings.cs +++ b/osu.Game/Localisation/ModSelectOverlayStrings.cs @@ -67,7 +67,7 @@ namespace osu.Game.Localisation /// /// "Performance points will not be granted due to active mods." /// - public static LocalisableString UnrankedExplanation => new TranslatableString(getKey(@"ranked_explanation"), @"Performance points will not be granted due to active mods."); + public static LocalisableString UnrankedExplanation => new TranslatableString(getKey(@"unranked_explanation"), @"Performance points will not be granted due to active mods."); private static string getKey(string key) => $@"{prefix}:{key}"; } From bce3bd55e5a863e52f41598c306a248a79638843 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 4 Mar 2024 16:08:17 +0900 Subject: [PATCH 287/508] Fix catch by moving cursor-specific handling local --- .../TestSceneResumeOverlay.cs | 16 +++++++++++++--- osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 7 +++++++ osu.Game/Rulesets/UI/DrawableRuleset.cs | 2 +- osu.Game/Screens/Play/ResumeOverlay.cs | 3 ++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs index 25d0b0a3d3..b35984a2fc 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneResumeOverlay.cs @@ -6,11 +6,11 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Testing; using osu.Game.Configuration; using osu.Game.Rulesets.Osu.UI; using osu.Game.Rulesets.Osu.UI.Cursor; +using osu.Game.Rulesets.UI; using osu.Game.Screens.Play; using osu.Game.Tests.Gameplay; using osu.Game.Tests.Visual; @@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Tests public partial class TestSceneResumeOverlay : OsuManualInputManagerTestScene { private ManualOsuInputManager osuInputManager = null!; - private CursorContainer cursor = null!; + private GameplayCursorContainer cursor = null!; private ResumeOverlay resume = null!; private bool resumeFired; @@ -99,7 +99,17 @@ namespace osu.Game.Rulesets.Osu.Tests private void loadContent() { - Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo) { Children = new Drawable[] { cursor = new CursorContainer(), resume = new OsuResumeOverlay { GameplayCursor = cursor }, } }; + Child = osuInputManager = new ManualOsuInputManager(new OsuRuleset().RulesetInfo) + { + Children = new Drawable[] + { + cursor = new GameplayCursorContainer(), + resume = new OsuResumeOverlay + { + GameplayCursor = cursor + }, + } + }; resumeFired = false; resume.ResumeAction = () => resumeFired = true; diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs index 8a84fe14e5..adc7bd97ff 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs @@ -39,6 +39,13 @@ namespace osu.Game.Rulesets.Osu.UI protected override void PopIn() { + // Can't display if the cursor is outside the window. + if (GameplayCursor.LastFrameState == Visibility.Hidden || !Contains(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre)) + { + Resume(); + return; + } + base.PopIn(); GameplayCursor.ActiveCursor.Hide(); diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs index 4aeb3d4862..218fdf5b86 100644 --- a/osu.Game/Rulesets/UI/DrawableRuleset.cs +++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs @@ -227,7 +227,7 @@ namespace osu.Game.Rulesets.UI public override void RequestResume(Action continueResume) { - if (ResumeOverlay != null && UseResumeOverlay && (Cursor == null || (Cursor.LastFrameState == Visibility.Visible && Contains(Cursor.ActiveCursor.ScreenSpaceDrawQuad.Centre)))) + if (ResumeOverlay != null && UseResumeOverlay) { ResumeOverlay.GameplayCursor = Cursor; ResumeOverlay.ResumeAction = continueResume; diff --git a/osu.Game/Screens/Play/ResumeOverlay.cs b/osu.Game/Screens/Play/ResumeOverlay.cs index fae406bd6b..a33dd79888 100644 --- a/osu.Game/Screens/Play/ResumeOverlay.cs +++ b/osu.Game/Screens/Play/ResumeOverlay.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.UI; using osuTK; using osuTK.Graphics; @@ -21,7 +22,7 @@ namespace osu.Game.Screens.Play /// public abstract partial class ResumeOverlay : VisibilityContainer { - public CursorContainer GameplayCursor { get; set; } + public GameplayCursorContainer GameplayCursor { get; set; } /// /// The action to be performed to complete resuming. From 6635d9be04952b43b41ff8e3f2596999a069ff74 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 4 Mar 2024 16:08:25 +0900 Subject: [PATCH 288/508] Add countdown display --- .../UI/DrawableCatchRuleset.cs | 3 +- .../Gameplay/TestSceneDelayedResumeOverlay.cs | 44 ++++++ osu.Game/Screens/Play/DelayedResumeOverlay.cs | 135 +++++++++++++++++- 3 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 osu.Game.Tests/Visual/Gameplay/TestSceneDelayedResumeOverlay.cs diff --git a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs index 580c90bcb4..32ebdc1159 100644 --- a/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/UI/DrawableCatchRuleset.cs @@ -17,6 +17,7 @@ using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Scoring; using osu.Game.Screens.Play; +using osuTK; namespace osu.Game.Rulesets.Catch.UI { @@ -54,6 +55,6 @@ namespace osu.Game.Rulesets.Catch.UI public override DrawableHitObject? CreateDrawableRepresentation(CatchHitObject h) => null; - protected override ResumeOverlay CreateResumeOverlay() => new DelayedResumeOverlay(); + protected override ResumeOverlay CreateResumeOverlay() => new DelayedResumeOverlay { Scale = new Vector2(0.65f) }; } } diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneDelayedResumeOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneDelayedResumeOverlay.cs new file mode 100644 index 0000000000..241a78b6b8 --- /dev/null +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneDelayedResumeOverlay.cs @@ -0,0 +1,44 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Osu; +using osu.Game.Screens.Play; +using osu.Game.Tests.Gameplay; + +namespace osu.Game.Tests.Visual.Gameplay +{ + public partial class TestSceneDelayedResumeOverlay : OsuTestScene + { + private ResumeOverlay resume = null!; + private bool resumeFired; + + [Cached] + private GameplayState gameplayState; + + public TestSceneDelayedResumeOverlay() + { + gameplayState = TestGameplayState.Create(new OsuRuleset()); + } + + [SetUp] + public void SetUp() => Schedule(loadContent); + + [Test] + public void TestResume() + { + AddStep("show", () => resume.Show()); + AddUntilStep("dismissed", () => resumeFired && resume.State.Value == Visibility.Hidden); + } + + private void loadContent() + { + Child = resume = new DelayedResumeOverlay(); + + resumeFired = false; + resume.ResumeAction = () => resumeFired = true; + } + } +} diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index ef39c8eb76..6f70a914f0 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -1,8 +1,18 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; using osu.Framework.Localisation; using osu.Framework.Threading; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osuTK; +using osuTK.Graphics; namespace osu.Game.Screens.Play { @@ -11,21 +21,140 @@ namespace osu.Game.Screens.Play /// public partial class DelayedResumeOverlay : ResumeOverlay { + private const double countdown_time = 800; + protected override LocalisableString Message => string.Empty; + [Resolved] + private OsuColour colours { get; set; } = null!; + private ScheduledDelegate? scheduledResume; + private int countdownCount = 3; + private double countdownStartTime; + + private Drawable content = null!; + private Drawable background = null!; + private SpriteText countdown = null!; + + public DelayedResumeOverlay() + { + Anchor = Anchor.Centre; + Origin = Anchor.Centre; + } + + [BackgroundDependencyLoader] + private void load() + { + Add(content = new CircularContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Masking = true, + BorderColour = colours.Yellow, + BorderThickness = 1, + Children = new[] + { + background = new Box + { + Size = new Vector2(250, 40), + Colour = Color4.Black, + Alpha = 0.8f + }, + new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(5), + Colour = colours.Yellow, + Children = new Drawable[] + { + // new Box + // { + // Anchor = Anchor.Centre, + // Origin = Anchor.Centre, + // Size = new Vector2(40, 3) + // }, + countdown = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + UseFullGlyphHeight = false, + AlwaysPresent = true, + Font = OsuFont.Numeric.With(size: 20, fixedWidth: true) + }, + // new Box + // { + // Anchor = Anchor.Centre, + // Origin = Anchor.Centre, + // Size = new Vector2(40, 3) + // } + } + } + } + } + } + }); + } protected override void PopIn() { - base.PopIn(); + this.FadeIn(); + + content.FadeInFromZero(150, Easing.OutQuint); + content.ScaleTo(new Vector2(1.5f, 1)).Then().ScaleTo(1, 150, Easing.OutElasticQuarter); + + countdownCount = 3; + countdownStartTime = Time.Current; scheduledResume?.Cancel(); - scheduledResume = Scheduler.AddDelayed(Resume, 800); + scheduledResume = Scheduler.AddDelayed(Resume, countdown_time); + } + + protected override void Update() + { + base.Update(); + updateCountdown(); + } + + private void updateCountdown() + { + double amountTimePassed = Math.Min(countdown_time, Time.Current - countdownStartTime) / countdown_time; + int newCount = 3 - (int)Math.Floor(amountTimePassed * 3); + + if (newCount > 0) + { + countdown.Alpha = 1; + countdown.Text = newCount.ToString(); + } + else + countdown.Alpha = 0; + + if (newCount != countdownCount) + { + if (newCount == 0) + content.ScaleTo(new Vector2(1.5f, 1), 150, Easing.OutQuint); + else + content.ScaleTo(new Vector2(1.05f, 1), 50, Easing.OutQuint).Then().ScaleTo(1, 50, Easing.Out); + } + + countdownCount = newCount; } protected override void PopOut() { - base.PopOut(); + this.Delay(150).FadeOut(); + + content.FadeOut(150, Easing.OutQuint); + scheduledResume?.Cancel(); } } From af2b80e0304e9541378fa9fa68caad0ca347a37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 4 Mar 2024 11:28:34 +0100 Subject: [PATCH 289/508] Add failing encode test --- .../Formats/LegacyScoreDecoderTest.cs | 2 +- .../Formats/LegacyScoreEncoderTest.cs | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs index 7e3967dc95..43e471320e 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreDecoderTest.cs @@ -432,7 +432,7 @@ namespace osu.Game.Tests.Beatmaps.Formats CultureInfo.CurrentCulture = originalCulture; } - private class TestLegacyScoreDecoder : LegacyScoreDecoder + public class TestLegacyScoreDecoder : LegacyScoreDecoder { private readonly int beatmapVersion; diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs new file mode 100644 index 0000000000..c0a7285f39 --- /dev/null +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs @@ -0,0 +1,55 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using System.IO; +using NUnit.Framework; +using osu.Game.Beatmaps.Formats; +using osu.Game.Rulesets.Catch; +using osu.Game.Rulesets.Scoring; +using osu.Game.Scoring; +using osu.Game.Scoring.Legacy; +using osu.Game.Tests.Resources; + +namespace osu.Game.Tests.Beatmaps.Formats +{ + public class LegacyScoreEncoderTest + { + [TestCase(1, 3)] + [TestCase(1, 0)] + [TestCase(0, 3)] + public void CatchMergesFruitAndDropletMisses(int missCount, int largeTickMissCount) + { + var ruleset = new CatchRuleset().RulesetInfo; + + var scoreInfo = TestResources.CreateTestScoreInfo(ruleset); + var beatmap = new TestBeatmap(ruleset); + scoreInfo.Statistics = new Dictionary + { + [HitResult.Great] = 50, + [HitResult.LargeTickHit] = 5, + [HitResult.Miss] = missCount, + [HitResult.LargeTickMiss] = largeTickMissCount + }; + var score = new Score { ScoreInfo = scoreInfo }; + + var decodedAfterEncode = encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, score, beatmap); + + Assert.That(decodedAfterEncode.ScoreInfo.GetCountMiss(), Is.EqualTo(missCount + largeTickMissCount)); + } + + private static Score encodeThenDecode(int beatmapVersion, Score score, TestBeatmap beatmap) + { + var encodeStream = new MemoryStream(); + + var encoder = new LegacyScoreEncoder(score, beatmap); + encoder.Encode(encodeStream); + + var decodeStream = new MemoryStream(encodeStream.GetBuffer()); + + var decoder = new LegacyScoreDecoderTest.TestLegacyScoreDecoder(beatmapVersion); + var decodedAfterEncode = decoder.Parse(decodeStream); + return decodedAfterEncode; + } + } +} From dcd6b028090a97ea1b2c43a374bb9210417b0adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 4 Mar 2024 11:35:31 +0100 Subject: [PATCH 290/508] Fix incorrect implementation of `GetCountMiss()` for catch --- .../Scoring/Legacy/ScoreInfoExtensions.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/osu.Game/Scoring/Legacy/ScoreInfoExtensions.cs b/osu.Game/Scoring/Legacy/ScoreInfoExtensions.cs index 07c35a334f..23624401e2 100644 --- a/osu.Game/Scoring/Legacy/ScoreInfoExtensions.cs +++ b/osu.Game/Scoring/Legacy/ScoreInfoExtensions.cs @@ -198,10 +198,25 @@ namespace osu.Game.Scoring.Legacy } } - public static int? GetCountMiss(this ScoreInfo scoreInfo) => - getCount(scoreInfo, HitResult.Miss); + public static int? GetCountMiss(this ScoreInfo scoreInfo) + { + switch (scoreInfo.Ruleset.OnlineID) + { + case 0: + case 1: + case 3: + return getCount(scoreInfo, HitResult.Miss); + + case 2: + return (getCount(scoreInfo, HitResult.Miss) ?? 0) + (getCount(scoreInfo, HitResult.LargeTickMiss) ?? 0); + } + + return null; + } public static void SetCountMiss(this ScoreInfo scoreInfo, int value) => + // this does not match the implementation of `GetCountMiss()` for catch, + // but we physically cannot recover that data anymore at this point. scoreInfo.Statistics[HitResult.Miss] = value; private static int? getCount(ScoreInfo scoreInfo, HitResult result) From b896d97a4f844498e0c1c914a0b70c4fdf70449f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 4 Mar 2024 11:45:44 +0100 Subject: [PATCH 291/508] Fix catch pp calculator not matching live with respect to miss handling --- .../Difficulty/CatchPerformanceCalculator.cs | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs index b30b85be2d..d07f25ba90 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs @@ -2,22 +2,21 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Collections.Generic; using System.Linq; using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Mods; -using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; +using osu.Game.Scoring.Legacy; namespace osu.Game.Rulesets.Catch.Difficulty { public class CatchPerformanceCalculator : PerformanceCalculator { - private int fruitsHit; - private int ticksHit; - private int tinyTicksHit; - private int tinyTicksMissed; - private int misses; + private int num300; + private int num100; + private int num50; + private int numKatu; + private int numMiss; public CatchPerformanceCalculator() : base(new CatchRuleset()) @@ -28,11 +27,11 @@ namespace osu.Game.Rulesets.Catch.Difficulty { var catchAttributes = (CatchDifficultyAttributes)attributes; - fruitsHit = score.Statistics.GetValueOrDefault(HitResult.Great); - ticksHit = score.Statistics.GetValueOrDefault(HitResult.LargeTickHit); - tinyTicksHit = score.Statistics.GetValueOrDefault(HitResult.SmallTickHit); - tinyTicksMissed = score.Statistics.GetValueOrDefault(HitResult.SmallTickMiss); - misses = score.Statistics.GetValueOrDefault(HitResult.Miss); + num300 = score.GetCount300() ?? 0; // HitResult.Great + num100 = score.GetCount100() ?? 0; // HitResult.LargeTickHit + num50 = score.GetCount50() ?? 0; // HitResult.SmallTickHit + numKatu = score.GetCountKatu() ?? 0; // HitResult.SmallTickMiss + numMiss = score.GetCountMiss() ?? 0; // HitResult.Miss PLUS HitResult.LargeTickMiss // We are heavily relying on aim in catch the beat double value = Math.Pow(5.0 * Math.Max(1.0, catchAttributes.StarRating / 0.0049) - 4.0, 2.0) / 100000.0; @@ -45,7 +44,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty (numTotalHits > 2500 ? Math.Log10(numTotalHits / 2500.0) * 0.475 : 0.0); value *= lengthBonus; - value *= Math.Pow(0.97, misses); + value *= Math.Pow(0.97, numMiss); // Combo scaling if (catchAttributes.MaxCombo > 0) @@ -86,8 +85,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty } private double accuracy() => totalHits() == 0 ? 0 : Math.Clamp((double)totalSuccessfulHits() / totalHits(), 0, 1); - private int totalHits() => tinyTicksHit + ticksHit + fruitsHit + misses + tinyTicksMissed; - private int totalSuccessfulHits() => tinyTicksHit + ticksHit + fruitsHit; - private int totalComboHits() => misses + ticksHit + fruitsHit; + private int totalHits() => num50 + num100 + num300 + numMiss + numKatu; + private int totalSuccessfulHits() => num50 + num100 + num300; + private int totalComboHits() => numMiss + num100 + num300; } } From 405958f73c560b5c3eae381255d5141e37c819c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 4 Mar 2024 14:43:53 +0100 Subject: [PATCH 292/508] Add test scene for drawable ranks --- .../Visual/Ranking/TestSceneDrawableRank.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 osu.Game.Tests/Visual/Ranking/TestSceneDrawableRank.cs diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneDrawableRank.cs b/osu.Game.Tests/Visual/Ranking/TestSceneDrawableRank.cs new file mode 100644 index 0000000000..804c8dfc44 --- /dev/null +++ b/osu.Game.Tests/Visual/Ranking/TestSceneDrawableRank.cs @@ -0,0 +1,39 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Linq; +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Online.Leaderboards; +using osu.Game.Scoring; +using osuTK; + +namespace osu.Game.Tests.Visual.Ranking +{ + public partial class TestSceneDrawableRank : OsuTestScene + { + [Test] + public void TestAllRanks() + { + AddStep("create content", () => Child = new FillFlowContainer + { + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Direction = FillDirection.Vertical, + Padding = new MarginPadding(20), + Spacing = new Vector2(10), + ChildrenEnumerable = Enum.GetValues().OrderBy(v => v).Select(rank => new DrawableRank(rank) + { + RelativeSizeAxes = Axes.None, + Size = new Vector2(50, 25), + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }) + }); + } + } +} From 6080c14dd5b589c982b09365aa1b5eb74ccd14ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 4 Mar 2024 14:47:49 +0100 Subject: [PATCH 293/508] Update F rank badge colours to match latest designs --- osu.Game/Graphics/OsuColour.cs | 6 +++++- osu.Game/Online/Leaderboards/DrawableRank.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/OsuColour.cs b/osu.Game/Graphics/OsuColour.cs index 985898958c..c479d0cfe4 100644 --- a/osu.Game/Graphics/OsuColour.cs +++ b/osu.Game/Graphics/OsuColour.cs @@ -63,8 +63,12 @@ namespace osu.Game.Graphics case ScoreRank.C: return Color4Extensions.FromHex(@"ff8e5d"); - default: + case ScoreRank.D: return Color4Extensions.FromHex(@"ff5a5a"); + + case ScoreRank.F: + default: + return Color4Extensions.FromHex(@"3f3f3f"); } } diff --git a/osu.Game/Online/Leaderboards/DrawableRank.cs b/osu.Game/Online/Leaderboards/DrawableRank.cs index 5177f35478..0b0ab11410 100644 --- a/osu.Game/Online/Leaderboards/DrawableRank.cs +++ b/osu.Game/Online/Leaderboards/DrawableRank.cs @@ -95,8 +95,12 @@ namespace osu.Game.Online.Leaderboards case ScoreRank.C: return Color4Extensions.FromHex(@"473625"); - default: + case ScoreRank.D: return Color4Extensions.FromHex(@"512525"); + + case ScoreRank.F: + default: + return Color4Extensions.FromHex(@"CC3333"); } } } From 9543908c7ab23cc397522ccaa1cfdc97c9d791b1 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 4 Mar 2024 23:36:45 +0300 Subject: [PATCH 294/508] Fix mod select overlay settings order not always matching panels order --- .../TestSceneModSelectOverlay.cs | 24 +++++++++++++++++++ osu.Game/Overlays/Mods/ModSettingsArea.cs | 11 +++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index b26e126249..6c75530a6e 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -859,6 +859,30 @@ namespace osu.Game.Tests.Visual.UserInterface () => modSelectOverlay.ChildrenOfType().Single().ModMultiplier.Value, () => Is.EqualTo(0.3).Within(Precision.DOUBLE_EPSILON)); } + [Test] + public void TestModSettingsOrder() + { + createScreen(); + + AddStep("select DT + HD + DF", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime(), new OsuModHidden(), new OsuModDeflate() }); + AddAssert("mod settings order: DT, HD, DF", () => + { + var columns = this.ChildrenOfType().Single().ChildrenOfType(); + return columns.ElementAt(0).Mod is OsuModDoubleTime && + columns.ElementAt(1).Mod is OsuModHidden && + columns.ElementAt(2).Mod is OsuModDeflate; + }); + + AddStep("replace DT with NC", () => SelectedMods.Value = SelectedMods.Value.Where(m => m is not ModDoubleTime).Append(new OsuModNightcore()).ToList()); + AddAssert("mod settings order: NC, HD, DF", () => + { + var columns = this.ChildrenOfType().Single().ChildrenOfType(); + return columns.ElementAt(0).Mod is OsuModNightcore && + columns.ElementAt(1).Mod is OsuModHidden && + columns.ElementAt(2).Mod is OsuModDeflate; + }); + } + private void waitForColumnLoad() => AddUntilStep("all column content loaded", () => modSelectOverlay.ChildrenOfType().Any() && modSelectOverlay.ChildrenOfType().All(column => column.IsLoaded && column.ItemsLoaded) diff --git a/osu.Game/Overlays/Mods/ModSettingsArea.cs b/osu.Game/Overlays/Mods/ModSettingsArea.cs index 54bfcc7199..d0e0f7e648 100644 --- a/osu.Game/Overlays/Mods/ModSettingsArea.cs +++ b/osu.Game/Overlays/Mods/ModSettingsArea.cs @@ -86,7 +86,10 @@ namespace osu.Game.Overlays.Mods { modSettingsFlow.Clear(); - foreach (var mod in SelectedMods.Value.AsOrdered()) + // Importantly, the selected mods bindable is already ordered by the mod select overlay (following the order of mod columns and panels). + // Using AsOrdered produces a slightly different order (e.g. DT and NC no longer becoming adjacent), + // which breaks user expectations when interacting with the overlay. + foreach (var mod in SelectedMods.Value) { var settings = mod.CreateSettingsControls().ToList(); @@ -110,10 +113,14 @@ namespace osu.Game.Overlays.Mods protected override bool OnMouseDown(MouseDownEvent e) => true; protected override bool OnHover(HoverEvent e) => true; - private partial class ModSettingsColumn : CompositeDrawable + public partial class ModSettingsColumn : CompositeDrawable { + public readonly Mod Mod; + public ModSettingsColumn(Mod mod, IEnumerable settingsControls) { + Mod = mod; + Width = 250; RelativeSizeAxes = Axes.Y; Padding = new MarginPadding { Bottom = 7 }; From 92f455f1995d32d380380b4a06adf34b21bfdc63 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 5 Mar 2024 03:01:01 +0300 Subject: [PATCH 295/508] Abstractify performance points calculation to a base class --- .../HUD/DefaultPerformancePointsCounter.cs | 91 +++++++++++++++++++ .../Play/HUD/PerformancePointsCounter.cs | 83 +---------------- 2 files changed, 93 insertions(+), 81 deletions(-) create mode 100644 osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs diff --git a/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs new file mode 100644 index 0000000000..3c4e58e575 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs @@ -0,0 +1,91 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +#nullable disable + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Resources.Localisation.Web; +using osuTK; + +namespace osu.Game.Screens.Play.HUD +{ + public partial class DefaultPerformancePointsCounter : PerformancePointsCounter + { + protected override bool IsRollingProportional => true; + + protected override double RollingDuration => 500; + + private const float alpha_when_invalid = 0.3f; + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = colours.BlueLighter; + } + + public override bool IsValid + { + get => base.IsValid; + set + { + if (value == IsValid) + return; + + base.IsValid = value; + DrawableCount.FadeTo(value ? 1 : alpha_when_invalid, 1000, Easing.OutQuint); + } + } + + protected override LocalisableString FormatCount(int count) => count.ToString(@"D"); + + protected override IHasText CreateText() => new TextComponent + { + Alpha = alpha_when_invalid + }; + + private partial class TextComponent : CompositeDrawable, IHasText + { + public LocalisableString Text + { + get => text.Text; + set => text.Text = value; + } + + private readonly OsuSpriteText text; + + public TextComponent() + { + AutoSizeAxes = Axes.Both; + + InternalChild = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(2), + Children = new Drawable[] + { + text = new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Font = OsuFont.Numeric.With(size: 16, fixedWidth: true) + }, + new OsuSpriteText + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Text = BeatmapsetsStrings.ShowScoreboardHeaderspp, + Font = OsuFont.Numeric.With(size: 8), + Padding = new MarginPadding { Bottom = 1.5f }, // align baseline better + } + } + }; + } + } + } +} diff --git a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs index f041e120f6..4b07e7da36 100644 --- a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs @@ -13,16 +13,9 @@ using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Extensions; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; -using osu.Framework.Localisation; using osu.Game.Beatmaps; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets; using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Judgements; @@ -31,7 +24,6 @@ using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Skinning; -using osuTK; namespace osu.Game.Screens.Play.HUD { @@ -39,12 +31,6 @@ namespace osu.Game.Screens.Play.HUD { public bool UsesFixedAnchor { get; set; } - protected override bool IsRollingProportional => true; - - protected override double RollingDuration => 500; - - private const float alpha_when_invalid = 0.3f; - [Resolved] private ScoreProcessor scoreProcessor { get; set; } @@ -60,18 +46,11 @@ namespace osu.Game.Screens.Play.HUD private PerformanceCalculator performanceCalculator; private ScoreInfo scoreInfo; - public PerformancePointsCounter() - { - Current.Value = DisplayedCount = 0; - } - private Mod[] clonedMods; [BackgroundDependencyLoader] - private void load(OsuColour colours, BeatmapDifficultyCache difficultyCache) + private void load(BeatmapDifficultyCache difficultyCache) { - Colour = colours.BlueLighter; - if (gameplayState != null) { performanceCalculator = gameplayState.Ruleset.CreatePerformanceCalculator(); @@ -107,19 +86,7 @@ namespace osu.Game.Screens.Play.HUD onJudgementChanged(gameplayState.LastJudgementResult.Value); } - private bool isValid; - - protected bool IsValid - { - set - { - if (value == isValid) - return; - - isValid = value; - DrawableCount.FadeTo(isValid ? 1 : alpha_when_invalid, 1000, Easing.OutQuint); - } - } + public virtual bool IsValid { get; set; } private void onJudgementChanged(JudgementResult judgement) { @@ -151,13 +118,6 @@ namespace osu.Game.Screens.Play.HUD return timedAttributes[Math.Clamp(attribIndex, 0, timedAttributes.Count - 1)].Attributes; } - protected override LocalisableString FormatCount(int count) => count.ToString(@"D"); - - protected override IHasText CreateText() => new TextComponent - { - Alpha = alpha_when_invalid - }; - protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); @@ -171,45 +131,6 @@ namespace osu.Game.Screens.Play.HUD loadCancellationSource?.Cancel(); } - private partial class TextComponent : CompositeDrawable, IHasText - { - public LocalisableString Text - { - get => text.Text; - set => text.Text = value; - } - - private readonly OsuSpriteText text; - - public TextComponent() - { - AutoSizeAxes = Axes.Both; - - InternalChild = new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(2), - Children = new Drawable[] - { - text = new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Font = OsuFont.Numeric.With(size: 16, fixedWidth: true) - }, - new OsuSpriteText - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Text = BeatmapsetsStrings.ShowScoreboardHeaderspp, - Font = OsuFont.Numeric.With(size: 8), - Padding = new MarginPadding { Bottom = 1.5f }, // align baseline better - } - } - }; - } - } - // TODO: This class shouldn't exist, but requires breaking changes to allow DifficultyCalculator to receive an IBeatmap. private class GameplayWorkingBeatmap : WorkingBeatmap { From 3ee57cdfba7c932dc4dbfb0351d644e1ce46c6d3 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 5 Mar 2024 03:01:46 +0300 Subject: [PATCH 296/508] Refactor performance points test scene to support skinning --- .../SkinnableHUDComponentTestScene.cs | 13 ++- .../TestScenePerformancePointsCounter.cs | 96 ++++++++----------- .../TestSceneSkinnableAccuracyCounter.cs | 6 +- .../TestSceneSkinnableHealthDisplay.cs | 6 +- .../Play/HUD/ArgonPerformancePointsCounter.cs | 9 ++ 5 files changed, 65 insertions(+), 65 deletions(-) create mode 100644 osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs diff --git a/osu.Game.Tests/Visual/Gameplay/SkinnableHUDComponentTestScene.cs b/osu.Game.Tests/Visual/Gameplay/SkinnableHUDComponentTestScene.cs index f54f50795e..7933647dd2 100644 --- a/osu.Game.Tests/Visual/Gameplay/SkinnableHUDComponentTestScene.cs +++ b/osu.Game.Tests/Visual/Gameplay/SkinnableHUDComponentTestScene.cs @@ -1,8 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using NUnit.Framework; using osu.Framework.Graphics; +using osu.Framework.Testing; using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; using osu.Game.Skinning; @@ -13,8 +13,13 @@ namespace osu.Game.Tests.Visual.Gameplay { protected override Ruleset CreateRulesetForSkinProvider() => new OsuRuleset(); - [SetUp] - public void SetUp() => Schedule(() => + [SetUpSteps] + public virtual void SetUpSteps() + { + AddStep("setup components", SetUpComponents); + } + + public void SetUpComponents() { SetContents(skin => { @@ -28,7 +33,7 @@ namespace osu.Game.Tests.Visual.Gameplay implementation.Origin = Anchor.Centre; return implementation; }); - }); + } protected abstract Drawable CreateDefaultImplementation(); protected virtual Drawable CreateArgonImplementation() => CreateDefaultImplementation(); diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs index 9622caabf5..986167279c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs @@ -3,102 +3,88 @@ #nullable disable -using System; -using System.Diagnostics; +using System.Linq; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Testing; -using osu.Game.Rulesets; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Judgements; +using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play; using osu.Game.Screens.Play.HUD; -using osuTK; +using osu.Game.Tests.Gameplay; namespace osu.Game.Tests.Visual.Gameplay { - public partial class TestScenePerformancePointsCounter : OsuTestScene + public partial class TestScenePerformancePointsCounter : SkinnableHUDComponentTestScene { - private DependencyProvidingContainer dependencyContainer; + [Cached(typeof(ScoreProcessor))] + private readonly ScoreProcessor scoreProcessor = new OsuScoreProcessor(); - private GameplayState gameplayState; - private ScoreProcessor scoreProcessor; + [Cached] + private readonly GameplayState gameplayState = TestGameplayState.Create(new OsuRuleset()); private int iteration; - private Bindable lastJudgementResult = new Bindable(); - private PerformancePointsCounter counter; - [SetUpSteps] - public void SetUpSteps() => AddStep("create components", () => + protected override Drawable CreateDefaultImplementation() => new DefaultPerformancePointsCounter(); + protected override Drawable CreateArgonImplementation() => new ArgonPerformancePointsCounter(); + protected override Drawable CreateLegacyImplementation() => Empty(); + + private Bindable lastJudgementResult => (Bindable)gameplayState.LastJudgementResult; + + public override void SetUpSteps() { - var ruleset = CreateRuleset(); - - Debug.Assert(ruleset != null); - - var beatmap = CreateWorkingBeatmap(ruleset.RulesetInfo) - .GetPlayableBeatmap(ruleset.RulesetInfo); - - lastJudgementResult = new Bindable(); - - gameplayState = new GameplayState(beatmap, ruleset); - gameplayState.LastJudgementResult.BindTo(lastJudgementResult); - - scoreProcessor = new ScoreProcessor(ruleset); - - Child = dependencyContainer = new DependencyProvidingContainer + AddStep("reset", () => { - RelativeSizeAxes = Axes.Both, - CachedDependencies = new (Type, object)[] - { - (typeof(GameplayState), gameplayState), - (typeof(ScoreProcessor), scoreProcessor) - } - }; + var ruleset = new OsuRuleset(); + var beatmap = CreateWorkingBeatmap(ruleset.RulesetInfo) + .GetPlayableBeatmap(ruleset.RulesetInfo); - iteration = 0; - }); + iteration = 0; + scoreProcessor.ApplyBeatmap(beatmap); + lastJudgementResult.SetDefault(); + }); - protected override Ruleset CreateRuleset() => new OsuRuleset(); + base.SetUpSteps(); + } - private void createCounter() => AddStep("Create counter", () => + [Test] + public void TestDisplay() { - dependencyContainer.Child = counter = new PerformancePointsCounter - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Scale = new Vector2(5), - }; - }); + AddSliderStep("pp", 0, 2000, 0, v => this.ChildrenOfType().ForEach(c => c.Current.Value = v)); + AddToggleStep("toggle validity", v => this.ChildrenOfType().ForEach(c => c.IsValid = v)); + } [Test] public void TestBasicCounting() { int previousValue = 0; - createCounter(); - AddAssert("counter displaying zero", () => counter.Current.Value == 0); + AddAssert("counter displaying zero", () => this.ChildrenOfType().All(c => c.Current.Value == 0)); AddRepeatStep("Add judgement", applyOneJudgement, 10); - AddUntilStep("counter non-zero", () => counter.Current.Value > 0); - AddUntilStep("counter opaque", () => counter.Child.Alpha == 1); + AddUntilStep("counter non-zero", () => this.ChildrenOfType().All(c => c.Current.Value > 0)); + AddUntilStep("counter valid", () => this.ChildrenOfType().All(c => c.IsValid)); AddStep("Revert judgement", () => { - previousValue = counter.Current.Value; + previousValue = this.ChildrenOfType().First().Current.Value; scoreProcessor.RevertResult(new JudgementResult(new HitObject(), new OsuJudgement())); }); - AddUntilStep("counter decreased", () => counter.Current.Value < previousValue); + AddUntilStep("counter decreased", () => this.ChildrenOfType().All(c => c.Current.Value < previousValue)); AddStep("Add judgement", applyOneJudgement); - AddUntilStep("counter non-zero", () => counter.Current.Value > 0); + AddUntilStep("counter non-zero", () => this.ChildrenOfType().All(c => c.Current.Value > 0)); } [Test] @@ -106,10 +92,10 @@ namespace osu.Game.Tests.Visual.Gameplay { AddRepeatStep("Add judgement", applyOneJudgement, 10); - createCounter(); + AddStep("recreate counter", SetUpComponents); - AddUntilStep("counter non-zero", () => counter.Current.Value > 0); - AddUntilStep("counter opaque", () => counter.Child.Alpha == 1); + AddUntilStep("counter non-zero", () => this.ChildrenOfType().All(c => c.Current.Value > 0)); + AddUntilStep("counter valid", () => this.ChildrenOfType().All(c => c.IsValid)); } private void applyOneJudgement() diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableAccuracyCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableAccuracyCounter.cs index e088d2ca87..d815b80cbc 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableAccuracyCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableAccuracyCounter.cs @@ -4,7 +4,6 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Testing; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play.HUD; @@ -21,10 +20,11 @@ namespace osu.Game.Tests.Visual.Gameplay protected override Drawable CreateDefaultImplementation() => new DefaultAccuracyCounter(); protected override Drawable CreateLegacyImplementation() => new LegacyAccuracyCounter(); - [SetUpSteps] - public void SetUpSteps() + public override void SetUpSteps() { AddStep("Set initial accuracy", () => scoreProcessor.Accuracy.Value = 1); + + base.SetUpSteps(); } [Test] diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHealthDisplay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHealthDisplay.cs index 1849e8abd0..3fd6caf7f2 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHealthDisplay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHealthDisplay.cs @@ -4,7 +4,6 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; -using osu.Framework.Testing; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Judgements; @@ -25,14 +24,15 @@ namespace osu.Game.Tests.Visual.Gameplay protected override Drawable CreateDefaultImplementation() => new DefaultHealthDisplay { Scale = new Vector2(0.6f) }; protected override Drawable CreateLegacyImplementation() => new LegacyHealthDisplay { Scale = new Vector2(0.6f) }; - [SetUpSteps] - public void SetUpSteps() + public override void SetUpSteps() { AddStep(@"Reset all", delegate { healthProcessor.Health.Value = 1; healthProcessor.Failed += () => false; // health won't be updated if the processor gets into a "fail" state. }); + + base.SetUpSteps(); } protected override void Update() diff --git a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs new file mode 100644 index 0000000000..9e6b5f81e0 --- /dev/null +++ b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs @@ -0,0 +1,9 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Screens.Play.HUD +{ + public partial class ArgonPerformancePointsCounter : PerformancePointsCounter + { + } +} From d7f1e50d66b10529a37d48c99a79a6b0ef2b54f8 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 5 Mar 2024 03:34:29 +0300 Subject: [PATCH 297/508] Add "Argon" performance points counter --- .../Play/HUD/ArgonPerformancePointsCounter.cs | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs index 9e6b5f81e0..022c1fab9e 100644 --- a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs @@ -1,9 +1,79 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; +using osu.Framework.Extensions.LocalisationExtensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Configuration; +using osu.Game.Localisation.SkinComponents; +using osu.Game.Resources.Localisation.Web; + namespace osu.Game.Screens.Play.HUD { public partial class ArgonPerformancePointsCounter : PerformancePointsCounter { + private ArgonCounterTextComponent text = null!; + + protected override double RollingDuration => 250; + + private const float alpha_when_invalid = 0.3f; + + [SettingSource("Wireframe opacity", "Controls the opacity of the wire frames behind the digits.")] + public BindableFloat WireframeOpacity { get; } = new BindableFloat(0.25f) + { + Precision = 0.01f, + MinValue = 0, + MaxValue = 1, + }; + + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.ShowLabel), nameof(SkinnableComponentStrings.ShowLabelDescription))] + public Bindable ShowLabel { get; } = new BindableBool(true); + + public override bool IsValid + { + get => base.IsValid; + set + { + if (value == IsValid) + return; + + base.IsValid = value; + text.FadeTo(value ? 1 : alpha_when_invalid, 1000, Easing.OutQuint); + } + } + + public override int DisplayedCount + { + get => base.DisplayedCount; + set + { + base.DisplayedCount = value; + updateWireframe(); + } + } + + private void updateWireframe() + { + int digitsRequiredForDisplayCount = getDigitsRequiredForDisplayCount(); + + if (digitsRequiredForDisplayCount != text.WireframeTemplate.Length) + text.WireframeTemplate = new string('#', digitsRequiredForDisplayCount); + } + + private int getDigitsRequiredForDisplayCount() + { + int digitsRequired = 1; + long c = DisplayedCount; + while ((c /= 10) > 0) + digitsRequired++; + return digitsRequired; + } + + protected override IHasText CreateText() => text = new ArgonCounterTextComponent(Anchor.TopRight, BeatmapsetsStrings.ShowScoreboardHeaderspp.ToUpper()) + { + WireframeOpacity = { BindTarget = WireframeOpacity }, + ShowLabel = { BindTarget = ShowLabel }, + }; } } From 0cbcfcecdc3f777efe1adbda732787c26c294ff6 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 5 Mar 2024 03:58:43 +0300 Subject: [PATCH 298/508] Integrate "Argon" performance points counter with HUD layout --- osu.Game/Skinning/ArgonSkin.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Skinning/ArgonSkin.cs b/osu.Game/Skinning/ArgonSkin.cs index 6fcab6a977..24e17d21f4 100644 --- a/osu.Game/Skinning/ArgonSkin.cs +++ b/osu.Game/Skinning/ArgonSkin.cs @@ -118,6 +118,7 @@ namespace osu.Game.Skinning var wedgePieces = container.OfType().ToArray(); var score = container.OfType().FirstOrDefault(); var accuracy = container.OfType().FirstOrDefault(); + var performancePoints = container.OfType().FirstOrDefault(); var combo = container.OfType().FirstOrDefault(); var songProgress = container.OfType().FirstOrDefault(); var keyCounter = container.OfType().FirstOrDefault(); @@ -159,6 +160,13 @@ namespace osu.Game.Skinning accuracy.Origin = Anchor.TopRight; } + if (performancePoints != null && accuracy != null) + { + performancePoints.Position = new Vector2(accuracy.X, accuracy.Y + accuracy.DrawHeight + 10); + performancePoints.Anchor = Anchor.TopRight; + performancePoints.Origin = Anchor.TopRight; + } + var hitError = container.OfType().FirstOrDefault(); if (hitError != null) @@ -224,6 +232,7 @@ namespace osu.Game.Skinning CornerRadius = { Value = 0.5f } }, new ArgonAccuracyCounter(), + new ArgonPerformancePointsCounter(), new ArgonComboCounter { Scale = new Vector2(1.3f) From b1477c30f2218ffd449f98f595c8a5c8a83fcfdf Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 5 Mar 2024 04:30:57 +0300 Subject: [PATCH 299/508] Add deserialisation test coverage --- .../Archives/modified-argon-20240305.osk | Bin 0 -> 2390 bytes osu.Game.Tests/Skins/SkinDeserialisationTest.cs | 2 ++ 2 files changed, 2 insertions(+) create mode 100644 osu.Game.Tests/Resources/Archives/modified-argon-20240305.osk diff --git a/osu.Game.Tests/Resources/Archives/modified-argon-20240305.osk b/osu.Game.Tests/Resources/Archives/modified-argon-20240305.osk new file mode 100644 index 0000000000000000000000000000000000000000..6db24352a5e62a877cc2c046fb8130a8dfe9c1b2 GIT binary patch literal 2390 zcmbW2dpMMN8^?cR97DS@&g?ZNheXUsPG!fLjLF21w2aeW#8?c=E7hb_DfD7=5^dS)gyfytpgUF6}Q6TUsltWadaEK}t4lyi37(jSeAOP^f008$n z_BdRKnvI5??bG8cotTbO5AEsvaS)5;cntNoKb_$vY4;@o4kI8aPxJhb3IN-Aa9^!p zNfrP}00&qP64~0(+$<>Y=O8kXObPv_N@j1l1`Q)&vGX6*5ygrKArEAMl)~)qI@oy2 zS~t9-ca!2GQr9rtue@+8`o!7+DnnMBH+hd#qrqyhJi4yr&b`CU^q&xs@MwO*Iu8G% ztexTATt)Hdrg!tTZ!1wrzSVEMc?=!Iv~?dPqi)p$NR^I}<-YQ$P?DSbfwe;-rV9sn zaYrPv_kY(iKF)_O`R`DzKgIK|=jG77Wu{Gqu~P44L>o*(4p}z#M0Psof6%T`RdTFp zT5_3Mv{Il~liCOTa&ptoK1(l~qS>RbAeQZ`&(qwDrD3A(60{5X9}X$dt*7Kx&Mj*8 zBJD}7%oe`y5LClHH=#{qS^Eabx|?uxzm>E`t%%UCrG`*k+!C(X?$VN4))JA|d#Gq( z=BOAEdYLj=`>~w)iPYHZC;1@F^}(m8H|1Y2uk#}w?#@X%jVZbmG~OqNBQczW(LhxVDCEH_Sy8%q*OWMFM*-j#z-ne7*&+v^Y4qCU>vE~1U+Cj8>p zK@DI1*<_*DOf08CSl|i6XLc{UW@t3S;cRVgjw`)rm5l64-gDD7XX6anlIr$kU9#wH zD?d}O!oQ1ie5j~j;}}F|OYXYS=B!a;b|dN!NW`TOWej@xbYOo7TIWncLKvySwlyq% zVBY%F=34jptzzk+sf`DYab1Y@bE}`ExMss;!UKh%VB1ok%?9>=wtFcL0D=GxLeG-O znj|u5+vrFNhp0{A5V_AUjNa8#me_>+p0{_DfU@FanV634O-+nT+~e0PAv}8VN`1V% zmDmM4aB>l1Rmr+x8B{LvMm*Pko*5R>VxnB8#K6a7JdAZ%h^h0C4~Z1OnE?%+A4COOx=`9_jzHM_%p{UcT<0?h9C3 zr-kpFuHi27Buhh8zn4QHksJsKo*4{*o@_)ZDG4_5OuJ74ZJ#VPkJz~7!^mr@Q&Tg_ zlCa6VnJaltsZ|{1se9g>e6x4)P$39EzuM)D-&)2~SmW%})Rq+d>x=GmqZ#9z6zXI7 zY)w6;k{Dg3@8HPuC#op5BdQJh2F$w7K{maV&SvQMYt-kxI9A5UV!Wt=(W@Cs*yl~d zy@M@ny)Rfz=DCxn54MfXjU04>f9S7ECT;}CWtz7}n+SNBnaVwQ(j&b05qocf$2 zp{M6j@G*<*QpL@qdK1krr}TXT5>9K$p9`FBtvwSEmGaQSzvS6yp-VwAvF0yI7%IqY zq9I^=3ZLh*n^PA60HS{{E{W_D^i6Qs#?%s~6YKcU9{04%uHCl77Tbr_u<7aPKcbD) z*45D|#jzl2A(}Q=jdm@b0^zQX?hdVkFz9FA?&ctuw>x4`xo`g; zeZP#o+xA?N?ubFX1i-)K>h2ue1G3ve+yk;B26Y|^zWJPd8FlyEx$fH$gDS`e{*4!R oC*ZEn?vZfUXGaVwo&T@0zj>K(7(RaP=X`(i_@% literal 0 HcmV?d00001 diff --git a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs index 6423e061c5..d979bdab93 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -60,6 +60,8 @@ namespace osu.Game.Tests.Skins "Archives/modified-argon-20231106.osk", // Covers "Argon" accuracy/score/combo counters, and wedges "Archives/modified-argon-20231108.osk", + // Covers "Argon" performance points counter + "Archives/modified-argon-20240305.osk", }; /// From 49b3e81e8aa2f9ba438d3218d06a9e167fd30191 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 5 Mar 2024 04:34:41 +0300 Subject: [PATCH 300/508] Migrate `DefaultPerformancePointsCounter` and rename it --- .../Visual/Gameplay/TestScenePerformancePointsCounter.cs | 3 ++- osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs | 2 +- osu.Game/Skinning/Skin.cs | 1 + .../Triangles/TrianglesPerformancePointsCounter.cs} | 5 +++-- osu.Game/Skinning/TrianglesSkin.cs | 3 ++- 5 files changed, 9 insertions(+), 5 deletions(-) rename osu.Game/{Screens/Play/HUD/DefaultPerformancePointsCounter.cs => Skinning/Triangles/TrianglesPerformancePointsCounter.cs} (94%) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs index 986167279c..eada72326d 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs @@ -18,6 +18,7 @@ using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play; using osu.Game.Screens.Play.HUD; +using osu.Game.Skinning.Triangles; using osu.Game.Tests.Gameplay; namespace osu.Game.Tests.Visual.Gameplay @@ -32,7 +33,7 @@ namespace osu.Game.Tests.Visual.Gameplay private int iteration; - protected override Drawable CreateDefaultImplementation() => new DefaultPerformancePointsCounter(); + protected override Drawable CreateDefaultImplementation() => new TrianglesPerformancePointsCounter(); protected override Drawable CreateArgonImplementation() => new ArgonPerformancePointsCounter(); protected override Drawable CreateLegacyImplementation() => Empty(); diff --git a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs index 4b07e7da36..c5ad106bcc 100644 --- a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs @@ -27,7 +27,7 @@ using osu.Game.Skinning; namespace osu.Game.Screens.Play.HUD { - public partial class PerformancePointsCounter : RollingCounter, ISerialisableDrawable + public abstract partial class PerformancePointsCounter : RollingCounter, ISerialisableDrawable { public bool UsesFixedAnchor { get; set; } diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 9ee69d033d..91b21f0308 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -153,6 +153,7 @@ namespace osu.Game.Skinning // handle namespace changes... jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.SongProgress", @"osu.Game.Screens.Play.HUD.DefaultSongProgress"); jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.HUD.LegacyComboCounter", @"osu.Game.Skinning.LegacyComboCounter"); + jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.HUD.PerformancePointsCounter", @"osu.Game.Skinning.Triangles.TrianglesPerformancePointsCounter"); var deserializedContent = JsonConvert.DeserializeObject>(jsonContent); diff --git a/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs b/osu.Game/Skinning/Triangles/TrianglesPerformancePointsCounter.cs similarity index 94% rename from osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs rename to osu.Game/Skinning/Triangles/TrianglesPerformancePointsCounter.cs index 3c4e58e575..99da2c0942 100644 --- a/osu.Game/Screens/Play/HUD/DefaultPerformancePointsCounter.cs +++ b/osu.Game/Skinning/Triangles/TrianglesPerformancePointsCounter.cs @@ -11,11 +11,12 @@ using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Resources.Localisation.Web; +using osu.Game.Screens.Play.HUD; using osuTK; -namespace osu.Game.Screens.Play.HUD +namespace osu.Game.Skinning.Triangles { - public partial class DefaultPerformancePointsCounter : PerformancePointsCounter + public partial class TrianglesPerformancePointsCounter : PerformancePointsCounter { protected override bool IsRollingProportional => true; diff --git a/osu.Game/Skinning/TrianglesSkin.cs b/osu.Game/Skinning/TrianglesSkin.cs index a2dca5d333..6158d4c7bf 100644 --- a/osu.Game/Skinning/TrianglesSkin.cs +++ b/osu.Game/Skinning/TrianglesSkin.cs @@ -14,6 +14,7 @@ using osu.Game.Extensions; using osu.Game.IO; using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD.HitErrorMeters; +using osu.Game.Skinning.Triangles; using osuTK; using osuTK.Graphics; @@ -167,7 +168,7 @@ namespace osu.Game.Skinning new DefaultKeyCounterDisplay(), new BarHitErrorMeter(), new BarHitErrorMeter(), - new PerformancePointsCounter() + new TrianglesPerformancePointsCounter() } }; From cceb616a18cc862f975da533bed42b49a89d2fa9 Mon Sep 17 00:00:00 2001 From: Jayden Date: Mon, 4 Mar 2024 22:25:36 -0500 Subject: [PATCH 301/508] Update failure messages Co-authored-by: Salman Ahmed --- osu.Desktop/DiscordRichPresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 035add8044..85b6129043 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -184,14 +184,14 @@ namespace osu.Desktop game.Window?.Raise(); if (!tryParseRoomSecret(args.Secret, out long roomId, out string? password)) - Logger.Log("Failed to parse the room secret Discord gave us", LoggingTarget.Network, LogLevel.Error); + Logger.Log("Could not parse room from Discord RPC Client", LoggingTarget.Network, LogLevel.Important); var request = new GetRoomRequest(roomId); request.Success += room => Schedule(() => { game.PresentMultiplayerMatch(room, password); }); - request.Failure += _ => Logger.Log("Couldn't find the room Discord gave us", LoggingTarget.Network, LogLevel.Error); + request.Failure += _ => Logger.Log($"Could not find room {roomId} from Discord RPC Client", LoggingTarget.Network, LogLevel.Important); api.Queue(request); } From 43841e210d2a1915d3c39bfe191ef62befbd3492 Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Tue, 5 Mar 2024 09:58:46 +0100 Subject: [PATCH 302/508] Use ObjectDisposedException.ThrowIf throw helper --- osu.Game/Database/RealmAccess.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Database/RealmAccess.cs b/osu.Game/Database/RealmAccess.cs index 4bd7f36cdd..167d170c81 100644 --- a/osu.Game/Database/RealmAccess.cs +++ b/osu.Game/Database/RealmAccess.cs @@ -489,8 +489,7 @@ namespace osu.Game.Database /// The work to run. public Task WriteAsync(Action action) { - if (isDisposed) - throw new ObjectDisposedException(nameof(RealmAccess)); + ObjectDisposedException.ThrowIf(isDisposed, this); // Required to ensure the write is tracked and accounted for before disposal. // Can potentially be avoided if we have a need to do so in the future. @@ -675,8 +674,7 @@ namespace osu.Game.Database private Realm getRealmInstance() { - if (isDisposed) - throw new ObjectDisposedException(nameof(RealmAccess)); + ObjectDisposedException.ThrowIf(isDisposed, this); bool tookSemaphoreLock = false; @@ -1189,8 +1187,7 @@ namespace osu.Game.Database if (!ThreadSafety.IsUpdateThread) throw new InvalidOperationException(@$"{nameof(BlockAllOperations)} must be called from the update thread."); - if (isDisposed) - throw new ObjectDisposedException(nameof(RealmAccess)); + ObjectDisposedException.ThrowIf(isDisposed, this); SynchronizationContext? syncContext = null; From 9bac60a98fc098cb4c6b1f118e61c5255bd5b235 Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Tue, 5 Mar 2024 10:19:47 +0100 Subject: [PATCH 303/508] Use ArgumentNullException.ThrowIfNull in more places --- osu.Game/Rulesets/UI/DrawableRuleset.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs index 13e28279e6..bdc0ff85ba 100644 --- a/osu.Game/Rulesets/UI/DrawableRuleset.cs +++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs @@ -135,8 +135,7 @@ namespace osu.Game.Rulesets.UI protected DrawableRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods = null) : base(ruleset) { - if (beatmap == null) - throw new ArgumentNullException(nameof(beatmap), "Beatmap cannot be null."); + ArgumentNullException.ThrowIfNull(beatmap); if (!(beatmap is Beatmap tBeatmap)) throw new ArgumentException($"{GetType()} expected the beatmap to contain hitobjects of type {typeof(TObject)}.", nameof(beatmap)); From a89130348469e1b1ea8e025bb2c6cf4a85da51b3 Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Tue, 5 Mar 2024 10:20:30 +0100 Subject: [PATCH 304/508] Use ArgumentOutOfRangeException throw helper methods --- osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs | 6 +++--- osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs | 2 +- osu.Game/Beatmaps/Timing/TimeSignature.cs | 3 +-- osu.Game/Rulesets/Difficulty/Utils/ReverseQueue.cs | 3 +-- osu.Game/Rulesets/Objects/Types/PathType.cs | 3 +-- osu.Game/Screens/Ranking/Statistics/SimpleStatisticTable.cs | 3 +-- osu.Game/Utils/LimitedCapacityQueue.cs | 3 +-- osu.Game/Utils/StatelessRNG.cs | 2 +- 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs index 835c67ff19..9cc0a8c414 100644 --- a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs @@ -58,9 +58,9 @@ namespace osu.Game.Rulesets.Osu.Beatmaps private void applyStacking(Beatmap beatmap, int startIndex, int endIndex) { - if (startIndex > endIndex) throw new ArgumentOutOfRangeException(nameof(startIndex), $"{nameof(startIndex)} cannot be greater than {nameof(endIndex)}."); - if (startIndex < 0) throw new ArgumentOutOfRangeException(nameof(startIndex), $"{nameof(startIndex)} cannot be less than 0."); - if (endIndex < 0) throw new ArgumentOutOfRangeException(nameof(endIndex), $"{nameof(endIndex)} cannot be less than 0."); + ArgumentOutOfRangeException.ThrowIfGreaterThan(startIndex, endIndex); + ArgumentOutOfRangeException.ThrowIfNegative(startIndex); + ArgumentOutOfRangeException.ThrowIfNegative(endIndex); int extendedEndIndex = endIndex; diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 448cfaf84c..3ead61f64a 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -334,7 +334,7 @@ namespace osu.Game.Rulesets.Osu.Edit /// The from a selected to a target . private OsuDistanceSnapGrid createGrid(Func sourceSelector, int targetOffset = 1) { - if (targetOffset < 1) throw new ArgumentOutOfRangeException(nameof(targetOffset)); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(targetOffset); int sourceIndex = -1; diff --git a/osu.Game/Beatmaps/Timing/TimeSignature.cs b/osu.Game/Beatmaps/Timing/TimeSignature.cs index 7499a725dc..377a878631 100644 --- a/osu.Game/Beatmaps/Timing/TimeSignature.cs +++ b/osu.Game/Beatmaps/Timing/TimeSignature.cs @@ -23,8 +23,7 @@ namespace osu.Game.Beatmaps.Timing public TimeSignature(int numerator) { - if (numerator < 1) - throw new ArgumentOutOfRangeException(nameof(numerator), numerator, "The numerator of a time signature must be positive."); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(numerator); Numerator = numerator; } diff --git a/osu.Game/Rulesets/Difficulty/Utils/ReverseQueue.cs b/osu.Game/Rulesets/Difficulty/Utils/ReverseQueue.cs index 3dc2d133ba..17c3c51cfb 100644 --- a/osu.Game/Rulesets/Difficulty/Utils/ReverseQueue.cs +++ b/osu.Game/Rulesets/Difficulty/Utils/ReverseQueue.cs @@ -27,8 +27,7 @@ namespace osu.Game.Rulesets.Difficulty.Utils public ReverseQueue(int initialCapacity) { - if (initialCapacity <= 0) - throw new ArgumentOutOfRangeException(nameof(initialCapacity)); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(initialCapacity); items = new T[initialCapacity]; capacity = initialCapacity; diff --git a/osu.Game/Rulesets/Objects/Types/PathType.cs b/osu.Game/Rulesets/Objects/Types/PathType.cs index 23f1ccf0bc..6983484dce 100644 --- a/osu.Game/Rulesets/Objects/Types/PathType.cs +++ b/osu.Game/Rulesets/Objects/Types/PathType.cs @@ -40,8 +40,7 @@ namespace osu.Game.Rulesets.Objects.Types public static PathType BSpline(int degree) { - if (degree <= 0) - throw new ArgumentOutOfRangeException(nameof(degree), "The degree of a B-Spline path must be greater than zero."); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(degree); return new PathType { Type = SplineType.BSpline, Degree = degree }; } diff --git a/osu.Game/Screens/Ranking/Statistics/SimpleStatisticTable.cs b/osu.Game/Screens/Ranking/Statistics/SimpleStatisticTable.cs index ed31bc8643..4abf0007a7 100644 --- a/osu.Game/Screens/Ranking/Statistics/SimpleStatisticTable.cs +++ b/osu.Game/Screens/Ranking/Statistics/SimpleStatisticTable.cs @@ -33,8 +33,7 @@ namespace osu.Game.Screens.Ranking.Statistics /// The s to display in this row. public SimpleStatisticTable(int columnCount, [ItemNotNull] IEnumerable items) { - if (columnCount < 1) - throw new ArgumentOutOfRangeException(nameof(columnCount)); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(columnCount); this.columnCount = columnCount; this.items = items.ToArray(); diff --git a/osu.Game/Utils/LimitedCapacityQueue.cs b/osu.Game/Utils/LimitedCapacityQueue.cs index d36aa8af2c..b96148d4a0 100644 --- a/osu.Game/Utils/LimitedCapacityQueue.cs +++ b/osu.Game/Utils/LimitedCapacityQueue.cs @@ -35,8 +35,7 @@ namespace osu.Game.Utils /// The number of items the queue can hold. public LimitedCapacityQueue(int capacity) { - if (capacity < 0) - throw new ArgumentOutOfRangeException(nameof(capacity)); + ArgumentOutOfRangeException.ThrowIfNegative(capacity); this.capacity = capacity; array = new T[capacity]; diff --git a/osu.Game/Utils/StatelessRNG.cs b/osu.Game/Utils/StatelessRNG.cs index 3db632fc42..8833dcbbdb 100644 --- a/osu.Game/Utils/StatelessRNG.cs +++ b/osu.Game/Utils/StatelessRNG.cs @@ -58,7 +58,7 @@ namespace osu.Game.Utils /// public static int NextInt(int maxValue, int seed, int series = 0) { - if (maxValue <= 0) throw new ArgumentOutOfRangeException(nameof(maxValue)); + ArgumentOutOfRangeException.ThrowIfNegativeOrZero(maxValue); return (int)(NextULong(seed, series) % (ulong)maxValue); } From 5965db4fd7344822d116aa7bd23ad2fa2ebfa22e Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Tue, 5 Mar 2024 10:20:57 +0100 Subject: [PATCH 305/508] Use ArgumentException.ThrowIfNullOrEmpty throw helper --- osu.Game/IO/WrappedStorage.cs | 3 +-- osu.Game/Online/API/OAuth.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/IO/WrappedStorage.cs b/osu.Game/IO/WrappedStorage.cs index 95ff26db6a..5a8f4aef59 100644 --- a/osu.Game/IO/WrappedStorage.cs +++ b/osu.Game/IO/WrappedStorage.cs @@ -80,8 +80,7 @@ namespace osu.Game.IO public override Storage GetStorageForDirectory(string path) { - if (string.IsNullOrEmpty(path)) - throw new ArgumentException("Must be non-null and not empty string", nameof(path)); + ArgumentException.ThrowIfNullOrEmpty(path); if (!path.EndsWith(Path.DirectorySeparatorChar)) path += Path.DirectorySeparatorChar; diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index 4829310870..b06d9c6586 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -39,8 +39,8 @@ namespace osu.Game.Online.API internal void AuthenticateWithLogin(string username, string password) { - if (string.IsNullOrEmpty(username)) throw new ArgumentException("Missing username."); - if (string.IsNullOrEmpty(password)) throw new ArgumentException("Missing password."); + ArgumentException.ThrowIfNullOrEmpty(username); + ArgumentException.ThrowIfNullOrEmpty(password); var accessTokenRequest = new AccessTokenRequestPassword(username, password) { From 6fabbe26166df10907358d5c58dc26f8cf17dbbe Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Tue, 5 Mar 2024 10:27:12 +0100 Subject: [PATCH 306/508] Use new ToDictionary() overload without delegates --- osu.Game/Online/API/Requests/Responses/SoloScoreInfo.cs | 4 ++-- osu.Game/Scoring/Legacy/LegacyReplaySoloScoreInfo.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/SoloScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/SoloScoreInfo.cs index 6f321fd401..64caddb2fc 100644 --- a/osu.Game/Online/API/Requests/Responses/SoloScoreInfo.cs +++ b/osu.Game/Online/API/Requests/Responses/SoloScoreInfo.cs @@ -245,8 +245,8 @@ namespace osu.Game.Online.API.Requests.Responses RulesetID = score.RulesetID, Passed = score.Passed, Mods = score.APIMods, - Statistics = score.Statistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value), - MaximumStatistics = score.MaximumStatistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value), + Statistics = score.Statistics.Where(kvp => kvp.Value != 0).ToDictionary(), + MaximumStatistics = score.MaximumStatistics.Where(kvp => kvp.Value != 0).ToDictionary(), }; } } diff --git a/osu.Game/Scoring/Legacy/LegacyReplaySoloScoreInfo.cs b/osu.Game/Scoring/Legacy/LegacyReplaySoloScoreInfo.cs index 2c5b91f10f..afdcef1d21 100644 --- a/osu.Game/Scoring/Legacy/LegacyReplaySoloScoreInfo.cs +++ b/osu.Game/Scoring/Legacy/LegacyReplaySoloScoreInfo.cs @@ -42,8 +42,8 @@ namespace osu.Game.Scoring.Legacy { OnlineID = score.OnlineID, Mods = score.APIMods, - Statistics = score.Statistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value), - MaximumStatistics = score.MaximumStatistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value), + Statistics = score.Statistics.Where(kvp => kvp.Value != 0).ToDictionary(), + MaximumStatistics = score.MaximumStatistics.Where(kvp => kvp.Value != 0).ToDictionary(), ClientVersion = score.ClientVersion, }; } From d0f7ab3316584f92957cd738c57e6dfd85fb9fcc Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Tue, 5 Mar 2024 17:18:59 +0100 Subject: [PATCH 307/508] Revert some changes --- osu.Game/Online/API/OAuth.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index b06d9c6586..4829310870 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -39,8 +39,8 @@ namespace osu.Game.Online.API internal void AuthenticateWithLogin(string username, string password) { - ArgumentException.ThrowIfNullOrEmpty(username); - ArgumentException.ThrowIfNullOrEmpty(password); + if (string.IsNullOrEmpty(username)) throw new ArgumentException("Missing username."); + if (string.IsNullOrEmpty(password)) throw new ArgumentException("Missing password."); var accessTokenRequest = new AccessTokenRequestPassword(username, password) { From e6f1a722cbb54a905a20c91fe30a8be072ba357c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 5 Mar 2024 18:48:58 +0100 Subject: [PATCH 308/508] Remove unused field and commented-out code --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index 6f70a914f0..08d00f8ac2 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -33,7 +33,6 @@ namespace osu.Game.Screens.Play private double countdownStartTime; private Drawable content = null!; - private Drawable background = null!; private SpriteText countdown = null!; public DelayedResumeOverlay() @@ -53,9 +52,9 @@ namespace osu.Game.Screens.Play Masking = true, BorderColour = colours.Yellow, BorderThickness = 1, - Children = new[] + Children = new Drawable[] { - background = new Box + new Box { Size = new Vector2(250, 40), Colour = Color4.Black, @@ -75,29 +74,14 @@ namespace osu.Game.Screens.Play AutoSizeAxes = Axes.Both, Spacing = new Vector2(5), Colour = colours.Yellow, - Children = new Drawable[] + Child = countdown = new OsuSpriteText { - // new Box - // { - // Anchor = Anchor.Centre, - // Origin = Anchor.Centre, - // Size = new Vector2(40, 3) - // }, - countdown = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - UseFullGlyphHeight = false, - AlwaysPresent = true, - Font = OsuFont.Numeric.With(size: 20, fixedWidth: true) - }, - // new Box - // { - // Anchor = Anchor.Centre, - // Origin = Anchor.Centre, - // Size = new Vector2(40, 3) - // } - } + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + UseFullGlyphHeight = false, + AlwaysPresent = true, + Font = OsuFont.Numeric.With(size: 20, fixedWidth: true) + }, } } } From 57daaa7fed6b7c7021e0c85d83ff8e532f657c7c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2024 04:17:15 +0800 Subject: [PATCH 309/508] Add logging for `GameplayClockContainer` starting or stopping --- osu.Game/Screens/Play/GameplayClockContainer.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index c039d1e535..255877e0aa 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -122,8 +122,17 @@ namespace osu.Game.Screens.Play StopGameplayClock(); } - protected virtual void StartGameplayClock() => GameplayClock.Start(); - protected virtual void StopGameplayClock() => GameplayClock.Stop(); + protected virtual void StartGameplayClock() + { + Logger.Log($"{nameof(GameplayClockContainer)} started via call to {nameof(StartGameplayClock)}"); + GameplayClock.Start(); + } + + protected virtual void StopGameplayClock() + { + Logger.Log($"{nameof(GameplayClockContainer)} stopped via call to {nameof(StopGameplayClock)}"); + GameplayClock.Stop(); + } /// /// Resets this and the source to an initial state ready for gameplay. From 65ce4ca390925c43ebb8167c4aa19c15b8b46b01 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2024 04:17:51 +0800 Subject: [PATCH 310/508] Never set `waitingOnFrames` if a replay is not attached --- osu.Game/Rulesets/UI/FrameStabilityContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs index 884310e44c..b49924762e 100644 --- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs +++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs @@ -189,7 +189,7 @@ namespace osu.Game.Rulesets.UI double timeBehind = Math.Abs(proposedTime - referenceClock.CurrentTime); isCatchingUp.Value = timeBehind > 200; - waitingOnFrames.Value = state == PlaybackState.NotValid; + waitingOnFrames.Value = hasReplayAttached && state == PlaybackState.NotValid; manualClock.CurrentTime = proposedTime; manualClock.Rate = Math.Abs(referenceClock.Rate) * direction; From b53777c2a42bab857664cb5c2887e5cced0c0625 Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 5 Mar 2024 18:15:53 -0500 Subject: [PATCH 311/508] Refactor room secret handling to use JSON Also log room secrets for debugging purposes --- osu.Desktop/DiscordRichPresence.cs | 41 ++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 85b6129043..7315ee0c17 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -5,6 +5,7 @@ using System; using System.Text; using DiscordRPC; using DiscordRPC.Message; +using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -147,7 +148,13 @@ namespace osu.Desktop Size = room.Users.Count, }; - presence.Secrets.JoinSecret = $"{room.RoomID}:{room.Settings.Password}"; + RoomSecret roomSecret = new RoomSecret + { + RoomID = room.RoomID, + Password = room.Settings.Password, + }; + + presence.Secrets.JoinSecret = JsonConvert.SerializeObject(roomSecret); } else { @@ -182,9 +189,13 @@ namespace osu.Desktop private void onJoin(object sender, JoinMessage args) { game.Window?.Raise(); + Logger.Log($"Received room secret from Discord RPC Client: {args.Secret}", LoggingTarget.Network, LogLevel.Debug); if (!tryParseRoomSecret(args.Secret, out long roomId, out string? password)) + { Logger.Log("Could not parse room from Discord RPC Client", LoggingTarget.Network, LogLevel.Important); + return; + } var request = new GetRoomRequest(roomId); request.Success += room => Schedule(() => @@ -216,21 +227,26 @@ namespace osu.Desktop }); } - private static bool tryParseRoomSecret(ReadOnlySpan secret, out long roomId, out string? password) + private static bool tryParseRoomSecret(string secretJson, out long roomId, out string? password) { roomId = 0; password = null; - int roomSecretSplitIndex = secret.IndexOf(':'); + RoomSecret? roomSecret; - if (roomSecretSplitIndex == -1) + try + { + roomSecret = JsonConvert.DeserializeObject(secretJson); + } + catch + { return false; + } - if (!long.TryParse(secret[..roomSecretSplitIndex], out roomId)) - return false; + if (roomSecret == null) return false; - password = secret[(roomSecretSplitIndex + 1)..].ToString(); - if (password.Length == 0) password = null; + roomId = roomSecret.RoomID; + password = roomSecret.Password; return true; } @@ -254,5 +270,14 @@ namespace osu.Desktop client.Dispose(); base.Dispose(isDisposing); } + + private class RoomSecret + { + [JsonProperty(@"roomId", Required = Required.Always)] + public long RoomID { get; set; } + + [JsonProperty(@"password", Required = Required.AllowNull)] + public string? Password { get; set; } + } } } From 98713003176da6b09bafeea7392564959098956b Mon Sep 17 00:00:00 2001 From: Jayden Date: Tue, 5 Mar 2024 18:22:39 -0500 Subject: [PATCH 312/508] Improve language of user-facing errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartłomiej Dach --- osu.Desktop/DiscordRichPresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 7315ee0c17..8fecd015d4 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -193,7 +193,7 @@ namespace osu.Desktop if (!tryParseRoomSecret(args.Secret, out long roomId, out string? password)) { - Logger.Log("Could not parse room from Discord RPC Client", LoggingTarget.Network, LogLevel.Important); + Logger.Log("Could not join multiplayer room.", LoggingTarget.Network, LogLevel.Important); return; } From 6455c0583b5e607baeca7f584410bc63515aa619 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2024 10:19:40 +0800 Subject: [PATCH 313/508] Update usage of `CircularProgress.Current` --- .../Skinning/Argon/ArgonSpinnerProgressArc.cs | 6 +++--- .../Skinning/Argon/ArgonSpinnerRingArc.cs | 6 +++--- osu.Game/Beatmaps/Drawables/Cards/BeatmapCardThumbnail.cs | 8 ++++++-- osu.Game/Overlays/Volume/VolumeMeter.cs | 6 +++--- .../Edit/Compose/Components/CircularDistanceSnapGrid.cs | 2 +- osu.Game/Screens/Edit/Timing/TapButton.cs | 6 +++--- osu.Game/Screens/Play/HUD/HoldForMenuButton.cs | 7 ++++++- .../Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs | 6 +++--- .../Screens/Ranking/Expanded/Accuracy/GradedCircles.cs | 2 +- osu.Game/Skinning/LegacySongProgress.cs | 4 ++-- 10 files changed, 31 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinnerProgressArc.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinnerProgressArc.cs index 76afeeb2c4..1de5b1f309 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinnerProgressArc.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinnerProgressArc.cs @@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon Origin = Anchor.Centre, Colour = Color4.White.Opacity(0.25f), RelativeSizeAxes = Axes.Both, - Current = { Value = arc_fill }, + Progress = arc_fill, Rotation = 90 - arc_fill * 180, InnerRadius = arc_radius, RoundedCaps = true, @@ -71,9 +71,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon background.Alpha = spinner.Progress >= 1 ? 0 : 1; fill.Alpha = (float)Interpolation.DampContinuously(fill.Alpha, spinner.Progress > 0 && spinner.Progress < 1 ? 1 : 0, 40f, (float)Math.Abs(Time.Elapsed)); - fill.Current.Value = (float)Interpolation.DampContinuously(fill.Current.Value, spinner.Progress >= 1 ? 0 : arc_fill * spinner.Progress, 40f, (float)Math.Abs(Time.Elapsed)); + fill.Progress = (float)Interpolation.DampContinuously(fill.Progress, spinner.Progress >= 1 ? 0 : arc_fill * spinner.Progress, 40f, (float)Math.Abs(Time.Elapsed)); - fill.Rotation = (float)(90 - fill.Current.Value * 180); + fill.Rotation = (float)(90 - fill.Progress * 180); } private partial class ProgressFill : CircularProgress diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinnerRingArc.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinnerRingArc.cs index 702c5c2675..12cd0994b4 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinnerRingArc.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinnerRingArc.cs @@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, - Current = { Value = arc_fill }, + Progress = arc_fill, Rotation = -arc_fill * 180, InnerRadius = arc_radius, RoundedCaps = true, @@ -44,10 +44,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon { base.Update(); - fill.Current.Value = (float)Interpolation.DampContinuously(fill.Current.Value, spinner.Progress >= 1 ? arc_fill_complete : arc_fill, 40f, (float)Math.Abs(Time.Elapsed)); + fill.Progress = (float)Interpolation.DampContinuously(fill.Progress, spinner.Progress >= 1 ? arc_fill_complete : arc_fill, 40f, (float)Math.Abs(Time.Elapsed)); fill.InnerRadius = (float)Interpolation.DampContinuously(fill.InnerRadius, spinner.Progress >= 1 ? arc_radius * 2.2f : arc_radius, 40f, (float)Math.Abs(Time.Elapsed)); - fill.Rotation = (float)(-fill.Current.Value * 180); + fill.Rotation = (float)(-fill.Progress * 180); } } } diff --git a/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardThumbnail.cs b/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardThumbnail.cs index 5a26a988fb..cd498c474a 100644 --- a/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardThumbnail.cs +++ b/osu.Game/Beatmaps/Drawables/Cards/BeatmapCardThumbnail.cs @@ -86,11 +86,15 @@ namespace osu.Game.Beatmaps.Drawables.Cards Dimmed.BindValueChanged(_ => updateState()); playButton.Playing.BindValueChanged(_ => updateState(), true); - ((IBindable)progress.Current).BindTo(playButton.Progress); - FinishTransforms(true); } + protected override void Update() + { + base.Update(); + progress.Progress = playButton.Progress.Value; + } + private void updateState() { bool shouldDim = Dimmed.Value || playButton.Playing.Value; diff --git a/osu.Game/Overlays/Volume/VolumeMeter.cs b/osu.Game/Overlays/Volume/VolumeMeter.cs index 6ec4971f06..e96cd0fa46 100644 --- a/osu.Game/Overlays/Volume/VolumeMeter.cs +++ b/osu.Game/Overlays/Volume/VolumeMeter.cs @@ -235,7 +235,7 @@ namespace osu.Game.Overlays.Volume Bindable.BindValueChanged(volume => { this.TransformTo(nameof(DisplayVolume), volume.NewValue, 400, Easing.OutQuint); }, true); - bgProgress.Current.Value = 0.75f; + bgProgress.Progress = 0.75f; } private int? displayVolumeInt; @@ -265,8 +265,8 @@ namespace osu.Game.Overlays.Volume text.Text = intValue.ToString(CultureInfo.CurrentCulture); } - volumeCircle.Current.Value = displayVolume * 0.75f; - volumeCircleGlow.Current.Value = displayVolume * 0.75f; + volumeCircle.Progress = displayVolume * 0.75f; + volumeCircleGlow.Progress = displayVolume * 0.75f; if (intVolumeChanged && IsLoaded) Scheduler.AddOnce(playTickSound); diff --git a/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs index e33ef66007..92fe52148c 100644 --- a/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs +++ b/osu.Game/Screens/Edit/Compose/Components/CircularDistanceSnapGrid.cs @@ -140,7 +140,7 @@ namespace osu.Game.Screens.Edit.Compose.Components Colour = this.baseColour = baseColour; - Current.Value = 1; + Progress = 1; } protected override void Update() diff --git a/osu.Game/Screens/Edit/Timing/TapButton.cs b/osu.Game/Screens/Edit/Timing/TapButton.cs index fd60fb1b5b..d2ae0e76cf 100644 --- a/osu.Game/Screens/Edit/Timing/TapButton.cs +++ b/osu.Game/Screens/Edit/Timing/TapButton.cs @@ -366,7 +366,7 @@ namespace osu.Game.Screens.Edit.Timing new CircularProgress { RelativeSizeAxes = Axes.Both, - Current = { Value = 1f / light_count - angular_light_gap }, + Progress = 1f / light_count - angular_light_gap, Colour = colourProvider.Background2, }, fillContent = new Container @@ -379,7 +379,7 @@ namespace osu.Game.Screens.Edit.Timing new CircularProgress { RelativeSizeAxes = Axes.Both, - Current = { Value = 1f / light_count - angular_light_gap }, + Progress = 1f / light_count - angular_light_gap, Blending = BlendingParameters.Additive }, // Please do not try and make sense of this. @@ -388,7 +388,7 @@ namespace osu.Game.Screens.Edit.Timing Glow = new CircularProgress { RelativeSizeAxes = Axes.Both, - Current = { Value = 1f / light_count - 0.01f }, + Progress = 1f / light_count - 0.01f, Blending = BlendingParameters.Additive }.WithEffect(new GlowEffect { diff --git a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs index a260156595..6d045e5f01 100644 --- a/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs +++ b/osu.Game/Screens/Play/HUD/HoldForMenuButton.cs @@ -198,9 +198,14 @@ namespace osu.Game.Screens.Play.HUD bind(); } + protected override void Update() + { + base.Update(); + circularProgress.Progress = Progress.Value; + } + private void bind() { - ((IBindable)circularProgress.Current).BindTo(Progress); Progress.ValueChanged += progress => { icon.Scale = new Vector2(1 + (float)progress.NewValue * 0.2f); diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 83b02a0951..2231346404 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -147,7 +147,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy Colour = OsuColour.Gray(47), Alpha = 0.5f, InnerRadius = accuracy_circle_radius + 0.01f, // Extends a little bit into the circle - Current = { Value = 1 }, + Progress = 1, }, accuracyCircle = new CircularProgress { @@ -268,7 +268,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy if (targetAccuracy < 1 && targetAccuracy >= visual_alignment_offset) targetAccuracy -= visual_alignment_offset; - accuracyCircle.FillTo(targetAccuracy, ACCURACY_TRANSFORM_DURATION, ACCURACY_TRANSFORM_EASING); + accuracyCircle.ProgressTo(targetAccuracy, ACCURACY_TRANSFORM_DURATION, ACCURACY_TRANSFORM_EASING); if (withFlair) { @@ -359,7 +359,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy .FadeOut(800, Easing.Out); accuracyCircle - .FillTo(accuracyS - GRADE_SPACING_PERCENTAGE / 2 - visual_alignment_offset, 70, Easing.OutQuint); + .ProgressTo(accuracyS - GRADE_SPACING_PERCENTAGE / 2 - visual_alignment_offset, 70, Easing.OutQuint); badges.Single(b => b.Rank == getRank(ScoreRank.S)) .FadeOut(70, Easing.OutQuint); diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs index 33b71c53a7..633ed6d92e 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/GradedCircles.cs @@ -67,7 +67,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy { public double RevealProgress { - set => Current.Value = Math.Clamp(value, startProgress, endProgress) - startProgress; + set => Progress = Math.Clamp(value, startProgress, endProgress) - startProgress; } private readonly double startProgress; diff --git a/osu.Game/Skinning/LegacySongProgress.cs b/osu.Game/Skinning/LegacySongProgress.cs index 4295060a3a..9af82c4992 100644 --- a/osu.Game/Skinning/LegacySongProgress.cs +++ b/osu.Game/Skinning/LegacySongProgress.cs @@ -72,14 +72,14 @@ namespace osu.Game.Skinning circularProgress.Scale = new Vector2(-1, 1); circularProgress.Anchor = Anchor.TopRight; circularProgress.Colour = new Colour4(199, 255, 47, 153); - circularProgress.Current.Value = 1 - progress; + circularProgress.Progress = 1 - progress; } else { circularProgress.Scale = new Vector2(1); circularProgress.Anchor = Anchor.TopLeft; circularProgress.Colour = new Colour4(255, 255, 255, 153); - circularProgress.Current.Value = progress; + circularProgress.Progress = progress; } } } From b53b752e543d563b1059cc66d6dd8c6077bb6e01 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2024 10:42:20 +0800 Subject: [PATCH 314/508] Update usage of `MathUtils` --- osu.Game.Rulesets.Osu/Mods/OsuModSpunOut.cs | 2 +- .../Objects/Drawables/DrawableSliderRepeat.cs | 2 +- osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs | 2 +- .../Skinning/Default/SpinnerRotationTracker.cs | 2 +- osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs | 2 +- osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs | 3 +-- osu.Game/Graphics/Cursor/MenuCursorContainer.cs | 2 +- osu.Game/Graphics/UserInterface/OsuNumberBox.cs | 4 +--- osu.Game/IO/Archives/ZipArchiveReader.cs | 3 +-- .../Overlays/Settings/Sections/Input/TabletAreaSelection.cs | 3 +-- osu.Game/Overlays/Settings/SettingsNumberBox.cs | 2 +- osu.Game/Screens/Menu/LogoVisualisation.cs | 4 ++-- osu.Game/Utils/GeometryUtils.cs | 5 ++--- 13 files changed, 15 insertions(+), 21 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModSpunOut.cs b/osu.Game.Rulesets.Osu/Mods/OsuModSpunOut.cs index df9544b71e..992f4d5f03 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModSpunOut.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModSpunOut.cs @@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Osu.Mods // multiply the SPM by 1.01 to ensure that the spinner is completed. if the calculation is left exact, // some spinners may not complete due to very minor decimal loss during calculation float rotationSpeed = (float)(1.01 * spinner.HitObject.SpinsRequired / spinner.HitObject.Duration); - spinner.RotationTracker.AddRotation(MathUtils.RadiansToDegrees((float)rateIndependentElapsedTime * rotationSpeed * MathF.PI * 2.0f)); + spinner.RotationTracker.AddRotation(float.RadiansToDegrees((float)rateIndependentElapsedTime * rotationSpeed * MathF.PI * 2.0f)); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs index 3239565528..fcbd0edfe0 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs @@ -146,7 +146,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables break; } - float aimRotation = MathUtils.RadiansToDegrees(MathF.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X)); + float aimRotation = float.RadiansToDegrees(MathF.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X)); while (Math.Abs(aimRotation - Arrow.Rotation) > 180) aimRotation += aimRotation < Arrow.Rotation ? 360 : -360; diff --git a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs index 1cf6bc91f0..d43e6092c2 100644 --- a/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs +++ b/osu.Game.Rulesets.Osu/Replays/OsuAutoGenerator.cs @@ -342,7 +342,7 @@ namespace osu.Game.Rulesets.Osu.Replays // 0.05 rad/ms, or ~477 RPM, as per stable. // the redundant conversion from RPM to rad/ms is here for ease of testing custom SPM specs. const float spin_rpm = 0.05f / (2 * MathF.PI) * 60000; - float radsPerMillisecond = MathUtils.DegreesToRadians(spin_rpm * 360) / 60000; + float radsPerMillisecond = float.DegreesToRadians(spin_rpm * 360) / 60000; switch (h) { diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerRotationTracker.cs b/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerRotationTracker.cs index 1d75663fd9..7e97f826f9 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerRotationTracker.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/SpinnerRotationTracker.cs @@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default if (mousePosition is Vector2 pos) { - float thisAngle = -MathUtils.RadiansToDegrees(MathF.Atan2(pos.X - DrawSize.X / 2, pos.Y - DrawSize.Y / 2)); + float thisAngle = -float.RadiansToDegrees(MathF.Atan2(pos.X - DrawSize.X / 2, pos.Y - DrawSize.Y / 2)); float delta = lastAngle == null ? 0 : thisAngle - lastAngle.Value; // Normalise the delta to -180 .. 180 diff --git a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs index f9d4a3b325..4b3b543ea4 100644 --- a/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs +++ b/osu.Game.Rulesets.Osu/Statistics/AccuracyHeatmap.cs @@ -246,7 +246,7 @@ namespace osu.Game.Rulesets.Osu.Statistics // Likewise sin(pi/2)=1 and sin(3pi/2)=-1, whereas we actually want these values to appear on the bottom/top respectively, so the y-coordinate also needs to be inverted. // // We also need to apply the anti-clockwise rotation. - double rotatedAngle = finalAngle - MathUtils.DegreesToRadians(rotation); + double rotatedAngle = finalAngle - float.DegreesToRadians(rotation); var rotatedCoordinate = -1 * new Vector2((float)Math.Cos(rotatedAngle), (float)Math.Sin(rotatedAngle)); Vector2 localCentre = new Vector2(points_per_dimension - 1) / 2; diff --git a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs index cf4700bf85..6689f087cb 100644 --- a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using osu.Framework.Graphics; -using osu.Framework.Utils; using osu.Game.Beatmaps.Legacy; using osu.Game.IO; using osu.Game.Storyboards; @@ -230,7 +229,7 @@ namespace osu.Game.Beatmaps.Formats { float startValue = Parsing.ParseFloat(split[4]); float endValue = split.Length > 5 ? Parsing.ParseFloat(split[5]) : startValue; - timelineGroup?.Rotation.Add(easing, startTime, endTime, MathUtils.RadiansToDegrees(startValue), MathUtils.RadiansToDegrees(endValue)); + timelineGroup?.Rotation.Add(easing, startTime, endTime, float.RadiansToDegrees(startValue), float.RadiansToDegrees(endValue)); break; } diff --git a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs index 7e42d45191..696ea62b42 100644 --- a/osu.Game/Graphics/Cursor/MenuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/MenuCursorContainer.cs @@ -157,7 +157,7 @@ namespace osu.Game.Graphics.Cursor if (dragRotationState == DragRotationState.Rotating && distance > 0) { Vector2 offset = e.MousePosition - positionMouseDown; - float degrees = MathUtils.RadiansToDegrees(MathF.Atan2(-offset.X, offset.Y)) + 24.3f; + float degrees = float.RadiansToDegrees(MathF.Atan2(-offset.X, offset.Y)) + 24.3f; // Always rotate in the direction of least distance float diff = (degrees - activeCursor.Rotation) % 360; diff --git a/osu.Game/Graphics/UserInterface/OsuNumberBox.cs b/osu.Game/Graphics/UserInterface/OsuNumberBox.cs index df92863797..e9b28f4771 100644 --- a/osu.Game/Graphics/UserInterface/OsuNumberBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuNumberBox.cs @@ -1,14 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Extensions; - namespace osu.Game.Graphics.UserInterface { public partial class OsuNumberBox : OsuTextBox { protected override bool AllowIme => false; - protected override bool CanAddCharacter(char character) => character.IsAsciiDigit(); + protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character); } } diff --git a/osu.Game/IO/Archives/ZipArchiveReader.cs b/osu.Game/IO/Archives/ZipArchiveReader.cs index 5ef03b3641..7d7ce858dd 100644 --- a/osu.Game/IO/Archives/ZipArchiveReader.cs +++ b/osu.Game/IO/Archives/ZipArchiveReader.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.Toolkit.HighPerformance; -using osu.Framework.Extensions; using osu.Framework.IO.Stores; using SharpCompress.Archives.Zip; using SixLabors.ImageSharp.Memory; @@ -36,7 +35,7 @@ namespace osu.Game.IO.Archives var owner = MemoryAllocator.Default.Allocate((int)entry.Size); using (Stream s = entry.OpenEntryStream()) - s.ReadToFill(owner.Memory.Span); + s.ReadExactly(owner.Memory.Span); return new MemoryOwnerMemoryStream(owner); } diff --git a/osu.Game/Overlays/Settings/Sections/Input/TabletAreaSelection.cs b/osu.Game/Overlays/Settings/Sections/Input/TabletAreaSelection.cs index 686002fe71..33f4f49173 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/TabletAreaSelection.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/TabletAreaSelection.cs @@ -13,7 +13,6 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; using osu.Framework.Input.Handlers.Tablet; -using osu.Framework.Utils; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osuTK; @@ -196,7 +195,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input var matrix = Matrix3.Identity; MatrixExtensions.TranslateFromLeft(ref matrix, offset); - MatrixExtensions.RotateFromLeft(ref matrix, MathUtils.DegreesToRadians(rotation.Value)); + MatrixExtensions.RotateFromLeft(ref matrix, float.DegreesToRadians(rotation.Value)); usableAreaQuad *= matrix; diff --git a/osu.Game/Overlays/Settings/SettingsNumberBox.cs b/osu.Game/Overlays/Settings/SettingsNumberBox.cs index a0f85eda31..cdf648fc5f 100644 --- a/osu.Game/Overlays/Settings/SettingsNumberBox.cs +++ b/osu.Game/Overlays/Settings/SettingsNumberBox.cs @@ -69,7 +69,7 @@ namespace osu.Game.Overlays.Settings { protected override bool AllowIme => false; - protected override bool CanAddCharacter(char character) => character.IsAsciiDigit(); + protected override bool CanAddCharacter(char character) => char.IsAsciiDigit(character); public new void NotifyInputError() => base.NotifyInputError(); } diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index b722b83280..c47ce91711 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -209,13 +209,13 @@ namespace osu.Game.Screens.Menu if (audioData[i] < amplitude_dead_zone) continue; - float rotation = MathUtils.DegreesToRadians(i / (float)bars_per_visualiser * 360 + j * 360 / visualiser_rounds); + float rotation = float.DegreesToRadians(i / (float)bars_per_visualiser * 360 + j * 360 / visualiser_rounds); float rotationCos = MathF.Cos(rotation); float rotationSin = MathF.Sin(rotation); // taking the cos and sin to the 0..1 range var barPosition = new Vector2(rotationCos / 2 + 0.5f, rotationSin / 2 + 0.5f) * size; - var barSize = new Vector2(size * MathF.Sqrt(2 * (1 - MathF.Cos(MathUtils.DegreesToRadians(360f / bars_per_visualiser)))) / 2f, bar_length * audioData[i]); + var barSize = new Vector2(size * MathF.Sqrt(2 * (1 - MathF.Cos(float.DegreesToRadians(360f / bars_per_visualiser)))) / 2f, bar_length * audioData[i]); // The distance between the position and the sides of the bar. var bottomOffset = new Vector2(-rotationSin * barSize.X / 2, rotationCos * barSize.X / 2); // The distance between the bottom side of the bar and the top side. diff --git a/osu.Game/Utils/GeometryUtils.cs b/osu.Game/Utils/GeometryUtils.cs index 725e93d098..dbeba4dfc1 100644 --- a/osu.Game/Utils/GeometryUtils.cs +++ b/osu.Game/Utils/GeometryUtils.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; -using osu.Framework.Utils; using osu.Game.Rulesets.Objects.Types; using osuTK; @@ -28,8 +27,8 @@ namespace osu.Game.Utils point.Y -= origin.Y; Vector2 ret; - ret.X = point.X * MathF.Cos(MathUtils.DegreesToRadians(angle)) + point.Y * MathF.Sin(MathUtils.DegreesToRadians(angle)); - ret.Y = point.X * -MathF.Sin(MathUtils.DegreesToRadians(angle)) + point.Y * MathF.Cos(MathUtils.DegreesToRadians(angle)); + ret.X = point.X * MathF.Cos(float.DegreesToRadians(angle)) + point.Y * MathF.Sin(float.DegreesToRadians(angle)); + ret.Y = point.X * -MathF.Sin(float.DegreesToRadians(angle)) + point.Y * MathF.Cos(float.DegreesToRadians(angle)); ret.X += origin.X; ret.Y += origin.Y; From 0696e7de524123d1b332a166c4cd81f5d6c24c15 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2024 10:42:42 +0800 Subject: [PATCH 315/508] Update ImageSharp usages --- osu.Game.Tests/Visual/Gameplay/TestScenePlayerMaxDimensions.cs | 2 +- osu.Game/Beatmaps/BeatmapPanelBackgroundTextureLoaderStore.cs | 2 +- osu.Game/Skinning/LegacyTextureLoaderStore.cs | 2 +- osu.Game/Skinning/MaxDimensionLimitedTextureLoaderStore.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerMaxDimensions.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerMaxDimensions.cs index 53a4abdd07..3f78dedec5 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerMaxDimensions.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerMaxDimensions.cs @@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual.Gameplay private TextureUpload upscale(TextureUpload textureUpload) { - var image = Image.LoadPixelData(textureUpload.Data.ToArray(), textureUpload.Width, textureUpload.Height); + var image = Image.LoadPixelData(textureUpload.Data, textureUpload.Width, textureUpload.Height); // The original texture upload will no longer be returned or used. textureUpload.Dispose(); diff --git a/osu.Game/Beatmaps/BeatmapPanelBackgroundTextureLoaderStore.cs b/osu.Game/Beatmaps/BeatmapPanelBackgroundTextureLoaderStore.cs index 128e100e4b..cf58ae73fe 100644 --- a/osu.Game/Beatmaps/BeatmapPanelBackgroundTextureLoaderStore.cs +++ b/osu.Game/Beatmaps/BeatmapPanelBackgroundTextureLoaderStore.cs @@ -64,7 +64,7 @@ namespace osu.Game.Beatmaps // The original texture upload will no longer be returned or used. textureUpload.Dispose(); - Size size = image.Size(); + Size size = image.Size; // Assume that panel backgrounds are always displayed using `FillMode.Fill`. // Also assume that all backgrounds are wider than they are tall, so the diff --git a/osu.Game/Skinning/LegacyTextureLoaderStore.cs b/osu.Game/Skinning/LegacyTextureLoaderStore.cs index 29206bbb85..5045374c14 100644 --- a/osu.Game/Skinning/LegacyTextureLoaderStore.cs +++ b/osu.Game/Skinning/LegacyTextureLoaderStore.cs @@ -73,7 +73,7 @@ namespace osu.Game.Skinning private TextureUpload convertToGrayscale(TextureUpload textureUpload) { - var image = Image.LoadPixelData(textureUpload.Data.ToArray(), textureUpload.Width, textureUpload.Height); + var image = Image.LoadPixelData(textureUpload.Data, textureUpload.Width, textureUpload.Height); // stable uses `0.299 * r + 0.587 * g + 0.114 * b` // (https://github.com/peppy/osu-stable-reference/blob/013c3010a9d495e3471a9c59518de17006f9ad89/osu!/Graphics/Textures/pTexture.cs#L138-L153) diff --git a/osu.Game/Skinning/MaxDimensionLimitedTextureLoaderStore.cs b/osu.Game/Skinning/MaxDimensionLimitedTextureLoaderStore.cs index f15097a169..58dadbe753 100644 --- a/osu.Game/Skinning/MaxDimensionLimitedTextureLoaderStore.cs +++ b/osu.Game/Skinning/MaxDimensionLimitedTextureLoaderStore.cs @@ -61,7 +61,7 @@ namespace osu.Game.Skinning if (textureUpload.Height > max_supported_texture_size || textureUpload.Width > max_supported_texture_size) { - var image = Image.LoadPixelData(textureUpload.Data.ToArray(), textureUpload.Width, textureUpload.Height); + var image = Image.LoadPixelData(textureUpload.Data, textureUpload.Width, textureUpload.Height); // The original texture upload will no longer be returned or used. textureUpload.Dispose(); From 4c7678225ee018e24724024fe88580c024164b55 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2024 12:13:41 +0800 Subject: [PATCH 316/508] Update framework --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 1b395a7c83..4901f30d8a 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -10,7 +10,7 @@ true - + diff --git a/osu.iOS.props b/osu.iOS.props index 747d6059da..6b63bfa1e2 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -23,6 +23,6 @@ iossimulator-x64 - + From 3a224211aa322a0055342f10bd36e0af3c3b078c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2024 12:17:00 +0800 Subject: [PATCH 317/508] Update various packages which shouldn't cause issues --- osu.Game.Benchmarks/osu.Game.Benchmarks.csproj | 2 +- osu.Game/osu.Game.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj b/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj index 64da5412a8..af84ee47f1 100644 --- a/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj +++ b/osu.Game.Benchmarks/osu.Game.Benchmarks.csproj @@ -7,7 +7,7 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 942763e388..b143a3a6b1 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -20,8 +20,8 @@ - - + + @@ -35,14 +35,14 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + From 98ca021e6628d94df508709482f047a2cff7cdde Mon Sep 17 00:00:00 2001 From: jvyden Date: Wed, 6 Mar 2024 01:17:11 -0500 Subject: [PATCH 318/508] Catch and warn about osu!stable lobbies --- osu.Desktop/DiscordRichPresence.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 8fecd015d4..b4a7e80d48 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -191,6 +191,15 @@ namespace osu.Desktop game.Window?.Raise(); Logger.Log($"Received room secret from Discord RPC Client: {args.Secret}", LoggingTarget.Network, LogLevel.Debug); + // Stable and Lazer share the same Discord client ID, meaning they can accept join requests from each other. + // Since they aren't compatible in multi, see if stable's format is being used and log to avoid confusion. + // https://discord.com/channels/188630481301012481/188630652340404224/1214697229063946291 + if (args.Secret[0] != '{') + { + Logger.Log("osu!stable rooms are not compatible with lazer.", LoggingTarget.Network, LogLevel.Important); + return; + } + if (!tryParseRoomSecret(args.Secret, out long roomId, out string? password)) { Logger.Log("Could not join multiplayer room.", LoggingTarget.Network, LogLevel.Important); From 53fffc6a75df70e82be5c1e1a3d2fe633f86c834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 6 Mar 2024 07:57:59 +0100 Subject: [PATCH 319/508] Remove unused using directives --- osu.Game/Overlays/Settings/SettingsNumberBox.cs | 1 - osu.Game/Screens/Menu/LogoVisualisation.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsNumberBox.cs b/osu.Game/Overlays/Settings/SettingsNumberBox.cs index cdf648fc5f..fbcdb4a968 100644 --- a/osu.Game/Overlays/Settings/SettingsNumberBox.cs +++ b/osu.Game/Overlays/Settings/SettingsNumberBox.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; -using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; diff --git a/osu.Game/Screens/Menu/LogoVisualisation.cs b/osu.Game/Screens/Menu/LogoVisualisation.cs index c47ce91711..6d9d2f69b7 100644 --- a/osu.Game/Screens/Menu/LogoVisualisation.cs +++ b/osu.Game/Screens/Menu/LogoVisualisation.cs @@ -14,7 +14,6 @@ using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering.Vertices; using osu.Framework.Graphics.Shaders; using osu.Framework.Graphics.Textures; -using osu.Framework.Utils; using osu.Game.Beatmaps; using osuTK; using osuTK.Graphics; From 08609e19d6bb13669cb4f44e0ae6b80a7444c786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 6 Mar 2024 11:40:10 +0100 Subject: [PATCH 320/508] Fix osu! standardised score estimation algorithm violating basic invariants As it turns out, the "lower" and "upper" estimates of the combo portion of the score being converted were misnomers. In selected cases (scores with high accuracy but combo being lower than max by more than a few objects) the janky score-based math could overestimate the count of remaining objects in a map. For instance, in one case the numbers worked out something like this: - Accuracy: practically 100% - Max combo on beatmap: 571x - Max combo for score: 551x The score-based estimation attempts to extract a "remaining object count" from score, by doing something along of sqrt(571^2 - 551^2). That comes out to _almost 150_. Which leads to the estimation overshooting the total max combo count on the beatmap by some hundred objects. To curtail this nonsense, enforce some basic invariants: - Neither estimate is allowed to exceed maximum achievable - Ensure that lower estimate is really lower and upper is really upper by just looking at the values and making sure that is so rather than just saying that it is. --- .../Database/StandardisedScoreMigrationTools.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/osu.Game/Database/StandardisedScoreMigrationTools.cs b/osu.Game/Database/StandardisedScoreMigrationTools.cs index 0594c80390..53ff1a25ca 100644 --- a/osu.Game/Database/StandardisedScoreMigrationTools.cs +++ b/osu.Game/Database/StandardisedScoreMigrationTools.cs @@ -415,7 +415,7 @@ namespace osu.Game.Database // Calculate how many times the longest combo the user has achieved in the play can repeat // without exceeding the combo portion in score V1 as achieved by the player. - // This is a pessimistic estimate; it intentionally does not operate on object count and uses only score instead. + // This it intentionally does not operate on object count and uses only score instead. double maximumOccurrencesOfLongestCombo = Math.Floor(comboPortionInScoreV1 / comboPortionFromLongestComboInScoreV1); double comboPortionFromRepeatedLongestCombosInScoreV1 = maximumOccurrencesOfLongestCombo * comboPortionFromLongestComboInScoreV1; @@ -426,13 +426,12 @@ namespace osu.Game.Database // ...and then based on that raw combo length, we calculate how much this last combo is worth in standardised score. double remainingComboPortionInStandardisedScore = Math.Pow(remainingCombo, 1 + ScoreProcessor.COMBO_EXPONENT); - double lowerEstimateOfComboPortionInStandardisedScore + double scoreBasedEstimateOfComboPortionInStandardisedScore = maximumOccurrencesOfLongestCombo * comboPortionFromLongestComboInStandardisedScore + remainingComboPortionInStandardisedScore; // Compute approximate upper estimate new score for that play. // This time, divide the remaining combo among remaining objects equally to achieve longest possible combo lengths. - // There is no rigorous proof that doing this will yield a correct upper bound, but it seems to work out in practice. remainingComboPortionInScoreV1 = comboPortionInScoreV1 - comboPortionFromLongestComboInScoreV1; double remainingCountOfObjectsGivingCombo = maximumLegacyCombo - score.MaxCombo - score.Statistics.GetValueOrDefault(HitResult.Miss); // Because we assumed all combos were equal, `remainingComboPortionInScoreV1` @@ -449,7 +448,17 @@ namespace osu.Game.Database // we can skip adding the 1 and just multiply by x ^ 0.5. remainingComboPortionInStandardisedScore = remainingCountOfObjectsGivingCombo * Math.Pow(lengthOfRemainingCombos, ScoreProcessor.COMBO_EXPONENT); - double upperEstimateOfComboPortionInStandardisedScore = comboPortionFromLongestComboInStandardisedScore + remainingComboPortionInStandardisedScore; + double objectCountBasedEstimateOfComboPortionInStandardisedScore = comboPortionFromLongestComboInStandardisedScore + remainingComboPortionInStandardisedScore; + + // Enforce some invariants on both of the estimates. + // In rare cases they can produce invalid results. + scoreBasedEstimateOfComboPortionInStandardisedScore = + Math.Clamp(scoreBasedEstimateOfComboPortionInStandardisedScore, 0, maximumAchievableComboPortionInStandardisedScore); + objectCountBasedEstimateOfComboPortionInStandardisedScore = + Math.Clamp(objectCountBasedEstimateOfComboPortionInStandardisedScore, 0, maximumAchievableComboPortionInStandardisedScore); + + double lowerEstimateOfComboPortionInStandardisedScore = Math.Min(scoreBasedEstimateOfComboPortionInStandardisedScore, objectCountBasedEstimateOfComboPortionInStandardisedScore); + double upperEstimateOfComboPortionInStandardisedScore = Math.Max(scoreBasedEstimateOfComboPortionInStandardisedScore, objectCountBasedEstimateOfComboPortionInStandardisedScore); // Approximate by combining lower and upper estimates. // As the lower-estimate is very pessimistic, we use a 30/70 ratio From 5b6703ec0da46259daddd777ee88be5317aba2d5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2024 19:23:29 +0800 Subject: [PATCH 321/508] Move optimisation to isolated method --- osu.Game/Storyboards/StoryboardSprite.cs | 76 +++++++++++++----------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/osu.Game/Storyboards/StoryboardSprite.cs b/osu.Game/Storyboards/StoryboardSprite.cs index 350438942e..4992ae128d 100644 --- a/osu.Game/Storyboards/StoryboardSprite.cs +++ b/osu.Game/Storyboards/StoryboardSprite.cs @@ -90,41 +90,8 @@ namespace osu.Game.Storyboards // Ignore the whole setup if there are loops. In theory they can be handled here too, however the logic will be overly complex. if (loops.Count == 0) { - // Here we are starting from maximum value and trying to minimise the end time on each step. - // There are few solid guesses we can make using which sprite's end time can be minimised: alpha = 0, scale = 0, colour.a = 0. - double[] deathTimes = - { - double.MaxValue, // alpha - double.MaxValue, // colour alpha - double.MaxValue, // scale - double.MaxValue, // scale x - double.MaxValue, // scale y - }; - - // The loops below are following the same pattern. - // We could be using TimelineGroup.EndValue here, however it's possible to have multiple commands with 0 value in a row - // so we are saving the earliest of them. - foreach (var alphaCommand in TimelineGroup.Alpha.Commands) - { - deathTimes[0] = alphaCommand.EndValue == 0 - ? Math.Min(alphaCommand.EndTime, deathTimes[0]) // commands are ordered by the start time, however end time may vary. Save the earliest. - : double.MaxValue; // If value isn't 0 (sprite becomes visible again), revert the saved state. - } - - foreach (var colourCommand in TimelineGroup.Colour.Commands) - deathTimes[1] = colourCommand.EndValue.A == 0 ? Math.Min(colourCommand.EndTime, deathTimes[1]) : double.MaxValue; - - foreach (var scaleCommand in TimelineGroup.Scale.Commands) - deathTimes[2] = scaleCommand.EndValue == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[2]) : double.MaxValue; - - foreach (var scaleCommand in TimelineGroup.VectorScale.Commands) - { - deathTimes[3] = scaleCommand.EndValue.X == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[3]) : double.MaxValue; - deathTimes[4] = scaleCommand.EndValue.Y == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[4]) : double.MaxValue; - } - // Take the minimum time of all the potential "death" reasons. - latestEndTime = deathTimes.Min(); + latestEndTime = calculateOptimisedEndTime(TimelineGroup); } // If the logic above fails to find anything or discarded by the fact that there are loops present, latestEndTime will be double.MaxValue @@ -238,6 +205,47 @@ namespace osu.Game.Storyboards return commands; } + private static double calculateOptimisedEndTime(CommandTimelineGroup timelineGroup) + { + // Here we are starting from maximum value and trying to minimise the end time on each step. + // There are few solid guesses we can make using which sprite's end time can be minimised: alpha = 0, scale = 0, colour.a = 0. + double[] deathTimes = + { + double.MaxValue, // alpha + double.MaxValue, // colour alpha + double.MaxValue, // scale + double.MaxValue, // scale x + double.MaxValue, // scale y + }; + + // The loops below are following the same pattern. + // We could be using TimelineGroup.EndValue here, however it's possible to have multiple commands with 0 value in a row + // so we are saving the earliest of them. + foreach (var alphaCommand in timelineGroup.Alpha.Commands) + { + if (alphaCommand.EndValue == 0) + // commands are ordered by the start time, however end time may vary. Save the earliest. + deathTimes[0] = Math.Min(alphaCommand.EndTime, deathTimes[0]); + else + // If value isn't 0 (sprite becomes visible again), revert the saved state. + deathTimes[0] = double.MaxValue; + } + + foreach (var colourCommand in timelineGroup.Colour.Commands) + deathTimes[1] = colourCommand.EndValue.A == 0 ? Math.Min(colourCommand.EndTime, deathTimes[1]) : double.MaxValue; + + foreach (var scaleCommand in timelineGroup.Scale.Commands) + deathTimes[2] = scaleCommand.EndValue == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[2]) : double.MaxValue; + + foreach (var scaleCommand in timelineGroup.VectorScale.Commands) + { + deathTimes[3] = scaleCommand.EndValue.X == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[3]) : double.MaxValue; + deathTimes[4] = scaleCommand.EndValue.Y == 0 ? Math.Min(scaleCommand.EndTime, deathTimes[4]) : double.MaxValue; + } + + return deathTimes.Min(); + } + public override string ToString() => $"{Path}, {Origin}, {InitialPosition}"; From 672f645cbab747d02cbb61d31283f604a3244ed8 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 6 Mar 2024 18:39:18 +0300 Subject: [PATCH 322/508] Clamp only on horizontal sides --- osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs index 6ba91fbbd5..8f9a2d7e74 100644 --- a/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs +++ b/osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs @@ -47,19 +47,18 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy AutoSizeAxes = Axes.Y, Children = new Drawable[] { + // Key images are placed side-to-side on the playfield, therefore ClampToEdge must be used to prevent any gaps between each key. upSprite = new Sprite { Origin = Anchor.BottomCentre, - // ClampToEdge is used to avoid gaps between keys, see: https://github.com/ppy/osu/issues/27431 - Texture = skin.GetTexture(upImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge), + Texture = skin.GetTexture(upImage, WrapMode.ClampToEdge, default), RelativeSizeAxes = Axes.X, Width = 1 }, downSprite = new Sprite { Origin = Anchor.BottomCentre, - // ClampToEdge is used to avoid gaps between keys, see: https://github.com/ppy/osu/issues/27431 - Texture = skin.GetTexture(downImage, WrapMode.ClampToEdge, WrapMode.ClampToEdge), + Texture = skin.GetTexture(downImage, WrapMode.ClampToEdge, default), RelativeSizeAxes = Axes.X, Width = 1, Alpha = 0 From 3121cf81e6f8ad0dd8ecb80b5dfc2cff4f55c306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 6 Mar 2024 21:30:09 +0100 Subject: [PATCH 323/508] Bump score version --- osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs index 775d87f3f2..4ee4231925 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs @@ -45,9 +45,10 @@ namespace osu.Game.Scoring.Legacy /// /// 30000013: All local scores will use lazer definitions of ranks for consistency. Recalculates the rank of all scores. /// 30000014: Fix edge cases in conversion for osu! scores on selected beatmaps. Reconvert all scores. + /// 30000015: Fix osu! standardised score estimation algorithm violating basic invariants. Reconvert all scores. /// /// - public const int LATEST_VERSION = 30000014; + public const int LATEST_VERSION = 30000015; /// /// The first stable-compatible YYYYMMDD format version given to lazer usage of replays. From aa3cd402ca9ed3d666aac0e9934f9290af01b828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 6 Mar 2024 21:30:31 +0100 Subject: [PATCH 324/508] Fix broken english --- osu.Game/Database/StandardisedScoreMigrationTools.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Database/StandardisedScoreMigrationTools.cs b/osu.Game/Database/StandardisedScoreMigrationTools.cs index 53ff1a25ca..6f2f8d64fa 100644 --- a/osu.Game/Database/StandardisedScoreMigrationTools.cs +++ b/osu.Game/Database/StandardisedScoreMigrationTools.cs @@ -415,7 +415,7 @@ namespace osu.Game.Database // Calculate how many times the longest combo the user has achieved in the play can repeat // without exceeding the combo portion in score V1 as achieved by the player. - // This it intentionally does not operate on object count and uses only score instead. + // This intentionally does not operate on object count and uses only score instead. double maximumOccurrencesOfLongestCombo = Math.Floor(comboPortionInScoreV1 / comboPortionFromLongestComboInScoreV1); double comboPortionFromRepeatedLongestCombosInScoreV1 = maximumOccurrencesOfLongestCombo * comboPortionFromLongestComboInScoreV1; From 336a6180e537ba1c205c488cead7c5494446b705 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 7 Mar 2024 08:20:20 +0300 Subject: [PATCH 325/508] Expose `TRANSITION_LENGTH` from tab control --- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index c260c92b43..f24977927f 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -116,18 +116,18 @@ namespace osu.Game.Graphics.UserInterface } } - private const float transition_length = 500; + protected const float TRANSITION_LENGTH = 500; - protected void FadeHovered() + protected virtual void FadeHovered() { - Bar.FadeIn(transition_length, Easing.OutQuint); - Text.FadeColour(Color4.White, transition_length, Easing.OutQuint); + Bar.FadeIn(TRANSITION_LENGTH, Easing.OutQuint); + Text.FadeColour(Color4.White, TRANSITION_LENGTH, Easing.OutQuint); } - protected void FadeUnhovered() + protected virtual void FadeUnhovered() { - Bar.FadeTo(IsHovered ? 1 : 0, transition_length, Easing.OutQuint); - Text.FadeColour(IsHovered ? Color4.White : AccentColour, transition_length, Easing.OutQuint); + Bar.FadeTo(IsHovered ? 1 : 0, TRANSITION_LENGTH, Easing.OutQuint); + Text.FadeColour(IsHovered ? Color4.White : AccentColour, TRANSITION_LENGTH, Easing.OutQuint); } protected override bool OnHover(HoverEvent e) From 0fe139a1892423030b1de36df957bff095fc6587 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 7 Mar 2024 08:20:46 +0300 Subject: [PATCH 326/508] Adjust editor screen switcher control design and behaviour --- .../Menus/EditorScreenSwitcherControl.cs | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Edit/Components/Menus/EditorScreenSwitcherControl.cs b/osu.Game/Screens/Edit/Components/Menus/EditorScreenSwitcherControl.cs index 1f6d61d0ad..2b0b1ea219 100644 --- a/osu.Game/Screens/Edit/Components/Menus/EditorScreenSwitcherControl.cs +++ b/osu.Game/Screens/Edit/Components/Menus/EditorScreenSwitcherControl.cs @@ -9,6 +9,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; using osuTK; +using osuTK.Graphics; namespace osu.Game.Screens.Edit.Components.Menus { @@ -21,7 +22,7 @@ namespace osu.Game.Screens.Edit.Components.Menus TabContainer.RelativeSizeAxes &= ~Axes.X; TabContainer.AutoSizeAxes = Axes.X; - TabContainer.Padding = new MarginPadding(10); + TabContainer.Spacing = Vector2.Zero; } [BackgroundDependencyLoader] @@ -42,30 +43,51 @@ namespace osu.Game.Screens.Edit.Components.Menus private partial class TabItem : OsuTabItem { - private const float transition_length = 250; + private readonly Box background; + private Color4 backgroundIdleColour; + private Color4 backgroundHoverColour; public TabItem(EditorScreenMode value) : base(value) { - Text.Margin = new MarginPadding(); + Text.Margin = new MarginPadding(10); Text.Anchor = Anchor.CentreLeft; Text.Origin = Anchor.CentreLeft; Text.Font = OsuFont.TorusAlternate; + Add(background = new Box + { + RelativeSizeAxes = Axes.Both, + Depth = float.MaxValue, + }); + Bar.Expire(); } - protected override void OnActivated() + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) { - base.OnActivated(); - Bar.ScaleTo(new Vector2(1, 5), transition_length, Easing.OutQuint); + backgroundIdleColour = colourProvider.Background2; + backgroundHoverColour = colourProvider.Background1; } - protected override void OnDeactivated() + protected override void LoadComplete() { - base.OnDeactivated(); - Bar.ScaleTo(Vector2.One, transition_length, Easing.OutQuint); + base.LoadComplete(); + background.Colour = backgroundIdleColour; + } + + protected override void FadeHovered() + { + base.FadeHovered(); + background.FadeColour(backgroundHoverColour, TRANSITION_LENGTH, Easing.OutQuint); + } + + protected override void FadeUnhovered() + { + base.FadeUnhovered(); + background.FadeColour(backgroundIdleColour, TRANSITION_LENGTH, Easing.OutQuint); } } } From 56caf1935043112ec13c5d0b1d43e9d23b8d1f7e Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 6 Mar 2024 22:48:54 -0800 Subject: [PATCH 327/508] Add visual test for failed S display --- .../TestSceneExpandedPanelMiddleContent.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs index d71c72f4ec..ceb2d4927c 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs @@ -88,8 +88,21 @@ namespace osu.Game.Tests.Visual.Ranking AddAssert("play time not displayed", () => !this.ChildrenOfType().Any()); } - private void showPanel(ScoreInfo score) => - Child = new ExpandedPanelMiddleContentContainer(score); + [TestCase(false)] + [TestCase(true)] + public void TestFailedSDisplay(bool withFlair) + { + AddStep("show failed S score", () => + { + var score = TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser())); + score.Rank = ScoreRank.A; + score.Accuracy = 0.975; + showPanel(score, withFlair); + }); + } + + private void showPanel(ScoreInfo score, bool withFlair = false) => + Child = new ExpandedPanelMiddleContentContainer(score, withFlair); private BeatmapInfo createTestBeatmap([NotNull] RealmUser author) { @@ -107,7 +120,7 @@ namespace osu.Game.Tests.Visual.Ranking private partial class ExpandedPanelMiddleContentContainer : Container { - public ExpandedPanelMiddleContentContainer(ScoreInfo score) + public ExpandedPanelMiddleContentContainer(ScoreInfo score, bool withFlair) { Anchor = Anchor.Centre; Origin = Anchor.Centre; @@ -119,7 +132,7 @@ namespace osu.Game.Tests.Visual.Ranking RelativeSizeAxes = Axes.Both, Colour = Color4Extensions.FromHex("#444"), }, - new ExpandedPanelMiddleContent(score) + new ExpandedPanelMiddleContent(score, withFlair) }; } } From c36232bc02ff9289b0ecc16a6235049f3ddaa63a Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 6 Mar 2024 20:08:46 -0800 Subject: [PATCH 328/508] Fix results screen accuracy circle not showing correctly for failed S with no flair --- .../Expanded/Accuracy/AccuracyCircle.cs | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 54829a6274..f04e4a6444 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -194,11 +194,11 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy rankText = new RankText(score.Rank) }; + if (isFailedSDueToMisses) + AddInternal(failedSRankText = new RankText(ScoreRank.S)); + if (withFlair) { - if (isFailedSDueToMisses) - AddInternal(failedSRankText = new RankText(ScoreRank.S)); - var applauseSamples = new List { applauseSampleName }; if (score.Rank >= ScoreRank.B) // when rank is B or higher, play legacy applause sample on legacy skins. @@ -326,24 +326,25 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy { rankText.Appear(); - if (!withFlair) return; - - Schedule(() => - { - isTicking = false; - rankImpactSound.Play(); - }); - - const double applause_pre_delay = 545f; - const double applause_volume = 0.8f; - - using (BeginDelayedSequence(applause_pre_delay)) + if (withFlair) { Schedule(() => { - rankApplauseSound.VolumeTo(applause_volume); - rankApplauseSound.Play(); + isTicking = false; + rankImpactSound.Play(); }); + + const double applause_pre_delay = 545f; + const double applause_volume = 0.8f; + + using (BeginDelayedSequence(applause_pre_delay)) + { + Schedule(() => + { + rankApplauseSound.VolumeTo(applause_volume); + rankApplauseSound.Play(); + }); + } } } From 1cafb0997713ee387f8994e972d64ad908aa4181 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 7 Mar 2024 17:22:38 +0900 Subject: [PATCH 329/508] Increase border thickness --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index 08d00f8ac2..ba49810b2b 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play AutoSizeAxes = Axes.Both, Masking = true, BorderColour = colours.Yellow, - BorderThickness = 1, + BorderThickness = 2, Children = new Drawable[] { new Box From 039520d55dc9b9cc55e143a6da8bb87f684ef882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 7 Mar 2024 09:49:20 +0100 Subject: [PATCH 330/508] Use slightly nicer parameterisation in test --- .../Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs index ceb2d4927c..d97946a1d5 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs @@ -88,9 +88,8 @@ namespace osu.Game.Tests.Visual.Ranking AddAssert("play time not displayed", () => !this.ChildrenOfType().Any()); } - [TestCase(false)] - [TestCase(true)] - public void TestFailedSDisplay(bool withFlair) + [Test] + public void TestFailedSDisplay([Values] bool withFlair) { AddStep("show failed S score", () => { From ca92a31cf97bcb28fd8d9e67fe0ac83b1085ac80 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 7 Mar 2024 21:10:11 +0900 Subject: [PATCH 331/508] Fix missing event unbinds --- osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs | 9 +++++++++ .../Components/Timeline/TimelineHitObjectBlueprint.cs | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs index 5ddc627642..3365b206cf 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs @@ -7,6 +7,7 @@ using osu.Framework.Allocation; using osu.Framework.Localisation; using osu.Game.Rulesets.Mania.UI; using osu.Framework.Bindables; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Game.Rulesets.Mania.Skinning; using osu.Game.Rulesets.Mods; @@ -101,6 +102,14 @@ namespace osu.Game.Rulesets.Mania.Mods return base.GetHeight(coverage) * reference_playfield_height / availablePlayfieldHeight; } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (skin.IsNotNull()) + skin.SourceChanged -= onSkinChanged; + } } } } diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs index 47dc3fb82e..d4afcc0151 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs @@ -6,6 +6,7 @@ using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; @@ -265,6 +266,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline return !Precision.AlmostIntersects(maskingBounds, rect); } + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (skin.IsNotNull()) + skin.SourceChanged -= updateColour; + } + private partial class Tick : Circle { public Tick() From 87b4406bdc01d5ff5a9dd0cbff59fdf4f25f5829 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Mar 2024 09:41:28 +0800 Subject: [PATCH 332/508] Pad at minimum three digits for argon pp display --- osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs index 022c1fab9e..c57e7bc7ea 100644 --- a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Bindables; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; @@ -55,7 +56,7 @@ namespace osu.Game.Screens.Play.HUD private void updateWireframe() { - int digitsRequiredForDisplayCount = getDigitsRequiredForDisplayCount(); + int digitsRequiredForDisplayCount = Math.Max(3, getDigitsRequiredForDisplayCount()); if (digitsRequiredForDisplayCount != text.WireframeTemplate.Length) text.WireframeTemplate = new string('#', digitsRequiredForDisplayCount); From f2753ef7a225316ec96ecb1ca8e1be261d2ca570 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Mar 2024 09:41:38 +0800 Subject: [PATCH 333/508] Decrease size of pp display relative to accuracy --- osu.Game/Skinning/ArgonSkin.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Skinning/ArgonSkin.cs b/osu.Game/Skinning/ArgonSkin.cs index 24e17d21f4..953badaf65 100644 --- a/osu.Game/Skinning/ArgonSkin.cs +++ b/osu.Game/Skinning/ArgonSkin.cs @@ -232,7 +232,10 @@ namespace osu.Game.Skinning CornerRadius = { Value = 0.5f } }, new ArgonAccuracyCounter(), - new ArgonPerformancePointsCounter(), + new ArgonPerformancePointsCounter + { + Scale = new Vector2(0.8f), + }, new ArgonComboCounter { Scale = new Vector2(1.3f) From ae2ef8ee1ece9083ca41118dc59846047d021022 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Mar 2024 10:19:00 +0800 Subject: [PATCH 334/508] Fix typo in wireframe description --- osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs | 2 +- osu.Game/Screens/Play/HUD/ArgonComboCounter.cs | 2 +- osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs | 2 +- osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs b/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs index 4cc04e1485..d7fe1f52ff 100644 --- a/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonAccuracyCounter.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Play.HUD { protected override double RollingDuration => 250; - [SettingSource("Wireframe opacity", "Controls the opacity of the wire frames behind the digits.")] + [SettingSource("Wireframe opacity", "Controls the opacity of the wireframes behind the digits.")] public BindableFloat WireframeOpacity { get; } = new BindableFloat(0.25f) { Precision = 0.01f, diff --git a/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs b/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs index 3f187650b2..db0480c566 100644 --- a/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonComboCounter.cs @@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play.HUD protected override double RollingDuration => 250; - [SettingSource("Wireframe opacity", "Controls the opacity of the wire frames behind the digits.")] + [SettingSource("Wireframe opacity", "Controls the opacity of the wireframes behind the digits.")] public BindableFloat WireframeOpacity { get; } = new BindableFloat(0.25f) { Precision = 0.01f, diff --git a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs index c57e7bc7ea..d4d842bd9a 100644 --- a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Play.HUD private const float alpha_when_invalid = 0.3f; - [SettingSource("Wireframe opacity", "Controls the opacity of the wire frames behind the digits.")] + [SettingSource("Wireframe opacity", "Controls the opacity of the wireframes behind the digits.")] public BindableFloat WireframeOpacity { get; } = new BindableFloat(0.25f) { Precision = 0.01f, diff --git a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs index a14ab3cbcd..8658651407 100644 --- a/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonScoreCounter.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Play.HUD protected override double RollingDuration => 250; - [SettingSource("Wireframe opacity", "Controls the opacity of the wire frames behind the digits.")] + [SettingSource("Wireframe opacity", "Controls the opacity of the wireframes behind the digits.")] public BindableFloat WireframeOpacity { get; } = new BindableFloat(0.25f) { Precision = 0.01f, From 0ebb12f67f97d82ef8931df095445c1c6542ba08 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Mar 2024 10:23:43 +0800 Subject: [PATCH 335/508] Move skinnable interface specification to non-`abstract` classes --- osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs | 3 ++- osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs | 2 +- .../Skinning/Triangles/TrianglesPerformancePointsCounter.cs | 4 +--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs index d4d842bd9a..1620da2f2e 100644 --- a/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/ArgonPerformancePointsCounter.cs @@ -9,10 +9,11 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Configuration; using osu.Game.Localisation.SkinComponents; using osu.Game.Resources.Localisation.Web; +using osu.Game.Skinning; namespace osu.Game.Screens.Play.HUD { - public partial class ArgonPerformancePointsCounter : PerformancePointsCounter + public partial class ArgonPerformancePointsCounter : PerformancePointsCounter, ISerialisableDrawable { private ArgonCounterTextComponent text = null!; diff --git a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs index c5ad106bcc..25c1387220 100644 --- a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs @@ -27,7 +27,7 @@ using osu.Game.Skinning; namespace osu.Game.Screens.Play.HUD { - public abstract partial class PerformancePointsCounter : RollingCounter, ISerialisableDrawable + public abstract partial class PerformancePointsCounter : RollingCounter { public bool UsesFixedAnchor { get; set; } diff --git a/osu.Game/Skinning/Triangles/TrianglesPerformancePointsCounter.cs b/osu.Game/Skinning/Triangles/TrianglesPerformancePointsCounter.cs index 99da2c0942..d6753a81ba 100644 --- a/osu.Game/Skinning/Triangles/TrianglesPerformancePointsCounter.cs +++ b/osu.Game/Skinning/Triangles/TrianglesPerformancePointsCounter.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -16,7 +14,7 @@ using osuTK; namespace osu.Game.Skinning.Triangles { - public partial class TrianglesPerformancePointsCounter : PerformancePointsCounter + public partial class TrianglesPerformancePointsCounter : PerformancePointsCounter, ISerialisableDrawable { protected override bool IsRollingProportional => true; From 928639863325278dd66fe428bdd10870b9ca0e64 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Mar 2024 10:26:08 +0800 Subject: [PATCH 336/508] Move naming migrations to more correct place --- osu.Game/Skinning/Skin.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 91b21f0308..e4ca908d90 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -133,6 +133,11 @@ namespace osu.Game.Skinning SkinLayoutInfo? layoutInfo = null; + // handle namespace changes... + jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.SongProgress", @"osu.Game.Screens.Play.HUD.DefaultSongProgress"); + jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.HUD.LegacyComboCounter", @"osu.Game.Skinning.LegacyComboCounter"); + jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.HUD.PerformancePointsCounter", @"osu.Game.Skinning.Triangles.TrianglesPerformancePointsCounter"); + try { // First attempt to deserialise using the new SkinLayoutInfo format @@ -150,11 +155,6 @@ namespace osu.Game.Skinning // If deserialisation using SkinLayoutInfo fails, attempt to deserialise using the old naked list. if (layoutInfo == null) { - // handle namespace changes... - jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.SongProgress", @"osu.Game.Screens.Play.HUD.DefaultSongProgress"); - jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.HUD.LegacyComboCounter", @"osu.Game.Skinning.LegacyComboCounter"); - jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.HUD.PerformancePointsCounter", @"osu.Game.Skinning.Triangles.TrianglesPerformancePointsCounter"); - var deserializedContent = JsonConvert.DeserializeObject>(jsonContent); if (deserializedContent == null) From fcc35a6accce8c849ec1de154d01e4fffa7ebc4a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Mar 2024 11:37:13 +0800 Subject: [PATCH 337/508] Fix cross-talk between pooled `DrawableSliderRepeat` usage causing incorrect rotation --- osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs index fcbd0edfe0..27c5278614 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs @@ -79,6 +79,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables base.OnApply(); Position = HitObject.Position - DrawableSlider.Position; + hasRotation = false; } protected override void CheckForResult(bool userTriggered, double timeOffset) => DrawableSlider.SliderInputManager.TryJudgeNestedObject(this, timeOffset); From 5e7d9ea04ac544b43bb349b99151f2599da5c747 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Mar 2024 13:59:04 +0800 Subject: [PATCH 338/508] Adjust scroll speed back to original --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index a5fc75aea3..dcd78833bd 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -346,7 +346,7 @@ namespace osu.Game.Overlays.Mods ScheduleAfterChildren(() => { columnScroll.ScrollToEnd(false); - columnScroll.ScrollTo(0, true, 0.0055); + columnScroll.ScrollTo(0); }); } From 44d0dc6113a408a15a18025325e55646a2147b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 8 Mar 2024 11:05:07 +0100 Subject: [PATCH 339/508] Fix 1px flashlight gaps when gameplay scaling mode is active Closes https://github.com/ppy/osu/issues/27522. Concerns mostly taiko and catch. Not much of a proper fix rather than a workaround but it is what it is. I tried a few other things, including setting `MaskingSmoothness = 0` on the scaling container itself, to no avail. --- osu.Game/Rulesets/Mods/ModFlashlight.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Mods/ModFlashlight.cs b/osu.Game/Rulesets/Mods/ModFlashlight.cs index c3775b0875..c924915bd0 100644 --- a/osu.Game/Rulesets/Mods/ModFlashlight.cs +++ b/osu.Game/Rulesets/Mods/ModFlashlight.cs @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Rendering; using osu.Framework.Graphics.Rendering.Vertices; @@ -88,7 +89,13 @@ namespace osu.Game.Rulesets.Mods flashlight.Combo.BindTo(Combo); flashlight.GetPlayfieldScale = () => drawableRuleset.Playfield.Scale; - drawableRuleset.Overlays.Add(flashlight); + drawableRuleset.Overlays.Add(new Container + { + RelativeSizeAxes = Axes.Both, + // workaround for 1px gaps on the edges of the playfield which would sometimes show with "gameplay" screen scaling active. + Padding = new MarginPadding(-1), + Child = flashlight, + }); } protected abstract Flashlight CreateFlashlight(); From 46e5bda40c68e15aca0dcbd3d468144d9efe6065 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 8 Mar 2024 19:02:12 +0800 Subject: [PATCH 340/508] Fix test failures --- osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs b/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs index 3dca179f2f..075fdd88ca 100644 --- a/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs +++ b/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModFlashlight.cs @@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods PassCondition = () => { var flashlightOverlay = Player.DrawableRuleset.Overlays - .OfType.Flashlight>() + .ChildrenOfType.Flashlight>() .First(); return Precision.AlmostEquals(mod.DefaultFlashlightSize * .5f, flashlightOverlay.GetSize()); From ad842b60f5416c83edf0f341575bd80572465b58 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Fri, 8 Mar 2024 21:43:18 +0900 Subject: [PATCH 341/508] Add support for Argon hitsounds --- osu.Game/Skinning/ArgonProSkin.cs | 6 ++++-- osu.Game/Skinning/ArgonSkin.cs | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Skinning/ArgonProSkin.cs b/osu.Game/Skinning/ArgonProSkin.cs index b753dd8fbe..6ec9945c0e 100644 --- a/osu.Game/Skinning/ArgonProSkin.cs +++ b/osu.Game/Skinning/ArgonProSkin.cs @@ -24,9 +24,11 @@ namespace osu.Game.Skinning { foreach (string lookup in sampleInfo.LookupNames) { - string remappedLookup = lookup.Replace(@"Gameplay/", @"Gameplay/ArgonPro/"); + var sample = Samples?.Get(lookup) + ?? Resources.AudioManager?.Samples.Get(lookup.Replace(@"Gameplay/", @"Gameplay/ArgonPro/")) + ?? Resources.AudioManager?.Samples.Get(lookup.Replace(@"Gameplay/", @"Gameplay/Argon/")) + ?? Resources.AudioManager?.Samples.Get(lookup); - var sample = Samples?.Get(remappedLookup) ?? Resources.AudioManager?.Samples.Get(remappedLookup); if (sample != null) return sample; } diff --git a/osu.Game/Skinning/ArgonSkin.cs b/osu.Game/Skinning/ArgonSkin.cs index 953badaf65..8fd393fcc5 100644 --- a/osu.Game/Skinning/ArgonSkin.cs +++ b/osu.Game/Skinning/ArgonSkin.cs @@ -77,7 +77,10 @@ namespace osu.Game.Skinning { foreach (string lookup in sampleInfo.LookupNames) { - var sample = Samples?.Get(lookup) ?? Resources.AudioManager?.Samples.Get(lookup); + var sample = Samples?.Get(lookup) + ?? Resources.AudioManager?.Samples.Get(lookup.Replace(@"Gameplay/", @"Gameplay/Argon/")) + ?? Resources.AudioManager?.Samples.Get(lookup); + if (sample != null) return sample; } From 27d78fdb087e0be54973ab40fb02818e747b9e62 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Sat, 9 Mar 2024 01:10:28 +0900 Subject: [PATCH 342/508] Add fallback to find spinner samples without a bank prefix --- osu.Game/Audio/HitSampleInfo.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Audio/HitSampleInfo.cs b/osu.Game/Audio/HitSampleInfo.cs index 24cb1730bf..f9c93d72ff 100644 --- a/osu.Game/Audio/HitSampleInfo.cs +++ b/osu.Game/Audio/HitSampleInfo.cs @@ -80,6 +80,8 @@ namespace osu.Game.Audio yield return $"Gameplay/{Bank}-{Name}{Suffix}"; yield return $"Gameplay/{Bank}-{Name}"; + + yield return $"Gameplay/{Name}"; } } From db1c59475b0e31fd17d6944804c23a65b206c756 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 9 Feb 2024 15:10:45 -0800 Subject: [PATCH 343/508] Wrap beatmap listing filters and match web spacing --- .../BeatmapListingSearchControl.cs | 1 + .../BeatmapListing/BeatmapSearchFilterRow.cs | 37 ++++--------------- ...BeatmapSearchMultipleSelectionFilterRow.cs | 4 +- .../Overlays/BeatmapListing/FilterTabItem.cs | 2 - 4 files changed, 9 insertions(+), 35 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs index 3fa0fc7a77..bab64165cb 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSearchControl.cs @@ -128,6 +128,7 @@ namespace osu.Game.Overlays.BeatmapListing RelativeSizeAxes = Axes.X, Direction = FillDirection.Vertical, Padding = new MarginPadding { Horizontal = 10 }, + Spacing = new Vector2(5), Children = new Drawable[] { generalFilter = new BeatmapSearchGeneralFilterRow(), diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs index 6d75521cb0..f79695a123 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs @@ -1,14 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osuTK; using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Localisation; @@ -49,8 +47,6 @@ namespace osu.Game.Overlays.BeatmapListing { new OsuSpriteText { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, Font = OsuFont.GetFont(size: 13), Text = header }, @@ -69,10 +65,8 @@ namespace osu.Game.Overlays.BeatmapListing { public BeatmapSearchFilter() { - Anchor = Anchor.BottomLeft; - Origin = Anchor.BottomLeft; RelativeSizeAxes = Axes.X; - Height = 15; + AutoSizeAxes = Axes.Y; TabContainer.Spacing = new Vector2(10, 0); @@ -83,33 +77,16 @@ namespace osu.Game.Overlays.BeatmapListing } } - [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider) - { - if (Dropdown is FilterDropdown fd) - fd.AccentColour = colourProvider.Light2; - } - - protected override Dropdown CreateDropdown() => new FilterDropdown(); + protected override Dropdown CreateDropdown() => null!; protected override TabItem CreateTabItem(T value) => new FilterTabItem(value); - private partial class FilterDropdown : OsuTabDropdown + protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer { - protected override DropdownHeader CreateHeader() => new FilterHeader - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight - }; - - private partial class FilterHeader : OsuTabDropdownHeader - { - public FilterHeader() - { - Background.Height = 1; - } - } - } + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + AllowMultiline = true, + }; } } } diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchMultipleSelectionFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchMultipleSelectionFilterRow.cs index abd2643a41..e59beb43ff 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchMultipleSelectionFilterRow.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchMultipleSelectionFilterRow.cs @@ -52,10 +52,8 @@ namespace osu.Game.Overlays.BeatmapListing [BackgroundDependencyLoader] private void load() { - Anchor = Anchor.BottomLeft; - Origin = Anchor.BottomLeft; RelativeSizeAxes = Axes.X; - Height = 15; + AutoSizeAxes = Axes.Y; Spacing = new Vector2(10, 0); AddRange(GetValues().Select(CreateTabItem)); diff --git a/osu.Game/Overlays/BeatmapListing/FilterTabItem.cs b/osu.Game/Overlays/BeatmapListing/FilterTabItem.cs index c33d5056fa..831cf812ff 100644 --- a/osu.Game/Overlays/BeatmapListing/FilterTabItem.cs +++ b/osu.Game/Overlays/BeatmapListing/FilterTabItem.cs @@ -33,8 +33,6 @@ namespace osu.Game.Overlays.BeatmapListing private void load() { AutoSizeAxes = Axes.Both; - Anchor = Anchor.BottomLeft; - Origin = Anchor.BottomLeft; AddRangeInternal(new Drawable[] { text = new OsuSpriteText From 26c97ef73314a5e307beb5b1b2b755fa78188dc7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 9 Mar 2024 00:51:33 +0300 Subject: [PATCH 344/508] Fix WikiPanelContainer causing poor performance --- osu.Game/Overlays/Wiki/WikiPanelContainer.cs | 68 +++++++++++++------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/osu.Game/Overlays/Wiki/WikiPanelContainer.cs b/osu.Game/Overlays/Wiki/WikiPanelContainer.cs index cbffe5732e..555dab852e 100644 --- a/osu.Game/Overlays/Wiki/WikiPanelContainer.cs +++ b/osu.Game/Overlays/Wiki/WikiPanelContainer.cs @@ -3,7 +3,6 @@ #nullable disable -using System; using Markdig.Syntax; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; @@ -22,29 +21,61 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Wiki { - public partial class WikiPanelContainer : Container + public partial class WikiPanelContainer : CompositeDrawable { - private WikiPanelMarkdownContainer panelContainer; + private const float padding = 3; private readonly string text; - private readonly bool isFullWidth; public WikiPanelContainer(string text, bool isFullWidth = false) { this.text = text; this.isFullWidth = isFullWidth; - - RelativeSizeAxes = Axes.X; - Padding = new MarginPadding(3); } + private PanelBackground background; + [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider, IAPIProvider api) + private void load(IAPIProvider api) { - Children = new Drawable[] + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + InternalChildren = new Drawable[] { + background = new PanelBackground + { + BypassAutoSizeAxes = Axes.Both + }, new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding(padding), + Child = new WikiPanelMarkdownContainer(isFullWidth) + { + CurrentPath = $@"{api.WebsiteRootUrl}/wiki/", + Text = text, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y + } + } + }; + } + + protected override void Update() + { + base.Update(); + background.Size = Parent!.DrawSize * new Vector2(Size.X, 1); + } + + private partial class PanelBackground : CompositeDrawable + { + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + Padding = new MarginPadding(padding); + InternalChild = new Container { RelativeSizeAxes = Axes.Both, Masking = true, @@ -60,22 +91,9 @@ namespace osu.Game.Overlays.Wiki { Colour = colourProvider.Background4, RelativeSizeAxes = Axes.Both, - }, - }, - panelContainer = new WikiPanelMarkdownContainer(isFullWidth) - { - CurrentPath = $@"{api.WebsiteRootUrl}/wiki/", - Text = text, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - } - }; - } - - protected override void Update() - { - base.Update(); - Height = Math.Max(panelContainer.Height, Parent!.DrawHeight); + } + }; + } } private partial class WikiPanelMarkdownContainer : WikiMarkdownContainer From dd36942508aee46ff0b0357daed108f293260924 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 9 Mar 2024 13:58:05 +0300 Subject: [PATCH 345/508] Reduce allocations in DrawableFlag tooltip --- osu.Game/Users/Drawables/DrawableFlag.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Users/Drawables/DrawableFlag.cs b/osu.Game/Users/Drawables/DrawableFlag.cs index 289f68ee7f..08c323d42c 100644 --- a/osu.Game/Users/Drawables/DrawableFlag.cs +++ b/osu.Game/Users/Drawables/DrawableFlag.cs @@ -15,11 +15,14 @@ namespace osu.Game.Users.Drawables { private readonly CountryCode countryCode; - public LocalisableString TooltipText => countryCode == CountryCode.Unknown ? string.Empty : countryCode.GetDescription(); + public LocalisableString TooltipText => countryCode == CountryCode.Unknown ? string.Empty : description; + + private readonly string description; public DrawableFlag(CountryCode countryCode) { this.countryCode = countryCode; + description = countryCode.GetDescription(); } [BackgroundDependencyLoader] From 58b6acde10eee69faedd57fcf5c6f1869eb8fba7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 9 Mar 2024 14:10:32 +0300 Subject: [PATCH 346/508] Further simplify tooltip text creation --- osu.Game/Users/Drawables/DrawableFlag.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Users/Drawables/DrawableFlag.cs b/osu.Game/Users/Drawables/DrawableFlag.cs index 08c323d42c..39f0ab370b 100644 --- a/osu.Game/Users/Drawables/DrawableFlag.cs +++ b/osu.Game/Users/Drawables/DrawableFlag.cs @@ -15,14 +15,14 @@ namespace osu.Game.Users.Drawables { private readonly CountryCode countryCode; - public LocalisableString TooltipText => countryCode == CountryCode.Unknown ? string.Empty : description; + public LocalisableString TooltipText => tooltipText; - private readonly string description; + private readonly string tooltipText; public DrawableFlag(CountryCode countryCode) { this.countryCode = countryCode; - description = countryCode.GetDescription(); + tooltipText = countryCode == CountryCode.Unknown ? string.Empty : countryCode.GetDescription(); } [BackgroundDependencyLoader] From b8a362fcb69390fb774bcb5a4afc78bb138ddf7e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 9 Mar 2024 20:17:27 +0800 Subject: [PATCH 347/508] Simplify assignment by using an auto property --- osu.Game/Users/Drawables/DrawableFlag.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Users/Drawables/DrawableFlag.cs b/osu.Game/Users/Drawables/DrawableFlag.cs index 39f0ab370b..6813b13cef 100644 --- a/osu.Game/Users/Drawables/DrawableFlag.cs +++ b/osu.Game/Users/Drawables/DrawableFlag.cs @@ -15,14 +15,12 @@ namespace osu.Game.Users.Drawables { private readonly CountryCode countryCode; - public LocalisableString TooltipText => tooltipText; - - private readonly string tooltipText; + public LocalisableString TooltipText { get; } public DrawableFlag(CountryCode countryCode) { this.countryCode = countryCode; - tooltipText = countryCode == CountryCode.Unknown ? string.Empty : countryCode.GetDescription(); + TooltipText = countryCode == CountryCode.Unknown ? string.Empty : countryCode.GetDescription(); } [BackgroundDependencyLoader] From 31739be49912ffedf1ae7a4deeb747b8b2ec9204 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 9 Mar 2024 20:46:48 +0800 Subject: [PATCH 348/508] Update resources --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index b143a3a6b1..55bd68dea0 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -37,7 +37,7 @@ - + From 549a8d678e4a9d8c91a1a220bef6f3519aaa687d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 9 Mar 2024 20:50:54 +0300 Subject: [PATCH 349/508] Reduce allocations in ControlPointList --- .../Screens/Edit/Timing/ControlPointList.cs | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Edit/Timing/ControlPointList.cs b/osu.Game/Screens/Edit/Timing/ControlPointList.cs index 7cd1dbc630..4e4090ccd0 100644 --- a/osu.Game/Screens/Edit/Timing/ControlPointList.cs +++ b/osu.Game/Screens/Edit/Timing/ControlPointList.cs @@ -162,26 +162,43 @@ namespace osu.Game.Screens.Edit.Timing // If the selected group only has one control point, update the tracking type. case 1: - trackedType = selectedGroup.Value?.ControlPoints.Single().GetType(); + trackedType = selectedGroup.Value?.ControlPoints[0].GetType(); break; // If the selected group has more than one control point, choose the first as the tracking type // if we don't already have a singular tracked type. default: - trackedType ??= selectedGroup.Value?.ControlPoints.FirstOrDefault()?.GetType(); + trackedType ??= selectedGroup.Value?.ControlPoints[0].GetType(); break; } } if (trackedType != null) { + double accurateTime = clock.CurrentTimeAccurate; + // We don't have an efficient way of looking up groups currently, only individual point types. // To improve the efficiency of this in the future, we should reconsider the overall structure of ControlPointInfo. // Find the next group which has the same type as the selected one. - var found = Beatmap.ControlPointInfo.Groups - .Where(g => g.ControlPoints.Any(cp => cp.GetType() == trackedType)) - .LastOrDefault(g => g.Time <= clock.CurrentTimeAccurate); + ControlPointGroup? found = null; + + for (int i = 0; i < Beatmap.ControlPointInfo.Groups.Count; i++) + { + var g = Beatmap.ControlPointInfo.Groups[i]; + + if (g.Time > accurateTime) + continue; + + for (int j = 0; j < g.ControlPoints.Count; j++) + { + if (g.ControlPoints[j].GetType() == trackedType) + { + found = g; + break; + } + } + } if (found != null) selectedGroup.Value = found; From e08651668c46f3c7cbef87b2fadd23d609e9fee2 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 9 Mar 2024 21:55:00 +0300 Subject: [PATCH 350/508] Fix TestSceneSkinnableSound failing --- osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs index 3f78dbfd96..6c8dc6a220 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs @@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual.Gameplay private TestSkinSourceContainer skinSource = null!; private PausableSkinnableSound skinnableSound = null!; - private const string sample_lookup = "Gameplay/normal-sliderslide"; + private const string sample_lookup = "Gameplay/Argon/normal-sliderslide"; [SetUpSteps] public void SetUpSteps() From 6ff4b1d7e3d461adf4b67c676a62f39ecfd7ec21 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 10 Mar 2024 15:42:03 +0300 Subject: [PATCH 351/508] Don't update SubTreeMasking in OsuPlayfield --- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 411a02c5af..80379094ae 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -9,6 +9,7 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; using osu.Game.Beatmaps; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; @@ -35,6 +36,8 @@ namespace osu.Game.Rulesets.Osu.UI private readonly JudgementPooler judgementPooler; + public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false; + public SmokeContainer Smoke { get; } public FollowPointRenderer FollowPoints { get; } From 6ecef33fd7a9dcee06349e1075e10ed3bce9e7c7 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 10 Mar 2024 22:45:29 +0300 Subject: [PATCH 352/508] Fic incorrect ExtendableCircle gradient --- .../Components/Timeline/TimelineHitObjectBlueprint.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs index d4afcc0151..7e6e886ff7 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs @@ -471,6 +471,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline /// public partial class ExtendableCircle : CompositeDrawable { + public new ColourInfo Colour + { + get => Content.Colour; + set => Content.Colour = value; + } + protected readonly Circle Content; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Content.ReceivePositionalInputAt(screenSpacePos); From 283de215d37aca9605bbf5b0a11dc440455bb348 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 11 Mar 2024 01:01:26 +0300 Subject: [PATCH 353/508] Adjust log message and comment --- osu.Desktop/DiscordRichPresence.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index b4a7e80d48..2e5db2f5c1 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -189,20 +189,14 @@ namespace osu.Desktop private void onJoin(object sender, JoinMessage args) { game.Window?.Raise(); - Logger.Log($"Received room secret from Discord RPC Client: {args.Secret}", LoggingTarget.Network, LogLevel.Debug); - // Stable and Lazer share the same Discord client ID, meaning they can accept join requests from each other. + Logger.Log($"Received room secret from Discord RPC Client: \"{args.Secret}\"", LoggingTarget.Network, LogLevel.Debug); + + // Stable and lazer share the same Discord client ID, meaning they can accept join requests from each other. // Since they aren't compatible in multi, see if stable's format is being used and log to avoid confusion. - // https://discord.com/channels/188630481301012481/188630652340404224/1214697229063946291 - if (args.Secret[0] != '{') + if (args.Secret[0] != '{' || !tryParseRoomSecret(args.Secret, out long roomId, out string? password)) { - Logger.Log("osu!stable rooms are not compatible with lazer.", LoggingTarget.Network, LogLevel.Important); - return; - } - - if (!tryParseRoomSecret(args.Secret, out long roomId, out string? password)) - { - Logger.Log("Could not join multiplayer room.", LoggingTarget.Network, LogLevel.Important); + Logger.Log("Could not join multiplayer room, invitation is invalid or incompatible.", LoggingTarget.Network, LogLevel.Important); return; } @@ -211,7 +205,7 @@ namespace osu.Desktop { game.PresentMultiplayerMatch(room, password); }); - request.Failure += _ => Logger.Log($"Could not find room {roomId} from Discord RPC Client", LoggingTarget.Network, LogLevel.Important); + request.Failure += _ => Logger.Log($"Could not join multiplayer room, room could not be found (room ID: {roomId}).", LoggingTarget.Network, LogLevel.Important); api.Queue(request); } From 2be6d1f1c60f6e146b056f3fc42c1205cea22826 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Mar 2024 11:26:03 +0800 Subject: [PATCH 354/508] Apply NRT to `OsuPlayfield` --- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 80379094ae..9b8128a107 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Diagnostics; using System.Linq; @@ -79,7 +77,7 @@ namespace osu.Game.Rulesets.Osu.UI NewResult += onNewResult; } - private IHitPolicy hitPolicy; + private IHitPolicy hitPolicy = null!; public IHitPolicy HitPolicy { @@ -119,12 +117,12 @@ namespace osu.Game.Rulesets.Osu.UI judgementAboveHitObjectLayer.Add(judgement.ProxiedAboveHitObjectsContent); } - [BackgroundDependencyLoader(true)] - private void load(OsuRulesetConfigManager config, IBeatmap beatmap) + [BackgroundDependencyLoader] + private void load(OsuRulesetConfigManager? config, IBeatmap? beatmap) { config?.BindWith(OsuRulesetSetting.PlayfieldBorderStyle, playfieldBorder.PlayfieldBorderStyle); - var osuBeatmap = (OsuBeatmap)beatmap; + var osuBeatmap = (OsuBeatmap?)beatmap; RegisterPool(20, 100); From f3d154a9955697cd25db6a2dd3393daf668acac2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Mar 2024 11:28:15 +0800 Subject: [PATCH 355/508] Add inline comment explaining optimisation --- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 9b8128a107..63030293ac 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -34,6 +34,8 @@ namespace osu.Game.Rulesets.Osu.UI private readonly JudgementPooler judgementPooler; + // For osu! gameplay, everything is always on screen. + // Skipping masking calculations improves performance in intense beatmaps (ie. https://osu.ppy.sh/beatmapsets/150945#osu/372245) public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false; public SmokeContainer Smoke { get; } From e3936930c7df32ccd53f6c8f4ea2dca14dec3934 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Mar 2024 13:11:57 +0800 Subject: [PATCH 356/508] Remove local optimisation in `DrawableHitObject` --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index de05219212..28aa2ccb79 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -15,7 +15,6 @@ using osu.Framework.Extensions.ListExtensions; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Graphics; -using osu.Framework.Graphics.Primitives; using osu.Framework.Lists; using osu.Framework.Threading; using osu.Framework.Utils; @@ -632,8 +631,6 @@ namespace osu.Game.Rulesets.Objects.Drawables #endregion - public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false; - protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); From d12b11e234f0e9d279e70c71ab595a063ec98e47 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Mar 2024 13:14:29 +0800 Subject: [PATCH 357/508] Revert "Remove local optimisation in `DrawableHitObject`" This reverts commit e3936930c7df32ccd53f6c8f4ea2dca14dec3934. --- osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 28aa2ccb79..de05219212 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -15,6 +15,7 @@ using osu.Framework.Extensions.ListExtensions; using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; using osu.Framework.Lists; using osu.Framework.Threading; using osu.Framework.Utils; @@ -631,6 +632,8 @@ namespace osu.Game.Rulesets.Objects.Drawables #endregion + public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false; + protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); From 091425db3091104269531f28218b3b309e50c426 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Mar 2024 14:43:54 +0800 Subject: [PATCH 358/508] Fix nullability hint --- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 63030293ac..a55a55f760 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Osu.UI public static readonly Vector2 BASE_SIZE = new Vector2(512, 384); - protected override GameplayCursorContainer CreateCursor() => new OsuCursorContainer(); + protected override GameplayCursorContainer? CreateCursor() => new OsuCursorContainer(); private readonly Container judgementAboveHitObjectLayer; From fc05268fc33fc16f214501f3dffe1ec33a301e29 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Mar 2024 14:45:52 +0800 Subject: [PATCH 359/508] Apply NRT to `DrawableOsuEditorRuleset` too --- osu.Game.Rulesets.Osu/Edit/DrawableOsuEditorRuleset.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/DrawableOsuEditorRuleset.cs b/osu.Game.Rulesets.Osu/Edit/DrawableOsuEditorRuleset.cs index 14e7b93f3a..68c565af4d 100644 --- a/osu.Game.Rulesets.Osu/Edit/DrawableOsuEditorRuleset.cs +++ b/osu.Game.Rulesets.Osu/Edit/DrawableOsuEditorRuleset.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mods; @@ -25,7 +23,7 @@ namespace osu.Game.Rulesets.Osu.Edit private partial class OsuEditorPlayfield : OsuPlayfield { - protected override GameplayCursorContainer CreateCursor() => null; + protected override GameplayCursorContainer? CreateCursor() => null; public OsuEditorPlayfield() { From e0f1f70b820030452c2f32d1d7dfe6417230f9c7 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 11 Mar 2024 15:52:38 +0900 Subject: [PATCH 360/508] Adjust NRT to prevent future issues This way, it will yet at us if the setter is ever moved out of the ctor. --- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index a55a55f760..4933eb4041 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -3,6 +3,7 @@ using System; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -79,11 +80,12 @@ namespace osu.Game.Rulesets.Osu.UI NewResult += onNewResult; } - private IHitPolicy hitPolicy = null!; + private IHitPolicy hitPolicy; public IHitPolicy HitPolicy { get => hitPolicy; + [MemberNotNull(nameof(hitPolicy))] set { hitPolicy = value ?? throw new ArgumentNullException(nameof(value)); From 226df7163e1b34eb4a78f02f0038493b673a8dce Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 11 Mar 2024 16:55:49 +0800 Subject: [PATCH 361/508] Update client ID --- osu.Desktop/DiscordRichPresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 2e5db2f5c1..4e3db2db2d 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -25,7 +25,7 @@ namespace osu.Desktop { internal partial class DiscordRichPresence : Component { - private const string client_id = "367827983903490050"; + private const string client_id = "1216669957799018608"; private DiscordRpcClient client = null!; From 169e2e1b4e21c824e586cd1be88b33875e9a2e30 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 11 Mar 2024 09:54:49 +0300 Subject: [PATCH 362/508] Change maximum room number to closest powers of two --- osu.Desktop/DiscordRichPresence.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 4e3db2db2d..886038bcf0 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -142,9 +142,8 @@ namespace osu.Desktop Privacy = string.IsNullOrEmpty(room.Settings.Password) ? Party.PrivacySetting.Public : Party.PrivacySetting.Private, ID = room.RoomID.ToString(), // technically lobbies can have infinite users, but Discord needs this to be set to something. - // 1024 just happens to look nice. - // https://discord.com/channels/188630481301012481/188630652340404224/1212967974793642034 - Max = 1024, + // to make party display sensible, assign a powers of two above participants count (8 at minimum). + Max = (int)Math.Max(8, Math.Pow(2, Math.Ceiling(Math.Log2(room.Users.Count)))), Size = room.Users.Count, }; From 8b730acb082379174f9a48b5fd132b184b4e9a81 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Mon, 11 Mar 2024 11:18:59 +0300 Subject: [PATCH 363/508] Update presence on changes to multiplayer room --- osu.Desktop/DiscordRichPresence.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 886038bcf0..8de1a08e7a 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -8,6 +8,7 @@ using DiscordRPC.Message; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Logging; using osu.Game; @@ -91,6 +92,8 @@ namespace osu.Desktop activity.BindValueChanged(_ => updateStatus()); privacyMode.BindValueChanged(_ => updateStatus()); + multiplayerClient.RoomUpdated += updateStatus; + client.Initialize(); } @@ -269,6 +272,9 @@ namespace osu.Desktop protected override void Dispose(bool isDisposing) { + if (multiplayerClient.IsNotNull()) + multiplayerClient.RoomUpdated -= updateStatus; + client.Dispose(); base.Dispose(isDisposing); } From e5e7c8f26841654a6819f3c88c40a347184c086b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 11 Mar 2024 14:58:28 +0100 Subject: [PATCH 364/508] Wrap beatmap listing filter names too While we're here fixing... Addresses https://github.com/ppy/osu/discussions/15452#discussioncomment-2734237. --- osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs index f79695a123..0b54a921f5 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs @@ -6,10 +6,10 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osuTK; using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Localisation; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays.BeatmapListing { @@ -45,9 +45,10 @@ namespace osu.Game.Overlays.BeatmapListing { new[] { - new OsuSpriteText + new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 13)) { - Font = OsuFont.GetFont(size: 13), + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Text = header }, filter = CreateFilter() From f30dfcb728b216659bf80ff513f7c0cdb97d56f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 11 Mar 2024 21:34:10 +0100 Subject: [PATCH 365/508] Fix ruleset medals not displaying due to deserialisation failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦 Reported in https://discord.com/channels/188630481301012481/188630652340404224/1216812697589518386. --- .../Notifications/WebSocket/Events/UserAchievementUnlock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Notifications/WebSocket/Events/UserAchievementUnlock.cs b/osu.Game/Online/Notifications/WebSocket/Events/UserAchievementUnlock.cs index 6c7c8af4f4..3f803a4fe5 100644 --- a/osu.Game/Online/Notifications/WebSocket/Events/UserAchievementUnlock.cs +++ b/osu.Game/Online/Notifications/WebSocket/Events/UserAchievementUnlock.cs @@ -14,7 +14,7 @@ namespace osu.Game.Online.Notifications.WebSocket.Events public uint AchievementId { get; set; } [JsonProperty("achievement_mode")] - public ushort? AchievementMode { get; set; } + public string? AchievementMode { get; set; } [JsonProperty("cover_url")] public string CoverUrl { get; set; } = string.Empty; From 5580ce31fa6c37c7c65a703cfe820705928453bd Mon Sep 17 00:00:00 2001 From: jvyden Date: Mon, 11 Mar 2024 18:15:18 -0400 Subject: [PATCH 366/508] Log Discord RPC updates --- osu.Desktop/DiscordRichPresence.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 8de1a08e7a..6c8bd26d3d 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -114,6 +114,8 @@ namespace osu.Desktop return; } + Logger.Log("Updating Discord RPC", LoggingTarget.Network, LogLevel.Debug); + if (activity.Value != null) { bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb; From e4e7dd14f30ee5c2d28ccc967a0a891fbbd076b7 Mon Sep 17 00:00:00 2001 From: jvyden Date: Mon, 11 Mar 2024 18:16:13 -0400 Subject: [PATCH 367/508] Revert "Update presence on changes to multiplayer room" This reverts commit 8b730acb082379174f9a48b5fd132b184b4e9a81. --- osu.Desktop/DiscordRichPresence.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 6c8bd26d3d..ca26cab0fd 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -8,7 +8,6 @@ using DiscordRPC.Message; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Logging; using osu.Game; @@ -92,8 +91,6 @@ namespace osu.Desktop activity.BindValueChanged(_ => updateStatus()); privacyMode.BindValueChanged(_ => updateStatus()); - multiplayerClient.RoomUpdated += updateStatus; - client.Initialize(); } @@ -274,9 +271,6 @@ namespace osu.Desktop protected override void Dispose(bool isDisposing) { - if (multiplayerClient.IsNotNull()) - multiplayerClient.RoomUpdated -= updateStatus; - client.Dispose(); base.Dispose(isDisposing); } From 83052fe1d98174a832e4ed7e9c52b04c5eb7c6c3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Mar 2024 15:41:50 +0800 Subject: [PATCH 368/508] Downgrade realm to work around crashes on latest release See https://github.com/ppy/osu/issues/27577. --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 55bd68dea0..0b70515abf 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -35,7 +35,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 961058f5c8ca538b1a96a82651b30e49b92c90c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 12 Mar 2024 09:05:28 +0100 Subject: [PATCH 369/508] Add failing test case --- .../Archives/skin-with-subfolder-zip-entries.osk | Bin 0 -> 894 bytes osu.Game.Tests/Skins/IO/ImportSkinTest.cs | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 osu.Game.Tests/Resources/Archives/skin-with-subfolder-zip-entries.osk diff --git a/osu.Game.Tests/Resources/Archives/skin-with-subfolder-zip-entries.osk b/osu.Game.Tests/Resources/Archives/skin-with-subfolder-zip-entries.osk new file mode 100644 index 0000000000000000000000000000000000000000..013bca3801866f95f7139fbed30f96fb2a6b2639 GIT binary patch literal 894 zcmWIWW@Zs#0D)fToCq)j3KSR^7~D$p6x{N2Qc{Z)+)8tD6!Oy)z(T2sC8b5F#rgr> z%q(1B^%IN$Ap?Py>iJ1=|6P_`x6zd4 zEfM)++L3fnI_cpXrRudEn*$3})-iOx*uii%%l&hv$>$w+S986db}^&p7Q5xc6-hd6 z^Nd!^C`)&ym`MU=a{~hd!)z=G1la}#`B~{vg}D5N fE2$vc@DwTG5N9$g8z=}_7+4rqFfuS40Ea68KA!II literal 0 HcmV?d00001 diff --git a/osu.Game.Tests/Skins/IO/ImportSkinTest.cs b/osu.Game.Tests/Skins/IO/ImportSkinTest.cs index 606a5afac2..62e7a80435 100644 --- a/osu.Game.Tests/Skins/IO/ImportSkinTest.cs +++ b/osu.Game.Tests/Skins/IO/ImportSkinTest.cs @@ -173,6 +173,16 @@ namespace osu.Game.Tests.Skins.IO assertCorrectMetadata(import1, "name 1 [my custom skin 1]", "author 1", 1.0m, osu); }); + [Test] + public Task TestImportWithSubfolder() => runSkinTest(async osu => + { + const string filename = "Archives/skin-with-subfolder-zip-entries.osk"; + var import = await loadSkinIntoOsu(osu, new ImportTask(TestResources.OpenResource(filename), filename)); + + assertCorrectMetadata(import, $"Totally fully features skin [Real Skin with Real Features] [{filename[..^4]}]", "Unknown", 2.7m, osu); + Assert.That(import.PerformRead(r => r.Files.Count), Is.EqualTo(3)); + }); + #endregion #region Cases where imports should be uniquely imported From 83e47b3c4c1c3a59c6ded7249797daa436d46572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 12 Mar 2024 09:06:24 +0100 Subject: [PATCH 370/508] Fix exports containing zero byte files after import from specific ZIP archives Closes https://github.com/ppy/osu/issues/27540. As it turns out, some ZIP archivers (like 7zip) will decide to add fake entries for directories, and some (like windows zipfolders) won't. The "directory" entries aren't really properly supported using any actual data or attributes, they're detected by sharpcompress basically by heuristics: https://github.com/adamhathcock/sharpcompress/blob/ab5535eba365ec8fae58f92d53763ddf2dbf45af/src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs#L19-L31 When importing into realm we have thus far presumed that these directory entries will not be a thing. Having them be a thing breaks multiple things, like: - When importing from ZIPs with separate directory entries, a separate `RealmFile` is created for a directory entry even though it doesn't represent a real file - As a result, when re-exporting a model with files imported from such an archive, a zero-byte file would be created because to the database it looks like it was originally a zero-byte file. If you want to have fun, google "zip empty directories". You'll see a whole gamut of languages, libraries, and developers stepping on this rake. Yet another episode of underspecced mistakes from decades ago that were somebody's "good idea" but continue to wreak havoc forevermore because now there are two competing conventions you can't just pick one. --- osu.Game/IO/Archives/ZipArchiveReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/IO/Archives/ZipArchiveReader.cs b/osu.Game/IO/Archives/ZipArchiveReader.cs index 7d7ce858dd..cc5c65d184 100644 --- a/osu.Game/IO/Archives/ZipArchiveReader.cs +++ b/osu.Game/IO/Archives/ZipArchiveReader.cs @@ -46,7 +46,7 @@ namespace osu.Game.IO.Archives archiveStream.Dispose(); } - public override IEnumerable Filenames => archive.Entries.Select(e => e.Key).ExcludeSystemFileNames(); + public override IEnumerable Filenames => archive.Entries.Where(e => !e.IsDirectory).Select(e => e.Key).ExcludeSystemFileNames(); private class MemoryOwnerMemoryStream : Stream { From 88ec0cdbc704e041bd6b77ff24d1a4206d888896 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Mar 2024 17:35:00 +0800 Subject: [PATCH 371/508] Fix seek ending too early in sample playback test --- .../TestSceneGameplaySamplePlayback.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs index 057197e819..ad3fe7cb7e 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplaySamplePlayback.cs @@ -18,6 +18,8 @@ namespace osu.Game.Tests.Visual.Gameplay { protected override bool AllowBackwardsSeeks => true; + private bool seek; + [Test] public void TestAllSamplesStopDuringSeek() { @@ -42,7 +44,7 @@ namespace osu.Game.Tests.Visual.Gameplay if (!samples.Any(s => s.Playing)) return false; - Player.ChildrenOfType().First().Seek(40000); + seek = true; return true; }); @@ -55,10 +57,27 @@ namespace osu.Game.Tests.Visual.Gameplay AddAssert("sample playback still disabled", () => sampleDisabler.SamplePlaybackDisabled.Value); + AddStep("stop seeking", () => seek = false); + AddUntilStep("seek finished, sample playback enabled", () => !sampleDisabler.SamplePlaybackDisabled.Value); AddUntilStep("any sample is playing", () => Player.ChildrenOfType().Any(s => s.IsPlaying)); } + protected override void Update() + { + base.Update(); + + if (seek) + { + // Frame stable playback is too fast to catch up these days. + // + // We want to keep seeking while asserting various test conditions, so + // continue to seek until we unset the flag. + var gameplayClockContainer = Player.ChildrenOfType().First(); + gameplayClockContainer.Seek(gameplayClockContainer.CurrentTime > 30000 ? 0 : 60000); + } + } + private IEnumerable allSounds => Player.ChildrenOfType(); private IEnumerable allLoopingSounds => allSounds.Where(sound => sound.Looping); From a4a433b92add36153d8f9b06ffa757480ff3b5ee Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 Mar 2024 20:14:50 +0800 Subject: [PATCH 372/508] Remember login by default Kinda what is expected from a user's perspective --- osu.Game/Configuration/OsuConfigManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index a71460ded7..f4a4c553d8 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -75,7 +75,7 @@ namespace osu.Game.Configuration #pragma warning restore CS0618 // Type or member is obsolete SetDefault(OsuSetting.AutomaticallyDownloadMissingBeatmaps, false); - SetDefault(OsuSetting.SavePassword, false).ValueChanged += enabled => + SetDefault(OsuSetting.SavePassword, true).ValueChanged += enabled => { if (enabled.NewValue) SetValue(OsuSetting.SaveUsername, true); From e2e99fc5cc392b57276a1c79f3b68c2831c64ac0 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Tue, 12 Mar 2024 21:07:21 -0700 Subject: [PATCH 373/508] Rearrange rankings overlay tabs to match web --- osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs | 2 +- osu.Game/Overlays/Rankings/RankingsScope.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs index cf132ed4da..0eaa6ce827 100644 --- a/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs +++ b/osu.Game/Overlays/Rankings/RankingsOverlayHeader.cs @@ -52,9 +52,9 @@ namespace osu.Game.Overlays.Rankings switch (scope) { case RankingsScope.Performance: - case RankingsScope.Spotlights: case RankingsScope.Score: case RankingsScope.Country: + case RankingsScope.Spotlights: return true; default: diff --git a/osu.Game/Overlays/Rankings/RankingsScope.cs b/osu.Game/Overlays/Rankings/RankingsScope.cs index 356a861764..0740c17e8c 100644 --- a/osu.Game/Overlays/Rankings/RankingsScope.cs +++ b/osu.Game/Overlays/Rankings/RankingsScope.cs @@ -11,15 +11,15 @@ namespace osu.Game.Overlays.Rankings [LocalisableDescription(typeof(RankingsStrings), nameof(RankingsStrings.TypePerformance))] Performance, - [LocalisableDescription(typeof(RankingsStrings), nameof(RankingsStrings.TypeCharts))] - Spotlights, - [LocalisableDescription(typeof(RankingsStrings), nameof(RankingsStrings.TypeScore))] Score, [LocalisableDescription(typeof(RankingsStrings), nameof(RankingsStrings.TypeCountry))] Country, + [LocalisableDescription(typeof(RankingsStrings), nameof(RankingsStrings.TypeCharts))] + Spotlights, + [LocalisableDescription(typeof(RankingsStrings), nameof(RankingsStrings.TypeKudosu))] Kudosu, } From 20c760835ab81c4a90c46656f69d8b59b0903fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 13 Mar 2024 13:55:49 +0100 Subject: [PATCH 374/508] Fix audio in video check crashing on unexpected failures --- osu.Game/Rulesets/Edit/Checks/CheckAudioInVideo.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckAudioInVideo.cs b/osu.Game/Rulesets/Edit/Checks/CheckAudioInVideo.cs index f712a7867d..38976dd4b5 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckAudioInVideo.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckAudioInVideo.cs @@ -1,8 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.IO; +using osu.Framework.Logging; using osu.Game.Beatmaps; using osu.Game.IO.FileAbstraction; using osu.Game.Rulesets.Edit.Checks.Components; @@ -75,6 +77,11 @@ namespace osu.Game.Rulesets.Edit.Checks { issue = new IssueTemplateFileError(this).Create(filename, "Unsupported format"); } + catch (Exception ex) + { + issue = new IssueTemplateFileError(this).Create(filename, "Internal failure - see logs for more info"); + Logger.Log($"Failed when running {nameof(CheckAudioInVideo)}: {ex}"); + } yield return issue; } From d32f19b546e63e844acaa3c4c3911225cb757ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 13 Mar 2024 15:18:20 +0100 Subject: [PATCH 375/508] Fix first word bold not applying correctly after first language change Closes https://github.com/ppy/osu/issues/27549. I'm not entirely sure why the old solution failed exactly, but also think it's unimportant because I think past me was an idiot and was playing stupid games with the juggling of indices between two callbacks with no ordering guarantees and expecting not to win stupid prizes. I'm not sure this requires any follow-up reconsiderations of that entire text flow API, but if opinions differ, I'll re-examine. --- osu.Game/Overlays/Mods/ModSelectColumn.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectColumn.cs b/osu.Game/Overlays/Mods/ModSelectColumn.cs index b2c5a054e1..61b29ef65b 100644 --- a/osu.Game/Overlays/Mods/ModSelectColumn.cs +++ b/osu.Game/Overlays/Mods/ModSelectColumn.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -8,9 +9,11 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Localisation; +using System.Linq; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osuTK; using osuTK.Graphics; @@ -181,17 +184,15 @@ namespace osu.Game.Overlays.Mods { headerText.Clear(); - int wordIndex = 0; + ITextPart part = headerText.AddText(text); + part.DrawablePartsRecreated += applySemiBoldToFirstWord; + applySemiBoldToFirstWord(part.Drawables); - ITextPart part = headerText.AddText(text, t => + void applySemiBoldToFirstWord(IEnumerable d) { - if (wordIndex == 0) - t.Font = t.Font.With(weight: FontWeight.SemiBold); - wordIndex += 1; - }); - - // Reset the index so that if the parts are refreshed (e.g. through changes in localisation) the correct word is re-emboldened. - part.DrawablePartsRecreated += _ => wordIndex = 0; + if (d.FirstOrDefault() is OsuSpriteText firstWord) + firstWord.Font = firstWord.Font.With(weight: FontWeight.SemiBold); + } } [BackgroundDependencyLoader] From 789a9f4dfa071dacc9157914e93792231d568923 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 14 Mar 2024 11:01:57 +0900 Subject: [PATCH 376/508] Initial redesign following flyte's design --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 125 +++++++++++------- 1 file changed, 79 insertions(+), 46 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index ba49810b2b..e9dd26a06b 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -3,10 +3,12 @@ using System; 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.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; using osu.Framework.Localisation; using osu.Framework.Threading; using osu.Game.Graphics; @@ -21,7 +23,12 @@ namespace osu.Game.Screens.Play /// public partial class DelayedResumeOverlay : ResumeOverlay { - private const double countdown_time = 800; + private const float outer_size = 200; + private const float inner_size = 150; + private const float progress_stroke_width = 7; + private const float progress_size = inner_size + progress_stroke_width / 2f; + + private const double countdown_time = 3000; protected override LocalisableString Message => string.Empty; @@ -31,9 +38,15 @@ namespace osu.Game.Screens.Play private ScheduledDelegate? scheduledResume; private int countdownCount = 3; private double countdownStartTime; + private bool countdownComplete; - private Drawable content = null!; - private SpriteText countdown = null!; + private Drawable outerContent = null!; + private Container innerContent = null!; + + private Container countdownComponents = null!; + private Drawable countdownBackground = null!; + private SpriteText countdownText = null!; + private CircularProgress countdownProgress = null!; public DelayedResumeOverlay() { @@ -44,44 +57,48 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load() { - Add(content = new CircularContainer + Add(outerContent = new Circle { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Masking = true, - BorderColour = colours.Yellow, - BorderThickness = 2, - Children = new Drawable[] + Size = new Vector2(outer_size), + Colour = Color4.Black.Opacity(0.25f) + }); + + Add(innerContent = new Container + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.Both, + Children = new[] { - new Box - { - Size = new Vector2(250, 40), - Colour = Color4.Black, - Alpha = 0.8f - }, - new Container + countdownBackground = new Circle { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, + Size = new Vector2(inner_size), + Colour = Color4.Black.Opacity(0.25f) + }, + countdownComponents = new Container + { + RelativeSizeAxes = Axes.Both, Children = new Drawable[] { - new FillFlowContainer + countdownProgress = new CircularProgress { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(5), - Colour = colours.Yellow, - Child = countdown = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - UseFullGlyphHeight = false, - AlwaysPresent = true, - Font = OsuFont.Numeric.With(size: 20, fixedWidth: true) - }, + Size = new Vector2(progress_size), + InnerRadius = progress_stroke_width / progress_size, + RoundedCaps = true + }, + countdownText = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + UseFullGlyphHeight = false, + AlwaysPresent = true, + Font = OsuFont.Torus.With(size: 70, weight: FontWeight.Light) } } } @@ -93,14 +110,26 @@ namespace osu.Game.Screens.Play { this.FadeIn(); - content.FadeInFromZero(150, Easing.OutQuint); - content.ScaleTo(new Vector2(1.5f, 1)).Then().ScaleTo(1, 150, Easing.OutElasticQuarter); + // The transition effects. + outerContent.FadeIn().ScaleTo(Vector2.Zero).Then().ScaleTo(Vector2.One, 200, Easing.OutQuint); + innerContent.FadeIn().ScaleTo(Vector2.Zero).Then().ScaleTo(Vector2.One, 400, Easing.OutElasticHalf); + countdownComponents.FadeOut().Then().Delay(50).FadeTo(1, 100); + // Reset states for various components. + countdownBackground.FadeIn(); + countdownText.FadeIn(); + countdownProgress.FadeIn().ScaleTo(1); + + countdownComplete = false; countdownCount = 3; countdownStartTime = Time.Current; scheduledResume?.Cancel(); - scheduledResume = Scheduler.AddDelayed(Resume, countdown_time); + scheduledResume = Scheduler.AddDelayed(() => + { + countdownComplete = true; + Resume(); + }, countdown_time); } protected override void Update() @@ -114,20 +143,14 @@ namespace osu.Game.Screens.Play double amountTimePassed = Math.Min(countdown_time, Time.Current - countdownStartTime) / countdown_time; int newCount = 3 - (int)Math.Floor(amountTimePassed * 3); - if (newCount > 0) - { - countdown.Alpha = 1; - countdown.Text = newCount.ToString(); - } - else - countdown.Alpha = 0; + countdownProgress.Current.Value = amountTimePassed; + countdownText.Text = Math.Max(1, newCount).ToString(); + countdownProgress.InnerRadius = progress_stroke_width / progress_size / countdownProgress.Scale.X; - if (newCount != countdownCount) + if (countdownCount != newCount && newCount > 0) { - if (newCount == 0) - content.ScaleTo(new Vector2(1.5f, 1), 150, Easing.OutQuint); - else - content.ScaleTo(new Vector2(1.05f, 1), 50, Easing.OutQuint).Then().ScaleTo(1, 50, Easing.Out); + countdownText.ScaleTo(0.25f).Then().ScaleTo(1, 200, Easing.OutQuint); + outerContent.Delay(25).Then().ScaleTo(1.05f, 100).Then().ScaleTo(1f, 200, Easing.Out); } countdownCount = newCount; @@ -135,9 +158,19 @@ namespace osu.Game.Screens.Play protected override void PopOut() { - this.Delay(150).FadeOut(); + this.Delay(300).FadeOut(); - content.FadeOut(150, Easing.OutQuint); + outerContent.FadeOut(); + countdownBackground.FadeOut(); + countdownText.FadeOut(); + + if (countdownComplete) + { + countdownProgress.ScaleTo(2f, 300, Easing.OutQuint); + countdownProgress.Delay(200).FadeOut(100, Easing.Out); + } + else + countdownProgress.FadeOut(); scheduledResume?.Cancel(); } From b431bb11764c4c4088eea49f4cd7f5e7611e4aa9 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 14 Mar 2024 12:24:12 +0900 Subject: [PATCH 377/508] Resolve post-merge issues --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index e9dd26a06b..196ca24358 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -32,9 +32,6 @@ namespace osu.Game.Screens.Play protected override LocalisableString Message => string.Empty; - [Resolved] - private OsuColour colours { get; set; } = null!; - private ScheduledDelegate? scheduledResume; private int countdownCount = 3; private double countdownStartTime; @@ -143,7 +140,7 @@ namespace osu.Game.Screens.Play double amountTimePassed = Math.Min(countdown_time, Time.Current - countdownStartTime) / countdown_time; int newCount = 3 - (int)Math.Floor(amountTimePassed * 3); - countdownProgress.Current.Value = amountTimePassed; + countdownProgress.Progress = amountTimePassed; countdownText.Text = Math.Max(1, newCount).ToString(); countdownProgress.InnerRadius = progress_stroke_width / progress_size / countdownProgress.Scale.X; From b309aad895b001e042ec85f2c6103457fdd801a1 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 8 Mar 2024 13:13:08 -0800 Subject: [PATCH 378/508] Fix noticeable masking artifact of beatmap cards when already downloaded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Had a similar fix before seeing https://github.com/ppy/osu/pull/20743#discussion_r994955470, but using that diff instead so co-authoring. Co-Authored-By: Bartłomiej Dach --- .../Drawables/Cards/CollapsibleButtonContainer.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs b/osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs index fe2ee8c7cc..32df1755a7 100644 --- a/osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs +++ b/osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs @@ -77,7 +77,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards downloadTracker, background = new Container { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.Y, Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, Child = new Box @@ -165,9 +165,11 @@ namespace osu.Game.Beatmaps.Drawables.Cards private void updateState() { - float targetWidth = Width - (ShowDetails.Value ? ButtonsExpandedWidth : ButtonsCollapsedWidth); + float buttonAreaWidth = ShowDetails.Value ? ButtonsExpandedWidth : ButtonsCollapsedWidth; + float mainAreaWidth = Width - buttonAreaWidth; - mainArea.ResizeWidthTo(targetWidth, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); + mainArea.ResizeWidthTo(mainAreaWidth, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); + background.ResizeWidthTo(buttonAreaWidth + BeatmapCard.CORNER_RADIUS, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); background.FadeColour(downloadTracker.State.Value == DownloadState.LocallyAvailable ? colours.Lime0 : colourProvider.Background3, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); buttons.FadeTo(ShowDetails.Value ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); From b4cee12db96644a8364ed1525aea51f526c1dcb6 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 14 Mar 2024 09:21:29 +0300 Subject: [PATCH 379/508] Use defined colours for counter background --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index 196ca24358..c6cfeca142 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -3,7 +3,6 @@ using System; using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -13,8 +12,8 @@ using osu.Framework.Localisation; using osu.Framework.Threading; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Overlays; using osuTK; -using osuTK.Graphics; namespace osu.Game.Screens.Play { @@ -54,12 +53,15 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load() { + // todo: this shouldn't define its own colour provider, but nothing in Player screen does, so let's do that for now. + var colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + Add(outerContent = new Circle { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(outer_size), - Colour = Color4.Black.Opacity(0.25f) + Colour = colourProvider.Background6, }); Add(innerContent = new Container @@ -74,7 +76,7 @@ namespace osu.Game.Screens.Play Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(inner_size), - Colour = Color4.Black.Opacity(0.25f) + Colour = colourProvider.Background4, }, countdownComponents = new Container { From f8a841e907e9b2deb3ca08c425a0e665a5c07775 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 14 Mar 2024 00:17:22 -0700 Subject: [PATCH 380/508] Add comment explaining why width is limited to the button area Same comment as https://github.com/ppy/osu/blob/a47ccb8edd2392258b6b7e176b222a9ecd511fc0/osu.Game/Screens/Select/BeatmapInfoWedgeV2.cs#L91-L92. --- osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs b/osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs index 32df1755a7..a29724032e 100644 --- a/osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs +++ b/osu.Game/Beatmaps/Drawables/Cards/CollapsibleButtonContainer.cs @@ -169,6 +169,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards float mainAreaWidth = Width - buttonAreaWidth; mainArea.ResizeWidthTo(mainAreaWidth, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); + + // By limiting the width we avoid this box showing up as an outline around the drawables that are on top of it. background.ResizeWidthTo(buttonAreaWidth + BeatmapCard.CORNER_RADIUS, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); background.FadeColour(downloadTracker.State.Value == DownloadState.LocallyAvailable ? colours.Lime0 : colourProvider.Background3, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); From 42bd558d7c159857ca7356b8485d710802685fc6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Mar 2024 22:41:29 +0800 Subject: [PATCH 381/508] Only update text when necessary (reducing unnecessary string allocadtions) --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index c6cfeca142..468e67901d 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play protected override LocalisableString Message => string.Empty; private ScheduledDelegate? scheduledResume; - private int countdownCount = 3; + private int? countdownCount; private double countdownStartTime; private bool countdownComplete; @@ -120,7 +120,7 @@ namespace osu.Game.Screens.Play countdownProgress.FadeIn().ScaleTo(1); countdownComplete = false; - countdownCount = 3; + countdownCount = null; countdownStartTime = Time.Current; scheduledResume?.Cancel(); @@ -143,11 +143,11 @@ namespace osu.Game.Screens.Play int newCount = 3 - (int)Math.Floor(amountTimePassed * 3); countdownProgress.Progress = amountTimePassed; - countdownText.Text = Math.Max(1, newCount).ToString(); countdownProgress.InnerRadius = progress_stroke_width / progress_size / countdownProgress.Scale.X; if (countdownCount != newCount && newCount > 0) { + countdownText.Text = Math.Max(1, newCount).ToString(); countdownText.ScaleTo(0.25f).Then().ScaleTo(1, 200, Easing.OutQuint); outerContent.Delay(25).Then().ScaleTo(1.05f, 100).Then().ScaleTo(1f, 200, Easing.Out); } From d7769ec3e25cc985fea44e6fb0d02ab668e2dd33 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Mar 2024 22:38:59 +0800 Subject: [PATCH 382/508] Adjust animation --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index 468e67901d..7c34050bbf 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -112,7 +112,7 @@ namespace osu.Game.Screens.Play // The transition effects. outerContent.FadeIn().ScaleTo(Vector2.Zero).Then().ScaleTo(Vector2.One, 200, Easing.OutQuint); innerContent.FadeIn().ScaleTo(Vector2.Zero).Then().ScaleTo(Vector2.One, 400, Easing.OutElasticHalf); - countdownComponents.FadeOut().Then().Delay(50).FadeTo(1, 100); + countdownComponents.FadeOut().Delay(50).FadeTo(1, 100); // Reset states for various components. countdownBackground.FadeIn(); @@ -166,7 +166,7 @@ namespace osu.Game.Screens.Play if (countdownComplete) { countdownProgress.ScaleTo(2f, 300, Easing.OutQuint); - countdownProgress.Delay(200).FadeOut(100, Easing.Out); + countdownProgress.FadeOut(100, Easing.Out); } else countdownProgress.FadeOut(); From 888245b44fa13e46a7fb23b4a801f3fd36d38fee Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Mar 2024 22:44:26 +0800 Subject: [PATCH 383/508] Reorder methods --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index 7c34050bbf..4b703ec3cf 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -131,6 +131,25 @@ namespace osu.Game.Screens.Play }, countdown_time); } + protected override void PopOut() + { + this.Delay(300).FadeOut(); + + outerContent.FadeOut(); + countdownBackground.FadeOut(); + countdownText.FadeOut(); + + if (countdownComplete) + { + countdownProgress.ScaleTo(2f, 300, Easing.OutQuint); + countdownProgress.FadeOut(100, Easing.Out); + } + else + countdownProgress.FadeOut(); + + scheduledResume?.Cancel(); + } + protected override void Update() { base.Update(); @@ -154,24 +173,5 @@ namespace osu.Game.Screens.Play countdownCount = newCount; } - - protected override void PopOut() - { - this.Delay(300).FadeOut(); - - outerContent.FadeOut(); - countdownBackground.FadeOut(); - countdownText.FadeOut(); - - if (countdownComplete) - { - countdownProgress.ScaleTo(2f, 300, Easing.OutQuint); - countdownProgress.FadeOut(100, Easing.Out); - } - else - countdownProgress.FadeOut(); - - scheduledResume?.Cancel(); - } } } From 2845303a74986d4310d7fb4a77b56a1bd980a8d3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Mar 2024 22:44:57 +0800 Subject: [PATCH 384/508] Fix non-matching scale outwards animation --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index 4b703ec3cf..c3c98510e3 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -142,7 +142,7 @@ namespace osu.Game.Screens.Play if (countdownComplete) { countdownProgress.ScaleTo(2f, 300, Easing.OutQuint); - countdownProgress.FadeOut(100, Easing.Out); + countdownProgress.FadeOut(300, Easing.OutQuint); } else countdownProgress.FadeOut(); From 23975d4dd162b503ccb0e79f0c0d570c5606f901 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Mar 2024 22:49:53 +0800 Subject: [PATCH 385/508] Add flash and reduce overall time for countdown to 2 seconds --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index c3c98510e3..fd1ce5d829 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -22,12 +22,15 @@ namespace osu.Game.Screens.Play /// public partial class DelayedResumeOverlay : ResumeOverlay { + // todo: this shouldn't define its own colour provider, but nothing in Player screen does, so let's do that for now. + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + private const float outer_size = 200; private const float inner_size = 150; private const float progress_stroke_width = 7; private const float progress_size = inner_size + progress_stroke_width / 2f; - private const double countdown_time = 3000; + private const double countdown_time = 2000; protected override LocalisableString Message => string.Empty; @@ -53,9 +56,6 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load() { - // todo: this shouldn't define its own colour provider, but nothing in Player screen does, so let's do that for now. - var colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); - Add(outerContent = new Circle { Anchor = Anchor.Centre, @@ -169,6 +169,8 @@ namespace osu.Game.Screens.Play countdownText.Text = Math.Max(1, newCount).ToString(); countdownText.ScaleTo(0.25f).Then().ScaleTo(1, 200, Easing.OutQuint); outerContent.Delay(25).Then().ScaleTo(1.05f, 100).Then().ScaleTo(1f, 200, Easing.Out); + + countdownBackground.FlashColour(colourProvider.Background3, 400, Easing.Out); } countdownCount = newCount; From 1aa695add9db68d3aef453f476486209a3aeb5f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 09:14:17 +0100 Subject: [PATCH 386/508] Implement alternate design of player loader disclaimers --- .../Screens/Play/PlayerLoaderDisclaimer.cs | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs diff --git a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs new file mode 100644 index 0000000000..c8112055c8 --- /dev/null +++ b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs @@ -0,0 +1,67 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Localisation; +using osu.Game.Graphics; +using osu.Game.Overlays; +using osuTK; + +namespace osu.Game.Screens.Play +{ + public partial class PlayerLoaderDisclaimer : CompositeDrawable + { + private readonly LocalisableString title; + private readonly LocalisableString content; + + public PlayerLoaderDisclaimer(LocalisableString title, LocalisableString content) + { + this.title = title; + this.content = content; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Width = SettingsToolboxGroup.CONTAINER_WIDTH; + AutoSizeAxes = Axes.Y; + + InternalChildren = new Drawable[] + { + new Circle + { + Width = 7, + Height = 15, + Margin = new MarginPadding { Top = 2 }, + Colour = colours.Orange1, + }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Left = 12 }, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Children = new[] + { + new TextFlowContainer(t => t.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17)) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Text = title, + }, + new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 16)) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Text = content, + } + } + } + }; + } + } +} From 42ae18976ff4287567f1b69c27d27215353573a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 09:27:33 +0100 Subject: [PATCH 387/508] Replace existing epilepsy warning with inline display --- .../Visual/Gameplay/TestScenePlayerLoader.cs | 35 +----- osu.Game/Screens/Play/EpilepsyWarning.cs | 102 ------------------ osu.Game/Screens/Play/PlayerLoader.cs | 67 +++++------- 3 files changed, 26 insertions(+), 178 deletions(-) delete mode 100644 osu.Game/Screens/Play/EpilepsyWarning.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index c6827d4197..dac8545729 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -334,13 +334,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("wait for current", () => loader.IsCurrentScreen()); - AddAssert($"epilepsy warning {(warning ? "present" : "absent")}", () => (getWarning() != null) == warning); - - if (warning) - { - AddUntilStep("sound volume decreased", () => Beatmap.Value.Track.AggregateVolume.Value == 0.25); - AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1); - } + AddAssert($"epilepsy warning {(warning ? "present" : "absent")}", () => this.ChildrenOfType().Count(), () => Is.EqualTo(warning ? 1 : 0)); restoreVolumes(); } @@ -357,30 +351,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("wait for current", () => loader.IsCurrentScreen()); - AddUntilStep("epilepsy warning absent", () => getWarning() == null); - - restoreVolumes(); - } - - [Test] - public void TestEpilepsyWarningEarlyExit() - { - saveVolumes(); - setFullVolume(); - - AddStep("enable storyboards", () => config.SetValue(OsuSetting.ShowStoryboard, true)); - AddStep("set epilepsy warning", () => epilepsyWarning = true); - AddStep("load dummy beatmap", () => resetPlayer(false)); - - AddUntilStep("wait for current", () => loader.IsCurrentScreen()); - - AddUntilStep("wait for epilepsy warning", () => getWarning().Alpha > 0); - AddUntilStep("warning is shown", () => getWarning().State.Value == Visibility.Visible); - - AddStep("exit early", () => loader.Exit()); - - AddUntilStep("warning is hidden", () => getWarning().State.Value == Visibility.Hidden); - AddUntilStep("sound volume restored", () => Beatmap.Value.Track.AggregateVolume.Value == 1); + AddUntilStep("epilepsy warning absent", () => this.ChildrenOfType().Single().Alpha, () => Is.Zero); restoreVolumes(); } @@ -479,8 +450,6 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("click notification", () => notification.TriggerClick()); } - private EpilepsyWarning getWarning() => loader.ChildrenOfType().SingleOrDefault(w => w.IsAlive); - private partial class TestPlayerLoader : PlayerLoader { public new VisualSettings VisualSettings => base.VisualSettings; diff --git a/osu.Game/Screens/Play/EpilepsyWarning.cs b/osu.Game/Screens/Play/EpilepsyWarning.cs deleted file mode 100644 index 6316bbdb4e..0000000000 --- a/osu.Game/Screens/Play/EpilepsyWarning.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -#nullable disable - -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; -using osu.Game.Graphics; -using osu.Game.Graphics.Containers; -using osu.Game.Screens.Backgrounds; -using osuTK; - -namespace osu.Game.Screens.Play -{ - public partial class EpilepsyWarning : VisibilityContainer - { - public const double FADE_DURATION = 250; - - public EpilepsyWarning() - { - RelativeSizeAxes = Axes.Both; - Alpha = 0f; - } - - private BackgroundScreenBeatmap dimmableBackground; - - public BackgroundScreenBeatmap DimmableBackground - { - get => dimmableBackground; - set - { - dimmableBackground = value; - - if (IsLoaded) - updateBackgroundFade(); - } - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - Children = new Drawable[] - { - new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new Drawable[] - { - new SpriteIcon - { - Colour = colours.Yellow, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Icon = FontAwesome.Solid.ExclamationTriangle, - Size = new Vector2(50), - }, - new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 25)) - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - TextAnchor = Anchor.Centre, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }.With(tfc => - { - tfc.AddText("This beatmap contains scenes with "); - tfc.AddText("rapidly flashing colours", s => - { - s.Font = s.Font.With(weight: FontWeight.Bold); - s.Colour = colours.Yellow; - }); - tfc.AddText("."); - - tfc.NewParagraph(); - tfc.AddText("Please take caution if you are affected by epilepsy."); - }), - } - } - }; - } - - protected override void PopIn() - { - updateBackgroundFade(); - - this.FadeIn(FADE_DURATION, Easing.OutQuint); - } - - private void updateBackgroundFade() - { - DimmableBackground?.FadeColour(OsuColour.Gray(0.5f), FADE_DURATION, Easing.OutQuint); - } - - protected override void PopOut() => this.FadeOut(FADE_DURATION); - } -} diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index aa730a8e0f..75240ba2ba 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -71,6 +71,7 @@ namespace osu.Game.Screens.Play protected Task? DisposalTask { get; private set; } + private FillFlowContainer disclaimers = null!; private OsuScrollContainer settingsScroll = null!; private Bindable showStoryboards = null!; @@ -137,7 +138,7 @@ namespace osu.Game.Screens.Play private ScheduledDelegate? scheduledPushPlayer; - private EpilepsyWarning? epilepsyWarning; + private PlayerLoaderDisclaimer? epilepsyWarning; private bool quickRestart; @@ -188,6 +189,16 @@ namespace osu.Game.Screens.Play Origin = Anchor.Centre, }, }), + disclaimers = new FillFlowContainer + { + Anchor = Anchor.TopLeft, + Origin = Anchor.TopLeft, + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Vertical, + Padding = new MarginPadding(padding), + Spacing = new Vector2(padding), + }, settingsScroll = new OsuScrollContainer { Anchor = Anchor.TopRight, @@ -216,11 +227,7 @@ namespace osu.Game.Screens.Play if (Beatmap.Value.BeatmapInfo.EpilepsyWarning) { - AddInternal(epilepsyWarning = new EpilepsyWarning - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }); + disclaimers.Add(epilepsyWarning = new PlayerLoaderDisclaimer("This beatmap contains scenes with rapidly flashing colours", "Please take caution if you are affected by epilepsy.")); } } @@ -229,6 +236,9 @@ namespace osu.Game.Screens.Play base.LoadComplete(); inputManager = GetContainingInputManager(); + + showStoryboards.BindValueChanged(val => epilepsyWarning?.FadeTo(val.NewValue ? 1 : 0, 250, Easing.OutQuint), true); + epilepsyWarning?.FinishTransforms(true); } #region Screen handling @@ -237,15 +247,10 @@ namespace osu.Game.Screens.Play { base.OnEntering(e); - ApplyToBackground(b => - { - if (epilepsyWarning != null) - epilepsyWarning.DimmableBackground = b; - }); - Beatmap.Value.Track.AddAdjustment(AdjustableProperty.Volume, volumeAdjustment); - // Start off-screen. + // Start side content off-screen. + disclaimers.MoveToX(-disclaimers.DrawWidth); settingsScroll.MoveToX(settingsScroll.DrawWidth); content.ScaleTo(0.7f); @@ -301,9 +306,6 @@ namespace osu.Game.Screens.Play cancelLoad(); ContentOut(); - // If the load sequence was interrupted, the epilepsy warning may already be displayed (or in the process of being displayed). - epilepsyWarning?.Hide(); - // Ensure the screen doesn't expire until all the outwards fade operations have completed. this.Delay(CONTENT_OUT_DURATION).FadeOut(); @@ -433,6 +435,8 @@ namespace osu.Game.Screens.Play content.FadeInFromZero(500, Easing.OutQuint); content.ScaleTo(1, 650, Easing.OutQuint).Then().Schedule(prepareNewPlayer); + disclaimers.FadeInFromZero(500, Easing.Out) + .MoveToX(0, 500, Easing.OutQuint); settingsScroll.FadeInFromZero(500, Easing.Out) .MoveToX(0, 500, Easing.OutQuint); @@ -466,6 +470,8 @@ namespace osu.Game.Screens.Play lowPassFilter = null; }); + disclaimers.FadeOut(CONTENT_OUT_DURATION, Easing.Out) + .MoveToX(-disclaimers.DrawWidth, CONTENT_OUT_DURATION * 2, Easing.OutQuint); settingsScroll.FadeOut(CONTENT_OUT_DURATION, Easing.OutQuint) .MoveToX(settingsScroll.DrawWidth, CONTENT_OUT_DURATION * 2, Easing.OutQuint); @@ -503,33 +509,8 @@ namespace osu.Game.Screens.Play TransformSequence pushSequence = this.Delay(0); - // only show if the warning was created (i.e. the beatmap needs it) - // and this is not a restart of the map (the warning expires after first load). - // - // note the late check of storyboard enable as the user may have just changed it - // from the settings on the loader screen. - if (epilepsyWarning?.IsAlive == true && showStoryboards.Value) - { - const double epilepsy_display_length = 3000; - - pushSequence - .Delay(CONTENT_OUT_DURATION) - .Schedule(() => epilepsyWarning.State.Value = Visibility.Visible) - .TransformBindableTo(volumeAdjustment, 0.25, EpilepsyWarning.FADE_DURATION, Easing.OutQuint) - .Delay(epilepsy_display_length) - .Schedule(() => - { - epilepsyWarning.Hide(); - epilepsyWarning.Expire(); - }) - .Delay(EpilepsyWarning.FADE_DURATION); - } - else - { - // This goes hand-in-hand with the restoration of low pass filter in contentOut(). - this.TransformBindableTo(volumeAdjustment, 0, CONTENT_OUT_DURATION, Easing.OutCubic); - epilepsyWarning?.Expire(); - } + // This goes hand-in-hand with the restoration of low pass filter in contentOut(). + this.TransformBindableTo(volumeAdjustment, 0, CONTENT_OUT_DURATION, Easing.OutCubic); pushSequence.Schedule(() => { From f3a444b7aca2295e92d473e7fe84a23aefd239b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 09:41:37 +0100 Subject: [PATCH 388/508] Add disclaimer for loved/qualified status --- .../Visual/Gameplay/TestScenePlayerLoader.cs | 43 ++++++++++++++++++- osu.Game/Screens/Play/PlayerLoader.cs | 12 ++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index dac8545729..91e35b067b 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -16,6 +16,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Screens; using osu.Framework.Testing; using osu.Framework.Utils; +using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; @@ -37,6 +38,7 @@ namespace osu.Game.Tests.Visual.Gameplay private TestPlayer player; private bool epilepsyWarning; + private BeatmapOnlineStatus onlineStatus; [Resolved] private AudioManager audioManager { get; set; } @@ -118,8 +120,9 @@ namespace osu.Game.Tests.Visual.Gameplay // Add intro time to test quick retry skipping (TestQuickRetry). workingBeatmap.BeatmapInfo.AudioLeadIn = 60000; - // Turn on epilepsy warning to test warning display (TestEpilepsyWarning). + // Set up data for testing disclaimer display. workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning; + workingBeatmap.BeatmapInfo.Status = onlineStatus; Beatmap.Value = workingBeatmap; @@ -356,6 +359,44 @@ namespace osu.Game.Tests.Visual.Gameplay restoreVolumes(); } + [TestCase(BeatmapOnlineStatus.Loved, 1)] + [TestCase(BeatmapOnlineStatus.Qualified, 1)] + [TestCase(BeatmapOnlineStatus.Graveyard, 0)] + public void TestStatusWarning(BeatmapOnlineStatus status, int expectedDisclaimerCount) + { + saveVolumes(); + setFullVolume(); + + AddStep("enable storyboards", () => config.SetValue(OsuSetting.ShowStoryboard, true)); + AddStep("disable epilepsy warning", () => epilepsyWarning = false); + AddStep("set beatmap status", () => onlineStatus = status); + AddStep("load dummy beatmap", () => resetPlayer(false)); + + AddUntilStep("wait for current", () => loader.IsCurrentScreen()); + + AddAssert($"disclaimer count is {expectedDisclaimerCount}", () => this.ChildrenOfType().Count(), () => Is.EqualTo(expectedDisclaimerCount)); + + restoreVolumes(); + } + + [Test] + public void TestCombinedWarnings() + { + saveVolumes(); + setFullVolume(); + + AddStep("enable storyboards", () => config.SetValue(OsuSetting.ShowStoryboard, true)); + AddStep("disable epilepsy warning", () => epilepsyWarning = true); + AddStep("set beatmap status", () => onlineStatus = BeatmapOnlineStatus.Loved); + AddStep("load dummy beatmap", () => resetPlayer(false)); + + AddUntilStep("wait for current", () => loader.IsCurrentScreen()); + + AddAssert($"disclaimer count is 2", () => this.ChildrenOfType().Count(), () => Is.EqualTo(2)); + + restoreVolumes(); + } + [TestCase(true, 1.0, false)] // on battery, above cutoff --> no warning [TestCase(false, 0.1, false)] // not on battery, below cutoff --> no warning [TestCase(true, 0.25, true)] // on battery, at cutoff --> warning diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 75240ba2ba..2d75b69b4a 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -18,6 +18,7 @@ using osu.Framework.Threading; using osu.Framework.Utils; using osu.Game.Audio; using osu.Game.Audio.Effects; +using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; @@ -229,6 +230,17 @@ namespace osu.Game.Screens.Play { disclaimers.Add(epilepsyWarning = new PlayerLoaderDisclaimer("This beatmap contains scenes with rapidly flashing colours", "Please take caution if you are affected by epilepsy.")); } + + switch (Beatmap.Value.BeatmapInfo.Status) + { + case BeatmapOnlineStatus.Loved: + disclaimers.Add(new PlayerLoaderDisclaimer("This beatmap is loved", "No performance points will be awarded.\nLeaderboards may be reset by the beatmap creator.")); + break; + + case BeatmapOnlineStatus.Qualified: + disclaimers.Add(new PlayerLoaderDisclaimer("This beatmap is qualified", "No performance points will be awarded.\nLeaderboards will be reset when the beatmap is ranked.")); + break; + } } protected override void LoadComplete() From 4688a53cf435861af05f8253d029f30a4e5db342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 09:43:09 +0100 Subject: [PATCH 389/508] Stay on player loader a bit longer if disclaimers are present Just to make reading the text easier. --- osu.Game/Screens/Play/PlayerLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 2d75b69b4a..29ad6d2a47 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play protected const double CONTENT_OUT_DURATION = 300; - protected virtual double PlayerPushDelay => 1800; + protected virtual double PlayerPushDelay => 1800 + disclaimers.Count * 500; public override bool HideOverlaysOnEnter => hideOverlays; From 4e2098adb86c73f8391255331c08dc5349567e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 09:46:18 +0100 Subject: [PATCH 390/508] Fix test crosstalk --- .../Visual/Gameplay/TestScenePlayerLoader.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index 91e35b067b..0ec4284a00 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -37,8 +37,8 @@ namespace osu.Game.Tests.Visual.Gameplay private TestPlayerLoader loader; private TestPlayer player; - private bool epilepsyWarning; - private BeatmapOnlineStatus onlineStatus; + private bool? epilepsyWarning; + private BeatmapOnlineStatus? onlineStatus; [Resolved] private AudioManager audioManager { get; set; } @@ -83,7 +83,12 @@ namespace osu.Game.Tests.Visual.Gameplay } [SetUp] - public void Setup() => Schedule(() => player = null); + public void Setup() => Schedule(() => + { + player = null; + epilepsyWarning = null; + onlineStatus = null; + }); [SetUpSteps] public override void SetUpSteps() @@ -121,8 +126,8 @@ namespace osu.Game.Tests.Visual.Gameplay workingBeatmap.BeatmapInfo.AudioLeadIn = 60000; // Set up data for testing disclaimer display. - workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning; - workingBeatmap.BeatmapInfo.Status = onlineStatus; + workingBeatmap.BeatmapInfo.EpilepsyWarning = epilepsyWarning ?? false; + workingBeatmap.BeatmapInfo.Status = onlineStatus ?? BeatmapOnlineStatus.Ranked; Beatmap.Value = workingBeatmap; From 49a087f7fcf764fe4764e4dff0c178287f2dc5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 10:58:00 +0100 Subject: [PATCH 391/508] Add localisation support --- osu.Game/Localisation/PlayerLoaderStrings.cs | 48 ++++++++++++++++++++ osu.Game/Screens/Play/PlayerLoader.cs | 6 +-- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Localisation/PlayerLoaderStrings.cs diff --git a/osu.Game/Localisation/PlayerLoaderStrings.cs b/osu.Game/Localisation/PlayerLoaderStrings.cs new file mode 100644 index 0000000000..eba98c7aa7 --- /dev/null +++ b/osu.Game/Localisation/PlayerLoaderStrings.cs @@ -0,0 +1,48 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Localisation; + +namespace osu.Game.Localisation +{ + public static class PlayerLoaderStrings + { + private const string prefix = @"osu.Game.Resources.Localisation.PlayerLoader"; + + /// + /// "This beatmap contains scenes with rapidly flashing colours" + /// + public static LocalisableString EpilepsyWarningTitle => new TranslatableString(getKey(@"epilepsy_warning_title"), @"This beatmap contains scenes with rapidly flashing colours"); + + /// + /// "Please take caution if you are affected by epilepsy." + /// + public static LocalisableString EpilepsyWarningContent => new TranslatableString(getKey(@"epilepsy_warning_content"), @"Please take caution if you are affected by epilepsy."); + + /// + /// "This beatmap is loved" + /// + public static LocalisableString LovedBeatmapDisclaimerTitle => new TranslatableString(getKey(@"loved_beatmap_disclaimer_title"), @"This beatmap is loved"); + + /// + /// "No performance points will be awarded. + /// Leaderboards may be reset by the beatmap creator." + /// + public static LocalisableString LovedBeatmapDisclaimerContent => new TranslatableString(getKey(@"loved_beatmap_disclaimer_content"), @"No performance points will be awarded. +Leaderboards may be reset by the beatmap creator."); + + /// + /// "This beatmap is qualified" + /// + public static LocalisableString QualifiedBeatmapDisclaimerTitle => new TranslatableString(getKey(@"qualified_beatmap_disclaimer_title"), @"This beatmap is qualified"); + + /// + /// "No performance points will be awarded. + /// Leaderboards will be reset when the beatmap is ranked." + /// + public static LocalisableString QualifiedBeatmapDisclaimerContent => new TranslatableString(getKey(@"qualified_beatmap_disclaimer_content"), @"No performance points will be awarded. +Leaderboards will be reset when the beatmap is ranked."); + + private static string getKey(string key) => $@"{prefix}:{key}"; + } +} diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 29ad6d2a47..ad9814e8c9 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -228,17 +228,17 @@ namespace osu.Game.Screens.Play if (Beatmap.Value.BeatmapInfo.EpilepsyWarning) { - disclaimers.Add(epilepsyWarning = new PlayerLoaderDisclaimer("This beatmap contains scenes with rapidly flashing colours", "Please take caution if you are affected by epilepsy.")); + disclaimers.Add(epilepsyWarning = new PlayerLoaderDisclaimer(PlayerLoaderStrings.EpilepsyWarningTitle, PlayerLoaderStrings.EpilepsyWarningContent)); } switch (Beatmap.Value.BeatmapInfo.Status) { case BeatmapOnlineStatus.Loved: - disclaimers.Add(new PlayerLoaderDisclaimer("This beatmap is loved", "No performance points will be awarded.\nLeaderboards may be reset by the beatmap creator.")); + disclaimers.Add(new PlayerLoaderDisclaimer(PlayerLoaderStrings.LovedBeatmapDisclaimerTitle, PlayerLoaderStrings.LovedBeatmapDisclaimerContent)); break; case BeatmapOnlineStatus.Qualified: - disclaimers.Add(new PlayerLoaderDisclaimer("This beatmap is qualified", "No performance points will be awarded.\nLeaderboards will be reset when the beatmap is ranked.")); + disclaimers.Add(new PlayerLoaderDisclaimer(PlayerLoaderStrings.QualifiedBeatmapDisclaimerTitle, PlayerLoaderStrings.QualifiedBeatmapDisclaimerContent)); break; } } From 5513a727488fb1825a2ca60514ab478b92623b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 10:33:32 +0100 Subject: [PATCH 392/508] Improve hiding transition when multiple disclaimers are visible --- osu.Game/Screens/Play/PlayerLoader.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index ad9814e8c9..0cc8ed0f4b 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -194,8 +194,10 @@ namespace osu.Game.Screens.Play { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, - RelativeSizeAxes = Axes.Y, - AutoSizeAxes = Axes.X, + Width = SettingsToolboxGroup.CONTAINER_WIDTH + padding * 2, + AutoSizeAxes = Axes.Y, + AutoSizeDuration = 250, + AutoSizeEasing = Easing.OutQuint, Direction = FillDirection.Vertical, Padding = new MarginPadding(padding), Spacing = new Vector2(padding), From 87682008fd0de936edb734c69d49cb0e7e4c4b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 11:26:48 +0100 Subject: [PATCH 393/508] Fix code quality inspection --- osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index 0ec4284a00..4b00a86950 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -397,7 +397,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddUntilStep("wait for current", () => loader.IsCurrentScreen()); - AddAssert($"disclaimer count is 2", () => this.ChildrenOfType().Count(), () => Is.EqualTo(2)); + AddAssert("disclaimer count is 2", () => this.ChildrenOfType().Count(), () => Is.EqualTo(2)); restoreVolumes(); } From 51568ba06a0465b3e3c3de13f4d9ce885c6e82ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 11:31:45 +0100 Subject: [PATCH 394/508] Add background to disclaimers --- .../Screens/Play/PlayerLoaderDisclaimer.cs | 52 ++++++++++++------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs index c8112055c8..b41a2d3112 100644 --- a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs +++ b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs @@ -24,40 +24,56 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, OverlayColourProvider colourProvider) { - Width = SettingsToolboxGroup.CONTAINER_WIDTH; + RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; + Masking = true; + CornerRadius = 5; InternalChildren = new Drawable[] { - new Circle + new Box { - Width = 7, - Height = 15, - Margin = new MarginPadding { Top = 2 }, - Colour = colours.Orange1, + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background4, }, - new FillFlowContainer + new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Left = 12 }, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0, 2), - Children = new[] + Padding = new MarginPadding(10), + Children = new Drawable[] { - new TextFlowContainer(t => t.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17)) + new Circle { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Text = title, + Width = 7, + Height = 15, + Margin = new MarginPadding { Top = 2 }, + Colour = colours.Orange1, }, - new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 16)) + new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Text = content, + Padding = new MarginPadding { Left = 12 }, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 2), + Children = new[] + { + new TextFlowContainer(t => t.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17)) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Text = title, + }, + new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 16)) + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Text = content, + } + } } } } From e6883b841802c5a8689ca80b13ca277022901b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 11:38:51 +0100 Subject: [PATCH 395/508] Tweak visuals further --- osu.Game/Screens/Play/PlayerLoader.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 0cc8ed0f4b..196180f3dd 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -200,7 +200,7 @@ namespace osu.Game.Screens.Play AutoSizeEasing = Easing.OutQuint, Direction = FillDirection.Vertical, Padding = new MarginPadding(padding), - Spacing = new Vector2(padding), + Spacing = new Vector2(20), }, settingsScroll = new OsuScrollContainer { @@ -269,9 +269,12 @@ namespace osu.Game.Screens.Play content.ScaleTo(0.7f); - contentIn(); + const double metadata_delay = 750; - MetadataInfo.Delay(750).FadeIn(500, Easing.OutQuint); + contentIn(); + MetadataInfo.Delay(metadata_delay).FadeIn(500, Easing.OutQuint); + disclaimers.Delay(metadata_delay).FadeInFromZero(500, Easing.Out) + .MoveToX(0, 500, Easing.OutQuint); // after an initial delay, start the debounced load check. // this will continue to execute even after resuming back on restart. @@ -449,8 +452,6 @@ namespace osu.Game.Screens.Play content.FadeInFromZero(500, Easing.OutQuint); content.ScaleTo(1, 650, Easing.OutQuint).Then().Schedule(prepareNewPlayer); - disclaimers.FadeInFromZero(500, Easing.Out) - .MoveToX(0, 500, Easing.OutQuint); settingsScroll.FadeInFromZero(500, Easing.Out) .MoveToX(0, 500, Easing.OutQuint); From a78210c88f6d3d519c4aa884033b3a30e8e82657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Mar 2024 11:45:27 +0100 Subject: [PATCH 396/508] Handle hover so that users can hover disclaimer to block load & read it --- osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs index b41a2d3112..9dd5a3832c 100644 --- a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs +++ b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Overlays; @@ -79,5 +80,8 @@ namespace osu.Game.Screens.Play } }; } + + // handle hover so that users can hover the disclaimer to delay load if they want to read it. + protected override bool OnHover(HoverEvent e) => true; } } From 0f8d526453b1ada099a52fa7d69340b9cb04963f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 16 Mar 2024 10:09:49 +0800 Subject: [PATCH 397/508] Adjust timings and delay disclaimers the same as settings --- osu.Game/Screens/Play/PlayerLoader.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 196180f3dd..75c97d594d 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -269,12 +269,10 @@ namespace osu.Game.Screens.Play content.ScaleTo(0.7f); - const double metadata_delay = 750; + const double metadata_delay = 500; - contentIn(); MetadataInfo.Delay(metadata_delay).FadeIn(500, Easing.OutQuint); - disclaimers.Delay(metadata_delay).FadeInFromZero(500, Easing.Out) - .MoveToX(0, 500, Easing.OutQuint); + contentIn(metadata_delay + 250); // after an initial delay, start the debounced load check. // this will continue to execute even after resuming back on restart. @@ -352,7 +350,7 @@ namespace osu.Game.Screens.Play { if (this.IsCurrentScreen()) content.StartTracking(logo, resuming ? 0 : 500, Easing.InOutExpo); - }, resuming ? 0 : 500); + }, resuming ? 0 : 250); } protected override void LogoExiting(OsuLogo logo) @@ -445,15 +443,21 @@ namespace osu.Game.Screens.Play this.MakeCurrent(); } - private void contentIn() + private void contentIn(double delayBeforeSideDisplays = 0) { MetadataInfo.Loading = true; content.FadeInFromZero(500, Easing.OutQuint); content.ScaleTo(1, 650, Easing.OutQuint).Then().Schedule(prepareNewPlayer); - settingsScroll.FadeInFromZero(500, Easing.Out) - .MoveToX(0, 500, Easing.OutQuint); + using (BeginDelayedSequence(delayBeforeSideDisplays)) + { + settingsScroll.FadeInFromZero(500, Easing.Out) + .MoveToX(0, 500, Easing.OutQuint); + + disclaimers.FadeInFromZero(500, Easing.Out) + .MoveToX(0, 500, Easing.OutQuint); + } AddRangeInternal(new[] { From a49c4ebea634cff84243192ef59e1fa273f5042f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 16 Mar 2024 10:23:21 +0800 Subject: [PATCH 398/508] Match settings panels' backgrounds visually and behaviourally --- .../Screens/Play/PlayerLoaderDisclaimer.cs | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs index 9dd5a3832c..3637a4b210 100644 --- a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs +++ b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs @@ -18,6 +18,8 @@ namespace osu.Game.Screens.Play private readonly LocalisableString title; private readonly LocalisableString content; + private Box background = null!; + public PlayerLoaderDisclaimer(LocalisableString title, LocalisableString content) { this.title = title; @@ -34,10 +36,11 @@ namespace osu.Game.Screens.Play InternalChildren = new Drawable[] { - new Box + background = new Box { RelativeSizeAxes = Axes.Both, Colour = colourProvider.Background4, + Alpha = 0.1f, }, new Container { @@ -81,7 +84,24 @@ namespace osu.Game.Screens.Play }; } - // handle hover so that users can hover the disclaimer to delay load if they want to read it. - protected override bool OnHover(HoverEvent e) => true; + protected override bool OnHover(HoverEvent e) + { + updateFadeState(); + + // handle hover so that users can hover the disclaimer to delay load if they want to read it. + return true; + } + + protected override void OnHoverLost(HoverLostEvent e) + { + updateFadeState(); + base.OnHoverLost(e); + } + + private void updateFadeState() + { + // Matches SettingsToolboxGroup + background.FadeTo(IsHovered ? 1 : 0.1f, (float)500, Easing.OutQuint); + } } } From bde3da2746c4f80e33dd9a632a8a9d95e7bef186 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 16 Mar 2024 11:11:42 +0800 Subject: [PATCH 399/508] Fix failing test --- .../Visual/Background/TestSceneUserDimBackgrounds.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index 204dea39b2..7d517b3155 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -9,6 +9,7 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Extensions; +using osu.Framework.Extensions.PolygonExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; @@ -90,12 +91,13 @@ namespace osu.Game.Tests.Visual.Background AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new LoadBlockingTestPlayer { BlockLoad = true }))); AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false); AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent()); - AddStep("Trigger background preview", () => + + AddUntilStep("Screen is dimmed and blur applied", () => { - InputManager.MoveMouseTo(playerLoader.ScreenPos); InputManager.MoveMouseTo(playerLoader.VisualSettingsPos); + return songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied(); }); - AddUntilStep("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); + AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); AddUntilStep("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.CheckBackgroundBlur(playerLoader.ExpectedBackgroundBlur)); } From a598ea5b97fd467395e901f8dbe08de4b620120b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 16 Mar 2024 12:14:32 +0800 Subject: [PATCH 400/508] Remove unused using statement --- osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index 7d517b3155..c5540eae88 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -9,7 +9,6 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Bindables; using osu.Framework.Extensions; -using osu.Framework.Extensions.PolygonExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; From c0ae94dc60d6ac9df97784760cee4b5e6baa046b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 16 Mar 2024 12:15:12 +0800 Subject: [PATCH 401/508] Attempt to fix test better --- .../Visual/Background/TestSceneUserDimBackgrounds.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index c5540eae88..aac7689b1b 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -89,7 +89,11 @@ namespace osu.Game.Tests.Visual.Background setupUserSettings(); AddStep("Start player loader", () => songSelect.Push(playerLoader = new TestPlayerLoader(player = new LoadBlockingTestPlayer { BlockLoad = true }))); AddUntilStep("Wait for Player Loader to load", () => playerLoader?.IsLoaded ?? false); - AddAssert("Background retained from song select", () => songSelect.IsBackgroundCurrent()); + AddAssert("Background retained from song select", () => + { + InputManager.MoveMouseTo(playerLoader); + return songSelect.IsBackgroundCurrent(); + }); AddUntilStep("Screen is dimmed and blur applied", () => { From 15c0b1a2ec786dbdac2263655229430764f2a1d3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 16 Mar 2024 13:18:42 +0800 Subject: [PATCH 402/508] Remove redundant cast --- osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs index 3637a4b210..592af166ba 100644 --- a/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs +++ b/osu.Game/Screens/Play/PlayerLoaderDisclaimer.cs @@ -101,7 +101,7 @@ namespace osu.Game.Screens.Play private void updateFadeState() { // Matches SettingsToolboxGroup - background.FadeTo(IsHovered ? 1 : 0.1f, (float)500, Easing.OutQuint); + background.FadeTo(IsHovered ? 1 : 0.1f, 500, Easing.OutQuint); } } } From ea3a9314f9dd3bb19fcc0aff6c1b212cf96cc560 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 13 Mar 2024 23:08:00 +0300 Subject: [PATCH 403/508] Improve TimelineControlPointDisplay performance --- .../Timeline/TimelineControlPointDisplay.cs | 104 +++++++++++++----- .../Components/Timeline/TopPointPiece.cs | 6 +- 2 files changed, 78 insertions(+), 32 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs index cd97b293ba..60d113ef58 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs @@ -1,10 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Collections.Specialized; -using System.Diagnostics; -using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Caching; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; @@ -15,6 +14,16 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline /// public partial class TimelineControlPointDisplay : TimelinePart { + [Resolved] + private Timeline? timeline { get; set; } + + /// + /// The visible time/position range of the timeline. + /// + private (float min, float max) visibleRange = (float.MinValue, float.MaxValue); + + private readonly Cached groupCache = new Cached(); + private readonly IBindableList controlPointGroups = new BindableList(); protected override void LoadBeatmap(EditorBeatmap beatmap) @@ -23,34 +32,71 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline controlPointGroups.UnbindAll(); controlPointGroups.BindTo(beatmap.ControlPointInfo.Groups); - controlPointGroups.BindCollectionChanged((_, args) => + controlPointGroups.BindCollectionChanged((_, _) => { - switch (args.Action) - { - case NotifyCollectionChangedAction.Reset: - Clear(); - break; - - case NotifyCollectionChangedAction.Add: - Debug.Assert(args.NewItems != null); - - foreach (var group in args.NewItems.OfType()) - Add(new TimelineControlPointGroup(group)); - break; - - case NotifyCollectionChangedAction.Remove: - Debug.Assert(args.OldItems != null); - - foreach (var group in args.OldItems.OfType()) - { - var matching = Children.SingleOrDefault(gv => ReferenceEquals(gv.Group, group)); - - matching?.Expire(); - } - - break; - } + invalidateGroups(); }, true); } + + protected override void Update() + { + base.Update(); + + if (timeline == null || DrawWidth <= 0) return; + + (float, float) newRange = ( + (ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopLeft).X - TopPointPiece.WIDTH) / DrawWidth * Content.RelativeChildSize.X, + (ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopRight).X) / DrawWidth * Content.RelativeChildSize.X); + + if (visibleRange != newRange) + { + visibleRange = newRange; + invalidateGroups(); + } + + if (!groupCache.IsValid) + recreateDrawableGroups(); + } + + private void invalidateGroups() => groupCache.Invalidate(); + + private void recreateDrawableGroups() + { + // Remove groups outside the visible range + for (int i = Count - 1; i >= 0; i--) + { + var g = Children[i]; + + if (!shouldBeVisible(g.Group)) + g.Expire(); + } + + // Add remaining ones + foreach (var group in controlPointGroups) + { + if (!shouldBeVisible(group)) + continue; + + bool alreadyVisible = false; + + foreach (var g in this) + { + if (ReferenceEquals(g.Group, group)) + { + alreadyVisible = true; + break; + } + } + + if (alreadyVisible) + continue; + + Add(new TimelineControlPointGroup(group)); + } + + groupCache.Validate(); + } + + private bool shouldBeVisible(ControlPointGroup group) => group.Time >= visibleRange.min && group.Time <= visibleRange.max; } } diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TopPointPiece.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TopPointPiece.cs index 243cdc6ddd..a40a805361 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TopPointPiece.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TopPointPiece.cs @@ -19,12 +19,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline protected OsuSpriteText Label { get; private set; } = null!; - private const float width = 80; + public const float WIDTH = 80; public TopPointPiece(ControlPoint point) { Point = point; - Width = width; + Width = WIDTH; Height = 16; Margin = new MarginPadding { Vertical = 4 }; @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline new Container { RelativeSizeAxes = Axes.Y, - Width = width - triangle_portion, + Width = WIDTH - triangle_portion, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Colour = Point.GetRepresentingColour(colours), From e825db61eeebc0e1f94b2f62b6dba30c478dd58a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 16 Mar 2024 12:26:56 +0300 Subject: [PATCH 404/508] Fix enumerator allocation --- .../Components/Timeline/TimelineControlPointDisplay.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs index 60d113ef58..950b717ffb 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs @@ -72,8 +72,10 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline } // Add remaining ones - foreach (var group in controlPointGroups) + for (int i = 0; i < controlPointGroups.Count; i++) { + var group = controlPointGroups[i]; + if (!shouldBeVisible(group)) continue; From 981ee54cdca16653753c85a71192f404cb80e85c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 16 Mar 2024 15:05:52 +0300 Subject: [PATCH 405/508] Fix transforms overhead in TimelineTickDisplay --- .../Edit/Compose/Components/Timeline/TimelineTickDisplay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineTickDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineTickDisplay.cs index 7e7bef8cf2..5348d03a38 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineTickDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineTickDisplay.cs @@ -165,7 +165,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline // save a few drawables beyond the currently used for edge cases. while (drawableIndex < Math.Min(usedDrawables + 16, Count)) - Children[drawableIndex++].Hide(); + Children[drawableIndex++].Alpha = 0; // expire any excess while (drawableIndex < Count) @@ -182,7 +182,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline point = Children[drawableIndex]; drawableIndex++; - point.Show(); + point.Alpha = 1; return point; } From 34a5e2d606070ba043afc501030933bd4f158412 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sat, 16 Mar 2024 15:20:37 +0300 Subject: [PATCH 406/508] Don't update subtree masking in TimelineTickDisplay --- .../Edit/Compose/Components/Timeline/TimelineTickDisplay.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineTickDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineTickDisplay.cs index 5348d03a38..c3adb43032 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineTickDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineTickDisplay.cs @@ -7,6 +7,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Caching; using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; using osu.Framework.Logging; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -18,6 +19,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline { public partial class TimelineTickDisplay : TimelinePart { + // With current implementation every tick in the sub-tree should be visible, no need to check whether they are masked away. + public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false; + [Resolved] private EditorBeatmap beatmap { get; set; } = null!; From 0a6960296ec1947594b06623cfd925433e09d380 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 16 Mar 2024 21:32:55 +0200 Subject: [PATCH 407/508] feat: Support filtering for multiple statuses --- .../Filtering/FilterQueryParserTest.cs | 22 ++++++++++---- osu.Game/Screens/Select/FilterCriteria.cs | 17 ++++++++++- osu.Game/Screens/Select/FilterQueryParser.cs | 29 ++++++++++++++++++- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs index bf888348ee..c109e5bad2 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs @@ -256,8 +256,9 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "status=r"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.AreEqual(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Min); - Assert.AreEqual(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Max); + Assert.IsNotNull(filterCriteria.OnlineStatus.Values); + Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values!); + Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); } [Test] @@ -268,10 +269,19 @@ namespace osu.Game.Tests.NonVisual.Filtering FilterQueryParser.ApplyQueries(filterCriteria, query); Assert.AreEqual("I want the pp", filterCriteria.SearchText.Trim()); Assert.AreEqual(4, filterCriteria.SearchTerms.Length); - Assert.AreEqual(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Min); - Assert.IsTrue(filterCriteria.OnlineStatus.IsLowerInclusive); - Assert.AreEqual(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Max); - Assert.IsTrue(filterCriteria.OnlineStatus.IsUpperInclusive); + Assert.IsNotNull(filterCriteria.OnlineStatus.Values); + Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); + } + + [Test] + public void TestApplyStatusMatches() + { + const string query = "status=ranked status=loved"; + var filterCriteria = new FilterCriteria(); + FilterQueryParser.ApplyQueries(filterCriteria, query); + Assert.IsNotNull(filterCriteria.OnlineStatus.Values); + Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); + Assert.Contains(BeatmapOnlineStatus.Loved, filterCriteria.OnlineStatus.Values); } [TestCase("creator")] diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index 46083f7c88..dd6b602ade 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Select public OptionalRange Length; public OptionalRange BPM; public OptionalRange BeatDivisor; - public OptionalRange OnlineStatus; + public OptionalArray OnlineStatus; public OptionalRange LastPlayed; public OptionalTextFilter Creator; public OptionalTextFilter Artist; @@ -114,6 +114,21 @@ namespace osu.Game.Screens.Select public IRulesetFilterCriteria? RulesetCriteria { get; set; } + public struct OptionalArray : IEquatable> + where T : struct + { + public bool HasFilter => Values?.Length > 0; + + public bool IsInRange(T value) + { + return Values?.Contains(value) ?? false; + } + + public T[]? Values; + + public bool Equals(OptionalArray other) => Values?.SequenceEqual(other.Values ?? Array.Empty()) ?? false; + } + public struct OptionalRange : IEquatable> where T : struct { diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index 2c4077dacf..208e7f559e 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select return TryUpdateCriteriaRange(ref criteria.BeatDivisor, op, value, tryParseInt); case "status": - return TryUpdateCriteriaRange(ref criteria.OnlineStatus, op, value, tryParseEnum); + return TryUpdateArrayRange(ref criteria.OnlineStatus, op, value, tryParseEnum); case "creator": case "author": @@ -300,6 +300,33 @@ namespace osu.Game.Screens.Select where T : struct => parseFunction.Invoke(val, out var converted) && tryUpdateCriteriaRange(ref range, op, converted); + /// + /// Attempts to parse a keyword filter of type , + /// from the specified and . + /// If can be parsed into using , the function returns true + /// and the resulting range constraint is stored into the 's expected values. + /// + /// The to store the parsed data into, if successful. + /// The operator for the keyword filter. Currently, only can be used. + /// The value of the keyword filter. + /// Function used to determine if can be converted to type . + public static bool TryUpdateArrayRange(ref FilterCriteria.OptionalArray range, Operator op, string val, TryParseFunction parseFunction) + where T : struct + => parseFunction.Invoke(val, out var converted) && tryUpdateArrayRange(ref range, op, converted); + + private static bool tryUpdateArrayRange(ref FilterCriteria.OptionalArray range, Operator op, T value) + where T : struct + { + if (op != Operator.Equal) + return false; + + range.Values ??= Array.Empty(); + + range.Values = range.Values.Append(value).ToArray(); + + return true; + } + private static bool tryUpdateCriteriaRange(ref FilterCriteria.OptionalRange range, Operator op, T value) where T : struct { From e1c1609271bee3b21c38383596f20f31c2a3573e Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 16 Mar 2024 21:48:44 +0200 Subject: [PATCH 408/508] chore: correct equal logic --- osu.Game/Screens/Select/FilterCriteria.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index dd6b602ade..6cec7a387d 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -126,7 +126,13 @@ namespace osu.Game.Screens.Select public T[]? Values; - public bool Equals(OptionalArray other) => Values?.SequenceEqual(other.Values ?? Array.Empty()) ?? false; + public bool Equals(OptionalArray other) + { + if (Values is null && other.Values is null) + return true; + + return Values?.SequenceEqual(other.Values ?? Array.Empty()) ?? false; + } } public struct OptionalRange : IEquatable> From 63816adbc081065fe68b9bc20b49b9329c4abbd2 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sat, 16 Mar 2024 21:20:12 -0300 Subject: [PATCH 409/508] Add verify checks to unused audio at the end --- .../Checks/CheckUnusedAudioAtEndTest.cs | 90 +++++++++++++++++++ .../CheckUnusedAudioAtEndStrings.cs | 19 ++++ osu.Game/Rulesets/Edit/BeatmapVerifier.cs | 2 + .../Edit/Checks/CheckUnusedAudioAtEnd.cs | 50 +++++++++++ 4 files changed, 161 insertions(+) create mode 100644 osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs create mode 100644 osu.Game/Localisation/CheckUnusedAudioAtEndStrings.cs create mode 100644 osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs diff --git a/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs b/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs new file mode 100644 index 0000000000..687feae63d --- /dev/null +++ b/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs @@ -0,0 +1,90 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using Moq; +using NUnit.Framework; +using osu.Framework.Timing; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Osu.Objects; +using static osu.Game.Tests.Visual.OsuTestScene.ClockBackedTestWorkingBeatmap; + +namespace osu.Game.Tests.Editing.Checks +{ + public class CheckUnusedAudioTest + { + private CheckUnusedAudioAtEnd check = null!; + + private IBeatmap beatmapNotFullyMapped = null!; + + private IBeatmap beatmapFullyMapped = null!; + + [SetUp] + public void Setup() + { + check = new CheckUnusedAudioAtEnd(); + beatmapNotFullyMapped = new Beatmap + { + HitObjects = + { + new HitCircle { StartTime = 0 }, + new HitCircle { StartTime = 1_298 }, + }, + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata { AudioFile = "abc123.jpg" } + } + }; + beatmapFullyMapped = new Beatmap + { + HitObjects = + { + new HitCircle { StartTime = 0 }, + new HitCircle { StartTime = 9000 }, + }, + BeatmapInfo = new BeatmapInfo + { + Metadata = new BeatmapMetadata { AudioFile = "abc123.jpg" } + } + }; + } + + [Test] + public void TestAudioNotFullyUsed() + { + var context = getContext(beatmapNotFullyMapped); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckUnusedAudioAtEnd.IssueTemplateUnusedAudioAtEnd); + } + + [Test] + public void TestAudioFullyUsed() + { + var context = getContext(beatmapFullyMapped); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + private BeatmapVerifierContext getContext(IBeatmap beatmap) + { + return new BeatmapVerifierContext(beatmap, getMockWorkingBeatmap(beatmap).Object); + } + + private Mock getMockWorkingBeatmap(IBeatmap beatmap) + { + var mockTrack = new TrackVirtualStore(new FramedClock()).GetVirtual(10000, "virtual"); + + var mockWorkingBeatmap = new Mock(); + mockWorkingBeatmap.SetupGet(w => w.Beatmap).Returns(beatmap); + mockWorkingBeatmap.SetupGet(w => w.Track).Returns(mockTrack); + + return mockWorkingBeatmap; + } + } +} diff --git a/osu.Game/Localisation/CheckUnusedAudioAtEndStrings.cs b/osu.Game/Localisation/CheckUnusedAudioAtEndStrings.cs new file mode 100644 index 0000000000..46f92237a9 --- /dev/null +++ b/osu.Game/Localisation/CheckUnusedAudioAtEndStrings.cs @@ -0,0 +1,19 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Localisation; + +namespace osu.Game.Localisation +{ + public static class CheckUnusedAudioAtEndStrings + { + private const string prefix = @"osu.Game.Resources.Localisation.CheckUnusedAudioAtEnd"; + + /// + /// "{0}% of the audio is not mapped." + /// + public static LocalisableString OfTheAudioIsNot(double percentageLeft) => new TranslatableString(getKey(@"of_the_audio_is_not"), @"{0}% of the audio is not mapped.", percentageLeft); + + private static string getKey(string key) => $@"{prefix}:{key}"; + } +} diff --git a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs index dcf5eb4da9..4bba72d828 100644 --- a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs +++ b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs @@ -36,12 +36,14 @@ namespace osu.Game.Rulesets.Edit new CheckConcurrentObjects(), new CheckZeroLengthObjects(), new CheckDrainLength(), + new CheckUnusedAudioAtEnd(), // Timing new CheckPreviewTime(), // Events new CheckBreaks() + }; public IEnumerable Run(BeatmapVerifierContext context) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs new file mode 100644 index 0000000000..c120e0993a --- /dev/null +++ b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs @@ -0,0 +1,50 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using System.Linq; +using osu.Game.Rulesets.Edit.Checks.Components; +using osu.Game.Rulesets.Objects; + +namespace osu.Game.Rulesets.Edit.Checks +{ + public class CheckUnusedAudioAtEnd : ICheck + { + public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Compose, "More than 20% unused audio at the end"); + + public IEnumerable PossibleTemplates => new IssueTemplate[] + { + new IssueTemplateUnusedAudioAtEnd(this), + }; + + public IEnumerable Run(BeatmapVerifierContext context) + { + double mappedLength = context.Beatmap.HitObjects.Last().GetEndTime(); + double trackLength = context.WorkingBeatmap.Track.Length; + + double mappedPercentage = calculatePercentage(mappedLength, trackLength); + + if (mappedPercentage < 80) + { + yield return new IssueTemplateUnusedAudioAtEnd(this).Create(); + } + + } + + private double calculatePercentage(double mappedLenght, double trackLenght) + { + return Math.Round(mappedLenght / trackLenght * 100); + } + + public class IssueTemplateUnusedAudioAtEnd : IssueTemplate + { + public IssueTemplateUnusedAudioAtEnd(ICheck check) + : base(check, IssueType.Problem, "There is more than 20% unused audio at the end.") + { + } + + public Issue Create() => new Issue(this); + } + } +} From f7aff76592c108ff3df1b97b3d2b8e8d7ded6938 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sat, 16 Mar 2024 23:03:06 -0300 Subject: [PATCH 410/508] Fix codefactor issues --- osu.Game/Rulesets/Edit/BeatmapVerifier.cs | 1 - osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs index 4bba72d828..4a316afd22 100644 --- a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs +++ b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs @@ -43,7 +43,6 @@ namespace osu.Game.Rulesets.Edit // Events new CheckBreaks() - }; public IEnumerable Run(BeatmapVerifierContext context) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs index c120e0993a..9c1f2748e9 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs @@ -29,7 +29,6 @@ namespace osu.Game.Rulesets.Edit.Checks { yield return new IssueTemplateUnusedAudioAtEnd(this).Create(); } - } private double calculatePercentage(double mappedLenght, double trackLenght) From 80f24a07916e9ae03fa4631e7f9018812139214d Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sat, 16 Mar 2024 23:30:59 -0300 Subject: [PATCH 411/508] Fix test class name not matching file name --- osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs b/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs index 687feae63d..29c5cb96fd 100644 --- a/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs @@ -14,7 +14,7 @@ using static osu.Game.Tests.Visual.OsuTestScene.ClockBackedTestWorkingBeatmap; namespace osu.Game.Tests.Editing.Checks { - public class CheckUnusedAudioTest + public class CheckUnusedAudioAtEndTest { private CheckUnusedAudioAtEnd check = null!; From d0678bfbee7952e2b82c6d25bd2abc5952937421 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Mon, 18 Mar 2024 15:30:43 +0200 Subject: [PATCH 412/508] chore: requested changes --- .../Filtering/FilterQueryParserTest.cs | 20 ++++++-- osu.Game/Screens/Select/FilterCriteria.cs | 19 +++---- osu.Game/Screens/Select/FilterQueryParser.cs | 50 +++++++++++++++---- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs index c109e5bad2..98d3286409 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs @@ -256,8 +256,7 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "status=r"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.IsNotNull(filterCriteria.OnlineStatus.Values); - Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values!); + Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); } @@ -269,7 +268,7 @@ namespace osu.Game.Tests.NonVisual.Filtering FilterQueryParser.ApplyQueries(filterCriteria, query); Assert.AreEqual("I want the pp", filterCriteria.SearchText.Trim()); Assert.AreEqual(4, filterCriteria.SearchTerms.Length); - Assert.IsNotNull(filterCriteria.OnlineStatus.Values); + Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); } @@ -279,11 +278,24 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "status=ranked status=loved"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.IsNotNull(filterCriteria.OnlineStatus.Values); + Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); Assert.Contains(BeatmapOnlineStatus.Loved, filterCriteria.OnlineStatus.Values); } + [Test] + public void TestApplyRangeStatusMatches() + { + const string query = "status>=r"; + var filterCriteria = new FilterCriteria(); + FilterQueryParser.ApplyQueries(filterCriteria, query); + Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); + Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); + Assert.Contains(BeatmapOnlineStatus.Approved, filterCriteria.OnlineStatus.Values); + Assert.Contains(BeatmapOnlineStatus.Qualified, filterCriteria.OnlineStatus.Values); + Assert.Contains(BeatmapOnlineStatus.Loved, filterCriteria.OnlineStatus.Values); + } + [TestCase("creator")] [TestCase("author")] [TestCase("mapper")] diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index 6cec7a387d..1d155574cf 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -34,7 +34,7 @@ namespace osu.Game.Screens.Select public OptionalRange Length; public OptionalRange BPM; public OptionalRange BeatDivisor; - public OptionalArray OnlineStatus; + public OptionalSet OnlineStatus = new OptionalSet(); public OptionalRange LastPlayed; public OptionalTextFilter Creator; public OptionalTextFilter Artist; @@ -114,24 +114,25 @@ namespace osu.Game.Screens.Select public IRulesetFilterCriteria? RulesetCriteria { get; set; } - public struct OptionalArray : IEquatable> + public struct OptionalSet : IEquatable> where T : struct { - public bool HasFilter => Values?.Length > 0; + public bool HasFilter => Values.Count > 0; public bool IsInRange(T value) { - return Values?.Contains(value) ?? false; + return Values.Contains(value); } - public T[]? Values; + public SortedSet Values = new SortedSet(); - public bool Equals(OptionalArray other) + public OptionalSet() { - if (Values is null && other.Values is null) - return true; + } - return Values?.SequenceEqual(other.Values ?? Array.Empty()) ?? false; + public bool Equals(OptionalSet other) + { + return Values.SetEquals(other.Values); } } diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index 208e7f559e..fbb09b93bd 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select return TryUpdateCriteriaRange(ref criteria.BeatDivisor, op, value, tryParseInt); case "status": - return TryUpdateArrayRange(ref criteria.OnlineStatus, op, value, tryParseEnum); + return TryUpdateSetRange(ref criteria.OnlineStatus, op, value, tryParseEnum); case "creator": case "author": @@ -306,23 +306,55 @@ namespace osu.Game.Screens.Select /// If can be parsed into using , the function returns true /// and the resulting range constraint is stored into the 's expected values. /// - /// The to store the parsed data into, if successful. + /// The to store the parsed data into, if successful. /// The operator for the keyword filter. Currently, only can be used. /// The value of the keyword filter. /// Function used to determine if can be converted to type . - public static bool TryUpdateArrayRange(ref FilterCriteria.OptionalArray range, Operator op, string val, TryParseFunction parseFunction) + public static bool TryUpdateSetRange(ref FilterCriteria.OptionalSet range, Operator op, string val, TryParseFunction parseFunction) where T : struct - => parseFunction.Invoke(val, out var converted) && tryUpdateArrayRange(ref range, op, converted); + => parseFunction.Invoke(val, out var converted) && tryUpdateSetRange(ref range, op, converted); - private static bool tryUpdateArrayRange(ref FilterCriteria.OptionalArray range, Operator op, T value) + private static bool tryUpdateSetRange(ref FilterCriteria.OptionalSet range, Operator op, T value) where T : struct { - if (op != Operator.Equal) - return false; + var enumValues = (T[])Enum.GetValues(typeof(T)); - range.Values ??= Array.Empty(); + foreach (var enumValue in enumValues) + { + switch (op) + { + case Operator.Less: + if (Comparer.Default.Compare(enumValue, value) < 0) + range.Values.Add(enumValue); - range.Values = range.Values.Append(value).ToArray(); + break; + + case Operator.LessOrEqual: + if (Comparer.Default.Compare(enumValue, value) <= 0) + range.Values.Add(enumValue); + + break; + + case Operator.Equal: + range.Values.Add(value); + break; + + case Operator.GreaterOrEqual: + if (Comparer.Default.Compare(enumValue, value) >= 0) + range.Values.Add(enumValue); + + break; + + case Operator.Greater: + if (Comparer.Default.Compare(enumValue, value) > 0) + range.Values.Add(enumValue); + + break; + + default: + return false; + } + } return true; } From 77119b2cdb1c4f2b743aa9a99eac1f48f74064d1 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Mon, 18 Mar 2024 16:44:42 +0200 Subject: [PATCH 413/508] chore: correct doc string --- osu.Game/Screens/Select/FilterQueryParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index fbb09b93bd..76d58963e7 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -307,7 +307,7 @@ namespace osu.Game.Screens.Select /// and the resulting range constraint is stored into the 's expected values. /// /// The to store the parsed data into, if successful. - /// The operator for the keyword filter. Currently, only can be used. + /// The operator for the keyword filter. /// The value of the keyword filter. /// Function used to determine if can be converted to type . public static bool TryUpdateSetRange(ref FilterCriteria.OptionalSet range, Operator op, string val, TryParseFunction parseFunction) From a3f3dcf853b6148c6c2cbebe41b88711c01d468a Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Mon, 18 Mar 2024 13:27:43 -0300 Subject: [PATCH 414/508] Inline percentage calculation --- osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs index 9c1f2748e9..8795eeac2d 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Edit.Checks double mappedLength = context.Beatmap.HitObjects.Last().GetEndTime(); double trackLength = context.WorkingBeatmap.Track.Length; - double mappedPercentage = calculatePercentage(mappedLength, trackLength); + double mappedPercentage = Math.Round(mappedLength / trackLength * 100); if (mappedPercentage < 80) { @@ -31,11 +31,6 @@ namespace osu.Game.Rulesets.Edit.Checks } } - private double calculatePercentage(double mappedLenght, double trackLenght) - { - return Math.Round(mappedLenght / trackLenght * 100); - } - public class IssueTemplateUnusedAudioAtEnd : IssueTemplate { public IssueTemplateUnusedAudioAtEnd(ICheck check) From 915a9682b5be54b090d39ae2a44beae8ea2c9ce7 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Mon, 18 Mar 2024 13:51:36 -0300 Subject: [PATCH 415/508] Fix issue type and display percentage left --- osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs index 8795eeac2d..d22303b7df 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs @@ -27,18 +27,19 @@ namespace osu.Game.Rulesets.Edit.Checks if (mappedPercentage < 80) { - yield return new IssueTemplateUnusedAudioAtEnd(this).Create(); + double percentageLeft = Math.Abs(mappedPercentage - 100); + yield return new IssueTemplateUnusedAudioAtEnd(this).Create(percentageLeft); } } public class IssueTemplateUnusedAudioAtEnd : IssueTemplate { public IssueTemplateUnusedAudioAtEnd(ICheck check) - : base(check, IssueType.Problem, "There is more than 20% unused audio at the end.") + : base(check, IssueType.Warning, "Currently there is {0}% unused audio at the end. Ensure the outro significantly contributes to the song, otherwise cut the outro.") { } - public Issue Create() => new Issue(this); + public Issue Create(double percentageLeft) => new Issue(this, percentageLeft); } } } From c23212f4efad0c58207265877a5130177f47d2e5 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Mon, 18 Mar 2024 14:02:33 -0300 Subject: [PATCH 416/508] Use `GetLastObjectTime` to calculate mapped length --- osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs index d22303b7df..d9a675fd17 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs @@ -3,9 +3,8 @@ using System; using System.Collections.Generic; -using System.Linq; +using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit.Checks.Components; -using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Edit.Checks { @@ -20,7 +19,7 @@ namespace osu.Game.Rulesets.Edit.Checks public IEnumerable Run(BeatmapVerifierContext context) { - double mappedLength = context.Beatmap.HitObjects.Last().GetEndTime(); + double mappedLength = context.Beatmap.GetLastObjectTime(); double trackLength = context.WorkingBeatmap.Track.Length; double mappedPercentage = Math.Round(mappedLength / trackLength * 100); From 0edc249637d56208bca655db17e274738df0b70e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 18 Mar 2024 20:38:19 +0300 Subject: [PATCH 417/508] Make Timeline non-nullable --- .../Components/Timeline/TimelineControlPointDisplay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs index 950b717ffb..1bf12e40d1 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs @@ -15,7 +15,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline public partial class TimelineControlPointDisplay : TimelinePart { [Resolved] - private Timeline? timeline { get; set; } + private Timeline timeline { get; set; } = null!; /// /// The visible time/position range of the timeline. @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline { base.Update(); - if (timeline == null || DrawWidth <= 0) return; + if (DrawWidth <= 0) return; (float, float) newRange = ( (ToLocalSpace(timeline.ScreenSpaceDrawQuad.TopLeft).X - TopPointPiece.WIDTH) / DrawWidth * Content.RelativeChildSize.X, From 7ca45c75b3348f66c0ec86e02a72c114abb27c8c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 18 Mar 2024 20:46:38 +0300 Subject: [PATCH 418/508] Don't iterate backwards on children without a reason --- .../Components/Timeline/TimelineControlPointDisplay.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs index 1bf12e40d1..8e522fa715 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs @@ -63,12 +63,10 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private void recreateDrawableGroups() { // Remove groups outside the visible range - for (int i = Count - 1; i >= 0; i--) + foreach (var drawableGroup in this) { - var g = Children[i]; - - if (!shouldBeVisible(g.Group)) - g.Expire(); + if (!shouldBeVisible(drawableGroup.Group)) + drawableGroup.Expire(); } // Add remaining ones From f6d7f18f2592071d98872e2cda18f8de9d20cfa1 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Mon, 18 Mar 2024 15:59:19 -0300 Subject: [PATCH 419/508] Remove unused localisation file --- .../CheckUnusedAudioAtEndStrings.cs | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 osu.Game/Localisation/CheckUnusedAudioAtEndStrings.cs diff --git a/osu.Game/Localisation/CheckUnusedAudioAtEndStrings.cs b/osu.Game/Localisation/CheckUnusedAudioAtEndStrings.cs deleted file mode 100644 index 46f92237a9..0000000000 --- a/osu.Game/Localisation/CheckUnusedAudioAtEndStrings.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Localisation; - -namespace osu.Game.Localisation -{ - public static class CheckUnusedAudioAtEndStrings - { - private const string prefix = @"osu.Game.Resources.Localisation.CheckUnusedAudioAtEnd"; - - /// - /// "{0}% of the audio is not mapped." - /// - public static LocalisableString OfTheAudioIsNot(double percentageLeft) => new TranslatableString(getKey(@"of_the_audio_is_not"), @"{0}% of the audio is not mapped.", percentageLeft); - - private static string getKey(string key) => $@"{prefix}:{key}"; - } -} From 5241c999c1f3300f36723a1d070c23240936c8da Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Mon, 18 Mar 2024 16:08:41 -0300 Subject: [PATCH 420/508] Add different warning to maps with storyboard/video --- .../Checks/CheckUnusedAudioAtEndTest.cs | 51 +++++++++++++++++-- .../Edit/Checks/CheckUnusedAudioAtEnd.cs | 37 +++++++++++++- 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs b/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs index 29c5cb96fd..33d73a8086 100644 --- a/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs @@ -4,12 +4,15 @@ using System.Linq; using Moq; using NUnit.Framework; +using osu.Framework.Graphics; using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Checks; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Storyboards; +using osuTK; using static osu.Game.Tests.Visual.OsuTestScene.ClockBackedTestWorkingBeatmap; namespace osu.Game.Tests.Editing.Checks @@ -47,7 +50,7 @@ namespace osu.Game.Tests.Editing.Checks }, BeatmapInfo = new BeatmapInfo { - Metadata = new BeatmapMetadata { AudioFile = "abc123.jpg" } + Metadata = new BeatmapMetadata { AudioFile = "abc123.jpg" }, } }; } @@ -62,6 +65,42 @@ namespace osu.Game.Tests.Editing.Checks Assert.That(issues.Single().Template is CheckUnusedAudioAtEnd.IssueTemplateUnusedAudioAtEnd); } + [Test] + public void TestAudioNotFullyUsedWithVideo() + { + var storyboard = new Storyboard(); + + var video = new StoryboardVideo("abc123.mp4", 0); + + storyboard.GetLayer("Video").Add(video); + + var mockWorkingBeatmap = getMockWorkingBeatmap(beatmapNotFullyMapped, storyboard); + + var context = getContext(beatmapNotFullyMapped, mockWorkingBeatmap); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckUnusedAudioAtEnd.IssueTemplateUnusedAudioAtEndStoryboardOrVideo); + } + + [Test] + public void TestAudioNotFullyUsedWithStoryboardElement() + { + var storyboard = new Storyboard(); + + var sprite = new StoryboardSprite("unknown", Anchor.TopLeft, Vector2.Zero); + + storyboard.GetLayer("Background").Add(sprite); + + var mockWorkingBeatmap = getMockWorkingBeatmap(beatmapNotFullyMapped, storyboard); + + var context = getContext(beatmapNotFullyMapped, mockWorkingBeatmap); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckUnusedAudioAtEnd.IssueTemplateUnusedAudioAtEndStoryboardOrVideo); + } + [Test] public void TestAudioFullyUsed() { @@ -73,16 +112,22 @@ namespace osu.Game.Tests.Editing.Checks private BeatmapVerifierContext getContext(IBeatmap beatmap) { - return new BeatmapVerifierContext(beatmap, getMockWorkingBeatmap(beatmap).Object); + return new BeatmapVerifierContext(beatmap, getMockWorkingBeatmap(beatmap, new Storyboard()).Object); } - private Mock getMockWorkingBeatmap(IBeatmap beatmap) + private BeatmapVerifierContext getContext(IBeatmap beatmap, Mock workingBeatmap) + { + return new BeatmapVerifierContext(beatmap, workingBeatmap.Object); + } + + private Mock getMockWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard) { var mockTrack = new TrackVirtualStore(new FramedClock()).GetVirtual(10000, "virtual"); var mockWorkingBeatmap = new Mock(); mockWorkingBeatmap.SetupGet(w => w.Beatmap).Returns(beatmap); mockWorkingBeatmap.SetupGet(w => w.Track).Returns(mockTrack); + mockWorkingBeatmap.SetupGet(w => w.Storyboard).Returns(storyboard); return mockWorkingBeatmap; } diff --git a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs index d9a675fd17..2f768b6ffa 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit.Checks.Components; +using osu.Game.Storyboards; namespace osu.Game.Rulesets.Edit.Checks { @@ -15,6 +16,7 @@ namespace osu.Game.Rulesets.Edit.Checks public IEnumerable PossibleTemplates => new IssueTemplate[] { new IssueTemplateUnusedAudioAtEnd(this), + new IssueTemplateUnusedAudioAtEndStoryboardOrVideo(this), }; public IEnumerable Run(BeatmapVerifierContext context) @@ -27,10 +29,33 @@ namespace osu.Game.Rulesets.Edit.Checks if (mappedPercentage < 80) { double percentageLeft = Math.Abs(mappedPercentage - 100); - yield return new IssueTemplateUnusedAudioAtEnd(this).Create(percentageLeft); + + bool storyboardIsPresent = isAnyStoryboardElementPresent(context.WorkingBeatmap.Storyboard); + + if (storyboardIsPresent) + { + yield return new IssueTemplateUnusedAudioAtEndStoryboardOrVideo(this).Create(percentageLeft); + } + else + { + yield return new IssueTemplateUnusedAudioAtEnd(this).Create(percentageLeft); + } } } + private bool isAnyStoryboardElementPresent(Storyboard storyboard) + { + foreach (var layer in storyboard.Layers) + { + foreach (var _ in layer.Elements) + { + return true; + } + } + + return false; + } + public class IssueTemplateUnusedAudioAtEnd : IssueTemplate { public IssueTemplateUnusedAudioAtEnd(ICheck check) @@ -40,5 +65,15 @@ namespace osu.Game.Rulesets.Edit.Checks public Issue Create(double percentageLeft) => new Issue(this, percentageLeft); } + + public class IssueTemplateUnusedAudioAtEndStoryboardOrVideo : IssueTemplate + { + public IssueTemplateUnusedAudioAtEndStoryboardOrVideo(ICheck check) + : base(check, IssueType.Warning, "Currently there is {0}% unused audio at the end. Ensure the outro significantly contributes to the song, or is being occupied by the video or storyboard, otherwise cut the outro.") + { + } + + public Issue Create(double percentageLeft) => new Issue(this, percentageLeft); + } } } From a8ce6a0bba5c65ab12360191d7589365d0996133 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 19 Mar 2024 02:43:34 +0300 Subject: [PATCH 421/508] Use `Slice` method instead of index range operators for readability --- .../Rulesets/Objects/Legacy/ConvertHitObjectParser.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs index 2b058d5e1f..283a59b7ed 100644 --- a/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs @@ -303,16 +303,16 @@ namespace osu.Game.Rulesets.Objects.Legacy { int startIndex = segmentsBuffer[i].StartIndex; int endIndex = segmentsBuffer[i + 1].StartIndex; - controlPoints.AddRange(convertPoints(segmentsBuffer[i].Type, allPoints[startIndex..endIndex], pointsBuffer[endIndex])); + controlPoints.AddRange(convertPoints(segmentsBuffer[i].Type, allPoints.Slice(startIndex, endIndex - startIndex), pointsBuffer[endIndex])); } else { int startIndex = segmentsBuffer[i].StartIndex; - controlPoints.AddRange(convertPoints(segmentsBuffer[i].Type, allPoints[startIndex..], null)); + controlPoints.AddRange(convertPoints(segmentsBuffer[i].Type, allPoints.Slice(startIndex), null)); } } - return mergePointsLists(controlPoints); + return mergeControlPointsLists(controlPoints); } finally { @@ -402,7 +402,7 @@ namespace osu.Game.Rulesets.Objects.Legacy - (p1.X - p0.X) * (p2.Y - p0.Y)); } - private PathControlPoint[] mergePointsLists(List> controlPointList) + private PathControlPoint[] mergeControlPointsLists(List> controlPointList) { int totalCount = 0; From af713a78695f4abd3e8023a98245f034fbb55da8 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 19 Mar 2024 17:20:59 +0900 Subject: [PATCH 422/508] Fix incorrectly encoded score IsPerfect value --- .../Formats/LegacyScoreEncoderTest.cs | 38 ++++++++++++++++--- osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs | 7 +++- osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs | 2 +- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs index c0a7285f39..c0bf47dfc9 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs @@ -6,6 +6,7 @@ using System.IO; using NUnit.Framework; using osu.Game.Beatmaps.Formats; using osu.Game.Rulesets.Catch; +using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Scoring.Legacy; @@ -21,9 +22,9 @@ namespace osu.Game.Tests.Beatmaps.Formats public void CatchMergesFruitAndDropletMisses(int missCount, int largeTickMissCount) { var ruleset = new CatchRuleset().RulesetInfo; - var scoreInfo = TestResources.CreateTestScoreInfo(ruleset); var beatmap = new TestBeatmap(ruleset); + scoreInfo.Statistics = new Dictionary { [HitResult.Great] = 50, @@ -31,14 +32,41 @@ namespace osu.Game.Tests.Beatmaps.Formats [HitResult.Miss] = missCount, [HitResult.LargeTickMiss] = largeTickMissCount }; - var score = new Score { ScoreInfo = scoreInfo }; - var decodedAfterEncode = encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, score, beatmap); + var score = new Score { ScoreInfo = scoreInfo }; + var decodedAfterEncode = encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, score, beatmap, out _); Assert.That(decodedAfterEncode.ScoreInfo.GetCountMiss(), Is.EqualTo(missCount + largeTickMissCount)); } - private static Score encodeThenDecode(int beatmapVersion, Score score, TestBeatmap beatmap) + [Test] + public void ScoreWithMissIsNotPerfect() + { + var ruleset = new OsuRuleset().RulesetInfo; + var scoreInfo = TestResources.CreateTestScoreInfo(ruleset); + var beatmap = new TestBeatmap(ruleset); + + scoreInfo.Statistics = new Dictionary + { + [HitResult.Great] = 2, + [HitResult.Miss] = 1, + }; + + scoreInfo.MaximumStatistics = new Dictionary + { + [HitResult.Great] = 3 + }; + + // Hit -> Miss -> Hit + scoreInfo.Combo = 1; + scoreInfo.MaxCombo = 1; + + encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, new Score { ScoreInfo = scoreInfo }, beatmap, out var decoder); + + Assert.That(decoder.DecodedPerfectValue, Is.False); + } + + private static Score encodeThenDecode(int beatmapVersion, Score score, TestBeatmap beatmap, out LegacyScoreDecoderTest.TestLegacyScoreDecoder decoder) { var encodeStream = new MemoryStream(); @@ -47,7 +75,7 @@ namespace osu.Game.Tests.Beatmaps.Formats var decodeStream = new MemoryStream(encodeStream.GetBuffer()); - var decoder = new LegacyScoreDecoderTest.TestLegacyScoreDecoder(beatmapVersion); + decoder = new LegacyScoreDecoderTest.TestLegacyScoreDecoder(beatmapVersion); var decodedAfterEncode = decoder.Parse(decodeStream); return decodedAfterEncode; } diff --git a/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs index 65e2c02655..f2c096da15 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs @@ -27,6 +27,11 @@ namespace osu.Game.Scoring.Legacy { public abstract class LegacyScoreDecoder { + /// + /// The decoded "IsPerfect" value. This isn't used by osu!lazer. + /// + public bool DecodedPerfectValue { get; private set; } + private IBeatmap currentBeatmap; private Ruleset currentRuleset; @@ -82,7 +87,7 @@ namespace osu.Game.Scoring.Legacy scoreInfo.MaxCombo = sr.ReadUInt16(); /* score.Perfect = */ - sr.ReadBoolean(); + DecodedPerfectValue = sr.ReadBoolean(); scoreInfo.Mods = currentRuleset.ConvertFromLegacyMods((LegacyMods)sr.ReadInt32()).ToArray(); diff --git a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs index 4ee4231925..1df54565e9 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs @@ -93,7 +93,7 @@ namespace osu.Game.Scoring.Legacy sw.Write((ushort)(score.ScoreInfo.GetCountMiss() ?? 0)); sw.Write((int)(score.ScoreInfo.TotalScore)); sw.Write((ushort)score.ScoreInfo.MaxCombo); - sw.Write(score.ScoreInfo.Combo == score.ScoreInfo.MaxCombo); + sw.Write(score.ScoreInfo.Combo == score.ScoreInfo.GetMaximumAchievableCombo()); sw.Write((int)score.ScoreInfo.Ruleset.CreateInstance().ConvertToLegacyMods(score.ScoreInfo.Mods)); sw.Write(getHpGraphFormatted()); From 6e3350941749a87b21ed2c819c063e7a556509f0 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 19 Mar 2024 17:44:37 +0900 Subject: [PATCH 423/508] Remove added property, use local decoding instead --- .../Formats/LegacyScoreEncoderTest.cs | 34 ++++++++++++++++--- osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs | 7 +--- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs index c0bf47dfc9..806f538249 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyScoreEncoderTest.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using NUnit.Framework; using osu.Game.Beatmaps.Formats; +using osu.Game.IO.Legacy; using osu.Game.Rulesets.Catch; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; @@ -34,7 +35,7 @@ namespace osu.Game.Tests.Beatmaps.Formats }; var score = new Score { ScoreInfo = scoreInfo }; - var decodedAfterEncode = encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, score, beatmap, out _); + var decodedAfterEncode = encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, score, beatmap); Assert.That(decodedAfterEncode.ScoreInfo.GetCountMiss(), Is.EqualTo(missCount + largeTickMissCount)); } @@ -61,12 +62,35 @@ namespace osu.Game.Tests.Beatmaps.Formats scoreInfo.Combo = 1; scoreInfo.MaxCombo = 1; - encodeThenDecode(LegacyBeatmapDecoder.LATEST_VERSION, new Score { ScoreInfo = scoreInfo }, beatmap, out var decoder); + using (var ms = new MemoryStream()) + { + new LegacyScoreEncoder(new Score { ScoreInfo = scoreInfo }, beatmap).Encode(ms, true); - Assert.That(decoder.DecodedPerfectValue, Is.False); + ms.Seek(0, SeekOrigin.Begin); + + using (var sr = new SerializationReader(ms)) + { + sr.ReadByte(); // ruleset id + sr.ReadInt32(); // version + sr.ReadString(); // beatmap hash + sr.ReadString(); // username + sr.ReadString(); // score hash + sr.ReadInt16(); // count300 + sr.ReadInt16(); // count100 + sr.ReadInt16(); // count50 + sr.ReadInt16(); // countGeki + sr.ReadInt16(); // countKatu + sr.ReadInt16(); // countMiss + sr.ReadInt32(); // total score + sr.ReadInt16(); // max combo + bool isPerfect = sr.ReadBoolean(); // full combo + + Assert.That(isPerfect, Is.False); + } + } } - private static Score encodeThenDecode(int beatmapVersion, Score score, TestBeatmap beatmap, out LegacyScoreDecoderTest.TestLegacyScoreDecoder decoder) + private static Score encodeThenDecode(int beatmapVersion, Score score, TestBeatmap beatmap) { var encodeStream = new MemoryStream(); @@ -75,7 +99,7 @@ namespace osu.Game.Tests.Beatmaps.Formats var decodeStream = new MemoryStream(encodeStream.GetBuffer()); - decoder = new LegacyScoreDecoderTest.TestLegacyScoreDecoder(beatmapVersion); + var decoder = new LegacyScoreDecoderTest.TestLegacyScoreDecoder(beatmapVersion); var decodedAfterEncode = decoder.Parse(decodeStream); return decodedAfterEncode; } diff --git a/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs index f2c096da15..65e2c02655 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs @@ -27,11 +27,6 @@ namespace osu.Game.Scoring.Legacy { public abstract class LegacyScoreDecoder { - /// - /// The decoded "IsPerfect" value. This isn't used by osu!lazer. - /// - public bool DecodedPerfectValue { get; private set; } - private IBeatmap currentBeatmap; private Ruleset currentRuleset; @@ -87,7 +82,7 @@ namespace osu.Game.Scoring.Legacy scoreInfo.MaxCombo = sr.ReadUInt16(); /* score.Perfect = */ - DecodedPerfectValue = sr.ReadBoolean(); + sr.ReadBoolean(); scoreInfo.Mods = currentRuleset.ConvertFromLegacyMods((LegacyMods)sr.ReadInt32()).ToArray(); From f6069d8d93b05c752b1aeaa36e4c269580880f26 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 19 Mar 2024 17:46:18 +0900 Subject: [PATCH 424/508] Compare against MaxCombo instead --- osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs index 1df54565e9..93f51ee74d 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs @@ -93,7 +93,7 @@ namespace osu.Game.Scoring.Legacy sw.Write((ushort)(score.ScoreInfo.GetCountMiss() ?? 0)); sw.Write((int)(score.ScoreInfo.TotalScore)); sw.Write((ushort)score.ScoreInfo.MaxCombo); - sw.Write(score.ScoreInfo.Combo == score.ScoreInfo.GetMaximumAchievableCombo()); + sw.Write(score.ScoreInfo.MaxCombo == score.ScoreInfo.GetMaximumAchievableCombo()); sw.Write((int)score.ScoreInfo.Ruleset.CreateInstance().ConvertToLegacyMods(score.ScoreInfo.Mods)); sw.Write(getHpGraphFormatted()); From 0de5ca8d2df633b044b41d121bb3ed97aee73e47 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2024 01:26:39 +0800 Subject: [PATCH 425/508] Update incorrect xmldoc --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index fd1ce5d829..8bb3ae8182 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -18,7 +18,7 @@ using osuTK; namespace osu.Game.Screens.Play { /// - /// Simple that resumes after 800ms. + /// Simple that resumes after a short delay. /// public partial class DelayedResumeOverlay : ResumeOverlay { From feaf59e15f701e1348122e17c4650420b8a581ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 19 Mar 2024 18:19:06 +0100 Subject: [PATCH 426/508] Use `HashSet` instead of `SortedSet` No need for it to be sorted. --- .../NonVisual/Filtering/FilterQueryParserTest.cs | 16 ++++++++-------- osu.Game/Screens/Select/FilterCriteria.cs | 12 +++--------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs index 98d3286409..bd706b5b4c 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs @@ -257,7 +257,7 @@ namespace osu.Game.Tests.NonVisual.Filtering var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); - Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); + Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked)); } [Test] @@ -269,7 +269,7 @@ namespace osu.Game.Tests.NonVisual.Filtering Assert.AreEqual("I want the pp", filterCriteria.SearchText.Trim()); Assert.AreEqual(4, filterCriteria.SearchTerms.Length); Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); - Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); + Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked)); } [Test] @@ -279,8 +279,8 @@ namespace osu.Game.Tests.NonVisual.Filtering var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); - Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); - Assert.Contains(BeatmapOnlineStatus.Loved, filterCriteria.OnlineStatus.Values); + Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked)); + Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Loved)); } [Test] @@ -290,10 +290,10 @@ namespace osu.Game.Tests.NonVisual.Filtering var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); - Assert.Contains(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Values); - Assert.Contains(BeatmapOnlineStatus.Approved, filterCriteria.OnlineStatus.Values); - Assert.Contains(BeatmapOnlineStatus.Qualified, filterCriteria.OnlineStatus.Values); - Assert.Contains(BeatmapOnlineStatus.Loved, filterCriteria.OnlineStatus.Values); + Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked)); + Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Approved)); + Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Qualified)); + Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Loved)); } [TestCase("creator")] diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index 1d155574cf..6750b07aba 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -119,21 +119,15 @@ namespace osu.Game.Screens.Select { public bool HasFilter => Values.Count > 0; - public bool IsInRange(T value) - { - return Values.Contains(value); - } + public bool IsInRange(T value) => Values.Contains(value); - public SortedSet Values = new SortedSet(); + public HashSet Values = new HashSet(); public OptionalSet() { } - public bool Equals(OptionalSet other) - { - return Values.SetEquals(other.Values); - } + public bool Equals(OptionalSet other) => Values.SetEquals(other.Values); } public struct OptionalRange : IEquatable> From 320373e3e0a50c5b94a0f5a68a108ce24b3da2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 19 Mar 2024 18:28:13 +0100 Subject: [PATCH 427/508] Rename method to match convention better --- osu.Game/Screens/Select/FilterQueryParser.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index 76d58963e7..194a288426 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select return TryUpdateCriteriaRange(ref criteria.BeatDivisor, op, value, tryParseInt); case "status": - return TryUpdateSetRange(ref criteria.OnlineStatus, op, value, tryParseEnum); + return TryUpdateCriteriaSet(ref criteria.OnlineStatus, op, value, tryParseEnum); case "creator": case "author": @@ -310,11 +310,11 @@ namespace osu.Game.Screens.Select /// The operator for the keyword filter. /// The value of the keyword filter. /// Function used to determine if can be converted to type . - public static bool TryUpdateSetRange(ref FilterCriteria.OptionalSet range, Operator op, string val, TryParseFunction parseFunction) + public static bool TryUpdateCriteriaSet(ref FilterCriteria.OptionalSet range, Operator op, string val, TryParseFunction parseFunction) where T : struct - => parseFunction.Invoke(val, out var converted) && tryUpdateSetRange(ref range, op, converted); + => parseFunction.Invoke(val, out var converted) && tryUpdateCriteriaSet(ref range, op, converted); - private static bool tryUpdateSetRange(ref FilterCriteria.OptionalSet range, Operator op, T value) + private static bool tryUpdateCriteriaSet(ref FilterCriteria.OptionalSet range, Operator op, T value) where T : struct { var enumValues = (T[])Enum.GetValues(typeof(T)); From af3f7dcbbfb3e5b955f45e56815238eae71ccbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 19 Mar 2024 18:31:07 +0100 Subject: [PATCH 428/508] Retouch update criteria method --- osu.Game/Screens/Select/FilterQueryParser.cs | 30 ++++++++------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index 194a288426..32b533e18d 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -311,44 +311,38 @@ namespace osu.Game.Screens.Select /// The value of the keyword filter. /// Function used to determine if can be converted to type . public static bool TryUpdateCriteriaSet(ref FilterCriteria.OptionalSet range, Operator op, string val, TryParseFunction parseFunction) - where T : struct + where T : struct, Enum => parseFunction.Invoke(val, out var converted) && tryUpdateCriteriaSet(ref range, op, converted); - private static bool tryUpdateCriteriaSet(ref FilterCriteria.OptionalSet range, Operator op, T value) - where T : struct + private static bool tryUpdateCriteriaSet(ref FilterCriteria.OptionalSet range, Operator op, T pivotValue) + where T : struct, Enum { - var enumValues = (T[])Enum.GetValues(typeof(T)); + var allDefinedValues = Enum.GetValues(); - foreach (var enumValue in enumValues) + foreach (var val in allDefinedValues) { + int compareResult = Comparer.Default.Compare(val, pivotValue); + switch (op) { case Operator.Less: - if (Comparer.Default.Compare(enumValue, value) < 0) - range.Values.Add(enumValue); - + if (compareResult < 0) range.Values.Add(val); break; case Operator.LessOrEqual: - if (Comparer.Default.Compare(enumValue, value) <= 0) - range.Values.Add(enumValue); - + if (compareResult <= 0) range.Values.Add(val); break; case Operator.Equal: - range.Values.Add(value); + if (compareResult == 0) range.Values.Add(val); break; case Operator.GreaterOrEqual: - if (Comparer.Default.Compare(enumValue, value) >= 0) - range.Values.Add(enumValue); - + if (compareResult >= 0) range.Values.Add(val); break; case Operator.Greater: - if (Comparer.Default.Compare(enumValue, value) > 0) - range.Values.Add(enumValue); - + if (compareResult > 0) range.Values.Add(val); break; default: From 0211ae12adbed9b0d37881fbc87774ca901a0953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 19 Mar 2024 19:16:33 +0100 Subject: [PATCH 429/508] Add failing test case for crash on empty beatmap --- .../Editing/Checks/CheckUnusedAudioAtEndTest.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs b/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs index 33d73a8086..bf996b06ea 100644 --- a/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckUnusedAudioAtEndTest.cs @@ -55,6 +55,16 @@ namespace osu.Game.Tests.Editing.Checks }; } + [Test] + public void TestEmptyBeatmap() + { + var context = getContext(new Beatmap()); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckUnusedAudioAtEnd.IssueTemplateUnusedAudioAtEnd); + } + [Test] public void TestAudioNotFullyUsed() { From 2b83e6bc4cc325375f1db483e84af25f73330087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 19 Mar 2024 19:17:22 +0100 Subject: [PATCH 430/508] Fix check crash on empty beatmap --- osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs index 2f768b6ffa..2e97fbeb99 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckUnusedAudioAtEnd.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using osu.Game.Beatmaps; using osu.Game.Rulesets.Edit.Checks.Components; using osu.Game.Storyboards; @@ -21,7 +22,7 @@ namespace osu.Game.Rulesets.Edit.Checks public IEnumerable Run(BeatmapVerifierContext context) { - double mappedLength = context.Beatmap.GetLastObjectTime(); + double mappedLength = context.Beatmap.HitObjects.Any() ? context.Beatmap.GetLastObjectTime() : 0; double trackLength = context.WorkingBeatmap.Track.Length; double mappedPercentage = Math.Round(mappedLength / trackLength * 100); From e4418547feba011e5461d2a9d5358d198d341427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 19 Mar 2024 19:19:07 +0100 Subject: [PATCH 431/508] Document `GetLastObjectTime()` exception on empty beatmap --- osu.Game/Beatmaps/IBeatmap.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Beatmaps/IBeatmap.cs b/osu.Game/Beatmaps/IBeatmap.cs index b5bb6ccafc..6fe494ca0f 100644 --- a/osu.Game/Beatmaps/IBeatmap.cs +++ b/osu.Game/Beatmaps/IBeatmap.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps.ControlPoints; @@ -129,6 +130,7 @@ namespace osu.Game.Beatmaps /// /// It's not super efficient so calls should be kept to a minimum. /// + /// If has no objects. public static double GetLastObjectTime(this IBeatmap beatmap) => beatmap.HitObjects.Max(h => h.GetEndTime()); #region Helper methods From 808d6e09436468c8690311f235852ed0dd7834c9 Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 19 Mar 2024 16:02:06 -0400 Subject: [PATCH 432/508] Prevent potential threading issues --- osu.Desktop/DiscordRichPresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index ca26cab0fd..080032a298 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -97,11 +97,13 @@ namespace osu.Desktop private void onReady(object _, ReadyMessage __) { Logger.Log("Discord RPC Client ready.", LoggingTarget.Network, LogLevel.Debug); - updateStatus(); + Schedule(updateStatus); } private void updateStatus() { + Debug.Assert(ThreadSafety.IsUpdateThread); + if (!client.IsInitialized) return; From 0ecfa580d7a48d247ab9fa9907fdd0f1d739d732 Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 19 Mar 2024 16:03:32 -0400 Subject: [PATCH 433/508] Move room code from activity code, prevent duplicate RPC updates --- osu.Desktop/DiscordRichPresence.cs | 68 +++++++++++++++++------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 080032a298..633b6324b7 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -2,12 +2,14 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Diagnostics; using System.Text; using DiscordRPC; using DiscordRPC.Message; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Development; using osu.Framework.Graphics; using osu.Framework.Logging; using osu.Game; @@ -48,6 +50,8 @@ namespace osu.Desktop private readonly Bindable privacyMode = new Bindable(); + private int usersCurrentlyInLobby = 0; + private readonly RichPresence presence = new RichPresence { Assets = new Assets { LargeImageKey = "osu_logo_lazer" }, @@ -115,10 +119,10 @@ namespace osu.Desktop Logger.Log("Updating Discord RPC", LoggingTarget.Network, LogLevel.Debug); + bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb; + if (activity.Value != null) { - bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb; - presence.State = truncate(activity.Value.GetStatus(hideIdentifiableInformation)); presence.Details = truncate(activity.Value.GetDetails(hideIdentifiableInformation) ?? string.Empty); @@ -137,33 +141,6 @@ namespace osu.Desktop { presence.Buttons = null; } - - if (!hideIdentifiableInformation && multiplayerClient.Room != null) - { - MultiplayerRoom room = multiplayerClient.Room; - presence.Party = new Party - { - Privacy = string.IsNullOrEmpty(room.Settings.Password) ? Party.PrivacySetting.Public : Party.PrivacySetting.Private, - ID = room.RoomID.ToString(), - // technically lobbies can have infinite users, but Discord needs this to be set to something. - // to make party display sensible, assign a powers of two above participants count (8 at minimum). - Max = (int)Math.Max(8, Math.Pow(2, Math.Ceiling(Math.Log2(room.Users.Count)))), - Size = room.Users.Count, - }; - - RoomSecret roomSecret = new RoomSecret - { - RoomID = room.RoomID, - Password = room.Settings.Password, - }; - - presence.Secrets.JoinSecret = JsonConvert.SerializeObject(roomSecret); - } - else - { - presence.Party = null; - presence.Secrets.JoinSecret = null; - } } else { @@ -171,6 +148,39 @@ namespace osu.Desktop presence.Details = string.Empty; } + if (!hideIdentifiableInformation && multiplayerClient.Room != null) + { + MultiplayerRoom room = multiplayerClient.Room; + + if (room.Users.Count == usersCurrentlyInLobby) + return; + + presence.Party = new Party + { + Privacy = string.IsNullOrEmpty(room.Settings.Password) ? Party.PrivacySetting.Public : Party.PrivacySetting.Private, + ID = room.RoomID.ToString(), + // technically lobbies can have infinite users, but Discord needs this to be set to something. + // to make party display sensible, assign a powers of two above participants count (8 at minimum). + Max = (int)Math.Max(8, Math.Pow(2, Math.Ceiling(Math.Log2(room.Users.Count)))), + Size = room.Users.Count, + }; + + RoomSecret roomSecret = new RoomSecret + { + RoomID = room.RoomID, + Password = room.Settings.Password, + }; + + presence.Secrets.JoinSecret = JsonConvert.SerializeObject(roomSecret); + usersCurrentlyInLobby = room.Users.Count; + } + else + { + presence.Party = null; + presence.Secrets.JoinSecret = null; + usersCurrentlyInLobby = 0; + } + // update user information if (privacyMode.Value == DiscordRichPresenceMode.Limited) presence.Assets.LargeImageText = string.Empty; From c71daba4f663164a8180561bbadc8e0ee6f78a46 Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 19 Mar 2024 16:05:13 -0400 Subject: [PATCH 434/508] Improve logging of RPC Co-authored-by: Salman Ahmed --- osu.Desktop/DiscordRichPresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 633b6324b7..f47b2eaba5 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -117,8 +117,6 @@ namespace osu.Desktop return; } - Logger.Log("Updating Discord RPC", LoggingTarget.Network, LogLevel.Debug); - bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb; if (activity.Value != null) @@ -181,6 +179,8 @@ namespace osu.Desktop usersCurrentlyInLobby = 0; } + Logger.Log($"Updating Discord RPC presence with activity status: {presence.State}, details: {presence.Details}", LoggingTarget.Network, LogLevel.Debug); + // update user information if (privacyMode.Value == DiscordRichPresenceMode.Limited) presence.Assets.LargeImageText = string.Empty; From 4305c3db5b70b70d1e28ba1deeb807b28742481e Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 19 Mar 2024 16:15:22 -0400 Subject: [PATCH 435/508] Show login overlay when joining room while not logged in --- osu.Desktop/DiscordRichPresence.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index f47b2eaba5..a2d7ace0e0 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -19,6 +19,7 @@ using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; +using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Users; using LogLevel = osu.Framework.Logging.LogLevel; @@ -42,6 +43,8 @@ namespace osu.Desktop [Resolved] private OsuGame game { get; set; } = null!; + private LoginOverlay? login { get; set; } + [Resolved] private MultiplayerClient multiplayerClient { get; set; } = null!; @@ -65,6 +68,8 @@ namespace osu.Desktop [BackgroundDependencyLoader] private void load(OsuConfigManager config) { + login = game.Dependencies.Get(); + client = new DiscordRpcClient(client_id) { SkipIdenticalPresence = false // handles better on discord IPC loss, see updateStatus call in onReady. @@ -203,6 +208,12 @@ namespace osu.Desktop { game.Window?.Raise(); + if (!api.IsLoggedIn) + { + Schedule(() => login?.Show()); + return; + } + Logger.Log($"Received room secret from Discord RPC Client: \"{args.Secret}\"", LoggingTarget.Network, LogLevel.Debug); // Stable and lazer share the same Discord client ID, meaning they can accept join requests from each other. From 1a08dbaa2ba929c26e3463163f3c8ac9523809c5 Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 19 Mar 2024 17:03:30 -0400 Subject: [PATCH 436/508] Fix code style --- osu.Desktop/DiscordRichPresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index a2d7ace0e0..d8013aabfe 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -53,7 +53,7 @@ namespace osu.Desktop private readonly Bindable privacyMode = new Bindable(); - private int usersCurrentlyInLobby = 0; + private int usersCurrentlyInLobby; private readonly RichPresence presence = new RichPresence { From d83a53fc944eea90ad8244e248ec762e6d6d6ad3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2024 12:10:05 +0800 Subject: [PATCH 437/508] Remove unused `ScreenBreadcrumbControl` See https://github.com/ppy/osu-framework/pull/6218#discussion_r1529932798. --- .../TestSceneScreenBreadcrumbControl.cs | 138 ------------------ .../UserInterface/ScreenBreadcrumbControl.cs | 48 ------ 2 files changed, 186 deletions(-) delete mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneScreenBreadcrumbControl.cs delete mode 100644 osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneScreenBreadcrumbControl.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneScreenBreadcrumbControl.cs deleted file mode 100644 index 968cf9f9db..0000000000 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneScreenBreadcrumbControl.cs +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using NUnit.Framework; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; -using osu.Framework.Screens; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; -using osu.Game.Graphics.UserInterfaceV2; -using osu.Game.Screens; -using osuTK; - -namespace osu.Game.Tests.Visual.UserInterface -{ - [TestFixture] - public partial class TestSceneScreenBreadcrumbControl : OsuTestScene - { - private readonly ScreenBreadcrumbControl breadcrumbs; - private readonly OsuScreenStack screenStack; - - public TestSceneScreenBreadcrumbControl() - { - OsuSpriteText titleText; - - IScreen startScreen = new TestScreenOne(); - - screenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }; - screenStack.Push(startScreen); - - Children = new Drawable[] - { - screenStack, - new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(10), - Children = new Drawable[] - { - breadcrumbs = new ScreenBreadcrumbControl(screenStack) - { - RelativeSizeAxes = Axes.X, - }, - titleText = new OsuSpriteText(), - }, - }, - }; - - breadcrumbs.Current.ValueChanged += screen => titleText.Text = $"Changed to {screen.NewValue}"; - breadcrumbs.Current.TriggerChange(); - - waitForCurrent(); - pushNext(); - waitForCurrent(); - pushNext(); - waitForCurrent(); - - AddStep(@"make start current", () => startScreen.MakeCurrent()); - - waitForCurrent(); - pushNext(); - waitForCurrent(); - AddAssert(@"only 2 items", () => breadcrumbs.Items.Count == 2); - AddStep(@"exit current", () => screenStack.CurrentScreen.Exit()); - AddAssert(@"current screen is first", () => startScreen == screenStack.CurrentScreen); - } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - breadcrumbs.StripColour = colours.Blue; - } - - private void pushNext() => AddStep(@"push next screen", () => ((TestScreen)screenStack.CurrentScreen).PushNext()); - private void waitForCurrent() => AddUntilStep("current screen", () => screenStack.CurrentScreen.IsCurrentScreen()); - - private abstract partial class TestScreen : OsuScreen - { - protected abstract string NextTitle { get; } - protected abstract TestScreen CreateNextScreen(); - - public TestScreen PushNext() - { - TestScreen screen = CreateNextScreen(); - this.Push(screen); - - return screen; - } - - protected TestScreen() - { - InternalChild = new FillFlowContainer - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Spacing = new Vector2(10), - Children = new Drawable[] - { - new OsuSpriteText - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Text = Title, - }, - new RoundedButton - { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Width = 100, - Text = $"Push {NextTitle}", - Action = () => PushNext(), - }, - }, - }; - } - } - - private partial class TestScreenOne : TestScreen - { - public override string Title => @"Screen One"; - protected override string NextTitle => @"Two"; - protected override TestScreen CreateNextScreen() => new TestScreenTwo(); - } - - private partial class TestScreenTwo : TestScreen - { - public override string Title => @"Screen Two"; - protected override string NextTitle => @"One"; - protected override TestScreen CreateNextScreen() => new TestScreenOne(); - } - } -} diff --git a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs b/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs deleted file mode 100644 index 65dce422d6..0000000000 --- a/osu.Game/Graphics/UserInterface/ScreenBreadcrumbControl.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -#nullable disable - -using System.Linq; -using osu.Framework.Extensions.IEnumerableExtensions; -using osu.Framework.Graphics.UserInterface; -using osu.Framework.Screens; - -namespace osu.Game.Graphics.UserInterface -{ - /// - /// A which follows the active screen (and allows navigation) in a stack. - /// - public partial class ScreenBreadcrumbControl : BreadcrumbControl - { - public ScreenBreadcrumbControl(ScreenStack stack) - { - stack.ScreenPushed += onPushed; - stack.ScreenExited += onExited; - - if (stack.CurrentScreen != null) - onPushed(null, stack.CurrentScreen); - } - - protected override void SelectTab(TabItem tab) - { - // override base method to prevent current item from being changed on click. - // depend on screen push/exit to change current item instead. - tab.Value.MakeCurrent(); - } - - private void onPushed(IScreen lastScreen, IScreen newScreen) - { - AddItem(newScreen); - Current.Value = newScreen; - } - - private void onExited(IScreen lastScreen, IScreen newScreen) - { - if (newScreen != null) - Current.Value = newScreen; - - Items.ToList().SkipWhile(s => s != Current.Value).Skip(1).ForEach(RemoveItem); - } - } -} From b11ae1c5714b43d33ebbec569faf6569d0304c25 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 20 Mar 2024 06:40:18 +0300 Subject: [PATCH 438/508] Organise code, still hook up to `RoomChanged` to update room privacy mode, and use `SkipIdenticalPresence` + scheduling to avoid potential rate-limits --- osu.Desktop/DiscordRichPresence.cs | 87 ++++++++++++++++++------------ 1 file changed, 54 insertions(+), 33 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index d8013aabfe..8e4af5c5b1 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -2,16 +2,16 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Diagnostics; using System.Text; using DiscordRPC; using DiscordRPC.Message; using Newtonsoft.Json; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Development; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Logging; +using osu.Framework.Threading; using osu.Game; using osu.Game.Configuration; using osu.Game.Extensions; @@ -53,8 +53,6 @@ namespace osu.Desktop private readonly Bindable privacyMode = new Bindable(); - private int usersCurrentlyInLobby; - private readonly RichPresence presence = new RichPresence { Assets = new Assets { LargeImageKey = "osu_logo_lazer" }, @@ -72,7 +70,9 @@ namespace osu.Desktop client = new DiscordRpcClient(client_id) { - SkipIdenticalPresence = false // handles better on discord IPC loss, see updateStatus call in onReady. + // SkipIdenticalPresence allows us to fire SetPresence at any point and leave it to the underlying implementation + // to check whether a difference has actually occurred before sending a command to Discord (with a minor caveat that's handled in onReady). + SkipIdenticalPresence = true }; client.OnReady += onReady; @@ -95,10 +95,11 @@ namespace osu.Desktop activity.BindTo(u.NewValue.Activity); }, true); - ruleset.BindValueChanged(_ => updateStatus()); - status.BindValueChanged(_ => updateStatus()); - activity.BindValueChanged(_ => updateStatus()); - privacyMode.BindValueChanged(_ => updateStatus()); + ruleset.BindValueChanged(_ => updatePresence()); + status.BindValueChanged(_ => updatePresence()); + activity.BindValueChanged(_ => updatePresence()); + privacyMode.BindValueChanged(_ => updatePresence()); + multiplayerClient.RoomUpdated += onRoomUpdated; client.Initialize(); } @@ -106,24 +107,44 @@ namespace osu.Desktop private void onReady(object _, ReadyMessage __) { Logger.Log("Discord RPC Client ready.", LoggingTarget.Network, LogLevel.Debug); - Schedule(updateStatus); + + // when RPC is lost and reconnected, we have to clear presence state for updatePresence to work (see DiscordRpcClient.SkipIdenticalPresence). + if (client.CurrentPresence != null) + client.SetPresence(null); + + updatePresence(); } - private void updateStatus() + private void onRoomUpdated() => updatePresence(); + + private ScheduledDelegate? presenceUpdateDelegate; + + private void updatePresence() { - Debug.Assert(ThreadSafety.IsUpdateThread); - - if (!client.IsInitialized) - return; - - if (status.Value == UserStatus.Offline || privacyMode.Value == DiscordRichPresenceMode.Off) + presenceUpdateDelegate?.Cancel(); + presenceUpdateDelegate = Scheduler.AddDelayed(() => { - client.ClearPresence(); - return; - } + if (!client.IsInitialized) + return; - bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb; + if (status.Value == UserStatus.Offline || privacyMode.Value == DiscordRichPresenceMode.Off) + { + client.ClearPresence(); + return; + } + bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb; + + updatePresenceStatus(hideIdentifiableInformation); + updatePresenceParty(hideIdentifiableInformation); + updatePresenceAssets(); + + client.SetPresence(presence); + }, 200); + } + + private void updatePresenceStatus(bool hideIdentifiableInformation) + { if (activity.Value != null) { presence.State = truncate(activity.Value.GetStatus(hideIdentifiableInformation)); @@ -150,14 +171,14 @@ namespace osu.Desktop presence.State = "Idle"; presence.Details = string.Empty; } + } + private void updatePresenceParty(bool hideIdentifiableInformation) + { if (!hideIdentifiableInformation && multiplayerClient.Room != null) { MultiplayerRoom room = multiplayerClient.Room; - if (room.Users.Count == usersCurrentlyInLobby) - return; - presence.Party = new Party { Privacy = string.IsNullOrEmpty(room.Settings.Password) ? Party.PrivacySetting.Public : Party.PrivacySetting.Private, @@ -175,17 +196,16 @@ namespace osu.Desktop }; presence.Secrets.JoinSecret = JsonConvert.SerializeObject(roomSecret); - usersCurrentlyInLobby = room.Users.Count; } else { presence.Party = null; presence.Secrets.JoinSecret = null; - usersCurrentlyInLobby = 0; } + } - Logger.Log($"Updating Discord RPC presence with activity status: {presence.State}, details: {presence.Details}", LoggingTarget.Network, LogLevel.Debug); - + private void updatePresenceAssets() + { // update user information if (privacyMode.Value == DiscordRichPresenceMode.Limited) presence.Assets.LargeImageText = string.Empty; @@ -200,17 +220,15 @@ namespace osu.Desktop // update ruleset presence.Assets.SmallImageKey = ruleset.Value.IsLegacyRuleset() ? $"mode_{ruleset.Value.OnlineID}" : "mode_custom"; presence.Assets.SmallImageText = ruleset.Value.Name; - - client.SetPresence(presence); } - private void onJoin(object sender, JoinMessage args) + private void onJoin(object sender, JoinMessage args) => Scheduler.AddOnce(() => { game.Window?.Raise(); if (!api.IsLoggedIn) { - Schedule(() => login?.Show()); + login?.Show(); return; } @@ -231,7 +249,7 @@ namespace osu.Desktop }); request.Failure += _ => Logger.Log($"Could not join multiplayer room, room could not be found (room ID: {roomId}).", LoggingTarget.Network, LogLevel.Important); api.Queue(request); - } + }); private static readonly int ellipsis_length = Encoding.UTF8.GetByteCount(new[] { '…' }); @@ -294,6 +312,9 @@ namespace osu.Desktop protected override void Dispose(bool isDisposing) { + if (multiplayerClient.IsNotNull()) + multiplayerClient.RoomUpdated -= onRoomUpdated; + client.Dispose(); base.Dispose(isDisposing); } From 5f86b5a2fa2b109ec63d283a84356dc46efb67ac Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 20 Mar 2024 07:36:15 +0300 Subject: [PATCH 439/508] Use DI correctly --- osu.Desktop/DiscordRichPresence.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 8e4af5c5b1..d78459ff28 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -43,6 +43,7 @@ namespace osu.Desktop [Resolved] private OsuGame game { get; set; } = null!; + [Resolved] private LoginOverlay? login { get; set; } [Resolved] @@ -66,8 +67,6 @@ namespace osu.Desktop [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - login = game.Dependencies.Get(); - client = new DiscordRpcClient(client_id) { // SkipIdenticalPresence allows us to fire SetPresence at any point and leave it to the underlying implementation From fd509c82f50a59293fee0978769bcaa02c28f852 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Mar 2024 12:52:54 +0800 Subject: [PATCH 440/508] Adjust code structure slightly --- .../Timeline/TimelineControlPointDisplay.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs index 8e522fa715..116a3ee105 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineControlPointDisplay.cs @@ -32,10 +32,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline controlPointGroups.UnbindAll(); controlPointGroups.BindTo(beatmap.ControlPointInfo.Groups); - controlPointGroups.BindCollectionChanged((_, _) => - { - invalidateGroups(); - }, true); + controlPointGroups.BindCollectionChanged((_, _) => groupCache.Invalidate(), true); } protected override void Update() @@ -51,19 +48,20 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline if (visibleRange != newRange) { visibleRange = newRange; - invalidateGroups(); + groupCache.Invalidate(); } if (!groupCache.IsValid) + { recreateDrawableGroups(); + groupCache.Validate(); + } } - private void invalidateGroups() => groupCache.Invalidate(); - private void recreateDrawableGroups() { // Remove groups outside the visible range - foreach (var drawableGroup in this) + foreach (TimelineControlPointGroup drawableGroup in this) { if (!shouldBeVisible(drawableGroup.Group)) drawableGroup.Expire(); @@ -93,8 +91,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline Add(new TimelineControlPointGroup(group)); } - - groupCache.Validate(); } private bool shouldBeVisible(ControlPointGroup group) => group.Time >= visibleRange.min && group.Time <= visibleRange.max; From 1f343b75454c416b8c17d98428330096213c7fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 20 Mar 2024 08:27:49 +0100 Subject: [PATCH 441/508] Add extended logging when discarding online metadata lookup results Related to: https://github.com/ppy/osu/issues/27674 Relevant log output for that particular case: [network] 2024-03-20 07:25:30 [verbose]: Performing request osu.Game.Online.API.Requests.GetBeatmapRequest [network] 2024-03-20 07:25:30 [verbose]: Request to https://dev.ppy.sh/api/v2/beatmaps/lookup successfully completed! [network] 2024-03-20 07:25:30 [verbose]: GetBeatmapRequest finished with response size of 3,170 bytes [database] 2024-03-20 07:25:30 [verbose]: [4fe02] [APIBeatmapMetadataSource] Online retrieval mapped Tsukiyama Sae - Hana Saku Iro wa Koi no Gotoshi (Log Off Now) [Destiny] to 744883 / 1613507. [database] 2024-03-20 07:25:30 [verbose]: Discarding metadata lookup result due to mismatching online ID (expected: 1570982 actual: 1613507) [network] 2024-03-20 07:25:30 [verbose]: Performing request osu.Game.Online.API.Requests.GetBeatmapRequest [network] 2024-03-20 07:25:30 [verbose]: Request to https://dev.ppy.sh/api/v2/beatmaps/lookup successfully completed! [network] 2024-03-20 07:25:30 [verbose]: GetBeatmapRequest finished with response size of 2,924 bytes [database] 2024-03-20 07:25:30 [verbose]: [4fe02] [APIBeatmapMetadataSource] Online retrieval mapped Tsukiyama Sae - Hana Saku Iro wa Koi no Gotoshi (Log Off Now) [Easy] to 744883 / 1570982. [database] 2024-03-20 07:25:30 [verbose]: Discarding metadata lookup result due to mismatching online ID (expected: 1613507 actual: 1570982) Note that the online IDs are swapped. --- osu.Game/Beatmaps/BeatmapUpdaterMetadataLookup.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Beatmaps/BeatmapUpdaterMetadataLookup.cs b/osu.Game/Beatmaps/BeatmapUpdaterMetadataLookup.cs index f395718a93..034ec31ee4 100644 --- a/osu.Game/Beatmaps/BeatmapUpdaterMetadataLookup.cs +++ b/osu.Game/Beatmaps/BeatmapUpdaterMetadataLookup.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using osu.Framework.Logging; using osu.Framework.Platform; using osu.Game.Online.API; @@ -85,10 +86,16 @@ namespace osu.Game.Beatmaps private bool shouldDiscardLookupResult(OnlineBeatmapMetadata result, BeatmapInfo beatmapInfo) { if (beatmapInfo.OnlineID > 0 && result.BeatmapID != beatmapInfo.OnlineID) + { + Logger.Log($"Discarding metadata lookup result due to mismatching online ID (expected: {beatmapInfo.OnlineID} actual: {result.BeatmapID})", LoggingTarget.Database); return true; + } if (beatmapInfo.OnlineID == -1 && result.MD5Hash != beatmapInfo.MD5Hash) + { + Logger.Log($"Discarding metadata lookup result due to mismatching hash (expected: {beatmapInfo.MD5Hash} actual: {result.MD5Hash})", LoggingTarget.Database); return true; + } return false; } From c78e203df5434495a79589559b973917a4088a3e Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 20 Mar 2024 17:30:34 +0900 Subject: [PATCH 442/508] Fix infinite health processor loop when no top-level objects This is unlikely to occur in actual gameplay, but occurs in the follow-up test. --- osu.Game/Rulesets/Scoring/LegacyDrainingHealthProcessor.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Rulesets/Scoring/LegacyDrainingHealthProcessor.cs b/osu.Game/Rulesets/Scoring/LegacyDrainingHealthProcessor.cs index 2bc3ea80ec..7cee5ebecf 100644 --- a/osu.Game/Rulesets/Scoring/LegacyDrainingHealthProcessor.cs +++ b/osu.Game/Rulesets/Scoring/LegacyDrainingHealthProcessor.cs @@ -108,6 +108,9 @@ namespace osu.Game.Rulesets.Scoring increaseHp(h); } + if (topLevelObjectCount == 0) + return testDrop; + if (!fail && currentHp < lowestHpEnd) { fail = true; From 66ace02e5872bd900acdaf7682a9178eea7dc168 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 20 Mar 2024 17:31:11 +0900 Subject: [PATCH 443/508] Add test for banana shower fail --- osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs index d0a8ce4bbc..1b46be01fb 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchHealthProcessorTest.cs @@ -19,6 +19,7 @@ namespace osu.Game.Rulesets.Catch.Tests [new Droplet(), 0.01, true], [new TinyDroplet(), 0, false], [new Banana(), 0, false], + [new BananaShower(), 0, false] ]; [TestCaseSource(nameof(test_cases))] From bf5640049a73e2eb01c5cc02814aaea43d7c00e5 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 20 Mar 2024 17:31:31 +0900 Subject: [PATCH 444/508] Fix banana showers causing fails when hp is at 0 --- osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs b/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs index 2f55f9a85f..b2509091fe 100644 --- a/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs +++ b/osu.Game.Rulesets.Catch/Scoring/CatchHealthProcessor.cs @@ -32,6 +32,10 @@ namespace osu.Game.Rulesets.Catch.Scoring if (result.Type == HitResult.SmallTickMiss) return false; + // on stable, banana showers don't exist as concrete objects themselves, so they can't cause a fail. + if (result.HitObject is BananaShower) + return false; + return base.CheckDefaultFailCondition(result); } From 4904c49c38b418f3a151c34c114be96983bb03b7 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Wed, 20 Mar 2024 09:31:58 -0300 Subject: [PATCH 445/508] Add abnormal difficulty settings checks --- .../CheckAbnormalDifficultySettingsTest.cs | 93 +++++++++++++++++++ osu.Game/Rulesets/Edit/BeatmapVerifier.cs | 5 +- .../Checks/CheckAbnormalDifficultySettings.cs | 82 ++++++++++++++++ 3 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Tests/Editing/Checks/CheckAbnormalDifficultySettingsTest.cs create mode 100644 osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs diff --git a/osu.Game.Tests/Editing/Checks/CheckAbnormalDifficultySettingsTest.cs b/osu.Game.Tests/Editing/Checks/CheckAbnormalDifficultySettingsTest.cs new file mode 100644 index 0000000000..94305755c4 --- /dev/null +++ b/osu.Game.Tests/Editing/Checks/CheckAbnormalDifficultySettingsTest.cs @@ -0,0 +1,93 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Edit.Checks; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Edit; +using osu.Game.Tests.Beatmaps; +using System.Linq; + +namespace osu.Game.Tests.Editing.Checks +{ + [TestFixture] + public class CheckAbnormalDifficultySettingsTest + { + private CheckAbnormalDifficultySettings check = null!; + + private IBeatmap beatmap = new Beatmap(); + + [SetUp] + public void Setup() + { + check = new CheckAbnormalDifficultySettings(); + beatmap.Difficulty = new(); + } + + [Test] + public void TestSettingsNormal() + { + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestAllSettingsMoreThanOneDecimal() + { + beatmap.Difficulty = new() + { + ApproachRate = 5.55f, + OverallDifficulty = 7.7777f, + CircleSize = 4.444f, + DrainRate = 1.1111111111f, + }; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(4)); + } + + [Test] + public void TestAllSettingsLessThanZero() + { + beatmap.Difficulty = new() + { + ApproachRate = -1, + OverallDifficulty = -20, + CircleSize = -11, + DrainRate = -34, + }; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(4)); + } + + [Test] + public void TestAllSettingsHigherThanTen() + { + beatmap.Difficulty = new() + { + ApproachRate = 14, + OverallDifficulty = 24, + CircleSize = 30, + DrainRate = 90, + }; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(4)); + } + + private BeatmapVerifierContext getContext() + { + return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); + } + } +} diff --git a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs index dcf5eb4da9..edabe941b7 100644 --- a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs +++ b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs @@ -41,7 +41,10 @@ namespace osu.Game.Rulesets.Edit new CheckPreviewTime(), // Events - new CheckBreaks() + new CheckBreaks(), + + // Settings + new CheckAbnormalDifficultySettings(), }; public IEnumerable Run(BeatmapVerifierContext context) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs new file mode 100644 index 0000000000..73049b323d --- /dev/null +++ b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs @@ -0,0 +1,82 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Game.Rulesets.Edit.Checks.Components; + + +namespace osu.Game.Rulesets.Edit.Checks +{ + public class CheckAbnormalDifficultySettings : ICheck + { + public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Abnormal difficulty settings"); + + public IEnumerable PossibleTemplates => new IssueTemplate[] + { + new IssueTemplateMoreThanOneDecimal(this), + new IssueTemplateOutOfRange(this), + }; + + public IEnumerable Run(BeatmapVerifierContext context) + { + var diff = context.Beatmap.Difficulty; + + if (hasMoreThanOneDecimalPlace(diff.ApproachRate)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate); + + if (isOutOfRange(diff.ApproachRate)) + yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate); + + + if (hasMoreThanOneDecimalPlace(diff.OverallDifficulty)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); + + if (isOutOfRange(diff.OverallDifficulty)) + yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); + + + if (hasMoreThanOneDecimalPlace(diff.CircleSize)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize); + + if (isOutOfRange(diff.CircleSize)) + yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize); + + + if (hasMoreThanOneDecimalPlace(diff.DrainRate)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + + if (isOutOfRange(diff.DrainRate)) + yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); + } + + private bool isOutOfRange(float setting) + { + return setting < 0f || setting > 10f; + } + + private bool hasMoreThanOneDecimalPlace(float setting) + { + return float.Round(setting, 1) != setting; + } + + public class IssueTemplateMoreThanOneDecimal : IssueTemplate + { + public IssueTemplateMoreThanOneDecimal(ICheck check) + : base(check, IssueType.Problem, "{0} {1} has more than one decimal place.") + { + } + + public Issue Create(string settingName, float settingValue) => new Issue(this, settingName, settingValue); + } + + public class IssueTemplateOutOfRange : IssueTemplate + { + public IssueTemplateOutOfRange(ICheck check) + : base(check, IssueType.Warning, "{0} is {1} although it is capped between 0 to 10 in-game.") + { + } + + public Issue Create(string settingName, float settingValue) => new Issue(this, settingName, settingValue); + } + } +} From ac7fca10d63e3f92db65572ea77ae0ab4bb58df6 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Thu, 21 Mar 2024 00:47:37 +0900 Subject: [PATCH 446/508] Warn about not using an official "deployed" build --- osu.Game/Localisation/NotificationsStrings.cs | 5 +++++ osu.Game/Updater/UpdateManager.cs | 6 ++++++ osu.Game/Utils/OfficialBuildAttribute.cs | 12 ++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 osu.Game/Utils/OfficialBuildAttribute.cs diff --git a/osu.Game/Localisation/NotificationsStrings.cs b/osu.Game/Localisation/NotificationsStrings.cs index f4965e4ebe..5328bcd066 100644 --- a/osu.Game/Localisation/NotificationsStrings.cs +++ b/osu.Game/Localisation/NotificationsStrings.cs @@ -125,6 +125,11 @@ Click to see what's new!", version); /// public static LocalisableString UpdateReadyToInstall => new TranslatableString(getKey(@"update_ready_to_install"), @"Update ready to install. Click to restart!"); + /// + /// "This is not an official build of the game and scores will not be submitted." + /// + public static LocalisableString NotOfficialBuild => new TranslatableString(getKey(@"not_official_build"), @"This is not an official build of the game and scores will not be submitted."); + /// /// "Downloading update..." /// diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 8f13e0f42a..bcb28d8b14 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -1,7 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Reflection; using System.Threading.Tasks; +using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -11,6 +13,7 @@ using osu.Game.Graphics; using osu.Game.Localisation; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; +using osu.Game.Utils; using osuTK; namespace osu.Game.Updater @@ -51,6 +54,9 @@ namespace osu.Game.Updater // only show a notification if we've previously saved a version to the config file (ie. not the first run). if (!string.IsNullOrEmpty(lastVersion)) Notifications.Post(new UpdateCompleteNotification(version)); + + if (RuntimeInfo.EntryAssembly.GetCustomAttribute() == null) + Notifications.Post(new SimpleNotification { Text = NotificationsStrings.NotOfficialBuild }); } // debug / local compilations will reset to a non-release string. diff --git a/osu.Game/Utils/OfficialBuildAttribute.cs b/osu.Game/Utils/OfficialBuildAttribute.cs new file mode 100644 index 0000000000..66c1ef5591 --- /dev/null +++ b/osu.Game/Utils/OfficialBuildAttribute.cs @@ -0,0 +1,12 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using JetBrains.Annotations; + +namespace osu.Game.Utils +{ + [UsedImplicitly] + [AttributeUsage(AttributeTargets.Assembly)] + public class OfficialBuildAttribute : Attribute; +} From c605e463a41388f43a0493d1246a813f1f7d4ab1 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Wed, 20 Mar 2024 15:52:16 -0300 Subject: [PATCH 447/508] Add mania keycount check --- .../Editor/Checks/CheckKeyCountTest.cs | 75 +++++++++++++++++++ .../Edit/Checks/CheckKeyCount.cs | 55 ++++++++++++++ .../Edit/ManiaBeatmapVerifier.cs | 24 ++++++ osu.Game.Rulesets.Mania/ManiaRuleset.cs | 2 + .../Checks/CheckAbnormalDifficultySettings.cs | 4 +- 5 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs create mode 100644 osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs create mode 100644 osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs new file mode 100644 index 0000000000..91361e2a62 --- /dev/null +++ b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs @@ -0,0 +1,75 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Objects; +using osu.Game.Tests.Beatmaps; +using osu.Game.Rulesets.Mania.Edit.Checks; +using System.Linq; + +namespace osu.Game.Rulesets.Mania.Tests.Editor.Checks +{ + [TestFixture] + public class CheckKeyCountTest + { + private CheckKeyCount check = null!; + + private IBeatmap beatmap = null!; + + [SetUp] + public void Setup() + { + check = new CheckKeyCount(); + + beatmap = new Beatmap() + { + BeatmapInfo = new BeatmapInfo + { + Ruleset = new ManiaRuleset().RulesetInfo + } + }; + } + + [Test] + public void TestKeycountFour() + { + beatmap.Difficulty.CircleSize = 4; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestKeycountSmallerThanFour() + { + beatmap.Difficulty.CircleSize = 1; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckKeyCount.IssueTemplateKeycountTooLow); + } + + [Test] + public void TestKeycountHigherThanTen() + { + beatmap.Difficulty.CircleSize = 11; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckKeyCount.IssueTemplateKeycountNonStandard); + } + + private BeatmapVerifierContext getContext() + { + return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); + } + } +} diff --git a/osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs b/osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs new file mode 100644 index 0000000000..57991bd3ff --- /dev/null +++ b/osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs @@ -0,0 +1,55 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks.Components; + +namespace osu.Game.Rulesets.Mania.Edit.Checks +{ + public class CheckKeyCount : ICheck + { + public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Check mania keycount."); + + public IEnumerable PossibleTemplates => new IssueTemplate[] + { + new IssueTemplateKeycountTooLow(this), + new IssueTemplateKeycountNonStandard(this), + }; + + public IEnumerable Run(BeatmapVerifierContext context) + { + var diff = context.Beatmap.Difficulty; + + if (diff.CircleSize < 4) + { + yield return new IssueTemplateKeycountTooLow(this).Create(diff.CircleSize); + } + + if (diff.CircleSize > 10) + { + yield return new IssueTemplateKeycountNonStandard(this).Create(diff.CircleSize); + } + } + + public class IssueTemplateKeycountTooLow : IssueTemplate + { + public IssueTemplateKeycountTooLow(ICheck check) + : base(check, IssueType.Problem, "Key count is {0} and must be 4 or higher.") + { + } + + public Issue Create(float current) => new Issue(this, current); + } + + public class IssueTemplateKeycountNonStandard : IssueTemplate + { + public IssueTemplateKeycountNonStandard(ICheck check) + : base(check, IssueType.Warning, "Key count {0} is higher than 10.") + { + } + + public Issue Create(float current) => new Issue(this, current); + } + } +} diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs b/osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs new file mode 100644 index 0000000000..778dcfc6e1 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using System.Linq; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks.Components; +using osu.Game.Rulesets.Mania.Edit.Checks; + +namespace osu.Game.Rulesets.Mania.Edit +{ + public class ManiaBeatmapVerifier : IBeatmapVerifier + { + private readonly List checks = new List + { + new CheckKeyCount(), + }; + + public IEnumerable Run(BeatmapVerifierContext context) + { + return checks.SelectMany(check => check.Run(context)); + } + } +} diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 0b54fb3da0..3d4803f1e4 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -65,6 +65,8 @@ namespace osu.Game.Rulesets.Mania public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this); + public override IBeatmapVerifier CreateBeatmapVerifier() => new ManiaBeatmapVerifier(); + public override ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap) { switch (skin) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs index 73049b323d..3c454a57fe 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using osu.Game.Rulesets.Edit.Checks.Components; - namespace osu.Game.Rulesets.Edit.Checks { public class CheckAbnormalDifficultySettings : ICheck @@ -20,6 +19,7 @@ namespace osu.Game.Rulesets.Edit.Checks public IEnumerable Run(BeatmapVerifierContext context) { var diff = context.Beatmap.Difficulty; + string ruleset = context.Beatmap.BeatmapInfo.Ruleset.ShortName; if (hasMoreThanOneDecimalPlace(diff.ApproachRate)) yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate); @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Edit.Checks if (hasMoreThanOneDecimalPlace(diff.CircleSize)) yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize); - if (isOutOfRange(diff.CircleSize)) + if (ruleset != "mania" && isOutOfRange(diff.CircleSize)) yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize); From 2d6a3b8e2b5e3f0023957868a0706f5df162e110 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Wed, 20 Mar 2024 16:51:27 -0300 Subject: [PATCH 448/508] Remove warning for 10K+ --- .../Editor/Checks/CheckKeyCountTest.cs | 12 ------------ .../Edit/Checks/CheckKeyCount.cs | 16 ---------------- 2 files changed, 28 deletions(-) diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs index 91361e2a62..564c611548 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs @@ -55,18 +55,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor.Checks Assert.That(issues.Single().Template is CheckKeyCount.IssueTemplateKeycountTooLow); } - [Test] - public void TestKeycountHigherThanTen() - { - beatmap.Difficulty.CircleSize = 11; - - var context = getContext(); - var issues = check.Run(context).ToList(); - - Assert.That(issues, Has.Count.EqualTo(1)); - Assert.That(issues.Single().Template is CheckKeyCount.IssueTemplateKeycountNonStandard); - } - private BeatmapVerifierContext getContext() { return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); diff --git a/osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs b/osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs index 57991bd3ff..51ead5f423 100644 --- a/osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs +++ b/osu.Game.Rulesets.Mania/Edit/Checks/CheckKeyCount.cs @@ -14,7 +14,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Checks public IEnumerable PossibleTemplates => new IssueTemplate[] { new IssueTemplateKeycountTooLow(this), - new IssueTemplateKeycountNonStandard(this), }; public IEnumerable Run(BeatmapVerifierContext context) @@ -25,11 +24,6 @@ namespace osu.Game.Rulesets.Mania.Edit.Checks { yield return new IssueTemplateKeycountTooLow(this).Create(diff.CircleSize); } - - if (diff.CircleSize > 10) - { - yield return new IssueTemplateKeycountNonStandard(this).Create(diff.CircleSize); - } } public class IssueTemplateKeycountTooLow : IssueTemplate @@ -41,15 +35,5 @@ namespace osu.Game.Rulesets.Mania.Edit.Checks public Issue Create(float current) => new Issue(this, current); } - - public class IssueTemplateKeycountNonStandard : IssueTemplate - { - public IssueTemplateKeycountNonStandard(ICheck check) - : base(check, IssueType.Warning, "Key count {0} is higher than 10.") - { - } - - public Issue Create(float current) => new Issue(this, current); - } } } From b132734f9c429da05b976544b266528c765019e6 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Wed, 20 Mar 2024 18:54:38 -0300 Subject: [PATCH 449/508] Fix codefactor issues --- .../Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs index 3c454a57fe..db154f4efc 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs @@ -27,21 +27,18 @@ namespace osu.Game.Rulesets.Edit.Checks if (isOutOfRange(diff.ApproachRate)) yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate); - if (hasMoreThanOneDecimalPlace(diff.OverallDifficulty)) yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); if (isOutOfRange(diff.OverallDifficulty)) yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); - if (hasMoreThanOneDecimalPlace(diff.CircleSize)) yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize); if (ruleset != "mania" && isOutOfRange(diff.CircleSize)) yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize); - if (hasMoreThanOneDecimalPlace(diff.DrainRate)) yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); From a07d5115bfef749e2b766a554ceb420c82206dd0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Mar 2024 11:42:22 +0800 Subject: [PATCH 450/508] Update resources --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index de7497d58e..0e091dbd37 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -36,7 +36,7 @@ - + From 55d66d4615e65bdbcc794d385da3210aa130d7cf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Mar 2024 11:45:46 +0800 Subject: [PATCH 451/508] Add sounds to countdown --- osu.Game/Screens/Play/DelayedResumeOverlay.cs | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/DelayedResumeOverlay.cs b/osu.Game/Screens/Play/DelayedResumeOverlay.cs index 8bb3ae8182..147d48ae02 100644 --- a/osu.Game/Screens/Play/DelayedResumeOverlay.cs +++ b/osu.Game/Screens/Play/DelayedResumeOverlay.cs @@ -3,6 +3,8 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -47,6 +49,8 @@ namespace osu.Game.Screens.Play private SpriteText countdownText = null!; private CircularProgress countdownProgress = null!; + private Sample? sampleCountdown; + public DelayedResumeOverlay() { Anchor = Anchor.Centre; @@ -54,7 +58,7 @@ namespace osu.Game.Screens.Play } [BackgroundDependencyLoader] - private void load() + private void load(AudioManager audio) { Add(outerContent = new Circle { @@ -103,6 +107,8 @@ namespace osu.Game.Screens.Play } } }); + + sampleCountdown = audio.Samples.Get(@"Gameplay/resume-countdown"); } protected override void PopIn() @@ -164,13 +170,24 @@ namespace osu.Game.Screens.Play countdownProgress.Progress = amountTimePassed; countdownProgress.InnerRadius = progress_stroke_width / progress_size / countdownProgress.Scale.X; - if (countdownCount != newCount && newCount > 0) + if (countdownCount != newCount) { - countdownText.Text = Math.Max(1, newCount).ToString(); - countdownText.ScaleTo(0.25f).Then().ScaleTo(1, 200, Easing.OutQuint); - outerContent.Delay(25).Then().ScaleTo(1.05f, 100).Then().ScaleTo(1f, 200, Easing.Out); + if (newCount > 0) + { + countdownText.Text = Math.Max(1, newCount).ToString(); + countdownText.ScaleTo(0.25f).Then().ScaleTo(1, 200, Easing.OutQuint); + outerContent.Delay(25).Then().ScaleTo(1.05f, 100).Then().ScaleTo(1f, 200, Easing.Out); - countdownBackground.FlashColour(colourProvider.Background3, 400, Easing.Out); + countdownBackground.FlashColour(colourProvider.Background3, 400, Easing.Out); + } + + var chan = sampleCountdown?.GetChannel(); + + if (chan != null) + { + chan.Frequency.Value = newCount == 0 ? 0.5f : 1; + chan.Play(); + } } countdownCount = newCount; From b99b0337cffd33519b1323adbda98cb13b395f63 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Mar 2024 13:06:25 +0800 Subject: [PATCH 452/508] Adjust text slightly --- osu.Game/Localisation/NotificationsStrings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Localisation/NotificationsStrings.cs b/osu.Game/Localisation/NotificationsStrings.cs index 5328bcd066..3188ca5533 100644 --- a/osu.Game/Localisation/NotificationsStrings.cs +++ b/osu.Game/Localisation/NotificationsStrings.cs @@ -126,9 +126,9 @@ Click to see what's new!", version); public static LocalisableString UpdateReadyToInstall => new TranslatableString(getKey(@"update_ready_to_install"), @"Update ready to install. Click to restart!"); /// - /// "This is not an official build of the game and scores will not be submitted." + /// "This is not an official build of the game. Scores will not be submitted and other online systems may not work as intended." /// - public static LocalisableString NotOfficialBuild => new TranslatableString(getKey(@"not_official_build"), @"This is not an official build of the game and scores will not be submitted."); + public static LocalisableString NotOfficialBuild => new TranslatableString(getKey(@"not_official_build"), @"This is not an official build of the game. Scores will not be submitted and other online systems may not work as intended."); /// /// "Downloading update..." From a4822fd615ef983be0399182f98159fc8546e427 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Fri, 22 Mar 2024 01:37:06 -0300 Subject: [PATCH 453/508] Make `CheckAbnormalDifficultySettings` abstract --- .../CheckAbnormalDifficultySettingsTest.cs | 93 ------------------- osu.Game/Rulesets/Edit/BeatmapVerifier.cs | 3 - .../Checks/CheckAbnormalDifficultySettings.cs | 41 ++------ 3 files changed, 8 insertions(+), 129 deletions(-) delete mode 100644 osu.Game.Tests/Editing/Checks/CheckAbnormalDifficultySettingsTest.cs diff --git a/osu.Game.Tests/Editing/Checks/CheckAbnormalDifficultySettingsTest.cs b/osu.Game.Tests/Editing/Checks/CheckAbnormalDifficultySettingsTest.cs deleted file mode 100644 index 94305755c4..0000000000 --- a/osu.Game.Tests/Editing/Checks/CheckAbnormalDifficultySettingsTest.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Game.Rulesets.Edit.Checks; -using NUnit.Framework; -using osu.Game.Beatmaps; -using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Edit; -using osu.Game.Tests.Beatmaps; -using System.Linq; - -namespace osu.Game.Tests.Editing.Checks -{ - [TestFixture] - public class CheckAbnormalDifficultySettingsTest - { - private CheckAbnormalDifficultySettings check = null!; - - private IBeatmap beatmap = new Beatmap(); - - [SetUp] - public void Setup() - { - check = new CheckAbnormalDifficultySettings(); - beatmap.Difficulty = new(); - } - - [Test] - public void TestSettingsNormal() - { - var context = getContext(); - var issues = check.Run(context).ToList(); - - Assert.That(issues, Has.Count.EqualTo(0)); - } - - [Test] - public void TestAllSettingsMoreThanOneDecimal() - { - beatmap.Difficulty = new() - { - ApproachRate = 5.55f, - OverallDifficulty = 7.7777f, - CircleSize = 4.444f, - DrainRate = 1.1111111111f, - }; - - var context = getContext(); - var issues = check.Run(context).ToList(); - - Assert.That(issues, Has.Count.EqualTo(4)); - } - - [Test] - public void TestAllSettingsLessThanZero() - { - beatmap.Difficulty = new() - { - ApproachRate = -1, - OverallDifficulty = -20, - CircleSize = -11, - DrainRate = -34, - }; - - var context = getContext(); - var issues = check.Run(context).ToList(); - - Assert.That(issues, Has.Count.EqualTo(4)); - } - - [Test] - public void TestAllSettingsHigherThanTen() - { - beatmap.Difficulty = new() - { - ApproachRate = 14, - OverallDifficulty = 24, - CircleSize = 30, - DrainRate = 90, - }; - - var context = getContext(); - var issues = check.Run(context).ToList(); - - Assert.That(issues, Has.Count.EqualTo(4)); - } - - private BeatmapVerifierContext getContext() - { - return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); - } - } -} diff --git a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs index edabe941b7..2eb52e88c7 100644 --- a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs +++ b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs @@ -42,9 +42,6 @@ namespace osu.Game.Rulesets.Edit // Events new CheckBreaks(), - - // Settings - new CheckAbnormalDifficultySettings(), }; public IEnumerable Run(BeatmapVerifierContext context) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs index db154f4efc..93592a866b 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs @@ -6,9 +6,9 @@ using osu.Game.Rulesets.Edit.Checks.Components; namespace osu.Game.Rulesets.Edit.Checks { - public class CheckAbnormalDifficultySettings : ICheck + public abstract class CheckAbnormalDifficultySettings : ICheck { - public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Abnormal difficulty settings"); + public abstract CheckMetadata Metadata { get; } public IEnumerable PossibleTemplates => new IssueTemplate[] { @@ -16,42 +16,17 @@ namespace osu.Game.Rulesets.Edit.Checks new IssueTemplateOutOfRange(this), }; - public IEnumerable Run(BeatmapVerifierContext context) - { - var diff = context.Beatmap.Difficulty; - string ruleset = context.Beatmap.BeatmapInfo.Ruleset.ShortName; + public abstract IEnumerable Run(BeatmapVerifierContext context); - if (hasMoreThanOneDecimalPlace(diff.ApproachRate)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate); - - if (isOutOfRange(diff.ApproachRate)) - yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate); - - if (hasMoreThanOneDecimalPlace(diff.OverallDifficulty)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); - - if (isOutOfRange(diff.OverallDifficulty)) - yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); - - if (hasMoreThanOneDecimalPlace(diff.CircleSize)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize); - - if (ruleset != "mania" && isOutOfRange(diff.CircleSize)) - yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize); - - if (hasMoreThanOneDecimalPlace(diff.DrainRate)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); - - if (isOutOfRange(diff.DrainRate)) - yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); - } - - private bool isOutOfRange(float setting) + /// + /// If the setting is out of the boundaries set by the editor (0 - 10) + /// + protected bool OutOfRange(float setting) { return setting < 0f || setting > 10f; } - private bool hasMoreThanOneDecimalPlace(float setting) + protected bool HasMoreThanOneDecimalPlace(float setting) { return float.Round(setting, 1) != setting; } From e2df0981843c3428fa11a232d341d97ac3e0505f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 22 Mar 2024 08:25:03 +0100 Subject: [PATCH 454/508] Add failing test case for desired artist sort behaviour --- .../SongSelect/TestSceneBeatmapCarousel.cs | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index de2ae3708f..c0102b238c 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -666,6 +666,56 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert($"Check {zzz_lowercase} is second last", () => carousel.BeatmapSets.SkipLast(1).Last().Metadata.Artist == zzz_lowercase); } + [Test] + public void TestSortByArtistUsesTitleAsTiebreaker() + { + var sets = new List(); + + AddStep("Populuate beatmap sets", () => + { + sets.Clear(); + + for (int i = 0; i < 20; i++) + { + var set = TestResources.CreateTestBeatmapSetInfo(); + + if (i == 4) + { + set.Beatmaps.ForEach(b => + { + b.Metadata.Artist = "ZZZ"; + b.Metadata.Title = "AAA"; + }); + } + + if (i == 8) + { + set.Beatmaps.ForEach(b => + { + b.Metadata.Artist = "ZZZ"; + b.Metadata.Title = "ZZZ"; + }); + } + + sets.Add(set); + } + }); + + loadBeatmaps(sets); + + AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false)); + AddAssert("Check last item", () => + { + var lastItem = carousel.BeatmapSets.Last(); + return lastItem.Metadata.Artist == "ZZZ" && lastItem.Metadata.Title == "ZZZ"; + }); + AddAssert("Check second last item", () => + { + var secondLastItem = carousel.BeatmapSets.SkipLast(1).Last(); + return secondLastItem.Metadata.Artist == "ZZZ" && secondLastItem.Metadata.Title == "AAA"; + }); + } + /// /// Ensures stability is maintained on different sort modes for items with equal properties. /// From a1880e89c299f55a8907050988b8200e854ed34b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 22 Mar 2024 08:31:59 +0100 Subject: [PATCH 455/508] Use title as tiebreaker when sorting beatmap carousel by artist Closes https://github.com/ppy/osu/issues/27548. Reference: https://github.com/peppy/osu-stable-reference/blob/e53980dd76857ee899f66ce519ba1597e7874f28/osu!/GameplayElements/Beatmaps/BeatmapTreeManager.cs#L341-L347 --- osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs index 43c9c621e8..7e15699804 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs @@ -69,6 +69,8 @@ namespace osu.Game.Screens.Select.Carousel default: case SortMode.Artist: comparison = OrdinalSortByCaseStringComparer.DEFAULT.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist); + if (comparison == 0) + goto case SortMode.Title; break; case SortMode.Title: From 6fa663c8cac732c6d705955f52565f1f78b7eddd Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Fri, 22 Mar 2024 14:48:22 -0300 Subject: [PATCH 456/508] Make check ruleset specific --- ...heckCatchAbnormalDifficultySettingsTest.cs | 158 ++++++++++++++ .../Edit/CatchBeatmapVerifier.cs | 3 +- .../CheckCatchAbnormalDifficultySettings.cs | 38 ++++ ...heckManiaAbnormalDifficultySettingsTest.cs | 121 +++++++++++ .../CheckManiaAbnormalDifficultySettings.cs | 32 +++ .../Edit/ManiaBeatmapVerifier.cs | 2 + .../CheckOsuAbnormalDifficultySettingsTest.cs | 194 ++++++++++++++++++ .../CheckOsuAbnormalDifficultySettings.cs | 43 ++++ .../Edit/OsuBeatmapVerifier.cs | 3 + ...heckTaikoAbnormalDifficultySettingsTest.cs | 84 ++++++++ .../CheckTaikoAbnormalDifficultySettings.cs | 26 +++ .../Edit/TaikoBeatmapVerifier.cs | 24 +++ osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 2 + 13 files changed, 729 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Rulesets.Catch.Tests/Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs create mode 100644 osu.Game.Rulesets.Catch/Edit/Checks/CheckCatchAbnormalDifficultySettings.cs create mode 100644 osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs create mode 100644 osu.Game.Rulesets.Mania/Edit/Checks/CheckManiaAbnormalDifficultySettings.cs create mode 100644 osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs create mode 100644 osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs create mode 100644 osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs create mode 100644 osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs create mode 100644 osu.Game.Rulesets.Taiko/Edit/TaikoBeatmapVerifier.cs diff --git a/osu.Game.Rulesets.Catch.Tests/Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Catch.Tests/Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs new file mode 100644 index 0000000000..2ae2e20215 --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs @@ -0,0 +1,158 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Catch.Edit.Checks; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Objects; +using osu.Game.Tests.Beatmaps; + +namespace osu.Game.Rulesets.Catch.Tests.Editor.Checks +{ + [TestFixture] + public class CheckCatchAbnormalDifficultySettingsTest + { + private CheckCatchAbnormalDifficultySettings check = null!; + + private IBeatmap beatmap = new Beatmap(); + + [SetUp] + public void Setup() + { + check = new CheckCatchAbnormalDifficultySettings(); + + beatmap.BeatmapInfo.Ruleset = new CatchRuleset().RulesetInfo; + beatmap.Difficulty = new BeatmapDifficulty() + { + ApproachRate = 5, + CircleSize = 5, + DrainRate = 5, + }; + } + + [Test] + public void TestNormalSettings() + { + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestApproachRateTwoDecimals() + { + beatmap.Difficulty.ApproachRate = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestCircleSizeTwoDecimals() + { + beatmap.Difficulty.CircleSize = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestDrainRateTwoDecimals() + { + beatmap.Difficulty.DrainRate = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestApproachRateUnder() + { + beatmap.Difficulty.ApproachRate = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestCircleSizeUnder() + { + beatmap.Difficulty.CircleSize = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestDrainRateUnder() + { + beatmap.Difficulty.DrainRate = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestApproachRateOver() + { + beatmap.Difficulty.ApproachRate = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestCircleSizeOver() + { + beatmap.Difficulty.CircleSize = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestDrainRateOver() + { + beatmap.Difficulty.DrainRate = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + private BeatmapVerifierContext getContext() + { + return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); + } + } +} diff --git a/osu.Game.Rulesets.Catch/Edit/CatchBeatmapVerifier.cs b/osu.Game.Rulesets.Catch/Edit/CatchBeatmapVerifier.cs index c7a41a4e22..71da6d5014 100644 --- a/osu.Game.Rulesets.Catch/Edit/CatchBeatmapVerifier.cs +++ b/osu.Game.Rulesets.Catch/Edit/CatchBeatmapVerifier.cs @@ -13,7 +13,8 @@ namespace osu.Game.Rulesets.Catch.Edit { private readonly List checks = new List { - new CheckBananaShowerGap() + new CheckBananaShowerGap(), + new CheckCatchAbnormalDifficultySettings(), }; public IEnumerable Run(BeatmapVerifierContext context) diff --git a/osu.Game.Rulesets.Catch/Edit/Checks/CheckCatchAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Catch/Edit/Checks/CheckCatchAbnormalDifficultySettings.cs new file mode 100644 index 0000000000..8295795f00 --- /dev/null +++ b/osu.Game.Rulesets.Catch/Edit/Checks/CheckCatchAbnormalDifficultySettings.cs @@ -0,0 +1,38 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Edit.Checks.Components; + +namespace osu.Game.Rulesets.Catch.Edit.Checks +{ + public class CheckCatchAbnormalDifficultySettings : CheckAbnormalDifficultySettings + { + public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks catch relevant settings"); + + public override IEnumerable Run(BeatmapVerifierContext context) + { + var diff = context.Beatmap.Difficulty; + + if (HasMoreThanOneDecimalPlace(diff.ApproachRate)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate); + + if (OutOfRange(diff.ApproachRate)) + yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate); + + if (HasMoreThanOneDecimalPlace(diff.CircleSize)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize); + + if (OutOfRange(diff.CircleSize)) + yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize); + + if (HasMoreThanOneDecimalPlace(diff.DrainRate)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + + if (OutOfRange(diff.DrainRate)) + yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); + } + } +} diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs new file mode 100644 index 0000000000..6c585aace3 --- /dev/null +++ b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs @@ -0,0 +1,121 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mania.Edit.Checks; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Objects; +using osu.Game.Tests.Beatmaps; + +namespace osu.Game.Rulesets.Mania.Tests.Editor.Checks +{ + [TestFixture] + public class CheckManiaAbnormalDifficultySettingsTest + { + private CheckManiaAbnormalDifficultySettings check = null!; + + private IBeatmap beatmap = new Beatmap(); + + [SetUp] + public void Setup() + { + check = new CheckManiaAbnormalDifficultySettings(); + + beatmap.BeatmapInfo.Ruleset = new ManiaRuleset().RulesetInfo; + beatmap.Difficulty = new BeatmapDifficulty() + { + OverallDifficulty = 5, + DrainRate = 5, + }; + } + + [Test] + public void TestNormalSettings() + { + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestOverallDifficultyTwoDecimals() + { + beatmap.Difficulty.OverallDifficulty = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestDrainRateTwoDecimals() + { + beatmap.Difficulty.DrainRate = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestOverallDifficultyUnder() + { + beatmap.Difficulty.OverallDifficulty = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestDrainRateUnder() + { + beatmap.Difficulty.DrainRate = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestOverallDifficultyOver() + { + beatmap.Difficulty.OverallDifficulty = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestDrainRateOver() + { + beatmap.Difficulty.DrainRate = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + private BeatmapVerifierContext getContext() + { + return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); + } + } +} diff --git a/osu.Game.Rulesets.Mania/Edit/Checks/CheckManiaAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Mania/Edit/Checks/CheckManiaAbnormalDifficultySettings.cs new file mode 100644 index 0000000000..ae0cc3aa4c --- /dev/null +++ b/osu.Game.Rulesets.Mania/Edit/Checks/CheckManiaAbnormalDifficultySettings.cs @@ -0,0 +1,32 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Edit.Checks.Components; + +namespace osu.Game.Rulesets.Mania.Edit.Checks +{ + public class CheckManiaAbnormalDifficultySettings : CheckAbnormalDifficultySettings + { + public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks mania relevant settings"); + + public override IEnumerable Run(BeatmapVerifierContext context) + { + var diff = context.Beatmap.Difficulty; + + if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); + + if (OutOfRange(diff.OverallDifficulty)) + yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); + + if (HasMoreThanOneDecimalPlace(diff.DrainRate)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + + if (OutOfRange(diff.DrainRate)) + yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); + } + } +} diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs b/osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs index 778dcfc6e1..4adabfa4d7 100644 --- a/osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs +++ b/osu.Game.Rulesets.Mania/Edit/ManiaBeatmapVerifier.cs @@ -13,7 +13,9 @@ namespace osu.Game.Rulesets.Mania.Edit { private readonly List checks = new List { + // Settings new CheckKeyCount(), + new CheckManiaAbnormalDifficultySettings(), }; public IEnumerable Run(BeatmapVerifierContext context) diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs new file mode 100644 index 0000000000..53ccd3c7a7 --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs @@ -0,0 +1,194 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Osu.Edit.Checks; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Edit; +using osu.Game.Tests.Beatmaps; +using System.Linq; + +namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks +{ + [TestFixture] + public class CheckOsuAbnormalDifficultySettingsTest + { + private CheckOsuAbnormalDifficultySettings check = null!; + + private IBeatmap beatmap = new Beatmap(); + + [SetUp] + public void Setup() + { + check = new CheckOsuAbnormalDifficultySettings(); + + beatmap.Difficulty = new BeatmapDifficulty() + { + ApproachRate = 5, + CircleSize = 5, + DrainRate = 5, + OverallDifficulty = 5, + }; + } + + [Test] + public void TestNormalSettings() + { + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestApproachRateTwoDecimals() + { + beatmap.Difficulty.ApproachRate = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestCircleSizeTwoDecimals() + { + beatmap.Difficulty.CircleSize = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestDrainRateTwoDecimals() + { + beatmap.Difficulty.DrainRate = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestOverallDifficultyTwoDecimals() + { + beatmap.Difficulty.OverallDifficulty = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestApproachRateUnder() + { + beatmap.Difficulty.ApproachRate = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestCircleSizeUnder() + { + beatmap.Difficulty.CircleSize = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestDrainRateUnder() + { + beatmap.Difficulty.DrainRate = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestOverallDifficultyUnder() + { + beatmap.Difficulty.OverallDifficulty = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestApproachRateOver() + { + beatmap.Difficulty.ApproachRate = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestCircleSizeOver() + { + beatmap.Difficulty.CircleSize = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestDrainRateOver() + { + beatmap.Difficulty.DrainRate = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestOverallDifficultyOver() + { + beatmap.Difficulty.OverallDifficulty = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + private BeatmapVerifierContext getContext() + { + return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); + } + } +} diff --git a/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs new file mode 100644 index 0000000000..c1eca7fff7 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs @@ -0,0 +1,43 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Edit.Checks.Components; + +namespace osu.Game.Rulesets.Osu.Edit.Checks +{ + public class CheckOsuAbnormalDifficultySettings : CheckAbnormalDifficultySettings + { + public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks osu relevant settings"); + public override IEnumerable Run(BeatmapVerifierContext context) + { + var diff = context.Beatmap.Difficulty; + + if (HasMoreThanOneDecimalPlace(diff.ApproachRate)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate); + + if (OutOfRange(diff.ApproachRate)) + yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate); + + if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); + + if (OutOfRange(diff.OverallDifficulty)) + yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); + + if (HasMoreThanOneDecimalPlace(diff.CircleSize)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize); + + if (OutOfRange(diff.CircleSize)) + yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize); + + if (HasMoreThanOneDecimalPlace(diff.DrainRate)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + + if (OutOfRange(diff.DrainRate)) + yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); + } + } +} diff --git a/osu.Game.Rulesets.Osu/Edit/OsuBeatmapVerifier.cs b/osu.Game.Rulesets.Osu/Edit/OsuBeatmapVerifier.cs index 325e9ed4cb..4b01a1fc39 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuBeatmapVerifier.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuBeatmapVerifier.cs @@ -21,6 +21,9 @@ namespace osu.Game.Rulesets.Osu.Edit new CheckTimeDistanceEquality(), new CheckLowDiffOverlaps(), new CheckTooShortSliders(), + + // Settings + new CheckOsuAbnormalDifficultySettings(), }; public IEnumerable Run(BeatmapVerifierContext context) diff --git a/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs new file mode 100644 index 0000000000..f10e62f3bf --- /dev/null +++ b/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs @@ -0,0 +1,84 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets.Taiko.Edit.Checks; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Edit; +using osu.Game.Tests.Beatmaps; +using System.Linq; + +namespace osu.Game.Rulesets.Taiko.Tests.Editor.Checks +{ + [TestFixture] + public class CheckTaikoAbnormalDifficultySettingsTest + { + private CheckTaikoAbnormalDifficultySettings check = null!; + + private IBeatmap beatmap = new Beatmap(); + + [SetUp] + public void Setup() + { + check = new CheckTaikoAbnormalDifficultySettings(); + + beatmap.BeatmapInfo.Ruleset = new TaikoRuleset().RulesetInfo; + beatmap.Difficulty = new BeatmapDifficulty() + { + OverallDifficulty = 5, + }; + } + + [Test] + public void TestNormalSettings() + { + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestOverallDifficultyTwoDecimals() + { + beatmap.Difficulty.OverallDifficulty = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + + [Test] + public void TestOverallDifficultyUnder() + { + beatmap.Difficulty.OverallDifficulty = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestOverallDifficultyOver() + { + beatmap.Difficulty.OverallDifficulty = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + private BeatmapVerifierContext getContext() + { + return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); + } + } +} diff --git a/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs new file mode 100644 index 0000000000..ce35f21853 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs @@ -0,0 +1,26 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Edit.Checks.Components; + +namespace osu.Game.Rulesets.Taiko.Edit.Checks +{ + public class CheckTaikoAbnormalDifficultySettings : CheckAbnormalDifficultySettings + { + public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks taiko relevant settings"); + + public override IEnumerable Run(BeatmapVerifierContext context) + { + var diff = context.Beatmap.Difficulty; + + if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); + + if (OutOfRange(diff.OverallDifficulty)) + yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); + } + } +} diff --git a/osu.Game.Rulesets.Taiko/Edit/TaikoBeatmapVerifier.cs b/osu.Game.Rulesets.Taiko/Edit/TaikoBeatmapVerifier.cs new file mode 100644 index 0000000000..f5c3f1846d --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Edit/TaikoBeatmapVerifier.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using System.Linq; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks.Components; +using osu.Game.Rulesets.Taiko.Edit.Checks; + +namespace osu.Game.Rulesets.Taiko.Edit +{ + public class TaikoBeatmapVerifier : IBeatmapVerifier + { + private readonly List checks = new List + { + new CheckTaikoAbnormalDifficultySettings(), + }; + + public IEnumerable Run(BeatmapVerifierContext context) + { + return checks.SelectMany(check => check.Run(context)); + } + } +} diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 24b0ec5d57..d7184bce60 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -188,6 +188,8 @@ namespace osu.Game.Rulesets.Taiko public override HitObjectComposer CreateHitObjectComposer() => new TaikoHitObjectComposer(this); + public override IBeatmapVerifier CreateBeatmapVerifier() => new TaikoBeatmapVerifier(); + public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => new TaikoDifficultyCalculator(RulesetInfo, beatmap); public override PerformanceCalculator CreatePerformanceCalculator() => new TaikoPerformanceCalculator(); From 6fbe1a5b8d1a80c6a5b1e277ee015162b7ea8083 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sat, 23 Mar 2024 19:22:47 -0300 Subject: [PATCH 457/508] Add video resolution check --- .../Checks/CheckVideoResolutionTest.cs | 86 +++++++++++++ .../Videos/test-video-resolution-high.mp4 | Bin 0 -> 13655 bytes osu.Game/Rulesets/Edit/BeatmapVerifier.cs | 1 + .../Edit/Checks/CheckVideoResolution.cs | 117 ++++++++++++++++++ 4 files changed, 204 insertions(+) create mode 100644 osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs create mode 100644 osu.Game.Tests/Resources/Videos/test-video-resolution-high.mp4 create mode 100644 osu.Game/Rulesets/Edit/Checks/CheckVideoResolution.cs diff --git a/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs b/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs new file mode 100644 index 0000000000..ab677a15d4 --- /dev/null +++ b/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs @@ -0,0 +1,86 @@ +using System.IO; +using System.Linq; +using Moq; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Edit.Checks; +using osu.Game.Rulesets.Objects; +using osu.Game.Storyboards; +using osu.Game.Tests.Beatmaps; +using osu.Game.Tests.Resources; + +namespace osu.Game.Tests.Editing.Checks +{ + [TestFixture] + public class CheckVideoResolutionTest + { + private CheckVideoResolution check = null!; + + private IBeatmap beatmap = null!; + + [SetUp] + public void Setup() + { + check = new CheckVideoResolution(); + beatmap = new Beatmap + { + BeatmapInfo = new BeatmapInfo + { + BeatmapSet = new BeatmapSetInfo + { + Files = + { + CheckTestHelpers.CreateMockFile("mp4"), + } + } + } + }; + } + + [Test] + public void TestNoVideo() + { + beatmap.BeatmapInfo.BeatmapSet?.Files.Clear(); + + var issues = check.Run(getContext(null)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(0)); + } + + [Test] + public void TestVideoAcceptableResolution() + { + using (var resourceStream = TestResources.OpenResource("Videos/test-video.mp4")) + { + var issues = check.Run(getContext(resourceStream)).ToList(); + Assert.That(issues, Has.Count.EqualTo(0)); + } + } + + [Test] + public void TestVideoHighResolution() + { + using (var resourceStream = TestResources.OpenResource("Videos/test-video-resolution-high.mp4")) + { + var issues = check.Run(getContext(resourceStream)).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckVideoResolution.IssueTemplateHighResolution); + } + } + + private BeatmapVerifierContext getContext(Stream? resourceStream) + { + var storyboard = new Storyboard(); + var layer = storyboard.GetLayer("Video"); + layer.Add(new StoryboardVideo("abc123.mp4", 0)); + + var mockWorkingBeatmap = new Mock(beatmap, null, null); + mockWorkingBeatmap.Setup(w => w.GetStream(It.IsAny())).Returns(resourceStream); + mockWorkingBeatmap.As().SetupGet(w => w.Storyboard).Returns(storyboard); + + return new BeatmapVerifierContext(beatmap, mockWorkingBeatmap.Object); + } + } +} diff --git a/osu.Game.Tests/Resources/Videos/test-video-resolution-high.mp4 b/osu.Game.Tests/Resources/Videos/test-video-resolution-high.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..fbdb00d3ad464a7f2d9d223d5fa9edb67fdaa689 GIT binary patch literal 13655 zcmeHNYiu0V75;YpN(5;gV#jvl*w+d1Be8d9b~hX2WTd!>A!=y}s_G(2+04$&dZ*sm z8PALz8>w`oR861}p_NJ_Xw$Spji?-o`cNZic$BCigpgEJYE!C;R1MG{r2)|bQn9Nu zJF`1$459)iAbjk3_`7$`x%b?2&;90(0kDicWvG^}0b$Tpwe*-cA@Q1#;DIGeHC>+o zkkclzGAg9%MWF63gh0P#srUnP3W3e#n)68&P?NV!aTLH!_NZgC%2(0VUU!ENE6TgD zTUUT{0Ju_-Z3{rFlC$ix2GU#Ywz>LwO;$w!Oq1vKeG>p1Up($S*_V}brmF)Js;qeT zB*Ut#=-b4+oKvVy^|v)Op8?P?p*c$Z&Aw7DmbJ>JLUl-}{PJ-#$BOsW*IRZv2jHA# zTi$?Bos%?ZzGo_=u25INHo!SZ{8s0e=Gj>Qo5TreOGw71+4E>0k+Esotlm6X^}9!J z++9`0fGRMcZr6G2Ui4@Pwb>W9?C<^7o3Fo4I+sa$&df`>Nz^(&0O}3VGFP&Wq}na32ha{60)&`Uer{E++`~U=dYt}x{phxAODcBFaVYtg9P7W*{eLany2Y(WG62-<20*^2 zu^W4bWAd$K;iuliv!~v}vt*ZI>;Gx2H&d&wv^BqUGwrQ&GHqTn60|Ikl)D{vk`XnPB&k@kldP%=g~A$yQC%n$nl?95S(s+f z;!oBT3Wb`bcMe}bZJ|&Ik*mw;(5-{Fro)?x*)N>+P3M@~5^4<{q|2MyUaBO##)sGX zo~iTUlrua%i+%WIKAiHUr+-R*2etW6pAL6X1*k#m~YKj1T54 zOUpI@%N_2cYn+^I9HMmKRwrE z)f5ebG?t`KExrS+xzE;V^Hv`E%QTeOK?F*tyj&{cAFoOt3yC>88T?WSp6CF3GX=ayluBN!G`I&mRaLzO%ZsG8P=4*(>Z0z0w3YH0WQLEOj9QnIpyeNnvycb{D>mN5=_dP zx+bRRS!SC`E~i>TjP+0U%aSedOd8V!j>(EB-=gOgA;$OeJj;ldoieOZ)u0+h1!G1^ z&txpc7W!h$&YFrSTSAiMbbVCJDx#e7FrHaCRZ_|T$MU9QLsB)-rgo@#TQPH@q{srt z(z$U{oJvW$W{9@HF-gx`wkfK4MNX;orb%@&rl={F(9hB-W6BgYRTg3_of2iyu${ZK zDq3VjH5JJg;%uj)j%4k$z%$)Y@~IKs5I7e!gcuuDrqsMG@ax^Xl&0pX<&u(Dq;XqF zaMVasB!`-cl@&N!uXMG0Xe*~&!+=6ThZr#24&n0vSMtvED6|bsn7P{-7P2Ahr_>*9jO0dKsn~$ zMeC(DXoCkkl;d52PVS=Ldxn0zEKsxMK8FtW?E6kY#w+Gm&vd|My*`JZQ1%uI*fTrx z+O9`pr&6mPJURBp3t#J)w> z0bDi-)SU%tw*htaK;1=P@tr{ZS%5Ks-waGtYJ6XoNH zxRTXCxtN=}DvSrl#pWY|fibcQf)F?tt8jQ=jI6THfpM{Uf-E>jR$iPh1s9u}QUc{- z^Y}e*M&=U1pt+cTeg)3Rfba?0CkwYPP_YGq_!0I%_^ZWvRGLje@0OJe2T8>~44Y%_ zo?Kv5Y@Veea4J?BY+}F*n`0l`YoIsUL2r)D4YEr}$f)a=U|Y-|;=xg|xqc6HbFAW> zBRDEH=iSoX9NRxT^V;6_*eUgmfj^o{UpNvu(!TwrtH*A>_t=c{52>X&7y6R6XV0^R zi%;Kiy9. Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using System.IO; +using osu.Framework.Logging; +using osu.Game.Beatmaps; +using osu.Game.IO.FileAbstraction; +using osu.Game.Rulesets.Edit.Checks.Components; +using osu.Game.Storyboards; +using TagLib; +using File = TagLib.File; + +namespace osu.Game.Rulesets.Edit.Checks +{ + public class CheckVideoResolution : ICheck + { + private const int max_video_width = 1280; + + private const int max_video_height = 720; + + public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Resources, "Too high video resolution."); + + public IEnumerable PossibleTemplates => new IssueTemplate[] + { + new IssueTemplateHighResolution(this), + new IssueTemplateFileError(this), + }; + + public IEnumerable Run(BeatmapVerifierContext context) + { + var beatmapSet = context.Beatmap.BeatmapInfo.BeatmapSet; + var videoPaths = getVideoPaths(context.WorkingBeatmap.Storyboard); + + foreach (string filename in videoPaths) + { + string? storagePath = beatmapSet?.GetPathForFile(filename); + + // Don't report any issues for missing video here since another check is already doing that (CheckAudioInVideo) + if (storagePath == null) continue; + + Issue issue; + + try + { + using (Stream data = context.WorkingBeatmap.GetStream(storagePath)) + using (File tagFile = File.Create(new StreamFileAbstraction(filename, data))) + { + int height = tagFile.Properties.VideoHeight; + int width = tagFile.Properties.VideoWidth; + + if (height <= max_video_height || width <= max_video_width) + continue; + + issue = new IssueTemplateHighResolution(this).Create(filename, width, height); + } + } + catch (CorruptFileException) + { + issue = new IssueTemplateFileError(this).Create(filename, "Corrupt file"); + } + catch (UnsupportedFormatException) + { + issue = new IssueTemplateFileError(this).Create(filename, "Unsupported format"); + } + catch (Exception ex) + { + issue = new IssueTemplateFileError(this).Create(filename, "Internal failure - see logs for more info"); + Logger.Log($"Failed when running {nameof(CheckVideoResolution)}: {ex}"); + } + + yield return issue; + } + } + + private List getVideoPaths(Storyboard storyboard) + { + var videoPaths = new List(); + + foreach (var layer in storyboard.Layers) + { + foreach (var element in layer.Elements) + { + if (element is not StoryboardVideo video) + continue; + + if (!videoPaths.Contains(video.Path)) + videoPaths.Add(video.Path); + } + } + + return videoPaths; + } + + public class IssueTemplateHighResolution : IssueTemplate + { + public IssueTemplateHighResolution(ICheck check) + : base(check, IssueType.Problem, "\"{0}\" resolution exceeds 1280x720 ({1}x{2})") + { + } + + public Issue Create(string filename, int width, int height) => new Issue(this, filename, width, height); + } + + public class IssueTemplateFileError : IssueTemplate + { + public IssueTemplateFileError(ICheck check) + : base(check, IssueType.Error, "Could not check resolution for \"{0}\" ({1}).") + { + } + + public Issue Create(string filename, string errorReason) => new Issue(this, filename, errorReason); + } + + } +} From eb938272040be14caa292fe65800356a6ae03a1a Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sat, 23 Mar 2024 23:11:13 -0300 Subject: [PATCH 458/508] Add missing copyright header --- osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs b/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs index ab677a15d4..1e16c67aab 100644 --- a/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckVideoResolutionTest.cs @@ -1,3 +1,6 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + using System.IO; using System.Linq; using Moq; From 8a05fecad5862d744d49b8febcb389e4e22b9850 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Sat, 23 Mar 2024 23:28:55 -0300 Subject: [PATCH 459/508] Fix formatting issue --- osu.Game/Rulesets/Edit/Checks/CheckVideoResolution.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckVideoResolution.cs b/osu.Game/Rulesets/Edit/Checks/CheckVideoResolution.cs index 831962e2e9..1b603b7e47 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckVideoResolution.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckVideoResolution.cs @@ -112,6 +112,5 @@ namespace osu.Game.Rulesets.Edit.Checks public Issue Create(string filename, string errorReason) => new Issue(this, filename, errorReason); } - } } From ef2a16dd8ff260efa5117a10352e6ec771dfa2c3 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 23 Mar 2024 16:41:40 +0800 Subject: [PATCH 460/508] Various renaming and class updates to allow multiple menu banners --- .../Visual/Menus/TestSceneMainMenu.cs | 46 +++++++++----- ...tleRequest.cs => GetMenuContentRequest.cs} | 4 +- .../API/Requests/Responses/APIMenuContent.cs | 42 +++++++++++++ .../API/Requests/Responses/APIMenuImage.cs | 57 +++++++++++++++++ .../API/Requests/Responses/APISystemTitle.cs | 30 --------- osu.Game/Screens/Menu/MainMenu.cs | 8 +-- .../{SystemTitle.cs => OnlineMenuBanner.cs} | 62 ++++++++++--------- 7 files changed, 169 insertions(+), 80 deletions(-) rename osu.Game/Online/API/Requests/{GetSystemTitleRequest.cs => GetMenuContentRequest.cs} (74%) create mode 100644 osu.Game/Online/API/Requests/Responses/APIMenuContent.cs create mode 100644 osu.Game/Online/API/Requests/Responses/APIMenuImage.cs delete mode 100644 osu.Game/Online/API/Requests/Responses/APISystemTitle.cs rename osu.Game/Screens/Menu/{SystemTitle.cs => OnlineMenuBanner.cs} (79%) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs b/osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs index 7053a9d544..3c78edb8a5 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs @@ -13,30 +13,48 @@ namespace osu.Game.Tests.Visual.Menus { public partial class TestSceneMainMenu : OsuGameTestScene { - private SystemTitle systemTitle => Game.ChildrenOfType().Single(); + private OnlineMenuBanner onlineMenuBanner => Game.ChildrenOfType().Single(); [Test] - public void TestSystemTitle() + public void TestOnlineMenuBanner() { - AddStep("set system title", () => systemTitle.Current.Value = new APISystemTitle + AddStep("set online content", () => onlineMenuBanner.Current.Value = new APIMenuContent { - Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png", - Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023", + Images = new[] + { + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png", + Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023", + } + } }); - AddAssert("system title not visible", () => systemTitle.State.Value, () => Is.EqualTo(Visibility.Hidden)); + AddAssert("system title not visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Hidden)); AddStep("enter menu", () => InputManager.Key(Key.Enter)); - AddUntilStep("system title visible", () => systemTitle.State.Value, () => Is.EqualTo(Visibility.Visible)); - AddStep("set another title", () => systemTitle.Current.Value = new APISystemTitle + AddUntilStep("system title visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Visible)); + AddStep("set another title", () => onlineMenuBanner.Current.Value = new APIMenuContent { - Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png", - Url = @"https://osu.ppy.sh/community/contests/189", + Images = new[] + { + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png", + Url = @"https://osu.ppy.sh/community/contests/189", + } + } }); - AddStep("set title with nonexistent image", () => systemTitle.Current.Value = new APISystemTitle + AddStep("set title with nonexistent image", () => onlineMenuBanner.Current.Value = new APIMenuContent { - Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2 - Url = @"https://osu.ppy.sh/community/contests/189", + Images = new[] + { + new APIMenuImage + { + Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2 + Url = @"https://osu.ppy.sh/community/contests/189", + } + } }); - AddStep("unset system title", () => systemTitle.Current.Value = null); + AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent()); } } } diff --git a/osu.Game/Online/API/Requests/GetSystemTitleRequest.cs b/osu.Game/Online/API/Requests/GetMenuContentRequest.cs similarity index 74% rename from osu.Game/Online/API/Requests/GetSystemTitleRequest.cs rename to osu.Game/Online/API/Requests/GetMenuContentRequest.cs index 52ca0c11eb..ad2bac6696 100644 --- a/osu.Game/Online/API/Requests/GetSystemTitleRequest.cs +++ b/osu.Game/Online/API/Requests/GetMenuContentRequest.cs @@ -5,9 +5,9 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Online.API.Requests { - public class GetSystemTitleRequest : OsuJsonWebRequest + public class GetMenuContentRequest : OsuJsonWebRequest { - public GetSystemTitleRequest() + public GetMenuContentRequest() : base(@"https://assets.ppy.sh/lazer-status.json") { } diff --git a/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs b/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs new file mode 100644 index 0000000000..acee6c99ba --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs @@ -0,0 +1,42 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using Newtonsoft.Json; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIMenuContent : IEquatable + { + /// + /// Images which should be displayed in rotation. + /// + [JsonProperty(@"images")] + public APIMenuImage[] Images { get; init; } = Array.Empty(); + + public DateTimeOffset LastUpdated { get; init; } + + public bool Equals(APIMenuContent? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return LastUpdated.Equals(other.LastUpdated); + } + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + + if (obj.GetType() != GetType()) return false; + + return Equals((APIMenuContent)obj); + } + + public override int GetHashCode() + { + return LastUpdated.GetHashCode(); + } + } +} diff --git a/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs b/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs new file mode 100644 index 0000000000..4824e23d4b --- /dev/null +++ b/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs @@ -0,0 +1,57 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using Newtonsoft.Json; + +namespace osu.Game.Online.API.Requests.Responses +{ + public class APIMenuImage : IEquatable + { + /// + /// A URL pointing to the image which should be displayed. Generally should be an @2x image filename. + /// + [JsonProperty(@"image")] + public string Image { get; init; } = string.Empty; + + /// + /// A URL that should be opened on clicking the image. + /// + [JsonProperty(@"url")] + public string Url { get; init; } = string.Empty; + + /// + /// The time at which this item should begin displaying. If null, will display immediately. + /// + [JsonProperty(@"begins")] + public DateTimeOffset? Begins { get; set; } + + /// + /// The time at which this item should stop displaying. If null, will display indefinitely. + /// + [JsonProperty(@"expires")] + public DateTimeOffset? Expires { get; set; } + + public bool Equals(APIMenuImage? other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return Image == other.Image && Url == other.Url; + } + + public override bool Equals(object? obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != GetType()) return false; + + return Equals((APIMenuImage)obj); + } + + public override int GetHashCode() + { + return HashCode.Combine(Image, Url); + } + } +} diff --git a/osu.Game/Online/API/Requests/Responses/APISystemTitle.cs b/osu.Game/Online/API/Requests/Responses/APISystemTitle.cs deleted file mode 100644 index bfa5c1043b..0000000000 --- a/osu.Game/Online/API/Requests/Responses/APISystemTitle.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using Newtonsoft.Json; - -namespace osu.Game.Online.API.Requests.Responses -{ - public class APISystemTitle : IEquatable - { - [JsonProperty(@"image")] - public string Image { get; set; } = string.Empty; - - [JsonProperty(@"url")] - public string Url { get; set; } = string.Empty; - - public bool Equals(APISystemTitle? other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - - return Image == other.Image && Url == other.Url; - } - - public override bool Equals(object? obj) => obj is APISystemTitle other && Equals(other); - - // ReSharper disable NonReadonlyMemberInGetHashCode - public override int GetHashCode() => HashCode.Combine(Image, Url); - } -} diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index decb901c32..235c5d5c56 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -98,7 +98,7 @@ namespace osu.Game.Screens.Menu private ParallaxContainer buttonsContainer; private SongTicker songTicker; private Container logoTarget; - private SystemTitle systemTitle; + private OnlineMenuBanner onlineMenuBanner; private MenuTip menuTip; private FillFlowContainer bottomElementsFlow; private SupporterDisplay supporterDisplay; @@ -178,7 +178,7 @@ namespace osu.Game.Screens.Menu Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, - systemTitle = new SystemTitle + onlineMenuBanner = new OnlineMenuBanner { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, @@ -201,12 +201,12 @@ namespace osu.Game.Screens.Menu case ButtonSystemState.Initial: case ButtonSystemState.Exit: ApplyToBackground(b => b.FadeColour(Color4.White, 500, Easing.OutSine)); - systemTitle.State.Value = Visibility.Hidden; + onlineMenuBanner.State.Value = Visibility.Hidden; break; default: ApplyToBackground(b => b.FadeColour(OsuColour.Gray(0.8f), 500, Easing.OutSine)); - systemTitle.State.Value = Visibility.Visible; + onlineMenuBanner.State.Value = Visibility.Visible; break; } }; diff --git a/osu.Game/Screens/Menu/SystemTitle.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs similarity index 79% rename from osu.Game/Screens/Menu/SystemTitle.cs rename to osu.Game/Screens/Menu/OnlineMenuBanner.cs index 813a470ed6..cf20196f85 100644 --- a/osu.Game/Screens/Menu/SystemTitle.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Linq; using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation; @@ -18,42 +19,28 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Screens.Menu { - public partial class SystemTitle : VisibilityContainer + public partial class OnlineMenuBanner : VisibilityContainer { - internal Bindable Current { get; } = new Bindable(); + internal Bindable Current { get; } = new Bindable(new APIMenuContent()); private const float transition_duration = 500; private Container content = null!; private CancellationTokenSource? cancellationTokenSource; - private SystemTitleImage? currentImage; - - private ScheduledDelegate? openUrlAction; + private MenuImage? currentImage; [BackgroundDependencyLoader] - private void load(OsuGame? game) + private void load() { AutoSizeAxes = Axes.Both; AutoSizeDuration = transition_duration; AutoSizeEasing = Easing.OutQuint; - InternalChild = content = new OsuClickableContainer + InternalChild = content = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, - Action = () => - { - currentImage?.Flash(); - - // Delay slightly to allow animation to play out. - openUrlAction?.Cancel(); - openUrlAction = Scheduler.AddDelayed(() => - { - if (!string.IsNullOrEmpty(Current.Value?.Url)) - game?.HandleLink(Current.Value.Url); - }, 250); - } }; } @@ -98,7 +85,7 @@ namespace osu.Game.Screens.Menu private void checkForUpdates() { - var request = new GetSystemTitleRequest(); + var request = new GetMenuContentRequest(); Task.Run(() => request.Perform()) .ContinueWith(r => { @@ -121,12 +108,12 @@ namespace osu.Game.Screens.Menu cancellationTokenSource = null; currentImage?.FadeOut(500, Easing.OutQuint).Expire(); - if (string.IsNullOrEmpty(Current.Value?.Image)) + if (Current.Value.Images.Length == 0) return; - LoadComponentAsync(new SystemTitleImage(Current.Value), loaded => + LoadComponentAsync(new MenuImage(Current.Value.Images.First()), loaded => { - if (!loaded.SystemTitle.Equals(Current.Value)) + if (!loaded.Image.Equals(Current.Value.Images.First())) loaded.Dispose(); content.Add(currentImage = loaded); @@ -134,22 +121,24 @@ namespace osu.Game.Screens.Menu } [LongRunningLoad] - private partial class SystemTitleImage : CompositeDrawable + private partial class MenuImage : OsuClickableContainer { - public readonly APISystemTitle SystemTitle; + public readonly APIMenuImage Image; private Sprite flash = null!; - public SystemTitleImage(APISystemTitle systemTitle) + private ScheduledDelegate? openUrlAction; + + public MenuImage(APIMenuImage image) { - SystemTitle = systemTitle; + Image = image; } [BackgroundDependencyLoader] - private void load(LargeTextureStore textureStore) + private void load(LargeTextureStore textureStore, OsuGame game) { - Texture? texture = textureStore.Get(SystemTitle.Image); - if (texture != null && SystemTitle.Image.Contains(@"@2x")) + Texture? texture = textureStore.Get(Image.Image); + if (texture != null && Image.Image.Contains(@"@2x")) texture.ScaleAdjust *= 2; AutoSizeAxes = Axes.Both; @@ -163,6 +152,19 @@ namespace osu.Game.Screens.Menu Blending = BlendingParameters.Additive, }, }; + + Action = () => + { + Flash(); + + // Delay slightly to allow animation to play out. + openUrlAction?.Cancel(); + openUrlAction = Scheduler.AddDelayed(() => + { + if (!string.IsNullOrEmpty(Image.Url)) + game?.HandleLink(Image.Url); + }, 250); + }; } protected override void LoadComplete() From 4c82e44291fdf23bf324d1d8f4a3092ede9437da Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 23 Mar 2024 20:07:17 +0800 Subject: [PATCH 461/508] Add isolated test coverage of online menu banner --- .../Visual/Menus/TestSceneMainMenu.cs | 23 ------ .../Visual/Menus/TestSceneOnlineMenuBanner.cs | 71 +++++++++++++++++++ 2 files changed, 71 insertions(+), 23 deletions(-) create mode 100644 osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs diff --git a/osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs b/osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs index 3c78edb8a5..e2a841d79a 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs @@ -32,29 +32,6 @@ namespace osu.Game.Tests.Visual.Menus AddAssert("system title not visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Hidden)); AddStep("enter menu", () => InputManager.Key(Key.Enter)); AddUntilStep("system title visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Visible)); - AddStep("set another title", () => onlineMenuBanner.Current.Value = new APIMenuContent - { - Images = new[] - { - new APIMenuImage - { - Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png", - Url = @"https://osu.ppy.sh/community/contests/189", - } - } - }); - AddStep("set title with nonexistent image", () => onlineMenuBanner.Current.Value = new APIMenuContent - { - Images = new[] - { - new APIMenuImage - { - Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2 - Url = @"https://osu.ppy.sh/community/contests/189", - } - } - }); - AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent()); } } } diff --git a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs new file mode 100644 index 0000000000..a80212e0a1 --- /dev/null +++ b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs @@ -0,0 +1,71 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; +using osu.Game.Online.API.Requests.Responses; +using osu.Game.Screens.Menu; + +namespace osu.Game.Tests.Visual.Menus +{ + public partial class TestSceneOnlineMenuBanner : OsuTestScene + { + private OnlineMenuBanner onlineMenuBanner = null!; + + [SetUpSteps] + public void SetUpSteps() + { + AddStep("Create banner", () => + { + Child = onlineMenuBanner = new OnlineMenuBanner + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + State = { Value = Visibility.Visible } + }; + }); + } + + [Test] + public void TestBasic() + { + AddAssert("system title not visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Hidden)); + AddStep("set online content", () => onlineMenuBanner.Current.Value = new APIMenuContent + { + Images = new[] + { + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png", + Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023", + } + }, + }); + AddStep("set another title", () => onlineMenuBanner.Current.Value = new APIMenuContent + { + Images = new[] + { + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png", + Url = @"https://osu.ppy.sh/community/contests/189", + } + } + }); + AddStep("set title with nonexistent image", () => onlineMenuBanner.Current.Value = new APIMenuContent + { + Images = new[] + { + new APIMenuImage + { + Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2 + Url = @"https://osu.ppy.sh/community/contests/189", + } + } + }); + AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent()); + } + } +} From ec4a9a5fdd4ffa1df41b2e26227d27d1277ae8d2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 23 Mar 2024 23:07:31 +0800 Subject: [PATCH 462/508] Make work again for simple case --- .../API/Requests/Responses/APIMenuContent.cs | 12 ++++++--- osu.Game/Screens/Menu/OnlineMenuBanner.cs | 25 +++++++------------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs b/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs index acee6c99ba..7b53488030 100644 --- a/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs +++ b/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Linq; using Newtonsoft.Json; namespace osu.Game.Online.API.Requests.Responses @@ -14,14 +15,12 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty(@"images")] public APIMenuImage[] Images { get; init; } = Array.Empty(); - public DateTimeOffset LastUpdated { get; init; } - public bool Equals(APIMenuContent? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; - return LastUpdated.Equals(other.LastUpdated); + return Images.SequenceEqual(other.Images); } public override bool Equals(object? obj) @@ -36,7 +35,12 @@ namespace osu.Game.Online.API.Requests.Responses public override int GetHashCode() { - return LastUpdated.GetHashCode(); + var hash = new HashCode(); + + foreach (var image in Images) + hash.Add(image.GetHashCode()); + + return hash.ToHashCode(); } } } diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index cf20196f85..613a6eed4c 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -78,7 +78,7 @@ namespace osu.Game.Screens.Menu { base.LoadComplete(); - Current.BindValueChanged(_ => loadNewImage(), true); + Current.BindValueChanged(_ => loadNewImages(), true); checkForUpdates(); } @@ -102,7 +102,7 @@ namespace osu.Game.Screens.Menu }); } - private void loadNewImage() + private void loadNewImages() { cancellationTokenSource?.Cancel(); cancellationTokenSource = null; @@ -131,19 +131,19 @@ namespace osu.Game.Screens.Menu public MenuImage(APIMenuImage image) { + AutoSizeAxes = Axes.Both; + Image = image; } [BackgroundDependencyLoader] - private void load(LargeTextureStore textureStore, OsuGame game) + private void load(LargeTextureStore textureStore, OsuGame? game) { Texture? texture = textureStore.Get(Image.Image); if (texture != null && Image.Image.Contains(@"@2x")) texture.ScaleAdjust *= 2; - AutoSizeAxes = Axes.Both; - - InternalChildren = new Drawable[] + Children = new Drawable[] { new Sprite { Texture = texture }, flash = new Sprite @@ -155,7 +155,9 @@ namespace osu.Game.Screens.Menu Action = () => { - Flash(); + flash.FadeInFromZero(50) + .Then() + .FadeOut(500, Easing.OutQuint); // Delay slightly to allow animation to play out. openUrlAction?.Cancel(); @@ -174,15 +176,6 @@ namespace osu.Game.Screens.Menu this.FadeInFromZero(500, Easing.OutQuint); flash.FadeOutFromOne(4000, Easing.OutQuint); } - - public Drawable Flash() - { - flash.FadeInFromZero(50) - .Then() - .FadeOut(500, Easing.OutQuint); - - return this; - } } } } From a4c619ea97c190a9a4929d89268677af7b72a985 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 24 Mar 2024 15:14:56 +0800 Subject: [PATCH 463/508] Add basic support for loading multiple images --- .../Visual/Menus/TestSceneOnlineMenuBanner.cs | 21 ++++- osu.Game/Screens/Menu/OnlineMenuBanner.cs | 80 ++++++++++--------- 2 files changed, 64 insertions(+), 37 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs index a80212e0a1..4cc379a18b 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs @@ -31,7 +31,6 @@ namespace osu.Game.Tests.Visual.Menus [Test] public void TestBasic() { - AddAssert("system title not visible", () => onlineMenuBanner.State.Value, () => Is.EqualTo(Visibility.Hidden)); AddStep("set online content", () => onlineMenuBanner.Current.Value = new APIMenuContent { Images = new[] @@ -43,6 +42,7 @@ namespace osu.Game.Tests.Visual.Menus } }, }); + AddStep("set another title", () => onlineMenuBanner.Current.Value = new APIMenuContent { Images = new[] @@ -54,6 +54,24 @@ namespace osu.Game.Tests.Visual.Menus } } }); + + AddStep("set multiple images", () => onlineMenuBanner.Current.Value = new APIMenuContent + { + Images = new[] + { + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png", + Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023", + }, + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png", + Url = @"https://osu.ppy.sh/community/contests/189", + } + }, + }); + AddStep("set title with nonexistent image", () => onlineMenuBanner.Current.Value = new APIMenuContent { Images = new[] @@ -65,6 +83,7 @@ namespace osu.Game.Tests.Visual.Menus } } }); + AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent()); } } diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index 613a6eed4c..587a93fb67 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -27,7 +27,6 @@ namespace osu.Game.Screens.Menu private Container content = null!; private CancellationTokenSource? cancellationTokenSource; - private MenuImage? currentImage; [BackgroundDependencyLoader] private void load() @@ -48,32 +47,6 @@ namespace osu.Game.Screens.Menu protected override void PopOut() => content.FadeOut(transition_duration, Easing.OutQuint); - protected override bool OnHover(HoverEvent e) - { - content.ScaleTo(1.05f, 2000, Easing.OutQuint); - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - content.ScaleTo(1f, 500, Easing.OutQuint); - base.OnHoverLost(e); - } - - protected override bool OnMouseDown(MouseDownEvent e) - { - content.ScaleTo(0.95f, 500, Easing.OutQuint); - return base.OnMouseDown(e); - } - - protected override void OnMouseUp(MouseUpEvent e) - { - content - .ScaleTo(0.95f) - .ScaleTo(1, 500, Easing.OutElastic); - base.OnMouseUp(e); - } - protected override void LoadComplete() { base.LoadComplete(); @@ -106,17 +79,26 @@ namespace osu.Game.Screens.Menu { cancellationTokenSource?.Cancel(); cancellationTokenSource = null; - currentImage?.FadeOut(500, Easing.OutQuint).Expire(); - if (Current.Value.Images.Length == 0) + var newContent = Current.Value; + + foreach (var i in content) + { + i.FadeOutFromOne(100, Easing.OutQuint) + .Expire(); + } + + if (newContent.Images.Length == 0) return; - LoadComponentAsync(new MenuImage(Current.Value.Images.First()), loaded => + LoadComponentsAsync(newContent.Images.Select(i => new MenuImage(i)), loaded => { - if (!loaded.Image.Equals(Current.Value.Images.First())) - loaded.Dispose(); + if (!newContent.Equals(Current.Value)) + return; - content.Add(currentImage = loaded); + content.AddRange(loaded); + + loaded.First().Show(); }, (cancellationTokenSource ??= new CancellationTokenSource()).Token); } @@ -132,6 +114,8 @@ namespace osu.Game.Screens.Menu public MenuImage(APIMenuImage image) { AutoSizeAxes = Axes.Both; + Anchor = Anchor.BottomCentre; + Origin = Anchor.BottomCentre; Image = image; } @@ -169,13 +153,37 @@ namespace osu.Game.Screens.Menu }; } - protected override void LoadComplete() + public override void Show() { - base.LoadComplete(); - this.FadeInFromZero(500, Easing.OutQuint); flash.FadeOutFromOne(4000, Easing.OutQuint); } + + protected override bool OnHover(HoverEvent e) + { + this.ScaleTo(1.05f, 2000, Easing.OutQuint); + return true; + } + + protected override void OnHoverLost(HoverLostEvent e) + { + this.ScaleTo(1f, 500, Easing.OutQuint); + base.OnHoverLost(e); + } + + protected override bool OnMouseDown(MouseDownEvent e) + { + this.ScaleTo(0.95f, 500, Easing.OutQuint); + return true; + } + + protected override void OnMouseUp(MouseUpEvent e) + { + this + .ScaleTo(0.95f) + .ScaleTo(1, 500, Easing.OutElastic); + base.OnMouseUp(e); + } } } } From d0b164b44f6d986f965c469cd838bfacbe0a3de6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 24 Mar 2024 23:37:30 +0800 Subject: [PATCH 464/508] Add automatic rotation support --- osu.Game/Screens/Menu/OnlineMenuBanner.cs | 38 +++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index 587a93fb67..a4648265ae 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -28,6 +28,10 @@ namespace osu.Game.Screens.Menu private Container content = null!; private CancellationTokenSource? cancellationTokenSource; + private int displayIndex = -1; + + private ScheduledDelegate? nextDisplay; + [BackgroundDependencyLoader] private void load() { @@ -77,16 +81,16 @@ namespace osu.Game.Screens.Menu private void loadNewImages() { + nextDisplay?.Cancel(); + cancellationTokenSource?.Cancel(); cancellationTokenSource = null; var newContent = Current.Value; - foreach (var i in content) - { - i.FadeOutFromOne(100, Easing.OutQuint) - .Expire(); - } + // A better fade out would be nice, but the menu content changes *very* rarely + // so let's keep things simple for now. + content.Clear(true); if (newContent.Images.Length == 0) return; @@ -96,12 +100,34 @@ namespace osu.Game.Screens.Menu if (!newContent.Equals(Current.Value)) return; + // start hidden + foreach (var image in loaded) + image.Hide(); + content.AddRange(loaded); - loaded.First().Show(); + displayIndex = -1; + showNext(); }, (cancellationTokenSource ??= new CancellationTokenSource()).Token); } + private void showNext() + { + nextDisplay?.Cancel(); + + bool previousShowing = displayIndex >= 0; + if (previousShowing) + content[displayIndex % content.Count].FadeOut(400, Easing.OutQuint); + + displayIndex++; + + using (BeginDelayedSequence(previousShowing ? 300 : 0)) + content[displayIndex % content.Count].Show(); + + if (content.Count > 1) + nextDisplay = Scheduler.AddDelayed(showNext, 12000); + } + [LongRunningLoad] private partial class MenuImage : OsuClickableContainer { From 3847aae57d88ea2156c7599c53a0e994fffd4760 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Mar 2024 12:14:40 +0800 Subject: [PATCH 465/508] Don't rotate when hovering --- osu.Game/Screens/Menu/OnlineMenuBanner.cs | 26 ++++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index a4648265ae..74062d5b9f 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -21,6 +21,8 @@ namespace osu.Game.Screens.Menu { public partial class OnlineMenuBanner : VisibilityContainer { + public double DelayBetweenRotation = 7500; + internal Bindable Current { get; } = new Bindable(new APIMenuContent()); private const float transition_duration = 500; @@ -115,21 +117,29 @@ namespace osu.Game.Screens.Menu { nextDisplay?.Cancel(); - bool previousShowing = displayIndex >= 0; - if (previousShowing) - content[displayIndex % content.Count].FadeOut(400, Easing.OutQuint); + // If the user is hovering a banner, don't rotate yet. + bool anyHovered = content.Any(i => i.IsHovered); - displayIndex++; + if (!anyHovered) + { + bool previousShowing = displayIndex >= 0; + if (previousShowing) + content[displayIndex % content.Count].FadeOut(400, Easing.OutQuint); - using (BeginDelayedSequence(previousShowing ? 300 : 0)) - content[displayIndex % content.Count].Show(); + displayIndex++; + + using (BeginDelayedSequence(previousShowing ? 300 : 0)) + content[displayIndex % content.Count].Show(); + } if (content.Count > 1) - nextDisplay = Scheduler.AddDelayed(showNext, 12000); + { + nextDisplay = Scheduler.AddDelayed(showNext, DelayBetweenRotation); + } } [LongRunningLoad] - private partial class MenuImage : OsuClickableContainer + public partial class MenuImage : OsuClickableContainer { public readonly APIMenuImage Image; From e9f15534ed7ea64b7cfe77360f488b3a63e703db Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Mar 2024 12:14:47 +0800 Subject: [PATCH 466/508] Improve test coverage --- .../Visual/Menus/TestSceneOnlineMenuBanner.cs | 75 ++++++++++++++++--- osu.Game/Screens/Menu/OnlineMenuBanner.cs | 7 +- 2 files changed, 71 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs index 4cc379a18b..6be5b80983 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -21,6 +22,8 @@ namespace osu.Game.Tests.Visual.Menus { Child = onlineMenuBanner = new OnlineMenuBanner { + FetchOnlineContent = false, + DelayBetweenRotation = 500, Anchor = Anchor.Centre, Origin = Anchor.Centre, State = { Value = Visibility.Visible } @@ -43,6 +46,18 @@ namespace osu.Game.Tests.Visual.Menus }, }); + AddUntilStep("wait for one image shown", () => + { + var images = onlineMenuBanner.ChildrenOfType(); + + if (images.Count() != 1) + return false; + + var image = images.Single(); + + return image.IsPresent && image.Image.Url == "https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023"; + }); + AddStep("set another title", () => onlineMenuBanner.Current.Value = new APIMenuContent { Images = new[] @@ -55,6 +70,40 @@ namespace osu.Game.Tests.Visual.Menus } }); + AddUntilStep("wait for new image shown", () => + { + var images = onlineMenuBanner.ChildrenOfType(); + + if (images.Count() != 1) + return false; + + var image = images.Single(); + + return image.IsPresent && image.Image.Url == "https://osu.ppy.sh/community/contests/189"; + }); + + AddStep("set title with nonexistent image", () => onlineMenuBanner.Current.Value = new APIMenuContent + { + Images = new[] + { + new APIMenuImage + { + Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2 + Url = @"https://osu.ppy.sh/community/contests/189", + } + } + }); + + AddUntilStep("wait for no image shown", () => !onlineMenuBanner.ChildrenOfType().Any()); + + AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent()); + + AddUntilStep("wait for no image shown", () => !onlineMenuBanner.ChildrenOfType().Any()); + } + + [Test] + public void TestMultipleImages() + { AddStep("set multiple images", () => onlineMenuBanner.Current.Value = new APIMenuContent { Images = new[] @@ -72,19 +121,25 @@ namespace osu.Game.Tests.Visual.Menus }, }); - AddStep("set title with nonexistent image", () => onlineMenuBanner.Current.Value = new APIMenuContent + AddUntilStep("wait for first image shown", () => { - Images = new[] - { - new APIMenuImage - { - Image = @"https://test.invalid/@2x", // .invalid TLD reserved by https://datatracker.ietf.org/doc/html/rfc2606#section-2 - Url = @"https://osu.ppy.sh/community/contests/189", - } - } + var images = onlineMenuBanner.ChildrenOfType(); + + if (images.Count() != 2) + return false; + + return images.First().IsPresent && !images.Last().IsPresent; }); - AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent()); + AddUntilStep("wait for second image shown", () => + { + var images = onlineMenuBanner.ChildrenOfType(); + + if (images.Count() != 2) + return false; + + return !images.First().IsPresent && images.Last().IsPresent; + }); } } } diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index 74062d5b9f..2ab6417370 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -21,7 +21,9 @@ namespace osu.Game.Screens.Menu { public partial class OnlineMenuBanner : VisibilityContainer { - public double DelayBetweenRotation = 7500; + public double DelayBetweenRotation { get; set; } = 7500; + + public bool FetchOnlineContent { get; set; } = true; internal Bindable Current { get; } = new Bindable(new APIMenuContent()); @@ -64,6 +66,9 @@ namespace osu.Game.Screens.Menu private void checkForUpdates() { + if (!FetchOnlineContent) + return; + var request = new GetMenuContentRequest(); Task.Run(() => request.Perform()) .ContinueWith(r => From f0614928b182bf2d575c5e298e29d2254fd28ecb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Mar 2024 13:19:12 +0800 Subject: [PATCH 467/508] Read from new location --- osu.Game/Online/API/Requests/GetMenuContentRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/Requests/GetMenuContentRequest.cs b/osu.Game/Online/API/Requests/GetMenuContentRequest.cs index ad2bac6696..26747489d6 100644 --- a/osu.Game/Online/API/Requests/GetMenuContentRequest.cs +++ b/osu.Game/Online/API/Requests/GetMenuContentRequest.cs @@ -8,7 +8,7 @@ namespace osu.Game.Online.API.Requests public class GetMenuContentRequest : OsuJsonWebRequest { public GetMenuContentRequest() - : base(@"https://assets.ppy.sh/lazer-status.json") + : base(@"https://assets.ppy.sh/menu-content.json") { } } From 057f86dd145dd5d0ba573737ca61aceb27dcc70a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Mar 2024 14:28:23 +0800 Subject: [PATCH 468/508] Add handling of expiration --- .../Visual/Menus/TestSceneOnlineMenuBanner.cs | 60 +++++++++++++++++++ .../API/Requests/Responses/APIMenuImage.cs | 4 ++ osu.Game/Screens/Menu/OnlineMenuBanner.cs | 60 ++++++++++++------- 3 files changed, 102 insertions(+), 22 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs index 6be5b80983..2dd08ce306 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Linq; using NUnit.Framework; using osu.Framework.Graphics; @@ -141,5 +142,64 @@ namespace osu.Game.Tests.Visual.Menus return !images.First().IsPresent && images.Last().IsPresent; }); } + + [Test] + public void TestExpiry() + { + AddStep("set multiple images, second expiring soon", () => onlineMenuBanner.Current.Value = new APIMenuContent + { + Images = new[] + { + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png", + Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023", + }, + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/wf2023-vote@2x.png", + Url = @"https://osu.ppy.sh/community/contests/189", + Expires = DateTimeOffset.Now.AddSeconds(2), + } + }, + }); + + AddUntilStep("wait for first image shown", () => + { + var images = onlineMenuBanner.ChildrenOfType(); + + if (images.Count() != 2) + return false; + + return images.First().IsPresent && !images.Last().IsPresent; + }); + + AddUntilStep("wait for second image shown", () => + { + var images = onlineMenuBanner.ChildrenOfType(); + + if (images.Count() != 2) + return false; + + return !images.First().IsPresent && images.Last().IsPresent; + }); + + AddUntilStep("wait for expiry", () => + { + return onlineMenuBanner + .ChildrenOfType() + .Any(i => !i.Image.IsCurrent); + }); + + AddUntilStep("wait for first image shown", () => + { + var images = onlineMenuBanner.ChildrenOfType(); + + if (images.Count() != 2) + return false; + + return images.First().IsPresent && !images.Last().IsPresent; + }); + } } } diff --git a/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs b/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs index 4824e23d4b..42129ca96e 100644 --- a/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs +++ b/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs @@ -20,6 +20,10 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty(@"url")] public string Url { get; init; } = string.Empty; + public bool IsCurrent => + (Begins == null || Begins < DateTimeOffset.UtcNow) && + (Expires == null || Expires > DateTimeOffset.UtcNow); + /// /// The time at which this item should begin displaying. If null, will display immediately. /// diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index 2ab6417370..55ceb84d7b 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Menu private const float transition_duration = 500; - private Container content = null!; + private Container content = null!; private CancellationTokenSource? cancellationTokenSource; private int displayIndex = -1; @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Menu AutoSizeDuration = transition_duration; AutoSizeEasing = Easing.OutQuint; - InternalChild = content = new Container + InternalChild = content = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -59,8 +59,7 @@ namespace osu.Game.Screens.Menu { base.LoadComplete(); - Current.BindValueChanged(_ => loadNewImages(), true); - + Current.BindValueChanged(loadNewImages, true); checkForUpdates(); } @@ -86,25 +85,24 @@ namespace osu.Game.Screens.Menu }); } - private void loadNewImages() + /// + /// Takes and materialises and displays drawables for all valid images to be displayed. + /// + /// + private void loadNewImages(ValueChangedEvent images) { nextDisplay?.Cancel(); cancellationTokenSource?.Cancel(); cancellationTokenSource = null; - var newContent = Current.Value; - // A better fade out would be nice, but the menu content changes *very* rarely // so let's keep things simple for now. content.Clear(true); - if (newContent.Images.Length == 0) - return; - - LoadComponentsAsync(newContent.Images.Select(i => new MenuImage(i)), loaded => + LoadComponentsAsync(images.NewValue.Images.Select(i => new MenuImage(i)), loaded => { - if (!newContent.Equals(Current.Value)) + if (!images.NewValue.Equals(Current.Value)) return; // start hidden @@ -127,20 +125,38 @@ namespace osu.Game.Screens.Menu if (!anyHovered) { - bool previousShowing = displayIndex >= 0; - if (previousShowing) - content[displayIndex % content.Count].FadeOut(400, Easing.OutQuint); + int previousIndex = displayIndex; - displayIndex++; + if (displayIndex == -1) + displayIndex = 0; - using (BeginDelayedSequence(previousShowing ? 300 : 0)) - content[displayIndex % content.Count].Show(); + // To handle expiration simply, arrange all images in best-next order. + // Fade in the first valid one, then handle fading out the last if required. + var currentRotation = content + .Skip(displayIndex + 1) + .Concat(content.Take(displayIndex + 1)); + + foreach (var image in currentRotation) + { + if (!image.Image.IsCurrent) continue; + + using (BeginDelayedSequence(previousIndex >= 0 ? 300 : 0)) + { + displayIndex = content.IndexOf(image); + + if (displayIndex != previousIndex) + image.Show(); + + break; + } + } + + if (previousIndex >= 0 && previousIndex != displayIndex) + content[previousIndex].FadeOut(400, Easing.OutQuint); } - if (content.Count > 1) - { - nextDisplay = Scheduler.AddDelayed(showNext, DelayBetweenRotation); - } + // Re-scheduling this method will both handle rotation and re-checking for expiration dates. + nextDisplay = Scheduler.AddDelayed(showNext, DelayBetweenRotation); } [LongRunningLoad] From bb9fa52fda51f46e4e0fe39e2be8196ab0dc0fba Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Mar 2024 14:53:05 +0800 Subject: [PATCH 469/508] Fix `displayIndex` not being correctly set to `-1` after last expiry date --- .../Visual/Menus/TestSceneOnlineMenuBanner.cs | 36 ++++++++++++++++++- osu.Game/Screens/Menu/OnlineMenuBanner.cs | 11 +++--- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs index 2dd08ce306..380085ce04 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs @@ -144,7 +144,41 @@ namespace osu.Game.Tests.Visual.Menus } [Test] - public void TestExpiry() + public void TestFutureSingle() + { + AddStep("set image with time constraints", () => onlineMenuBanner.Current.Value = new APIMenuContent + { + Images = new[] + { + new APIMenuImage + { + Image = @"https://assets.ppy.sh/main-menu/project-loved-2@2x.png", + Url = @"https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023", + Begins = DateTimeOffset.Now.AddSeconds(2), + Expires = DateTimeOffset.Now.AddSeconds(5), + }, + }, + }); + + AddUntilStep("wait for no image shown", () => !onlineMenuBanner.ChildrenOfType().Any(i => i.IsPresent)); + + AddUntilStep("wait for one image shown", () => + { + var images = onlineMenuBanner.ChildrenOfType(); + + if (images.Count() != 1) + return false; + + var image = images.Single(); + + return image.IsPresent && image.Image.Url == "https://osu.ppy.sh/home/news/2023-12-21-project-loved-december-2023"; + }); + + AddUntilStep("wait for no image shown", () => !onlineMenuBanner.ChildrenOfType().Any(i => i.IsPresent)); + } + + [Test] + public void TestExpiryMultiple() { AddStep("set multiple images, second expiring soon", () => onlineMenuBanner.Current.Value = new APIMenuContent { diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index 55ceb84d7b..37bec7aa63 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -127,14 +127,15 @@ namespace osu.Game.Screens.Menu { int previousIndex = displayIndex; - if (displayIndex == -1) - displayIndex = 0; - // To handle expiration simply, arrange all images in best-next order. // Fade in the first valid one, then handle fading out the last if required. var currentRotation = content - .Skip(displayIndex + 1) - .Concat(content.Take(displayIndex + 1)); + .Skip(Math.Max(0, previousIndex) + 1) + .Concat(content.Take(Math.Max(0, previousIndex) + 1)); + + // After the loop, displayIndex will be the new valid index or -1 if + // none valid. + displayIndex = -1; foreach (var image in currentRotation) { From 78037fa4773dfc8f8063d45e104bd84131515bcc Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Mon, 25 Mar 2024 04:19:14 -0300 Subject: [PATCH 470/508] Handle new combo on `HandleReverse` --- .../Edit/CatchSelectionHandler.cs | 33 ++++++++++++++++--- .../Edit/OsuSelectionHandler.cs | 20 +++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs b/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs index 418351e2f3..e3d82cc517 100644 --- a/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs +++ b/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs @@ -76,21 +76,44 @@ namespace osu.Game.Rulesets.Catch.Edit public override bool HandleReverse() { + var hitObjects = EditorBeatmap.SelectedHitObjects; + double selectionStartTime = SelectedItems.Min(h => h.StartTime); double selectionEndTime = SelectedItems.Max(h => h.GetEndTime()); - EditorBeatmap.PerformOnSelection(hitObject => - { - hitObject.StartTime = selectionEndTime - (hitObject.GetEndTime() - selectionStartTime); + var newComboPlaces = hitObjects + .OfType() + .Where(h => h.NewCombo) + .Select(obj => obj.StartTime) + .ToList(); - if (hitObject is JuiceStream juiceStream) + foreach (var h in hitObjects) + { + h.StartTime = selectionEndTime - (h.GetEndTime() - selectionStartTime); + + if (h is JuiceStream juiceStream) { juiceStream.Path.Reverse(out Vector2 positionalOffset); juiceStream.OriginalX += positionalOffset.X; juiceStream.LegacyConvertedY += positionalOffset.Y; EditorBeatmap.Update(juiceStream); } - }); + } + + foreach (var h in hitObjects) + { + if (h is CatchHitObject obj) obj.NewCombo = false; + } + + foreach (double place in newComboPlaces) + { + hitObjects + .OfType() + .Where(obj => obj.StartTime == place) + .ToList() + .ForEach(obj => obj.NewCombo = true); + } + return true; } diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs index cea2adc6e2..b4980b55d4 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs @@ -85,6 +85,12 @@ namespace osu.Game.Rulesets.Osu.Edit bool moreThanOneObject = hitObjects.Count > 1; + var newComboPlaces = hitObjects + .OfType() + .Where(h => h.NewCombo) + .Select(obj => obj.StartTime) + .ToList(); + foreach (var h in hitObjects) { if (moreThanOneObject) @@ -97,6 +103,20 @@ namespace osu.Game.Rulesets.Osu.Edit } } + foreach (var h in hitObjects) + { + if (h is OsuHitObject obj) obj.NewCombo = false; + } + + foreach (double place in newComboPlaces) + { + hitObjects + .OfType() + .Where(obj => obj.StartTime == place) + .ToList() + .ForEach(obj => obj.NewCombo = true); + } + return true; } From 3db88fbcea288f5c4136739bd26e0bdab9e0b05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 25 Mar 2024 17:54:20 +0100 Subject: [PATCH 471/508] Use less confusing message format when logging discord errors The "code" is a number, so it looked weird when put in the middle without any nearby punctuation. Example: An error occurred with Discord RPC Client: 5005 secrets cannot currently be sent with buttons --- osu.Desktop/DiscordRichPresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index d78459ff28..eaa9a90f27 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -75,7 +75,7 @@ namespace osu.Desktop }; client.OnReady += onReady; - client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Code} {e.Message}", LoggingTarget.Network, LogLevel.Error); + client.OnError += (_, e) => Logger.Log($"An error occurred with Discord RPC Client: {e.Message} ({e.Code})", LoggingTarget.Network, LogLevel.Error); // A URI scheme is required to support game invitations, as well as informing Discord of the game executable path to support launching the game when a user clicks on join/spectate. client.RegisterUriScheme(); From e95f29cf4ba8840e0305bbae7637d01ddc03f285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 25 Mar 2024 17:57:13 +0100 Subject: [PATCH 472/508] Rename `updatePresence() => schedulePresenceUpdate()` The method doesn't actually update anything by itself, and I want to free up the `updatePresence()` name for the actual update. --- osu.Desktop/DiscordRichPresence.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index eaa9a90f27..811f2f3548 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -94,10 +94,10 @@ namespace osu.Desktop activity.BindTo(u.NewValue.Activity); }, true); - ruleset.BindValueChanged(_ => updatePresence()); - status.BindValueChanged(_ => updatePresence()); - activity.BindValueChanged(_ => updatePresence()); - privacyMode.BindValueChanged(_ => updatePresence()); + ruleset.BindValueChanged(_ => schedulePresenceUpdate()); + status.BindValueChanged(_ => schedulePresenceUpdate()); + activity.BindValueChanged(_ => schedulePresenceUpdate()); + privacyMode.BindValueChanged(_ => schedulePresenceUpdate()); multiplayerClient.RoomUpdated += onRoomUpdated; client.Initialize(); @@ -111,14 +111,14 @@ namespace osu.Desktop if (client.CurrentPresence != null) client.SetPresence(null); - updatePresence(); + schedulePresenceUpdate(); } - private void onRoomUpdated() => updatePresence(); + private void onRoomUpdated() => schedulePresenceUpdate(); private ScheduledDelegate? presenceUpdateDelegate; - private void updatePresence() + private void schedulePresenceUpdate() { presenceUpdateDelegate?.Cancel(); presenceUpdateDelegate = Scheduler.AddDelayed(() => From a398754a27ac26a1f6e57790b2c609226ad805fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 25 Mar 2024 18:00:42 +0100 Subject: [PATCH 473/508] Merge all presence methods into one I'm about to make them interdependent (and it's discord's fault), so it doesn't really make sense to make them separate at this point I don't think. And it felt weird anyway. --- osu.Desktop/DiscordRichPresence.cs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index 811f2f3548..d67437ba62 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -134,16 +134,14 @@ namespace osu.Desktop bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb; - updatePresenceStatus(hideIdentifiableInformation); - updatePresenceParty(hideIdentifiableInformation); - updatePresenceAssets(); - + updatePresence(hideIdentifiableInformation); client.SetPresence(presence); }, 200); } - private void updatePresenceStatus(bool hideIdentifiableInformation) + private void updatePresence(bool hideIdentifiableInformation) { + // user activity if (activity.Value != null) { presence.State = truncate(activity.Value.GetStatus(hideIdentifiableInformation)); @@ -170,10 +168,8 @@ namespace osu.Desktop presence.State = "Idle"; presence.Details = string.Empty; } - } - private void updatePresenceParty(bool hideIdentifiableInformation) - { + // user party if (!hideIdentifiableInformation && multiplayerClient.Room != null) { MultiplayerRoom room = multiplayerClient.Room; @@ -201,11 +197,9 @@ namespace osu.Desktop presence.Party = null; presence.Secrets.JoinSecret = null; } - } - private void updatePresenceAssets() - { - // update user information + // game images: + // large image tooltip if (privacyMode.Value == DiscordRichPresenceMode.Limited) presence.Assets.LargeImageText = string.Empty; else @@ -216,7 +210,7 @@ namespace osu.Desktop presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty); } - // update ruleset + // small image presence.Assets.SmallImageKey = ruleset.Value.IsLegacyRuleset() ? $"mode_{ruleset.Value.OnlineID}" : "mode_custom"; presence.Assets.SmallImageText = ruleset.Value.Name; } From 53c3aec3c364a2541180e1bc34b4c40ee688f2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 25 Mar 2024 18:02:54 +0100 Subject: [PATCH 474/508] Fix discord RPC errors in multiplayer Reproduction steps: 1. Go to multiplayer 2. Create a room 3. Play a map to completion 4. Wait for "secrets cannot currently be sent with buttons" error messages The fix is to clear the buttons since they're the less important ones. --- osu.Desktop/DiscordRichPresence.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index d67437ba62..6e8554d617 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -191,6 +191,9 @@ namespace osu.Desktop }; presence.Secrets.JoinSecret = JsonConvert.SerializeObject(roomSecret); + // discord cannot handle both secrets and buttons at the same time, so we need to choose something. + // the multiplayer room seems more important. + presence.Buttons = null; } else { From 6266af8a5696edb32da2f57b877f84dbcab66e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 25 Mar 2024 18:57:58 +0100 Subject: [PATCH 475/508] Fix taiko legacy score simulator not including swell tick score gain into bonus portion Reported in https://discord.com/channels/188630481301012481/1097318920991559880/1221836384038551613. Example score: https://osu.ppy.sh/scores/1855965185 The cause of the overestimation was an error in taiko's score simulator. In lazer taiko, swell ticks don't give any score anymore, while they did in stable. For all intents and purposes, swell ticks can be considered "bonus" objects that "don't give any actual bonus score". Which is to say, during simulation of a legacy score swell ticks hit should be treated as bonus, because if they aren't, then otherwise they will be treated essentially as *normal hits*, meaning that they will be included in the *accuracy* portion of score, which breaks all sorts of follow-up assumptions: - The accuracy portion of the best possible total score becomes overinflated in comparison to reality, while the combo portion of that maximum score becomes underestimated. - Because the affected score has low accuracy, the estimated accuracy portion of the score (as given by maximmum accuracy portion of score times the actual numerical accuracy of the score) is also low. - However, the next step is estimating the combo portion, which is done by taking legacy total score, subtracting the aforementioned estimation for accuracy total score from that, and then dividing the result by the maximum achievable combo score on the map. Because most of actual "combo" score from swell ticks was "moved" into the accuracy portion due to the aforementioned error, the maximum achievable combo score becomes so small that the estimated combo portion exceeds 1. Instead, this change makes it so that gains from swell ticks are treated as "bonus", which means that they are excluded from the accuracy portion of score and instead count into the bonus portion of score, bringing the scores concerned more in line with expectations - although due to pessimistic assumptions in the simulation of the swell itself, the conversion will still overestimate total score for affected scores, just not by *that* much. --- osu.Game.Rulesets.Taiko/Difficulty/TaikoLegacyScoreSimulator.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoLegacyScoreSimulator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoLegacyScoreSimulator.cs index 66ff0fc3d9..9839d94277 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoLegacyScoreSimulator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoLegacyScoreSimulator.cs @@ -95,6 +95,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty case SwellTick: scoreIncrease = 300; increaseCombo = false; + isBonus = true; + bonusResult = HitResult.IgnoreHit; break; case DrumRollTick: From 73926592b91e1cf6348b3e7ae3c68142dbbd8d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 25 Mar 2024 19:27:38 +0100 Subject: [PATCH 476/508] Bump legacy score version to recalculate all scores --- osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs index 93f51ee74d..0f00cce080 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreEncoder.cs @@ -46,9 +46,10 @@ namespace osu.Game.Scoring.Legacy /// 30000013: All local scores will use lazer definitions of ranks for consistency. Recalculates the rank of all scores. /// 30000014: Fix edge cases in conversion for osu! scores on selected beatmaps. Reconvert all scores. /// 30000015: Fix osu! standardised score estimation algorithm violating basic invariants. Reconvert all scores. + /// 30000016: Fix taiko standardised score estimation algorithm not including swell tick score gain into bonus portion. Reconvert all scores. /// /// - public const int LATEST_VERSION = 30000015; + public const int LATEST_VERSION = 30000016; /// /// The first stable-compatible YYYYMMDD format version given to lazer usage of replays. From 10683de578590d9a17c690df4ef9fc89515599a5 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Tue, 26 Mar 2024 04:59:47 -0300 Subject: [PATCH 477/508] Use order of new combo flags instead of `StartTime` --- .../Edit/CatchSelectionHandler.cs | 22 +++++++------------ .../Edit/OsuSelectionHandler.cs | 22 +++++++------------ 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs b/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs index e3d82cc517..e3d2347c4d 100644 --- a/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs +++ b/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs @@ -81,12 +81,13 @@ namespace osu.Game.Rulesets.Catch.Edit double selectionStartTime = SelectedItems.Min(h => h.StartTime); double selectionEndTime = SelectedItems.Max(h => h.GetEndTime()); - var newComboPlaces = hitObjects + var newComboOrder = hitObjects .OfType() - .Where(h => h.NewCombo) - .Select(obj => obj.StartTime) + .Select(obj => obj.NewCombo) .ToList(); + newComboOrder.Reverse(); + foreach (var h in hitObjects) { h.StartTime = selectionEndTime - (h.GetEndTime() - selectionStartTime); @@ -100,18 +101,11 @@ namespace osu.Game.Rulesets.Catch.Edit } } - foreach (var h in hitObjects) + int i = 0; + foreach (bool newCombo in newComboOrder) { - if (h is CatchHitObject obj) obj.NewCombo = false; - } - - foreach (double place in newComboPlaces) - { - hitObjects - .OfType() - .Where(obj => obj.StartTime == place) - .ToList() - .ForEach(obj => obj.NewCombo = true); + hitObjects.OfType().ToList()[i].NewCombo = newCombo; + i++; } return true; diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs index b4980b55d4..df39ab8fce 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs @@ -85,12 +85,13 @@ namespace osu.Game.Rulesets.Osu.Edit bool moreThanOneObject = hitObjects.Count > 1; - var newComboPlaces = hitObjects + var newComboOrder = hitObjects .OfType() - .Where(h => h.NewCombo) - .Select(obj => obj.StartTime) + .Select(obj => obj.NewCombo) .ToList(); + newComboOrder.Reverse(); + foreach (var h in hitObjects) { if (moreThanOneObject) @@ -103,18 +104,11 @@ namespace osu.Game.Rulesets.Osu.Edit } } - foreach (var h in hitObjects) + int i = 0; + foreach (bool newCombo in newComboOrder) { - if (h is OsuHitObject obj) obj.NewCombo = false; - } - - foreach (double place in newComboPlaces) - { - hitObjects - .OfType() - .Where(obj => obj.StartTime == place) - .ToList() - .ForEach(obj => obj.NewCombo = true); + hitObjects.OfType().ToList()[i].NewCombo = newCombo; + i++; } return true; From 9b923b19094bbcdf3f130d005085de70368cb8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 26 Mar 2024 10:55:49 +0100 Subject: [PATCH 478/508] Fix code quality issues --- .../Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs | 4 ++-- .../Editor/Checks/CheckKeyCountTest.cs | 2 +- .../Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs | 4 ++-- .../Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs | 4 ++-- .../Edit/Checks/CheckOsuAbnormalDifficultySettings.cs | 1 + .../Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs | 4 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Catch.Tests/Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs index 2ae2e20215..33aa4cba5d 100644 --- a/osu.Game.Rulesets.Catch.Tests/Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/Editor/Checks/CheckCatchAbnormalDifficultySettingsTest.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor.Checks { private CheckCatchAbnormalDifficultySettings check = null!; - private IBeatmap beatmap = new Beatmap(); + private readonly IBeatmap beatmap = new Beatmap(); [SetUp] public void Setup() @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor.Checks check = new CheckCatchAbnormalDifficultySettings(); beatmap.BeatmapInfo.Ruleset = new CatchRuleset().RulesetInfo; - beatmap.Difficulty = new BeatmapDifficulty() + beatmap.Difficulty = new BeatmapDifficulty { ApproachRate = 5, CircleSize = 5, diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs index 564c611548..b40a62176c 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckKeyCountTest.cs @@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor.Checks { check = new CheckKeyCount(); - beatmap = new Beatmap() + beatmap = new Beatmap { BeatmapInfo = new BeatmapInfo { diff --git a/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs index 6c585aace3..da5ab037e5 100644 --- a/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs +++ b/osu.Game.Rulesets.Mania.Tests/Editor/Checks/CheckManiaAbnormalDifficultySettingsTest.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor.Checks { private CheckManiaAbnormalDifficultySettings check = null!; - private IBeatmap beatmap = new Beatmap(); + private readonly IBeatmap beatmap = new Beatmap(); [SetUp] public void Setup() @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor.Checks check = new CheckManiaAbnormalDifficultySettings(); beatmap.BeatmapInfo.Ruleset = new ManiaRuleset().RulesetInfo; - beatmap.Difficulty = new BeatmapDifficulty() + beatmap.Difficulty = new BeatmapDifficulty { OverallDifficulty = 5, DrainRate = 5, diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs index 53ccd3c7a7..5f49714d93 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/Checks/CheckOsuAbnormalDifficultySettingsTest.cs @@ -17,14 +17,14 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor.Checks { private CheckOsuAbnormalDifficultySettings check = null!; - private IBeatmap beatmap = new Beatmap(); + private readonly IBeatmap beatmap = new Beatmap(); [SetUp] public void Setup() { check = new CheckOsuAbnormalDifficultySettings(); - beatmap.Difficulty = new BeatmapDifficulty() + beatmap.Difficulty = new BeatmapDifficulty { ApproachRate = 5, CircleSize = 5, diff --git a/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs index c1eca7fff7..7ad861f317 100644 --- a/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs +++ b/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs @@ -11,6 +11,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks public class CheckOsuAbnormalDifficultySettings : CheckAbnormalDifficultySettings { public override CheckMetadata Metadata => new CheckMetadata(CheckCategory.Settings, "Checks osu relevant settings"); + public override IEnumerable Run(BeatmapVerifierContext context) { var diff = context.Beatmap.Difficulty; diff --git a/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs index f10e62f3bf..4a6cf0313a 100644 --- a/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs +++ b/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Editor.Checks { private CheckTaikoAbnormalDifficultySettings check = null!; - private IBeatmap beatmap = new Beatmap(); + private readonly IBeatmap beatmap = new Beatmap(); [SetUp] public void Setup() @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Editor.Checks check = new CheckTaikoAbnormalDifficultySettings(); beatmap.BeatmapInfo.Ruleset = new TaikoRuleset().RulesetInfo; - beatmap.Difficulty = new BeatmapDifficulty() + beatmap.Difficulty = new BeatmapDifficulty { OverallDifficulty = 5, }; From 8fb308c1925e1cdbda3eba6e58b7ef5c8fb1fe89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 26 Mar 2024 10:57:20 +0100 Subject: [PATCH 479/508] Add failing test coverage for checking taiko HP too I was wrong, taiko uses HP (to calculate miss penalty). --- ...heckTaikoAbnormalDifficultySettingsTest.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs b/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs index 4a6cf0313a..6a50fd0956 100644 --- a/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs +++ b/osu.Game.Rulesets.Taiko.Tests/Editor/Checks/CheckTaikoAbnormalDifficultySettingsTest.cs @@ -52,6 +52,18 @@ namespace osu.Game.Rulesets.Taiko.Tests.Editor.Checks Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); } + [Test] + public void TestDrainRateTwoDecimals() + { + beatmap.Difficulty.DrainRate = 5.55f; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateMoreThanOneDecimal); + } + [Test] public void TestOverallDifficultyUnder() { @@ -76,6 +88,30 @@ namespace osu.Game.Rulesets.Taiko.Tests.Editor.Checks Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); } + [Test] + public void TestDrainRateUnder() + { + beatmap.Difficulty.DrainRate = -10; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + + [Test] + public void TestDrainRateOver() + { + beatmap.Difficulty.DrainRate = 20; + + var context = getContext(); + var issues = check.Run(context).ToList(); + + Assert.That(issues, Has.Count.EqualTo(1)); + Assert.That(issues.Single().Template is CheckAbnormalDifficultySettings.IssueTemplateOutOfRange); + } + private BeatmapVerifierContext getContext() { return new BeatmapVerifierContext(beatmap, new TestWorkingBeatmap(beatmap)); From e7cf1ab4df36879306ef6e4c38b535ba370a0e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 26 Mar 2024 10:58:39 +0100 Subject: [PATCH 480/508] Add checks for taiko drain rate --- .../Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs index ce35f21853..10e2867ca0 100644 --- a/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs +++ b/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs @@ -21,6 +21,12 @@ namespace osu.Game.Rulesets.Taiko.Edit.Checks if (OutOfRange(diff.OverallDifficulty)) yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); + + if (HasMoreThanOneDecimalPlace(diff.DrainRate)) + yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + + if (OutOfRange(diff.DrainRate)) + yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); } } } From 1866b4b6b10d1990db311eb96ae02c5c5609e918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 26 Mar 2024 11:13:03 +0100 Subject: [PATCH 481/508] Refactor abstract check to reduce duplication --- .../CheckCatchAbnormalDifficultySettings.cs | 25 +++++++------- .../CheckManiaAbnormalDifficultySettings.cs | 17 +++++----- .../CheckOsuAbnormalDifficultySettings.cs | 33 ++++++++++--------- .../CheckTaikoAbnormalDifficultySettings.cs | 17 +++++----- .../Checks/CheckAbnormalDifficultySettings.cs | 13 +++++--- 5 files changed, 57 insertions(+), 48 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Edit/Checks/CheckCatchAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Catch/Edit/Checks/CheckCatchAbnormalDifficultySettings.cs index 8295795f00..d2c3df0872 100644 --- a/osu.Game.Rulesets.Catch/Edit/Checks/CheckCatchAbnormalDifficultySettings.cs +++ b/osu.Game.Rulesets.Catch/Edit/Checks/CheckCatchAbnormalDifficultySettings.cs @@ -15,24 +15,25 @@ namespace osu.Game.Rulesets.Catch.Edit.Checks public override IEnumerable Run(BeatmapVerifierContext context) { var diff = context.Beatmap.Difficulty; + Issue? issue; - if (HasMoreThanOneDecimalPlace(diff.ApproachRate)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate); + if (HasMoreThanOneDecimalPlace("Approach rate", diff.ApproachRate, out issue)) + yield return issue; - if (OutOfRange(diff.ApproachRate)) - yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate); + if (OutOfRange("Approach rate", diff.ApproachRate, out issue)) + yield return issue; - if (HasMoreThanOneDecimalPlace(diff.CircleSize)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize); + if (HasMoreThanOneDecimalPlace("Circle size", diff.CircleSize, out issue)) + yield return issue; - if (OutOfRange(diff.CircleSize)) - yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize); + if (OutOfRange("Circle size", diff.CircleSize, out issue)) + yield return issue; - if (HasMoreThanOneDecimalPlace(diff.DrainRate)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + if (HasMoreThanOneDecimalPlace("Drain rate", diff.DrainRate, out issue)) + yield return issue; - if (OutOfRange(diff.DrainRate)) - yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); + if (OutOfRange("Drain rate", diff.DrainRate, out issue)) + yield return issue; } } } diff --git a/osu.Game.Rulesets.Mania/Edit/Checks/CheckManiaAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Mania/Edit/Checks/CheckManiaAbnormalDifficultySettings.cs index ae0cc3aa4c..233c602c21 100644 --- a/osu.Game.Rulesets.Mania/Edit/Checks/CheckManiaAbnormalDifficultySettings.cs +++ b/osu.Game.Rulesets.Mania/Edit/Checks/CheckManiaAbnormalDifficultySettings.cs @@ -15,18 +15,19 @@ namespace osu.Game.Rulesets.Mania.Edit.Checks public override IEnumerable Run(BeatmapVerifierContext context) { var diff = context.Beatmap.Difficulty; + Issue? issue; - if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); + if (HasMoreThanOneDecimalPlace("Overall difficulty", diff.OverallDifficulty, out issue)) + yield return issue; - if (OutOfRange(diff.OverallDifficulty)) - yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); + if (OutOfRange("Overall difficulty", diff.OverallDifficulty, out issue)) + yield return issue; - if (HasMoreThanOneDecimalPlace(diff.DrainRate)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + if (HasMoreThanOneDecimalPlace("Drain rate", diff.DrainRate, out issue)) + yield return issue; - if (OutOfRange(diff.DrainRate)) - yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); + if (OutOfRange("Drain rate", diff.DrainRate, out issue)) + yield return issue; } } } diff --git a/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs index 7ad861f317..1c44d54633 100644 --- a/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs +++ b/osu.Game.Rulesets.Osu/Edit/Checks/CheckOsuAbnormalDifficultySettings.cs @@ -15,30 +15,31 @@ namespace osu.Game.Rulesets.Osu.Edit.Checks public override IEnumerable Run(BeatmapVerifierContext context) { var diff = context.Beatmap.Difficulty; + Issue? issue; - if (HasMoreThanOneDecimalPlace(diff.ApproachRate)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Approach rate", diff.ApproachRate); + if (HasMoreThanOneDecimalPlace("Approach rate", diff.ApproachRate, out issue)) + yield return issue; - if (OutOfRange(diff.ApproachRate)) - yield return new IssueTemplateOutOfRange(this).Create("Approach rate", diff.ApproachRate); + if (OutOfRange("Approach rate", diff.ApproachRate, out issue)) + yield return issue; - if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); + if (HasMoreThanOneDecimalPlace("Overall difficulty", diff.OverallDifficulty, out issue)) + yield return issue; - if (OutOfRange(diff.OverallDifficulty)) - yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); + if (OutOfRange("Overall difficulty", diff.OverallDifficulty, out issue)) + yield return issue; - if (HasMoreThanOneDecimalPlace(diff.CircleSize)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Circle size", diff.CircleSize); + if (HasMoreThanOneDecimalPlace("Circle size", diff.CircleSize, out issue)) + yield return issue; - if (OutOfRange(diff.CircleSize)) - yield return new IssueTemplateOutOfRange(this).Create("Circle size", diff.CircleSize); + if (OutOfRange("Circle size", diff.CircleSize, out issue)) + yield return issue; - if (HasMoreThanOneDecimalPlace(diff.DrainRate)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + if (HasMoreThanOneDecimalPlace("Drain rate", diff.DrainRate, out issue)) + yield return issue; - if (OutOfRange(diff.DrainRate)) - yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); + if (OutOfRange("Drain rate", diff.DrainRate, out issue)) + yield return issue; } } } diff --git a/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs b/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs index 10e2867ca0..38ba7b1b01 100644 --- a/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs +++ b/osu.Game.Rulesets.Taiko/Edit/Checks/CheckTaikoAbnormalDifficultySettings.cs @@ -15,18 +15,19 @@ namespace osu.Game.Rulesets.Taiko.Edit.Checks public override IEnumerable Run(BeatmapVerifierContext context) { var diff = context.Beatmap.Difficulty; + Issue? issue; - if (HasMoreThanOneDecimalPlace(diff.OverallDifficulty)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Overall difficulty", diff.OverallDifficulty); + if (HasMoreThanOneDecimalPlace("Overall difficulty", diff.OverallDifficulty, out issue)) + yield return issue; - if (OutOfRange(diff.OverallDifficulty)) - yield return new IssueTemplateOutOfRange(this).Create("Overall difficulty", diff.OverallDifficulty); + if (OutOfRange("Overall difficulty", diff.OverallDifficulty, out issue)) + yield return issue; - if (HasMoreThanOneDecimalPlace(diff.DrainRate)) - yield return new IssueTemplateMoreThanOneDecimal(this).Create("Drain rate", diff.DrainRate); + if (HasMoreThanOneDecimalPlace("Drain rate", diff.DrainRate, out issue)) + yield return issue; - if (OutOfRange(diff.DrainRate)) - yield return new IssueTemplateOutOfRange(this).Create("Drain rate", diff.DrainRate); + if (OutOfRange("Drain rate", diff.DrainRate, out issue)) + yield return issue; } } } diff --git a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs index 93592a866b..638f0cfd53 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckAbnormalDifficultySettings.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using osu.Game.Rulesets.Edit.Checks.Components; namespace osu.Game.Rulesets.Edit.Checks @@ -21,14 +22,18 @@ namespace osu.Game.Rulesets.Edit.Checks /// /// If the setting is out of the boundaries set by the editor (0 - 10) /// - protected bool OutOfRange(float setting) + protected bool OutOfRange(string setting, float value, [NotNullWhen(true)] out Issue? issue) { - return setting < 0f || setting > 10f; + bool hasIssue = value < 0f || value > 10f; + issue = hasIssue ? new IssueTemplateOutOfRange(this).Create(setting, value) : null; + return hasIssue; } - protected bool HasMoreThanOneDecimalPlace(float setting) + protected bool HasMoreThanOneDecimalPlace(string setting, float value, [NotNullWhen(true)] out Issue? issue) { - return float.Round(setting, 1) != setting; + bool hasIssue = float.Round(value, 1) != value; + issue = hasIssue ? new IssueTemplateMoreThanOneDecimal(this).Create(setting, value) : null; + return hasIssue; } public class IssueTemplateMoreThanOneDecimal : IssueTemplate From c24eb066dc4927580ffecfe79460819bc5486f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 26 Mar 2024 12:03:24 +0100 Subject: [PATCH 482/508] Update tests to match new expected behaviour Co-authored-by: Vlad Frangu --- .../Filtering/FilterQueryParserTest.cs | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs index bd706b5b4c..ea14412f55 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs @@ -273,12 +273,21 @@ namespace osu.Game.Tests.NonVisual.Filtering } [Test] - public void TestApplyStatusMatches() + public void TestApplyMultipleEqualityStatusQueries() { const string query = "status=ranked status=loved"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); + Assert.That(filterCriteria.OnlineStatus.Values, Is.Empty); + } + + [Test] + public void TestApplyEqualStatusQueryWithMultipleValues() + { + const string query = "status=ranked,loved"; + var filterCriteria = new FilterCriteria(); + FilterQueryParser.ApplyQueries(filterCriteria, query); + Assert.That(filterCriteria.OnlineStatus.Values, Is.Not.Empty); Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked)); Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Loved)); } @@ -289,13 +298,43 @@ namespace osu.Game.Tests.NonVisual.Filtering const string query = "status>=r"; var filterCriteria = new FilterCriteria(); FilterQueryParser.ApplyQueries(filterCriteria, query); - Assert.IsNotEmpty(filterCriteria.OnlineStatus.Values); + Assert.That(filterCriteria.OnlineStatus.Values, Has.Count.EqualTo(4)); Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Ranked)); Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Approved)); Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Qualified)); Assert.That(filterCriteria.OnlineStatus.Values, Contains.Item(BeatmapOnlineStatus.Loved)); } + [Test] + public void TestApplyRangeStatusWithMultipleMatchesQuery() + { + const string query = "status>=r,l"; + var filterCriteria = new FilterCriteria(); + FilterQueryParser.ApplyQueries(filterCriteria, query); + Assert.That(filterCriteria.OnlineStatus.Values, Is.EquivalentTo(Enum.GetValues())); + } + + [Test] + public void TestApplyTwoRangeStatusQuery() + { + const string query = "status>r status Date: Tue, 26 Mar 2024 12:20:38 +0100 Subject: [PATCH 483/508] Update `OptionalSet` implementation to intersect across multiple filters rather than union --- osu.Game/Screens/Select/FilterCriteria.cs | 9 +- osu.Game/Screens/Select/FilterQueryParser.cs | 86 ++++++++++++-------- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index 6750b07aba..01b0e9b7d9 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -114,17 +114,18 @@ namespace osu.Game.Screens.Select public IRulesetFilterCriteria? RulesetCriteria { get; set; } - public struct OptionalSet : IEquatable> - where T : struct + public readonly struct OptionalSet : IEquatable> + where T : struct, Enum { - public bool HasFilter => Values.Count > 0; + public bool HasFilter => true; public bool IsInRange(T value) => Values.Contains(value); - public HashSet Values = new HashSet(); + public HashSet Values { get; } public OptionalSet() { + Values = Enum.GetValues().ToHashSet(); } public bool Equals(OptionalSet other) => Values.SetEquals(other.Values); diff --git a/osu.Game/Screens/Select/FilterQueryParser.cs b/osu.Game/Screens/Select/FilterQueryParser.cs index 32b533e18d..4e49495f47 100644 --- a/osu.Game/Screens/Select/FilterQueryParser.cs +++ b/osu.Game/Screens/Select/FilterQueryParser.cs @@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select return TryUpdateCriteriaRange(ref criteria.BeatDivisor, op, value, tryParseInt); case "status": - return TryUpdateCriteriaSet(ref criteria.OnlineStatus, op, value, tryParseEnum); + return TryUpdateCriteriaSet(ref criteria.OnlineStatus, op, value); case "creator": case "author": @@ -302,54 +302,70 @@ namespace osu.Game.Screens.Select /// /// Attempts to parse a keyword filter of type , - /// from the specified and . - /// If can be parsed into using , the function returns true + /// from the specified and . + /// If can be parsed successfully, the function returns true /// and the resulting range constraint is stored into the 's expected values. /// /// The to store the parsed data into, if successful. /// The operator for the keyword filter. - /// The value of the keyword filter. - /// Function used to determine if can be converted to type . - public static bool TryUpdateCriteriaSet(ref FilterCriteria.OptionalSet range, Operator op, string val, TryParseFunction parseFunction) - where T : struct, Enum - => parseFunction.Invoke(val, out var converted) && tryUpdateCriteriaSet(ref range, op, converted); - - private static bool tryUpdateCriteriaSet(ref FilterCriteria.OptionalSet range, Operator op, T pivotValue) + /// The value of the keyword filter. + public static bool TryUpdateCriteriaSet(ref FilterCriteria.OptionalSet range, Operator op, string filterValue) where T : struct, Enum { - var allDefinedValues = Enum.GetValues(); + var matchingValues = new HashSet(); - foreach (var val in allDefinedValues) + if (op == Operator.Equal && filterValue.Contains(',')) { - int compareResult = Comparer.Default.Compare(val, pivotValue); + string[] splitValues = filterValue.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); - switch (op) + foreach (string splitValue in splitValues) { - case Operator.Less: - if (compareResult < 0) range.Values.Add(val); - break; - - case Operator.LessOrEqual: - if (compareResult <= 0) range.Values.Add(val); - break; - - case Operator.Equal: - if (compareResult == 0) range.Values.Add(val); - break; - - case Operator.GreaterOrEqual: - if (compareResult >= 0) range.Values.Add(val); - break; - - case Operator.Greater: - if (compareResult > 0) range.Values.Add(val); - break; - - default: + if (!tryParseEnum(splitValue, out var parsedValue)) return false; + + matchingValues.Add(parsedValue); + } + } + else + { + if (!tryParseEnum(filterValue, out var pivotValue)) + return false; + + var allDefinedValues = Enum.GetValues(); + + foreach (var val in allDefinedValues) + { + int compareResult = Comparer.Default.Compare(val, pivotValue); + + switch (op) + { + case Operator.Less: + if (compareResult < 0) matchingValues.Add(val); + break; + + case Operator.LessOrEqual: + if (compareResult <= 0) matchingValues.Add(val); + break; + + case Operator.Equal: + if (compareResult == 0) matchingValues.Add(val); + break; + + case Operator.GreaterOrEqual: + if (compareResult >= 0) matchingValues.Add(val); + break; + + case Operator.Greater: + if (compareResult > 0) matchingValues.Add(val); + break; + + default: + return false; + } } } + range.Values.IntersectWith(matchingValues); return true; } From 9474156df4bb33bda65c0bd2d68d565825f1b3d1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2024 20:21:12 +0800 Subject: [PATCH 484/508] Improve equality implementations --- .../API/Requests/Responses/APIMenuContent.cs | 10 +--------- .../API/Requests/Responses/APIMenuImage.cs | 17 +++++------------ 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs b/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs index 7b53488030..6aad0f6c87 100644 --- a/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs +++ b/osu.Game/Online/API/Requests/Responses/APIMenuContent.cs @@ -23,15 +23,7 @@ namespace osu.Game.Online.API.Requests.Responses return Images.SequenceEqual(other.Images); } - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - - if (obj.GetType() != GetType()) return false; - - return Equals((APIMenuContent)obj); - } + public override bool Equals(object? other) => other is APIMenuContent content && Equals(content); public override int GetHashCode() { diff --git a/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs b/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs index 42129ca96e..8aff08099a 100644 --- a/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs +++ b/osu.Game/Online/API/Requests/Responses/APIMenuImage.cs @@ -28,34 +28,27 @@ namespace osu.Game.Online.API.Requests.Responses /// The time at which this item should begin displaying. If null, will display immediately. /// [JsonProperty(@"begins")] - public DateTimeOffset? Begins { get; set; } + public DateTimeOffset? Begins { get; init; } /// /// The time at which this item should stop displaying. If null, will display indefinitely. /// [JsonProperty(@"expires")] - public DateTimeOffset? Expires { get; set; } + public DateTimeOffset? Expires { get; init; } public bool Equals(APIMenuImage? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; - return Image == other.Image && Url == other.Url; + return Image == other.Image && Url == other.Url && Begins == other.Begins && Expires == other.Expires; } - public override bool Equals(object? obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != GetType()) return false; - - return Equals((APIMenuImage)obj); - } + public override bool Equals(object? other) => other is APIMenuImage content && Equals(content); public override int GetHashCode() { - return HashCode.Combine(Image, Url); + return HashCode.Combine(Image, Url, Begins, Expires); } } } From fd649edabae36603cccfc8a847a81de05b32f257 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2024 20:21:48 +0800 Subject: [PATCH 485/508] Also don't rotate images during a drag operation --- osu.Game/Screens/Menu/OnlineMenuBanner.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index 37bec7aa63..260c021719 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -120,8 +120,8 @@ namespace osu.Game.Screens.Menu { nextDisplay?.Cancel(); - // If the user is hovering a banner, don't rotate yet. - bool anyHovered = content.Any(i => i.IsHovered); + // If the user is interacting with a banner, don't rotate yet. + bool anyHovered = content.Any(i => i.IsHovered || i.IsDragged); if (!anyHovered) { @@ -242,6 +242,8 @@ namespace osu.Game.Screens.Menu .ScaleTo(1, 500, Easing.OutElastic); base.OnMouseUp(e); } + + protected override bool OnDragStart(DragStartEvent e) => true; } } } From e77d4c8cfaf66e1e717b0094632a3704b77e73f0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2024 20:28:03 +0800 Subject: [PATCH 486/508] Remove unnecessary `Math.Max` --- osu.Game/Screens/Menu/OnlineMenuBanner.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Menu/OnlineMenuBanner.cs b/osu.Game/Screens/Menu/OnlineMenuBanner.cs index 260c021719..6f98b73939 100644 --- a/osu.Game/Screens/Menu/OnlineMenuBanner.cs +++ b/osu.Game/Screens/Menu/OnlineMenuBanner.cs @@ -130,8 +130,8 @@ namespace osu.Game.Screens.Menu // To handle expiration simply, arrange all images in best-next order. // Fade in the first valid one, then handle fading out the last if required. var currentRotation = content - .Skip(Math.Max(0, previousIndex) + 1) - .Concat(content.Take(Math.Max(0, previousIndex) + 1)); + .Skip(previousIndex + 1) + .Concat(content.Take(previousIndex + 1)); // After the loop, displayIndex will be the new valid index or -1 if // none valid. From dee88573a756f9652628d13f2033cd4b78244870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 26 Mar 2024 13:44:12 +0100 Subject: [PATCH 487/508] Fix test failure in visual browser I'm not sure why it's failing headless and I'm not particularly interested in finding that out right now. --- osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs index 380085ce04..60e42838d8 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Online.API.Requests.Responses; using osu.Game.Screens.Menu; +using osuTK; namespace osu.Game.Tests.Visual.Menus { @@ -95,7 +96,7 @@ namespace osu.Game.Tests.Visual.Menus } }); - AddUntilStep("wait for no image shown", () => !onlineMenuBanner.ChildrenOfType().Any()); + AddUntilStep("wait for no image shown", () => onlineMenuBanner.ChildrenOfType().Single().Size, () => Is.EqualTo(Vector2.Zero)); AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent()); From b4ccbc68e447f0dba68470d70510195bfad009f5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2024 21:20:22 +0800 Subject: [PATCH 488/508] Fix failing test --- osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs index 60e42838d8..0b90fd13c3 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneOnlineMenuBanner.cs @@ -96,7 +96,7 @@ namespace osu.Game.Tests.Visual.Menus } }); - AddUntilStep("wait for no image shown", () => onlineMenuBanner.ChildrenOfType().Single().Size, () => Is.EqualTo(Vector2.Zero)); + AddUntilStep("wait for no image shown", () => onlineMenuBanner.ChildrenOfType().SingleOrDefault()?.Size, () => Is.EqualTo(Vector2.Zero)); AddStep("unset system title", () => onlineMenuBanner.Current.Value = new APIMenuContent()); From a5f15a119e325f954e8f5358227269a99dec4e5e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2024 22:51:54 +0800 Subject: [PATCH 489/508] Apply rate adjust fix in all cases rather than specifically for `Clock.Rate == 1` --- osu.Game/Graphics/Containers/BeatSyncedContainer.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index a14dfd4d64..de9a5aff3a 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -96,10 +96,8 @@ namespace osu.Game.Graphics.Containers // In the case of gameplay, we are usually within a hierarchy with the correct rate applied to our `Drawable.Clock`. // This means that the amount of early adjustment is adjusted in line with audio track rate changes. // But other cases like the osu! logo at the main menu won't correctly have this rate information. - // - // So for cases where the rate of the source isn't in sync with our hierarchy, let's assume we need to account for it locally. - if (Clock.Rate == 1 && BeatSyncSource.Clock.Rate != Clock.Rate) - early *= BeatSyncSource.Clock.Rate; + // We can adjust here to ensure the applied early activation always matches expectations. + early *= BeatSyncSource.Clock.Rate / Clock.Rate; currentTrackTime = BeatSyncSource.Clock.CurrentTime + early; From 4c1a1b54be7ffab08eb6e2713dbeca953f15044c Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 27 Mar 2024 00:07:51 +0900 Subject: [PATCH 490/508] Fix NVAPI startup exception on non-Windows platforms --- osu.Desktop/NVAPI.cs | 2 ++ osu.Desktop/Program.cs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Desktop/NVAPI.cs b/osu.Desktop/NVAPI.cs index 78a814c585..554f89a847 100644 --- a/osu.Desktop/NVAPI.cs +++ b/osu.Desktop/NVAPI.cs @@ -8,11 +8,13 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using osu.Framework.Logging; namespace osu.Desktop { [SuppressMessage("ReSharper", "InconsistentNaming")] + [SupportedOSPlatform("windows")] internal static class NVAPI { private const string osu_filename = "osu!.exe"; diff --git a/osu.Desktop/Program.cs b/osu.Desktop/Program.cs index 73670adc49..2d7ec5aa5f 100644 --- a/osu.Desktop/Program.cs +++ b/osu.Desktop/Program.cs @@ -70,7 +70,8 @@ namespace osu.Desktop // NVIDIA profiles are based on the executable name of a process. // Lazer and stable share the same executable name. // Stable sets this setting to "Off", which may not be what we want, so let's force it back to the default "Auto" on startup. - NVAPI.ThreadedOptimisations = NvThreadControlSetting.OGL_THREAD_CONTROL_DEFAULT; + if (OperatingSystem.IsWindows()) + NVAPI.ThreadedOptimisations = NvThreadControlSetting.OGL_THREAD_CONTROL_DEFAULT; // Back up the cwd before DesktopGameHost changes it string cwd = Environment.CurrentDirectory; From 01a72d5afaa788e707308bea0764565ad1b044e6 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Tue, 26 Mar 2024 12:10:40 -0300 Subject: [PATCH 491/508] Fix combo not reversing properly depending on the order of selection --- .../Edit/CatchSelectionHandler.cs | 17 +++++++++-------- .../Edit/OsuSelectionHandler.cs | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs b/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs index e3d2347c4d..f8fe9805e6 100644 --- a/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs +++ b/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs @@ -76,17 +76,15 @@ namespace osu.Game.Rulesets.Catch.Edit public override bool HandleReverse() { - var hitObjects = EditorBeatmap.SelectedHitObjects; + var hitObjects = EditorBeatmap.SelectedHitObjects + .OfType() + .OrderBy(obj => obj.StartTime) + .ToList(); double selectionStartTime = SelectedItems.Min(h => h.StartTime); double selectionEndTime = SelectedItems.Max(h => h.GetEndTime()); - var newComboOrder = hitObjects - .OfType() - .Select(obj => obj.NewCombo) - .ToList(); - - newComboOrder.Reverse(); + var newComboOrder = hitObjects.Select(obj => obj.NewCombo).ToList(); foreach (var h in hitObjects) { @@ -101,10 +99,13 @@ namespace osu.Game.Rulesets.Catch.Edit } } + // re-order objects again after flipping their times + hitObjects = [.. hitObjects.OrderBy(obj => obj.StartTime)]; + int i = 0; foreach (bool newCombo in newComboOrder) { - hitObjects.OfType().ToList()[i].NewCombo = newCombo; + hitObjects[i].NewCombo = newCombo; i++; } diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs index df39ab8fce..0e889cab81 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs @@ -78,19 +78,17 @@ namespace osu.Game.Rulesets.Osu.Edit public override bool HandleReverse() { - var hitObjects = EditorBeatmap.SelectedHitObjects; + var hitObjects = EditorBeatmap.SelectedHitObjects + .OfType() + .OrderBy(obj => obj.StartTime) + .ToList(); double endTime = hitObjects.Max(h => h.GetEndTime()); double startTime = hitObjects.Min(h => h.StartTime); bool moreThanOneObject = hitObjects.Count > 1; - var newComboOrder = hitObjects - .OfType() - .Select(obj => obj.NewCombo) - .ToList(); - - newComboOrder.Reverse(); + var newComboOrder = hitObjects.Select(obj => obj.NewCombo).ToList(); foreach (var h in hitObjects) { @@ -104,10 +102,13 @@ namespace osu.Game.Rulesets.Osu.Edit } } + // re-order objects again after flipping their times + hitObjects = [.. hitObjects.OrderBy(obj => obj.StartTime)]; + int i = 0; foreach (bool newCombo in newComboOrder) { - hitObjects.OfType().ToList()[i].NewCombo = newCombo; + hitObjects[i].NewCombo = newCombo; i++; } From e02ad6cf94d3a9bba0cbcac6ecee5a0125f9da89 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2024 23:38:34 +0800 Subject: [PATCH 492/508] Fix test regression --- osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModTouchDevice.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModTouchDevice.cs b/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModTouchDevice.cs index fdb1cac3e5..8c81431770 100644 --- a/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModTouchDevice.cs +++ b/osu.Game.Rulesets.Osu.Tests/Mods/TestSceneOsuModTouchDevice.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods private SessionStatics statics { get; set; } = null!; private ScoreAccessibleSoloPlayer currentPlayer = null!; - private readonly ManualClock manualClock = new ManualClock { Rate = 0 }; + private readonly ManualClock manualClock = new ManualClock { Rate = 1 }; protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null) => new ClockBackedTestWorkingBeatmap(beatmap, storyboard, new FramedClock(manualClock), Audio); From 0b29a762b8aa712d1a0b697f367ae809a0896f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 26 Mar 2024 17:36:00 +0100 Subject: [PATCH 493/508] Add precautionary guard to avoid potential div-by-zero Probably wouldn't happen outside of tests, but I'd rather not find out next release. --- osu.Game/Graphics/Containers/BeatSyncedContainer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs index de9a5aff3a..7210371ebf 100644 --- a/osu.Game/Graphics/Containers/BeatSyncedContainer.cs +++ b/osu.Game/Graphics/Containers/BeatSyncedContainer.cs @@ -97,7 +97,8 @@ namespace osu.Game.Graphics.Containers // This means that the amount of early adjustment is adjusted in line with audio track rate changes. // But other cases like the osu! logo at the main menu won't correctly have this rate information. // We can adjust here to ensure the applied early activation always matches expectations. - early *= BeatSyncSource.Clock.Rate / Clock.Rate; + if (Clock.Rate > 0) + early *= BeatSyncSource.Clock.Rate / Clock.Rate; currentTrackTime = BeatSyncSource.Clock.CurrentTime + early; From 4490dbf8960214dcc9d3f67dbfc88ab5255c6e94 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 27 Mar 2024 13:37:47 +0900 Subject: [PATCH 494/508] Update diffcalc workflow --- .github/workflows/diffcalc.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/diffcalc.yml b/.github/workflows/diffcalc.yml index 7a2dcecb9c..2ed176fe8d 100644 --- a/.github/workflows/diffcalc.yml +++ b/.github/workflows/diffcalc.yml @@ -110,10 +110,14 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.comment.body, '!diffcalc') }} steps: - name: Check permissions - if: ${{ github.event_name != 'workflow_dispatch' }} - uses: actions-cool/check-user-permission@a0668c9aec87f3875fc56170b6452a453e9dd819 # v2.2.0 - with: - require: 'write' + run: | + ALLOWED_USERS=(smoogipoo peppy bdach) + for i in "${ALLOWED_USERS[@]}"; do + if [[ "${{ github.actor }}" == "$i" ]]; then + exit 0 + fi + done + exit 1 create-comment: name: Create PR comment From 60c93d2c6de6690913ba6f9552615116c2470a29 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Wed, 27 Mar 2024 08:22:51 -0300 Subject: [PATCH 495/508] Add reverse pattern visual tests --- .../Editor/TestSceneCatchReverseSelection.cs | 313 ++++++++++++++++ .../Editor/TestSceneOsuReverseSelection.cs | 347 ++++++++++++++++++ 2 files changed, 660 insertions(+) create mode 100644 osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs create mode 100644 osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuReverseSelection.cs diff --git a/osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs b/osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs new file mode 100644 index 0000000000..c8a48f76eb --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs @@ -0,0 +1,313 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Objects; +using osu.Game.Tests.Beatmaps; +using osuTK; +using osuTK.Input; + +namespace osu.Game.Rulesets.Catch.Tests.Editor +{ + [TestFixture] + public partial class TestSceneCatchReverseSelection : TestSceneEditor + { + protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false); + + [Test] + public void TestReverseSelectionTwoFruits() + { + float fruit1OldX = default; + float fruit2OldX = default; + + addObjects([ + new Fruit + { + StartTime = 200, + X = fruit1OldX = 0, + }, + new Fruit + { + StartTime = 400, + X = fruit2OldX = 20, + } + ]); + + selectEverything(); + reverseSelection(); + + AddAssert("fruit1 is at fruit2's X", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).EffectiveX, + () => Is.EqualTo(fruit2OldX) + ); + + AddAssert("fruit2 is at fruit1's X", + () => EditorBeatmap.HitObjects.OfType().ElementAt(1).EffectiveX, + () => Is.EqualTo(fruit1OldX) + ); + + AddAssert("fruit2 is not a new combo", + () => EditorBeatmap.HitObjects.OfType().ElementAt(1).NewCombo, + () => Is.EqualTo(false) + ); + } + + [Test] + public void TestReverseSelectionThreeFruits() + { + float fruit1OldX = default; + float fruit2OldX = default; + float fruit3OldX = default; + + addObjects([ + new Fruit + { + StartTime = 200, + X = fruit1OldX = 0, + }, + new Fruit + { + StartTime = 400, + X = fruit2OldX = 20, + }, + new Fruit + { + StartTime = 600, + X = fruit3OldX = 40, + } + ]); + + selectEverything(); + reverseSelection(); + + AddAssert("fruit1 is at fruit3's X", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).EffectiveX, + () => Is.EqualTo(fruit3OldX) + ); + + AddAssert("fruit2's X is unchanged", + () => EditorBeatmap.HitObjects.OfType().ElementAt(1).EffectiveX, + () => Is.EqualTo(fruit2OldX) + ); + + AddAssert("fruit3's is at fruit1's X", + () => EditorBeatmap.HitObjects.OfType().ElementAt(2).EffectiveX, + () => Is.EqualTo(fruit1OldX) + ); + + AddAssert("fruit3 is not a new combo", + () => EditorBeatmap.HitObjects.OfType().ElementAt(2).NewCombo, + () => Is.EqualTo(false) + ); + } + + [Test] + public void TestReverseSelectionFruitAndJuiceStream() + { + addObjects([ + new Fruit + { + StartTime = 200, + X = 0, + }, + new JuiceStream + { + StartTime = 400, + X = 20, + Path = new SliderPath + { + ControlPoints = + { + new PathControlPoint(), + new PathControlPoint(new Vector2(50)) + } + } + } + ]); + + selectEverything(); + reverseSelection(); + + AddAssert("First element is juice stream", + () => EditorBeatmap.HitObjects.First().GetType(), + () => Is.EqualTo(typeof(JuiceStream)) + ); + + AddAssert("Last element is fruit", + () => EditorBeatmap.HitObjects.Last().GetType(), + () => Is.EqualTo(typeof(Fruit)) + ); + + AddAssert("Fruit is not new combo", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).NewCombo, + () => Is.EqualTo(false) + ); + } + + [Test] + public void TestReverseSelectionTwoFruitsAndJuiceStream() + { + addObjects([ + new Fruit + { + StartTime = 200, + X = 0, + }, + new Fruit + { + StartTime = 400, + X = 20, + }, + new JuiceStream + { + StartTime = 600, + X = 40, + Path = new SliderPath + { + ControlPoints = + { + new PathControlPoint(), + new PathControlPoint(new Vector2(50)) + } + } + } + ]); + + selectEverything(); + reverseSelection(); + + AddAssert("First element is juice stream", + () => EditorBeatmap.HitObjects.First().GetType(), + () => Is.EqualTo(typeof(JuiceStream)) + ); + + AddAssert("Middle element is Fruit", + () => EditorBeatmap.HitObjects.ElementAt(1).GetType(), + () => Is.EqualTo(typeof(Fruit)) + ); + + AddAssert("Last element is Fruit", + () => EditorBeatmap.HitObjects.Last().GetType(), + () => Is.EqualTo(typeof(Fruit)) + ); + + AddAssert("Last fruit is not new combo", + () => EditorBeatmap.HitObjects.OfType().Last().NewCombo, + () => Is.EqualTo(false) + ); + } + + [Test] + public void TestReverseSelectionTwoCombos() + { + float fruit1OldX = default; + float fruit2OldX = default; + float fruit3OldX = default; + + float fruit4OldX = default; + float fruit5OldX = default; + float fruit6OldX = default; + + addObjects([ + new Fruit + { + StartTime = 200, + X = fruit1OldX = 0, + }, + new Fruit + { + StartTime = 400, + X = fruit2OldX = 20, + }, + new Fruit + { + StartTime = 600, + X = fruit3OldX = 40, + }, + + new Fruit + { + StartTime = 800, + NewCombo = true, + X = fruit4OldX = 60, + }, + new Fruit + { + StartTime = 1000, + X = fruit5OldX = 80, + }, + new Fruit + { + StartTime = 1200, + X = fruit6OldX = 100, + } + ]); + + selectEverything(); + reverseSelection(); + + AddAssert("fruit1 is at fruit6 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).EffectiveX, + () => Is.EqualTo(fruit6OldX) + ); + + AddAssert("fruit2 is at fruit5 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(1).EffectiveX, + () => Is.EqualTo(fruit5OldX) + ); + + AddAssert("fruit3 is at fruit4 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(2).EffectiveX, + () => Is.EqualTo(fruit4OldX) + ); + + AddAssert("fruit4 is at fruit3 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(3).EffectiveX, + () => Is.EqualTo(fruit3OldX) + ); + + AddAssert("fruit5 is at fruit2 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(4).EffectiveX, + () => Is.EqualTo(fruit2OldX) + ); + + AddAssert("fruit6 is at fruit1 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(5).EffectiveX, + () => Is.EqualTo(fruit1OldX) + ); + + AddAssert("fruit1 is new combo", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).NewCombo, + () => Is.EqualTo(true) + ); + + AddAssert("fruit4 is new combo", + () => EditorBeatmap.HitObjects.OfType().ElementAt(3).NewCombo, + () => Is.EqualTo(true) + ); + } + + private void addObjects(CatchHitObject[] hitObjects) => AddStep("Add objects", () => EditorBeatmap.AddRange(hitObjects)); + + private void selectEverything() + { + AddStep("Select everything", () => + { + EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + }); + } + + private void reverseSelection() + { + AddStep("Reverse selection", () => + { + InputManager.PressKey(Key.LControl); + InputManager.Key(Key.G); + InputManager.ReleaseKey(Key.LControl); + }); + } + } +} diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuReverseSelection.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuReverseSelection.cs new file mode 100644 index 0000000000..33104288ab --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuReverseSelection.cs @@ -0,0 +1,347 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Tests.Beatmaps; +using osuTK; +using osuTK.Input; + +namespace osu.Game.Rulesets.Osu.Tests.Editor +{ + [TestFixture] + public partial class TestSceneOsuReverseSelection : TestSceneOsuEditor + { + protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false); + + [Test] + public void TestReverseSelectionTwoCircles() + { + Vector2 circle1OldPosition = default; + Vector2 circle2OldPosition = default; + + AddStep("Add circles", () => + { + var circle1 = new HitCircle + { + StartTime = 0, + Position = circle1OldPosition = new Vector2(208, 240) + }; + var circle2 = new HitCircle + { + StartTime = 200, + Position = circle2OldPosition = new Vector2(256, 144) + }; + + EditorBeatmap.AddRange([circle1, circle2]); + }); + + AddStep("Select circles", () => + { + EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + }); + + AddStep("Reverse selection", () => + { + InputManager.PressKey(Key.LControl); + InputManager.Key(Key.G); + InputManager.ReleaseKey(Key.LControl); + }); + + AddAssert("circle1 is at circle2 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, + () => Is.EqualTo(circle2OldPosition) + ); + + AddAssert("circle2 is at circle1 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(1).Position, + () => Is.EqualTo(circle1OldPosition) + ); + + AddAssert("circle2 is not a new combo", + () => EditorBeatmap.HitObjects.OfType().ElementAt(1).NewCombo, + () => Is.EqualTo(false) + ); + } + + [Test] + public void TestReverseSelectionThreeCircles() + { + Vector2 circle1OldPosition = default; + Vector2 circle2OldPosition = default; + Vector2 circle3OldPosition = default; + + AddStep("Add circles", () => + { + var circle1 = new HitCircle + { + StartTime = 0, + Position = circle1OldPosition = new Vector2(208, 240) + }; + var circle2 = new HitCircle + { + StartTime = 200, + Position = circle2OldPosition = new Vector2(256, 144) + }; + var circle3 = new HitCircle + { + StartTime = 400, + Position = circle3OldPosition = new Vector2(304, 240) + }; + + EditorBeatmap.AddRange([circle1, circle2, circle3]); + }); + + AddStep("Select circles", () => + { + EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + }); + + AddStep("Reverse selection", () => + { + InputManager.PressKey(Key.LControl); + InputManager.Key(Key.G); + InputManager.ReleaseKey(Key.LControl); + }); + + AddAssert("circle1 is at circle3 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, + () => Is.EqualTo(circle3OldPosition) + ); + + AddAssert("circle3 is at circle1 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(2).Position, + () => Is.EqualTo(circle1OldPosition) + ); + + AddAssert("circle3 is not a new combo", + () => EditorBeatmap.HitObjects.OfType().ElementAt(2).NewCombo, + () => Is.EqualTo(false) + ); + } + + [Test] + public void TestReverseSelectionCircleAndSlider() + { + Vector2 circleOldPosition = default; + Vector2 sliderHeadOldPosition = default; + Vector2 sliderTailOldPosition = default; + + AddStep("Add objects", () => + { + var circle = new HitCircle + { + StartTime = 0, + Position = circleOldPosition = new Vector2(208, 240) + }; + var slider = new Slider + { + StartTime = 200, + Position = sliderHeadOldPosition = new Vector2(257, 144), + Path = new SliderPath + { + ControlPoints = + { + new PathControlPoint(), + new PathControlPoint(new Vector2(100)) + } + } + }; + + sliderTailOldPosition = slider.EndPosition; + + EditorBeatmap.AddRange([circle, slider]); + }); + + AddStep("Select objects", () => + { + var circle = (HitCircle)EditorBeatmap.HitObjects[0]; + var slider = (Slider)EditorBeatmap.HitObjects[1]; + + EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + }); + + AddStep("Reverse selection", () => + { + InputManager.PressKey(Key.LControl); + InputManager.Key(Key.G); + InputManager.ReleaseKey(Key.LControl); + }); + + AddAssert("circle is at the same position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, + () => Is.EqualTo(circleOldPosition) + ); + + AddAssert("Slider head is at slider tail", () => + Vector2.Distance(EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, sliderTailOldPosition) < 1); + + AddAssert("Slider tail is at slider head", () => + Vector2.Distance(EditorBeatmap.HitObjects.OfType().ElementAt(0).EndPosition, sliderHeadOldPosition) < 1); + } + + [Test] + public void TestReverseSelectionTwoCirclesAndSlider() + { + Vector2 circle1OldPosition = default; + Vector2 circle2OldPosition = default; + + Vector2 sliderHeadOldPosition = default; + Vector2 sliderTailOldPosition = default; + + AddStep("Add objects", () => + { + var circle1 = new HitCircle + { + StartTime = 0, + Position = circle1OldPosition = new Vector2(208, 240) + }; + var circle2 = new HitCircle + { + StartTime = 200, + Position = circle2OldPosition = new Vector2(256, 144) + }; + var slider = new Slider + { + StartTime = 200, + Position = sliderHeadOldPosition = new Vector2(304, 240), + Path = new SliderPath + { + ControlPoints = + { + new PathControlPoint(), + new PathControlPoint(new Vector2(100)) + } + } + }; + + sliderTailOldPosition = slider.EndPosition; + + EditorBeatmap.AddRange([circle1, circle2, slider]); + }); + + AddStep("Select objects", () => + { + EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + }); + + AddStep("Reverse selection", () => + { + InputManager.PressKey(Key.LControl); + InputManager.Key(Key.G); + InputManager.ReleaseKey(Key.LControl); + }); + + AddAssert("circle1 is at circle2 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, + () => Is.EqualTo(circle2OldPosition) + ); + + AddAssert("circle2 is at circle1 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(1).Position, + () => Is.EqualTo(circle1OldPosition) + ); + + AddAssert("Slider head is at slider tail", () => + Vector2.Distance(EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, sliderTailOldPosition) < 1); + + AddAssert("Slider tail is at slider head", () => + Vector2.Distance(EditorBeatmap.HitObjects.OfType().ElementAt(0).EndPosition, sliderHeadOldPosition) < 1); + } + + [Test] + public void TestReverseSelectionTwoCombos() + { + Vector2 circle1OldPosition = default; + Vector2 circle2OldPosition = default; + Vector2 circle3OldPosition = default; + + Vector2 circle4OldPosition = default; + Vector2 circle5OldPosition = default; + Vector2 circle6OldPosition = default; + + AddStep("Add circles", () => + { + var circle1 = new HitCircle + { + StartTime = 0, + Position = circle1OldPosition = new Vector2(216, 240) + }; + var circle2 = new HitCircle + { + StartTime = 200, + Position = circle2OldPosition = new Vector2(120, 192) + }; + var circle3 = new HitCircle + { + StartTime = 400, + Position = circle3OldPosition = new Vector2(216, 144) + }; + + var circle4 = new HitCircle + { + StartTime = 646, + NewCombo = true, + Position = circle4OldPosition = new Vector2(296, 240) + }; + var circle5 = new HitCircle + { + StartTime = 846, + Position = circle5OldPosition = new Vector2(392, 162) + }; + var circle6 = new HitCircle + { + StartTime = 1046, + Position = circle6OldPosition = new Vector2(296, 144) + }; + + EditorBeatmap.AddRange([circle1, circle2, circle3, circle4, circle5, circle6]); + }); + + AddStep("Select circles", () => + { + EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + }); + + AddStep("Reverse selection", () => + { + InputManager.PressKey(Key.LControl); + InputManager.Key(Key.G); + InputManager.ReleaseKey(Key.LControl); + }); + + AddAssert("circle1 is at circle6 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, + () => Is.EqualTo(circle6OldPosition) + ); + + AddAssert("circle2 is at circle5 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(1).Position, + () => Is.EqualTo(circle5OldPosition) + ); + + AddAssert("circle3 is at circle4 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(2).Position, + () => Is.EqualTo(circle4OldPosition) + ); + + AddAssert("circle4 is at circle3 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(3).Position, + () => Is.EqualTo(circle3OldPosition) + ); + + AddAssert("circle5 is at circle2 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(4).Position, + () => Is.EqualTo(circle2OldPosition) + ); + + AddAssert("circle6 is at circle1 position", + () => EditorBeatmap.HitObjects.OfType().ElementAt(5).Position, + () => Is.EqualTo(circle1OldPosition) + ); + } + } +} From 53900d5472ac14a41003f5353bd704e42e245a7b Mon Sep 17 00:00:00 2001 From: Susko3 Date: Wed, 27 Mar 2024 18:56:26 +0100 Subject: [PATCH 496/508] Fix tests failing locally due to not using invariant culture --- osu.Game/Skinning/SkinImporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/SkinImporter.cs b/osu.Game/Skinning/SkinImporter.cs index 3e948a8afb..59c7f0ba26 100644 --- a/osu.Game/Skinning/SkinImporter.cs +++ b/osu.Game/Skinning/SkinImporter.cs @@ -132,7 +132,7 @@ namespace osu.Game.Skinning { // skins without a skin.ini are supposed to import using the "latest version" spec. // see https://github.com/peppy/osu-stable-reference/blob/1531237b63392e82c003c712faa028406073aa8f/osu!/Graphics/Skinning/SkinManager.cs#L297-L298 - newLines.Add($"Version: {SkinConfiguration.LATEST_VERSION}"); + newLines.Add(FormattableString.Invariant($"Version: {SkinConfiguration.LATEST_VERSION}")); // In the case a skin doesn't have a skin.ini yet, let's create one. writeNewSkinIni(); From a9cbabf71135ff97c587a1c01079b56850ef27f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 28 Mar 2024 10:05:26 +0100 Subject: [PATCH 497/508] Simplify tests --- .../Editor/TestSceneCatchReverseSelection.cs | 196 ++++++------------ .../Editor/TestSceneOsuReverseSelection.cs | 177 ++++++---------- 2 files changed, 133 insertions(+), 240 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs b/osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs index c8a48f76eb..36a0e3388e 100644 --- a/osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs +++ b/osu.Game.Rulesets.Catch.Tests/Editor/TestSceneCatchReverseSelection.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using System.Linq; using NUnit.Framework; using osu.Game.Beatmaps; @@ -20,93 +21,78 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor [Test] public void TestReverseSelectionTwoFruits() { - float fruit1OldX = default; - float fruit2OldX = default; + CatchHitObject[] objects = null!; + bool[] newCombos = null!; addObjects([ new Fruit { StartTime = 200, - X = fruit1OldX = 0, + X = 0, }, new Fruit { StartTime = 400, - X = fruit2OldX = 20, + X = 20, } ]); + AddStep("store objects & new combo data", () => + { + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); + }); + selectEverything(); reverseSelection(); - AddAssert("fruit1 is at fruit2's X", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).EffectiveX, - () => Is.EqualTo(fruit2OldX) - ); - - AddAssert("fruit2 is at fruit1's X", - () => EditorBeatmap.HitObjects.OfType().ElementAt(1).EffectiveX, - () => Is.EqualTo(fruit1OldX) - ); - - AddAssert("fruit2 is not a new combo", - () => EditorBeatmap.HitObjects.OfType().ElementAt(1).NewCombo, - () => Is.EqualTo(false) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); } [Test] public void TestReverseSelectionThreeFruits() { - float fruit1OldX = default; - float fruit2OldX = default; - float fruit3OldX = default; + CatchHitObject[] objects = null!; + bool[] newCombos = null!; addObjects([ new Fruit { StartTime = 200, - X = fruit1OldX = 0, + X = 0, }, new Fruit { StartTime = 400, - X = fruit2OldX = 20, + X = 20, }, new Fruit { StartTime = 600, - X = fruit3OldX = 40, + X = 40, } ]); + AddStep("store objects & new combo data", () => + { + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); + }); + selectEverything(); reverseSelection(); - AddAssert("fruit1 is at fruit3's X", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).EffectiveX, - () => Is.EqualTo(fruit3OldX) - ); - - AddAssert("fruit2's X is unchanged", - () => EditorBeatmap.HitObjects.OfType().ElementAt(1).EffectiveX, - () => Is.EqualTo(fruit2OldX) - ); - - AddAssert("fruit3's is at fruit1's X", - () => EditorBeatmap.HitObjects.OfType().ElementAt(2).EffectiveX, - () => Is.EqualTo(fruit1OldX) - ); - - AddAssert("fruit3 is not a new combo", - () => EditorBeatmap.HitObjects.OfType().ElementAt(2).NewCombo, - () => Is.EqualTo(false) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); } [Test] public void TestReverseSelectionFruitAndJuiceStream() { + CatchHitObject[] objects = null!; + bool[] newCombos = null!; + addObjects([ new Fruit { @@ -128,28 +114,25 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor } ]); + AddStep("store objects & new combo data", () => + { + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); + }); + selectEverything(); reverseSelection(); - AddAssert("First element is juice stream", - () => EditorBeatmap.HitObjects.First().GetType(), - () => Is.EqualTo(typeof(JuiceStream)) - ); - - AddAssert("Last element is fruit", - () => EditorBeatmap.HitObjects.Last().GetType(), - () => Is.EqualTo(typeof(Fruit)) - ); - - AddAssert("Fruit is not new combo", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).NewCombo, - () => Is.EqualTo(false) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); } [Test] public void TestReverseSelectionTwoFruitsAndJuiceStream() { + CatchHitObject[] objects = null!; + bool[] newCombos = null!; + addObjects([ new Fruit { @@ -176,122 +159,79 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor } ]); + AddStep("store objects & new combo data", () => + { + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); + }); + selectEverything(); reverseSelection(); - AddAssert("First element is juice stream", - () => EditorBeatmap.HitObjects.First().GetType(), - () => Is.EqualTo(typeof(JuiceStream)) - ); - - AddAssert("Middle element is Fruit", - () => EditorBeatmap.HitObjects.ElementAt(1).GetType(), - () => Is.EqualTo(typeof(Fruit)) - ); - - AddAssert("Last element is Fruit", - () => EditorBeatmap.HitObjects.Last().GetType(), - () => Is.EqualTo(typeof(Fruit)) - ); - - AddAssert("Last fruit is not new combo", - () => EditorBeatmap.HitObjects.OfType().Last().NewCombo, - () => Is.EqualTo(false) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); } [Test] public void TestReverseSelectionTwoCombos() { - float fruit1OldX = default; - float fruit2OldX = default; - float fruit3OldX = default; - - float fruit4OldX = default; - float fruit5OldX = default; - float fruit6OldX = default; + CatchHitObject[] objects = null!; + bool[] newCombos = null!; addObjects([ new Fruit { StartTime = 200, - X = fruit1OldX = 0, + X = 0, }, new Fruit { StartTime = 400, - X = fruit2OldX = 20, + X = 20, }, new Fruit { StartTime = 600, - X = fruit3OldX = 40, + X = 40, }, new Fruit { StartTime = 800, NewCombo = true, - X = fruit4OldX = 60, + X = 60, }, new Fruit { StartTime = 1000, - X = fruit5OldX = 80, + X = 80, }, new Fruit { StartTime = 1200, - X = fruit6OldX = 100, + X = 100, } ]); + AddStep("store objects & new combo data", () => + { + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); + }); + selectEverything(); reverseSelection(); - AddAssert("fruit1 is at fruit6 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).EffectiveX, - () => Is.EqualTo(fruit6OldX) - ); - - AddAssert("fruit2 is at fruit5 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(1).EffectiveX, - () => Is.EqualTo(fruit5OldX) - ); - - AddAssert("fruit3 is at fruit4 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(2).EffectiveX, - () => Is.EqualTo(fruit4OldX) - ); - - AddAssert("fruit4 is at fruit3 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(3).EffectiveX, - () => Is.EqualTo(fruit3OldX) - ); - - AddAssert("fruit5 is at fruit2 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(4).EffectiveX, - () => Is.EqualTo(fruit2OldX) - ); - - AddAssert("fruit6 is at fruit1 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(5).EffectiveX, - () => Is.EqualTo(fruit1OldX) - ); - - AddAssert("fruit1 is new combo", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).NewCombo, - () => Is.EqualTo(true) - ); - - AddAssert("fruit4 is new combo", - () => EditorBeatmap.HitObjects.OfType().ElementAt(3).NewCombo, - () => Is.EqualTo(true) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); } private void addObjects(CatchHitObject[] hitObjects) => AddStep("Add objects", () => EditorBeatmap.AddRange(hitObjects)); + private IEnumerable getObjects() => EditorBeatmap.HitObjects.OfType(); + + private IEnumerable getObjectNewCombos() => getObjects().Select(ho => ho.NewCombo); + private void selectEverything() { AddStep("Select everything", () => diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuReverseSelection.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuReverseSelection.cs index 33104288ab..28c1577fcb 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuReverseSelection.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuReverseSelection.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using System.Linq; using NUnit.Framework; using osu.Game.Beatmaps; @@ -20,30 +21,33 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor [Test] public void TestReverseSelectionTwoCircles() { - Vector2 circle1OldPosition = default; - Vector2 circle2OldPosition = default; + OsuHitObject[] objects = null!; + bool[] newCombos = null!; AddStep("Add circles", () => { var circle1 = new HitCircle { StartTime = 0, - Position = circle1OldPosition = new Vector2(208, 240) + Position = new Vector2(208, 240) }; var circle2 = new HitCircle { StartTime = 200, - Position = circle2OldPosition = new Vector2(256, 144) + Position = new Vector2(256, 144) }; EditorBeatmap.AddRange([circle1, circle2]); }); - AddStep("Select circles", () => + AddStep("store objects & new combo data", () => { - EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); }); + AddStep("Select circles", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects)); + AddStep("Reverse selection", () => { InputManager.PressKey(Key.LControl); @@ -51,55 +55,45 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor InputManager.ReleaseKey(Key.LControl); }); - AddAssert("circle1 is at circle2 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, - () => Is.EqualTo(circle2OldPosition) - ); - - AddAssert("circle2 is at circle1 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(1).Position, - () => Is.EqualTo(circle1OldPosition) - ); - - AddAssert("circle2 is not a new combo", - () => EditorBeatmap.HitObjects.OfType().ElementAt(1).NewCombo, - () => Is.EqualTo(false) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); } [Test] public void TestReverseSelectionThreeCircles() { - Vector2 circle1OldPosition = default; - Vector2 circle2OldPosition = default; - Vector2 circle3OldPosition = default; + OsuHitObject[] objects = null!; + bool[] newCombos = null!; AddStep("Add circles", () => { var circle1 = new HitCircle { StartTime = 0, - Position = circle1OldPosition = new Vector2(208, 240) + Position = new Vector2(208, 240) }; var circle2 = new HitCircle { StartTime = 200, - Position = circle2OldPosition = new Vector2(256, 144) + Position = new Vector2(256, 144) }; var circle3 = new HitCircle { StartTime = 400, - Position = circle3OldPosition = new Vector2(304, 240) + Position = new Vector2(304, 240) }; EditorBeatmap.AddRange([circle1, circle2, circle3]); }); - AddStep("Select circles", () => + AddStep("store objects & new combo data", () => { - EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); }); + AddStep("Select circles", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects)); + AddStep("Reverse selection", () => { InputManager.PressKey(Key.LControl); @@ -107,26 +101,16 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor InputManager.ReleaseKey(Key.LControl); }); - AddAssert("circle1 is at circle3 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, - () => Is.EqualTo(circle3OldPosition) - ); - - AddAssert("circle3 is at circle1 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(2).Position, - () => Is.EqualTo(circle1OldPosition) - ); - - AddAssert("circle3 is not a new combo", - () => EditorBeatmap.HitObjects.OfType().ElementAt(2).NewCombo, - () => Is.EqualTo(false) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); } [Test] public void TestReverseSelectionCircleAndSlider() { - Vector2 circleOldPosition = default; + OsuHitObject[] objects = null!; + bool[] newCombos = null!; + Vector2 sliderHeadOldPosition = default; Vector2 sliderTailOldPosition = default; @@ -135,7 +119,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor var circle = new HitCircle { StartTime = 0, - Position = circleOldPosition = new Vector2(208, 240) + Position = new Vector2(208, 240) }; var slider = new Slider { @@ -156,14 +140,14 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor EditorBeatmap.AddRange([circle, slider]); }); - AddStep("Select objects", () => + AddStep("store objects & new combo data", () => { - var circle = (HitCircle)EditorBeatmap.HitObjects[0]; - var slider = (Slider)EditorBeatmap.HitObjects[1]; - - EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); }); + AddStep("Select objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects)); + AddStep("Reverse selection", () => { InputManager.PressKey(Key.LControl); @@ -171,10 +155,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor InputManager.ReleaseKey(Key.LControl); }); - AddAssert("circle is at the same position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, - () => Is.EqualTo(circleOldPosition) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); AddAssert("Slider head is at slider tail", () => Vector2.Distance(EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, sliderTailOldPosition) < 1); @@ -186,8 +168,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor [Test] public void TestReverseSelectionTwoCirclesAndSlider() { - Vector2 circle1OldPosition = default; - Vector2 circle2OldPosition = default; + OsuHitObject[] objects = null!; + bool[] newCombos = null!; Vector2 sliderHeadOldPosition = default; Vector2 sliderTailOldPosition = default; @@ -197,12 +179,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor var circle1 = new HitCircle { StartTime = 0, - Position = circle1OldPosition = new Vector2(208, 240) + Position = new Vector2(208, 240) }; var circle2 = new HitCircle { StartTime = 200, - Position = circle2OldPosition = new Vector2(256, 144) + Position = new Vector2(256, 144) }; var slider = new Slider { @@ -223,11 +205,14 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor EditorBeatmap.AddRange([circle1, circle2, slider]); }); - AddStep("Select objects", () => + AddStep("store objects & new combo data", () => { - EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); }); + AddStep("Select objects", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects)); + AddStep("Reverse selection", () => { InputManager.PressKey(Key.LControl); @@ -235,15 +220,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor InputManager.ReleaseKey(Key.LControl); }); - AddAssert("circle1 is at circle2 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, - () => Is.EqualTo(circle2OldPosition) - ); - - AddAssert("circle2 is at circle1 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(1).Position, - () => Is.EqualTo(circle1OldPosition) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); AddAssert("Slider head is at slider tail", () => Vector2.Distance(EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, sliderTailOldPosition) < 1); @@ -255,57 +233,55 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor [Test] public void TestReverseSelectionTwoCombos() { - Vector2 circle1OldPosition = default; - Vector2 circle2OldPosition = default; - Vector2 circle3OldPosition = default; - - Vector2 circle4OldPosition = default; - Vector2 circle5OldPosition = default; - Vector2 circle6OldPosition = default; + OsuHitObject[] objects = null!; + bool[] newCombos = null!; AddStep("Add circles", () => { var circle1 = new HitCircle { StartTime = 0, - Position = circle1OldPosition = new Vector2(216, 240) + Position = new Vector2(216, 240) }; var circle2 = new HitCircle { StartTime = 200, - Position = circle2OldPosition = new Vector2(120, 192) + Position = new Vector2(120, 192) }; var circle3 = new HitCircle { StartTime = 400, - Position = circle3OldPosition = new Vector2(216, 144) + Position = new Vector2(216, 144) }; var circle4 = new HitCircle { StartTime = 646, NewCombo = true, - Position = circle4OldPosition = new Vector2(296, 240) + Position = new Vector2(296, 240) }; var circle5 = new HitCircle { StartTime = 846, - Position = circle5OldPosition = new Vector2(392, 162) + Position = new Vector2(392, 162) }; var circle6 = new HitCircle { StartTime = 1046, - Position = circle6OldPosition = new Vector2(296, 144) + Position = new Vector2(296, 144) }; EditorBeatmap.AddRange([circle1, circle2, circle3, circle4, circle5, circle6]); }); - AddStep("Select circles", () => + AddStep("store objects & new combo data", () => { - EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects); + objects = getObjects().ToArray(); + newCombos = getObjectNewCombos().ToArray(); }); + AddStep("Select circles", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects)); + AddStep("Reverse selection", () => { InputManager.PressKey(Key.LControl); @@ -313,35 +289,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor InputManager.ReleaseKey(Key.LControl); }); - AddAssert("circle1 is at circle6 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(0).Position, - () => Is.EqualTo(circle6OldPosition) - ); - - AddAssert("circle2 is at circle5 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(1).Position, - () => Is.EqualTo(circle5OldPosition) - ); - - AddAssert("circle3 is at circle4 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(2).Position, - () => Is.EqualTo(circle4OldPosition) - ); - - AddAssert("circle4 is at circle3 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(3).Position, - () => Is.EqualTo(circle3OldPosition) - ); - - AddAssert("circle5 is at circle2 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(4).Position, - () => Is.EqualTo(circle2OldPosition) - ); - - AddAssert("circle6 is at circle1 position", - () => EditorBeatmap.HitObjects.OfType().ElementAt(5).Position, - () => Is.EqualTo(circle1OldPosition) - ); + AddAssert("objects reversed", getObjects, () => Is.EqualTo(objects.Reverse())); + AddAssert("new combo positions preserved", getObjectNewCombos, () => Is.EqualTo(newCombos)); } + + private IEnumerable getObjects() => EditorBeatmap.HitObjects.OfType(); + + private IEnumerable getObjectNewCombos() => getObjects().Select(ho => ho.NewCombo); } } From 2f786ffc32d925d15d3417f696ac3a046dc2af80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 28 Mar 2024 10:12:27 +0100 Subject: [PATCH 498/508] Simplify implementation --- .../Edit/CatchSelectionHandler.cs | 21 +++++++++---------- .../Edit/OsuSelectionHandler.cs | 21 +++++++++---------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs b/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs index f8fe9805e6..a2784126eb 100644 --- a/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs +++ b/osu.Game.Rulesets.Catch/Edit/CatchSelectionHandler.cs @@ -77,13 +77,16 @@ namespace osu.Game.Rulesets.Catch.Edit public override bool HandleReverse() { var hitObjects = EditorBeatmap.SelectedHitObjects - .OfType() - .OrderBy(obj => obj.StartTime) - .ToList(); + .OfType() + .OrderBy(obj => obj.StartTime) + .ToList(); double selectionStartTime = SelectedItems.Min(h => h.StartTime); double selectionEndTime = SelectedItems.Max(h => h.GetEndTime()); + // the expectation is that even if the objects themselves are reversed temporally, + // the position of new combos in the selection should remain the same. + // preserve it for later before doing the reversal. var newComboOrder = hitObjects.Select(obj => obj.NewCombo).ToList(); foreach (var h in hitObjects) @@ -99,15 +102,11 @@ namespace osu.Game.Rulesets.Catch.Edit } } - // re-order objects again after flipping their times - hitObjects = [.. hitObjects.OrderBy(obj => obj.StartTime)]; + // re-order objects by start time again after reversing, and restore new combo flag positioning + hitObjects = hitObjects.OrderBy(obj => obj.StartTime).ToList(); - int i = 0; - foreach (bool newCombo in newComboOrder) - { - hitObjects[i].NewCombo = newCombo; - i++; - } + for (int i = 0; i < hitObjects.Count; ++i) + hitObjects[i].NewCombo = newComboOrder[i]; return true; } diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs index 0e889cab81..b33272968b 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs @@ -79,15 +79,18 @@ namespace osu.Game.Rulesets.Osu.Edit public override bool HandleReverse() { var hitObjects = EditorBeatmap.SelectedHitObjects - .OfType() - .OrderBy(obj => obj.StartTime) - .ToList(); + .OfType() + .OrderBy(obj => obj.StartTime) + .ToList(); double endTime = hitObjects.Max(h => h.GetEndTime()); double startTime = hitObjects.Min(h => h.StartTime); bool moreThanOneObject = hitObjects.Count > 1; + // the expectation is that even if the objects themselves are reversed temporally, + // the position of new combos in the selection should remain the same. + // preserve it for later before doing the reversal. var newComboOrder = hitObjects.Select(obj => obj.NewCombo).ToList(); foreach (var h in hitObjects) @@ -102,15 +105,11 @@ namespace osu.Game.Rulesets.Osu.Edit } } - // re-order objects again after flipping their times - hitObjects = [.. hitObjects.OrderBy(obj => obj.StartTime)]; + // re-order objects by start time again after reversing, and restore new combo flag positioning + hitObjects = hitObjects.OrderBy(obj => obj.StartTime).ToList(); - int i = 0; - foreach (bool newCombo in newComboOrder) - { - hitObjects[i].NewCombo = newCombo; - i++; - } + for (int i = 0; i < hitObjects.Count; ++i) + hitObjects[i].NewCombo = newComboOrder[i]; return true; } From cbbb46cad87d40b3416e23c60f8dc5bf391004c9 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 29 Mar 2024 00:25:03 +0900 Subject: [PATCH 499/508] Update action versions in diffcalc workflow --- .github/workflows/diffcalc.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/diffcalc.yml b/.github/workflows/diffcalc.yml index 2ed176fe8d..7fd0f798cd 100644 --- a/.github/workflows/diffcalc.yml +++ b/.github/workflows/diffcalc.yml @@ -126,7 +126,7 @@ jobs: if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request }} steps: - name: Create comment - uses: thollander/actions-comment-pull-request@363c6f6eae92cc5c3a66e95ba016fc771bb38943 # v2.4.2 + uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0 with: comment_tag: ${{ env.EXECUTION_ID }} message: | @@ -253,7 +253,7 @@ jobs: - name: Restore cache id: restore-cache - uses: maxnowack/local-cache@038cc090b52e4f205fbc468bf5b0756df6f68775 # v1 + uses: maxnowack/local-cache@720e69c948191660a90aa1cf6a42fc4d2dacdf30 # v2 with: path: ${{ steps.query.outputs.DATA_NAME }}.tar.bz2 key: ${{ steps.query.outputs.DATA_NAME }} @@ -284,7 +284,7 @@ jobs: - name: Restore cache id: restore-cache - uses: maxnowack/local-cache@038cc090b52e4f205fbc468bf5b0756df6f68775 # v1 + uses: maxnowack/local-cache@720e69c948191660a90aa1cf6a42fc4d2dacdf30 # v2 with: path: ${{ steps.query.outputs.DATA_NAME }}.tar.bz2 key: ${{ steps.query.outputs.DATA_NAME }} @@ -358,7 +358,7 @@ jobs: steps: - name: Update comment on success if: ${{ needs.generator.result == 'success' }} - uses: thollander/actions-comment-pull-request@363c6f6eae92cc5c3a66e95ba016fc771bb38943 # v2.4.2 + uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0 with: comment_tag: ${{ env.EXECUTION_ID }} mode: upsert @@ -369,7 +369,7 @@ jobs: - name: Update comment on failure if: ${{ needs.generator.result == 'failure' }} - uses: thollander/actions-comment-pull-request@363c6f6eae92cc5c3a66e95ba016fc771bb38943 # v2.4.2 + uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0 with: comment_tag: ${{ env.EXECUTION_ID }} mode: upsert @@ -379,7 +379,7 @@ jobs: - name: Update comment on cancellation if: ${{ needs.generator.result == 'cancelled' }} - uses: thollander/actions-comment-pull-request@363c6f6eae92cc5c3a66e95ba016fc771bb38943 # v2.4.2 + uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # v2.5.0 with: comment_tag: ${{ env.EXECUTION_ID }} mode: delete From c51a2e169d374b1cb820e2975def1cb2bbd902f7 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2024 12:19:06 +0800 Subject: [PATCH 500/508] Add test coverage of crash scenario --- osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs index e603f72bb8..24c9d1294f 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs @@ -74,6 +74,10 @@ namespace osu.Game.Tests.Visual.Menus }); AddStep("enter code", () => loginOverlay.ChildrenOfType().First().Text = "88800088"); assertAPIState(APIState.Online); + + AddStep("set failing", () => { dummyAPI.SetState(APIState.Failing); }); + AddStep("return to online", () => { dummyAPI.SetState(APIState.Online); }); + AddStep("clear handler", () => dummyAPI.HandleRequest = null); } From fef8afb833b7ddfd42b97260faff7593da514868 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2024 12:03:05 +0800 Subject: [PATCH 501/508] Fix double binding causing game crash after API enters failing state See https://sentry.ppy.sh/organizations/ppy/issues/33406/?alert_rule_id=4&alert_timestamp=1711655107332&alert_type=email&environment=production&project=2&referrer=alert_email --- osu.Game/Overlays/Login/LoginPanel.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Login/LoginPanel.cs b/osu.Game/Overlays/Login/LoginPanel.cs index 25bf612bc3..d5c7ed29b8 100644 --- a/osu.Game/Overlays/Login/LoginPanel.cs +++ b/osu.Game/Overlays/Login/LoginPanel.cs @@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Login [Resolved] private OsuColour colours { get; set; } = null!; - private UserDropdown dropdown = null!; + private UserDropdown? dropdown; /// /// Called to request a hide of a parent displaying this container. @@ -68,6 +68,14 @@ namespace osu.Game.Overlays.Login apiState.BindValueChanged(onlineStateChanged, true); } + protected override void LoadComplete() + { + base.LoadComplete(); + + userStatus.BindTo(api.LocalUser.Value.Status); + userStatus.BindValueChanged(e => updateDropdownCurrent(e.NewValue), true); + } + private void onlineStateChanged(ValueChangedEvent state) => Schedule(() => { form = null; @@ -144,9 +152,6 @@ namespace osu.Game.Overlays.Login }, }; - userStatus.BindTo(api.LocalUser.Value.Status); - userStatus.BindValueChanged(e => updateDropdownCurrent(e.NewValue), true); - dropdown.Current.BindValueChanged(action => { switch (action.NewValue) @@ -171,6 +176,7 @@ namespace osu.Game.Overlays.Login break; } }, true); + break; } @@ -180,6 +186,9 @@ namespace osu.Game.Overlays.Login private void updateDropdownCurrent(UserStatus? status) { + if (dropdown == null) + return; + switch (status) { case UserStatus.Online: From d9cf5b5440ff3146e94d1c5da5c3c7c11bd53dd8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2024 15:44:01 +0800 Subject: [PATCH 502/508] Fix bindable not being correctly re-bound across local user changes --- .../Visual/Menus/TestSceneLoginOverlay.cs | 12 +++++++++ osu.Game/Overlays/Login/LoginPanel.cs | 25 +++++++++++-------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs index 24c9d1294f..460d7814e0 100644 --- a/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs +++ b/osu.Game.Tests/Visual/Menus/TestSceneLoginOverlay.cs @@ -15,6 +15,7 @@ using osu.Game.Online.API.Requests; using osu.Game.Overlays; using osu.Game.Overlays.Login; using osu.Game.Overlays.Settings; +using osu.Game.Users; using osu.Game.Users.Drawables; using osuTK.Input; @@ -72,13 +73,24 @@ namespace osu.Game.Tests.Visual.Menus return false; }); + AddStep("enter code", () => loginOverlay.ChildrenOfType().First().Text = "88800088"); assertAPIState(APIState.Online); + assertDropdownState(UserAction.Online); AddStep("set failing", () => { dummyAPI.SetState(APIState.Failing); }); AddStep("return to online", () => { dummyAPI.SetState(APIState.Online); }); AddStep("clear handler", () => dummyAPI.HandleRequest = null); + + assertDropdownState(UserAction.Online); + AddStep("change user state", () => dummyAPI.LocalUser.Value.Status.Value = UserStatus.DoNotDisturb); + assertDropdownState(UserAction.DoNotDisturb); + } + + private void assertDropdownState(UserAction state) + { + AddAssert($"dropdown state is {state}", () => loginOverlay.ChildrenOfType().First().Current.Value, () => Is.EqualTo(state)); } private void assertAPIState(APIState expected) => diff --git a/osu.Game/Overlays/Login/LoginPanel.cs b/osu.Game/Overlays/Login/LoginPanel.cs index d5c7ed29b8..a8adf4ce8c 100644 --- a/osu.Game/Overlays/Login/LoginPanel.cs +++ b/osu.Game/Overlays/Login/LoginPanel.cs @@ -15,6 +15,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Localisation; using osu.Game.Online.API; +using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays.Settings; using osu.Game.Users; using osuTK; @@ -37,8 +38,10 @@ namespace osu.Game.Overlays.Login /// public Action? RequestHide; + private IBindable user = null!; + private readonly Bindable status = new Bindable(); + private readonly IBindable apiState = new Bindable(); - private readonly Bindable userStatus = new Bindable(); [Resolved] private IAPIProvider api { get; set; } = null!; @@ -61,19 +64,21 @@ namespace osu.Game.Overlays.Login AutoSizeAxes = Axes.Y; } - [BackgroundDependencyLoader] - private void load() - { - apiState.BindTo(api.State); - apiState.BindValueChanged(onlineStateChanged, true); - } - protected override void LoadComplete() { base.LoadComplete(); - userStatus.BindTo(api.LocalUser.Value.Status); - userStatus.BindValueChanged(e => updateDropdownCurrent(e.NewValue), true); + apiState.BindTo(api.State); + apiState.BindValueChanged(onlineStateChanged, true); + + user = api.LocalUser.GetBoundCopy(); + user.BindValueChanged(u => + { + status.UnbindBindings(); + status.BindTo(u.NewValue.Status); + }, true); + + status.BindValueChanged(e => updateDropdownCurrent(e.NewValue), true); } private void onlineStateChanged(ValueChangedEvent state) => Schedule(() => From 233b9eb1723fb44a26c1a65c1d583e3e6f87f7b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2024 17:11:55 +0800 Subject: [PATCH 503/508] Avoid reporting an import as successful when all beatmaps failed to import --- osu.Game/Beatmaps/BeatmapImporter.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Beatmaps/BeatmapImporter.cs b/osu.Game/Beatmaps/BeatmapImporter.cs index 5ff3ab64b2..9ca0aafddd 100644 --- a/osu.Game/Beatmaps/BeatmapImporter.cs +++ b/osu.Game/Beatmaps/BeatmapImporter.cs @@ -434,6 +434,9 @@ namespace osu.Game.Beatmaps } } + if (!beatmaps.Any()) + throw new ArgumentException($"No valid beatmap files found in the beatmap archive."); + return beatmaps; } } From df4a28db915653f79603ef78ea44af48d781391e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2024 17:32:20 +0800 Subject: [PATCH 504/508] Fix failing test due to missing ruleset store --- osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs b/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs index 5f722e381c..016928c6d6 100644 --- a/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs +++ b/osu.Game.Tests/Database/LegacyBeatmapImporterTest.cs @@ -12,6 +12,7 @@ using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.IO; +using osu.Game.Rulesets; using osu.Game.Tests.Resources; namespace osu.Game.Tests.Database @@ -77,6 +78,7 @@ namespace osu.Game.Tests.Database { using (HeadlessGameHost host = new CleanRunHeadlessGameHost()) using (var tmpStorage = new TemporaryNativeStorage("stable-songs-folder")) + using (new RealmRulesetStore(realm, storage)) { var stableStorage = new StableStorage(tmpStorage.GetFullPath(""), host); var songsStorage = stableStorage.GetStorageForDirectory(StableStorage.STABLE_DEFAULT_SONGS_PATH); From 2d3b273974de4cb85dea652f3915a37f7ee0451e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 29 Mar 2024 10:36:17 +0100 Subject: [PATCH 505/508] Remove redundant string interpolation --- osu.Game/Beatmaps/BeatmapImporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapImporter.cs b/osu.Game/Beatmaps/BeatmapImporter.cs index 9ca0aafddd..2137f33e77 100644 --- a/osu.Game/Beatmaps/BeatmapImporter.cs +++ b/osu.Game/Beatmaps/BeatmapImporter.cs @@ -435,7 +435,7 @@ namespace osu.Game.Beatmaps } if (!beatmaps.Any()) - throw new ArgumentException($"No valid beatmap files found in the beatmap archive."); + throw new ArgumentException("No valid beatmap files found in the beatmap archive."); return beatmaps; } From e06df34a1c7f57ffec818be87264c4e82b61e508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 29 Mar 2024 11:16:31 +0100 Subject: [PATCH 506/508] Apply partial fade on pp display on results screen when score will not give pp --- .../TestSceneExpandedPanelMiddleContent.cs | 37 +++++++++++++++++++ osu.Game/Localisation/ResultsScreenStrings.cs | 24 ++++++++++++ .../Statistics/PerformanceStatistic.cs | 32 ++++++++++++++-- 3 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 osu.Game/Localisation/ResultsScreenStrings.cs diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs index d97946a1d5..9f7726313a 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs @@ -14,13 +14,16 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Testing; using osu.Game.Beatmaps; using osu.Game.Graphics.Sprites; +using osu.Game.Localisation; using osu.Game.Models; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu; +using osu.Game.Rulesets.Osu.Mods; using osu.Game.Scoring; using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking.Expanded; +using osu.Game.Screens.Ranking.Expanded.Statistics; using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Resources; using osuTK; @@ -67,6 +70,40 @@ namespace osu.Game.Tests.Visual.Ranking AddAssert("play time displayed", () => this.ChildrenOfType().Any()); } + [Test] + public void TestPPShownAsProvisionalWhenBeatmapHasNoLeaderboard() + { + AddStep("show example score", () => + { + var beatmap = createTestBeatmap(new RealmUser()); + beatmap.Status = BeatmapOnlineStatus.Graveyard; + showPanel(TestResources.CreateTestScoreInfo(beatmap)); + }); + + AddAssert("pp display faded out", () => + { + var ppDisplay = this.ChildrenOfType().Single(); + return ppDisplay.Alpha == 0.5 && ppDisplay.TooltipText == ResultsScreenStrings.NoPPForUnrankedBeatmaps; + }); + } + + [Test] + public void TestPPShownAsProvisionalWhenUnrankedModsArePresent() + { + AddStep("show example score", () => + { + var score = TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser())); + score.Mods = score.Mods.Append(new OsuModDifficultyAdjust()).ToArray(); + showPanel(score); + }); + + AddAssert("pp display faded out", () => + { + var ppDisplay = this.ChildrenOfType().Single(); + return ppDisplay.Alpha == 0.5 && ppDisplay.TooltipText == ResultsScreenStrings.NoPPForUnrankedMods; + }); + } + [Test] public void TestWithDefaultDate() { diff --git a/osu.Game/Localisation/ResultsScreenStrings.cs b/osu.Game/Localisation/ResultsScreenStrings.cs new file mode 100644 index 0000000000..54e7717af9 --- /dev/null +++ b/osu.Game/Localisation/ResultsScreenStrings.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Localisation; + +namespace osu.Game.Localisation +{ + public static class ResultsScreenStrings + { + private const string prefix = @"osu.Game.Resources.Localisation.ResultsScreen"; + + /// + /// "Performance points are not granted for this score because the beatmap is not ranked." + /// + public static LocalisableString NoPPForUnrankedBeatmaps => new TranslatableString(getKey(@"no_pp_for_unranked_beatmaps"), @"Performance points are not granted for this score because the beatmap is not ranked."); + + /// + /// "Performance points are not granted for this score because of unranked mods." + /// + public static LocalisableString NoPPForUnrankedMods => new TranslatableString(getKey(@"no_pp_for_unranked_mods"), @"Performance points are not granted for this score because of unranked mods."); + + private static string getKey(string key) => $@"{prefix}:{key}"; + } +} diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 22c1e26d43..0a9c68eafc 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -4,20 +4,26 @@ #nullable disable using System; +using System.Linq; using System.Threading; using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Graphics.UserInterface; using osu.Game.Resources.Localisation.Web; using osu.Game.Scoring; +using osu.Game.Localisation; namespace osu.Game.Screens.Ranking.Expanded.Statistics { - public partial class PerformanceStatistic : StatisticDisplay + public partial class PerformanceStatistic : StatisticDisplay, IHasTooltip { + public LocalisableString TooltipText { get; private set; } + private readonly ScoreInfo score; private readonly Bindable performance = new Bindable(); @@ -37,7 +43,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics { if (score.PP.HasValue) { - setPerformanceValue(score.PP.Value); + setPerformanceValue(score, score.PP.Value); } else { @@ -52,15 +58,33 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics var result = await performanceCalculator.CalculateAsync(score, attributes.Value.Attributes, cancellationToken ?? default).ConfigureAwait(false); - Schedule(() => setPerformanceValue(result.Total)); + Schedule(() => setPerformanceValue(score, result.Total)); }, cancellationToken ?? default); } } - private void setPerformanceValue(double? pp) + private void setPerformanceValue(ScoreInfo scoreInfo, double? pp) { if (pp.HasValue) + { performance.Value = (int)Math.Round(pp.Value, MidpointRounding.AwayFromZero); + + if (!scoreInfo.BeatmapInfo!.Status.GrantsPerformancePoints()) + { + Alpha = 0.5f; + TooltipText = ResultsScreenStrings.NoPPForUnrankedBeatmaps; + } + else if (scoreInfo.Mods.Any(m => !m.Ranked)) + { + Alpha = 0.5f; + TooltipText = ResultsScreenStrings.NoPPForUnrankedMods; + } + else + { + Alpha = 1f; + TooltipText = default; + } + } } public override void Appear() From c21805589eb2014bd07e6386b9398734e9a99dcb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 29 Mar 2024 22:40:04 +0800 Subject: [PATCH 507/508] Fix taiko mascot size not matching stable --- osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs b/osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs index 7b1e31112e..e863c4c2e4 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs @@ -27,7 +27,8 @@ namespace osu.Game.Rulesets.Taiko.UI InternalChild = textureAnimation = createTextureAnimation(state).With(animation => { animation.Origin = animation.Anchor = Anchor.BottomLeft; - animation.Scale = new Vector2(0.51f); // close enough to stable + // matches stable (https://github.com/peppy/osu-stable-reference/blob/054d0380c19aa5972be176d9d242ceb0e1630ae6/osu!/GameModes/Play/Rulesets/Taiko/TaikoMascot.cs#L34) + animation.Scale = new Vector2(0.6f); }); RelativeSizeAxes = Axes.Both; From 51f79c33e1c93ecb4cbf71e5de820941a0fa622e Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 29 Mar 2024 23:33:04 +0300 Subject: [PATCH 508/508] Fix URL pointing to non-existent commit --- osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs b/osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs index e863c4c2e4..90f7782aba 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoMascotAnimation.cs @@ -27,7 +27,7 @@ namespace osu.Game.Rulesets.Taiko.UI InternalChild = textureAnimation = createTextureAnimation(state).With(animation => { animation.Origin = animation.Anchor = Anchor.BottomLeft; - // matches stable (https://github.com/peppy/osu-stable-reference/blob/054d0380c19aa5972be176d9d242ceb0e1630ae6/osu!/GameModes/Play/Rulesets/Taiko/TaikoMascot.cs#L34) + // matches stable (https://github.com/peppy/osu-stable-reference/blob/e53980dd76857ee899f66ce519ba1597e7874f28/osu!/GameModes/Play/Rulesets/Taiko/TaikoMascot.cs#L34) animation.Scale = new Vector2(0.6f); });