From 3829d278451c71aa4223c70520331f970ad79cb7 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 29 Apr 2022 12:19:22 +0300 Subject: [PATCH 01/10] Update overlay ruleset selector design --- osu.Game/Overlays/OverlayRulesetTabItem.cs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 9d4afc94d1..4f58d4c189 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -5,14 +5,12 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; using osuTK.Graphics; using osuTK; using osu.Framework.Allocation; -using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { @@ -26,7 +24,7 @@ namespace osu.Game.Overlays set { accentColour = value; - text.FadeColour(value, 120, Easing.OutQuint); + icon.FadeColour(value, 120, Easing.OutQuint); } } @@ -35,7 +33,7 @@ namespace osu.Game.Overlays [Resolved] private OverlayColourProvider colourProvider { get; set; } - private readonly OsuSpriteText text; + private readonly Drawable icon; public OverlayRulesetTabItem(RulesetInfo value) : base(value) @@ -48,15 +46,14 @@ namespace osu.Game.Overlays { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Spacing = new Vector2(3, 0), - Child = text = new OsuSpriteText + Spacing = new Vector2(5f, 0), + Child = icon = new ConstrainedIconContainer { - Origin = Anchor.Centre, Anchor = Anchor.Centre, - Text = value.Name, - Font = OsuFont.GetFont(size: 14), - ShadowColour = Color4.Black.Opacity(0.75f) - } + Origin = Anchor.Centre, + Size = new Vector2(20f), + Icon = value.CreateInstance().CreateIcon(), + }, }, new HoverClickSounds() }); @@ -91,7 +88,6 @@ namespace osu.Game.Overlays private void updateState() { - text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); AccentColour = Enabled.Value ? getActiveColour() : colourProvider.Foreground1; } From 4016fe1e19695637ea0a954b63ec633fcff2d5b4 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 29 Apr 2022 12:19:47 +0300 Subject: [PATCH 02/10] Adjust profile ruleset selector to new design Looks weird with `AlwaysPresent`. --- .../Profile/Header/Components/ProfileRulesetTabItem.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs index 3d20fba542..15640ddc5e 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs @@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Profile.Header.Components isDefault = value; - icon.FadeTo(isDefault ? 1 : 0, 200, Easing.OutQuint); + icon.Alpha = isDefault ? 1 : 0; } } @@ -47,7 +47,6 @@ namespace osu.Game.Overlays.Profile.Header.Components Origin = Anchor.Centre, Anchor = Anchor.Centre, Alpha = 0, - AlwaysPresent = true, Icon = FontAwesome.Solid.Star, Size = new Vector2(12), }); From fae8d86e154df9e31674a2b94f66a79c259ba709 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 29 Apr 2022 12:20:33 +0300 Subject: [PATCH 03/10] Fix regressed profile ruleset selector test scene Due to the changes in `APIUser`, which change equality to be based on ID. --- .../Visual/Online/TestSceneProfileRulesetSelector.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs index cbbe8b8eac..4e572b665b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs @@ -32,14 +32,14 @@ namespace osu.Game.Tests.Visual.Online }; AddStep("set osu! as default", () => selector.SetDefaultRuleset(new OsuRuleset().RulesetInfo)); - AddStep("set mania as default", () => selector.SetDefaultRuleset(new ManiaRuleset().RulesetInfo)); AddStep("set taiko as default", () => selector.SetDefaultRuleset(new TaikoRuleset().RulesetInfo)); AddStep("set catch as default", () => selector.SetDefaultRuleset(new CatchRuleset().RulesetInfo)); + AddStep("set mania as default", () => selector.SetDefaultRuleset(new ManiaRuleset().RulesetInfo)); - AddStep("User with osu as default", () => user.Value = new APIUser { PlayMode = "osu" }); - AddStep("User with mania as default", () => user.Value = new APIUser { PlayMode = "mania" }); - AddStep("User with taiko as default", () => user.Value = new APIUser { PlayMode = "taiko" }); - AddStep("User with catch as default", () => user.Value = new APIUser { PlayMode = "fruits" }); + AddStep("User with osu as default", () => user.Value = new APIUser { Id = 0, PlayMode = "osu" }); + AddStep("User with taiko as default", () => user.Value = new APIUser { Id = 2, PlayMode = "taiko" }); + AddStep("User with catch as default", () => user.Value = new APIUser { Id = 3, PlayMode = "fruits" }); + AddStep("User with mania as default", () => user.Value = new APIUser { Id = 1, PlayMode = "mania" }); AddStep("null user", () => user.Value = null); } } From 5e19bdbf430b76c8124f81afd4e6d04a69978950 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 29 Apr 2022 12:21:12 +0300 Subject: [PATCH 04/10] Refactor beatmap ruleset selector test scene --- .../Online/TestSceneBeatmapRulesetSelector.cs | 99 ++++++++++--------- 1 file changed, 53 insertions(+), 46 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs index 63741451f3..c550c9afda 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs @@ -4,11 +4,11 @@ using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; -using osu.Framework.Graphics.UserInterface; +using osu.Framework.Graphics; +using osu.Framework.Testing; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet; -using osu.Game.Rulesets; namespace osu.Game.Tests.Visual.Online { @@ -17,79 +17,86 @@ namespace osu.Game.Tests.Visual.Online [Cached] private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); - private readonly TestRulesetSelector selector; + private BeatmapRulesetSelector selector; - public TestSceneBeatmapRulesetSelector() + [SetUp] + public void SetUp() => Schedule(() => Child = selector = new BeatmapRulesetSelector { - Add(selector = new TestRulesetSelector()); - } + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + BeatmapSet = new APIBeatmapSet(), + }); - [Resolved] - private IRulesetStore rulesets { get; set; } + [Test] + public void TestDisplay() + { + AddSliderStep("osu", 0, 100, 0, v => updateBeatmaps(0, v)); + AddSliderStep("taiko", 0, 100, 0, v => updateBeatmaps(1, v)); + AddSliderStep("fruits", 0, 100, 0, v => updateBeatmaps(2, v)); + AddSliderStep("mania", 0, 100, 0, v => updateBeatmaps(3, v)); + + void updateBeatmaps(int ruleset, int count) + { + if (selector == null) + return; + + selector.BeatmapSet = new APIBeatmapSet + { + Beatmaps = selector.BeatmapSet.Beatmaps + .Where(b => b.Ruleset.OnlineID != ruleset) + .Concat(Enumerable.Range(0, count).Select(_ => new APIBeatmap { RulesetID = ruleset })) + .ToArray(), + }; + } + } [Test] public void TestMultipleRulesetsBeatmapSet() { - var enabledRulesets = rulesets.AvailableRulesets.Skip(1).Take(2); - AddStep("load multiple rulesets beatmapset", () => - { - selector.BeatmapSet = new APIBeatmapSet - { - Beatmaps = enabledRulesets.Select(r => new APIBeatmap { RulesetID = r.OnlineID }).ToArray() - }; - }); - - var tabItems = selector.TabContainer.TabItems; - AddAssert("other rulesets disabled", () => tabItems.Except(tabItems.Where(t => enabledRulesets.Any(r => r.Equals(t.Value)))).All(t => !t.Enabled.Value)); - AddAssert("left-most ruleset selected", () => tabItems.First(t => t.Enabled.Value).Active.Value); - } - - [Test] - public void TestSingleRulesetBeatmapSet() - { - var enabledRuleset = rulesets.AvailableRulesets.Last(); - - AddStep("load single ruleset beatmapset", () => { selector.BeatmapSet = new APIBeatmapSet { Beatmaps = new[] { - new APIBeatmap - { - RulesetID = enabledRuleset.OnlineID - } + new APIBeatmap { RulesetID = 1 }, + new APIBeatmap { RulesetID = 2 }, } }; }); - AddAssert("single ruleset selected", () => selector.SelectedTab.Value.Equals(enabledRuleset)); + AddAssert("osu disabled", () => !selector.ChildrenOfType().Single(t => t.Value.OnlineID == 0).Enabled.Value); + AddAssert("mania disabled", () => !selector.ChildrenOfType().Single(t => t.Value.OnlineID == 3).Enabled.Value); + + AddAssert("taiko selected", () => selector.ChildrenOfType().Single(t => t.Active.Value).Value.OnlineID == 1); + } + + [Test] + public void TestSingleRulesetBeatmapSet() + { + AddStep("load single ruleset beatmapset", () => + { + selector.BeatmapSet = new APIBeatmapSet + { + Beatmaps = new[] { new APIBeatmap { RulesetID = 3 } } + }; + }); + + AddAssert("single ruleset selected", () => selector.ChildrenOfType().Single(t => t.Active.Value).Value.OnlineID == 3); } [Test] public void TestEmptyBeatmapSet() { AddStep("load empty beatmapset", () => selector.BeatmapSet = new APIBeatmapSet()); - - AddAssert("no ruleset selected", () => selector.SelectedTab == null); - AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value)); + AddAssert("all rulesets disabled", () => selector.ChildrenOfType().All(t => !t.Active.Value && !t.Enabled.Value)); } [Test] public void TestNullBeatmapSet() { AddStep("load null beatmapset", () => selector.BeatmapSet = null); - - AddAssert("no ruleset selected", () => selector.SelectedTab == null); - AddAssert("all rulesets disabled", () => selector.TabContainer.TabItems.All(t => !t.Enabled.Value)); - } - - private class TestRulesetSelector : BeatmapRulesetSelector - { - public new TabItem SelectedTab => base.SelectedTab; - - public new TabFillFlowContainer TabContainer => base.TabContainer; + AddAssert("all rulesets disabled", () => selector.ChildrenOfType().All(t => !t.Active.Value && !t.Enabled.Value)); } } } From 55c03dc04d0505f462c41876a50797acc3698f0b Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 29 Apr 2022 12:40:40 +0300 Subject: [PATCH 05/10] Fix silly mistake in ordering and update test colour scheme --- .../Visual/Online/TestSceneProfileRulesetSelector.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs index 4e572b665b..ae90872439 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs @@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.Online public class TestSceneProfileRulesetSelector : OsuTestScene { [Cached] - private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green); + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink); public TestSceneProfileRulesetSelector() { @@ -37,9 +37,9 @@ namespace osu.Game.Tests.Visual.Online AddStep("set mania as default", () => selector.SetDefaultRuleset(new ManiaRuleset().RulesetInfo)); AddStep("User with osu as default", () => user.Value = new APIUser { Id = 0, PlayMode = "osu" }); - AddStep("User with taiko as default", () => user.Value = new APIUser { Id = 2, PlayMode = "taiko" }); - AddStep("User with catch as default", () => user.Value = new APIUser { Id = 3, PlayMode = "fruits" }); - AddStep("User with mania as default", () => user.Value = new APIUser { Id = 1, PlayMode = "mania" }); + AddStep("User with taiko as default", () => user.Value = new APIUser { Id = 1, PlayMode = "taiko" }); + AddStep("User with catch as default", () => user.Value = new APIUser { Id = 2, PlayMode = "fruits" }); + AddStep("User with mania as default", () => user.Value = new APIUser { Id = 3, PlayMode = "mania" }); AddStep("null user", () => user.Value = null); } } From 9ea3e244e7d141b1a0d56862a03a2f15aa56a372 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 29 Apr 2022 12:48:05 +0300 Subject: [PATCH 06/10] Adjust ruleset tab item content spacing to match web Not too noticeable, but better match web in any case. --- osu.Game/Overlays/OverlayRulesetTabItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 4f58d4c189..32177b2b96 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -46,7 +46,7 @@ namespace osu.Game.Overlays { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Spacing = new Vector2(5f, 0), + Spacing = new Vector2(4f, 0), Child = icon = new ConstrainedIconContainer { Anchor = Anchor.Centre, From 3996972867507a1b46c551d7c921a5a973dad3c1 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 30 Apr 2022 12:23:08 +0300 Subject: [PATCH 07/10] Remove unnecessary `f` suffix --- osu.Game/Overlays/OverlayRulesetTabItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 32177b2b96..84815b0cc1 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -46,7 +46,7 @@ namespace osu.Game.Overlays { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Spacing = new Vector2(4f, 0), + Spacing = new Vector2(4, 0), Child = icon = new ConstrainedIconContainer { Anchor = Anchor.Centre, From c7ab9a89285f457737a6e5b1f2261da4a46c4e0c Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 30 Apr 2022 15:35:04 +0300 Subject: [PATCH 08/10] Add ruleset tab item tooltips --- osu.Game/Overlays/OverlayRulesetTabItem.cs | 6 ++++- .../Components/ProfileRulesetTabItem.cs | 23 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 84815b0cc1..8ed75a528b 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -10,11 +10,13 @@ using osu.Game.Rulesets; using osuTK.Graphics; using osuTK; using osu.Framework.Allocation; +using osu.Framework.Graphics.Cursor; +using osu.Framework.Localisation; using osu.Game.Graphics.Containers; namespace osu.Game.Overlays { - public class OverlayRulesetTabItem : TabItem + public class OverlayRulesetTabItem : TabItem, IHasTooltip { private Color4 accentColour; @@ -35,6 +37,8 @@ namespace osu.Game.Overlays private readonly Drawable icon; + public LocalisableString TooltipText => Value.Name; + public OverlayRulesetTabItem(RulesetInfo value) : base(value) { diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs index 15640ddc5e..4a44e285bf 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs @@ -2,7 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osu.Game.Resources.Localisation.Web; using osu.Game.Rulesets; using osuTK; using osuTK.Graphics; @@ -42,14 +45,20 @@ namespace osu.Game.Overlays.Profile.Header.Components public ProfileRulesetTabItem(RulesetInfo value) : base(value) { - Add(icon = new SpriteIcon + Add(icon = new DefaultRulesetIcon { Alpha = 0 }); + } + + public class DefaultRulesetIcon : SpriteIcon, IHasTooltip + { + public LocalisableString TooltipText => UsersStrings.ShowEditDefaultPlaymodeIsDefaultTooltip; + + public DefaultRulesetIcon() { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Alpha = 0, - Icon = FontAwesome.Solid.Star, - Size = new Vector2(12), - }); + Origin = Anchor.Centre; + Anchor = Anchor.Centre; + Icon = FontAwesome.Solid.Star; + Size = new Vector2(12); + } } } } From ba5da8a52aa40cc4c1092854f33b9054b4fbe5e1 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 30 Apr 2022 15:36:15 +0300 Subject: [PATCH 09/10] Fix tooltips not shown on selected tab --- osu.Game/Overlays/OverlayRulesetTabItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 8ed75a528b..1f11b98881 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -71,7 +71,7 @@ namespace osu.Game.Overlays Enabled.BindValueChanged(_ => updateState(), true); } - public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree; + public override bool PropagatePositionalInputSubTree => Enabled.Value && base.PropagatePositionalInputSubTree; protected override bool OnHover(HoverEvent e) { From 4b30d0e59b84cc4a8a496cd5d2ab8fcf16f125f8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 May 2022 17:42:56 +0900 Subject: [PATCH 10/10] Fix first-run overlay's song select applying track adjustments Closes https://github.com/ppy/osu/issues/18041. --- osu.Game/Overlays/FirstRunSetup/ScreenUIScale.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/FirstRunSetup/ScreenUIScale.cs b/osu.Game/Overlays/FirstRunSetup/ScreenUIScale.cs index 1bd82f6d99..862506add2 100644 --- a/osu.Game/Overlays/FirstRunSetup/ScreenUIScale.cs +++ b/osu.Game/Overlays/FirstRunSetup/ScreenUIScale.cs @@ -99,6 +99,8 @@ namespace osu.Game.Overlays.FirstRunSetup private class NestedSongSelect : PlaySongSelect { protected override bool ControlGlobalMusic => false; + + public override bool? AllowTrackAdjustments => false; } private class PinnedMainMenu : MainMenu