From 0abb48882cdeb636d20aa9030582642458dbb545 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 16:22:54 +0300 Subject: [PATCH 01/67] Implement GamemodeControl --- .../Header/Components/GamemodeControl.cs | 142 ++++++++++++++++++ osu.Game/Overlays/Profile/ProfileHeader.cs | 12 +- 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs new file mode 100644 index 0000000000..5909082fc8 --- /dev/null +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs @@ -0,0 +1,142 @@ +// 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.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; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Profile.Header.Components +{ + public class GamemodeControl : TabControl + { + protected override Dropdown CreateDropdown() => null; + + protected override TabItem CreateTabItem(string value) => new GamemodeTabItem(value) + { + AccentColour = AccentColour + }; + + private Color4 accentColour = Color4.White; + + public Color4 AccentColour + { + get => accentColour; + set + { + if (accentColour == value) + return; + + accentColour = value; + + foreach (TabItem tabItem in TabContainer) + { + ((GamemodeTabItem)tabItem).AccentColour = value; + } + } + } + + public GamemodeControl() + { + TabContainer.Masking = false; + TabContainer.Spacing = new Vector2(15, 0); + AutoSizeAxes = Axes.Both; + } + + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + foreach (var r in rulesets.AvailableRulesets) + AddItem(r.Name); + } + + protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer + { + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + }; + + private class GamemodeTabItem : TabItem + { + private readonly OsuSpriteText text; + + private Color4 accentColour; + + public Color4 AccentColour + { + get => accentColour; + set + { + if (accentColour == value) + return; + + accentColour = value; + + updateState(); + } + } + + public GamemodeTabItem(string value) + : base(value) + { + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + text = new OsuSpriteText + { + Margin = new MarginPadding { Bottom = 10 }, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Text = value, + Font = OsuFont.GetFont() + }, + new HoverClickSounds() + }; + } + + protected override bool OnHover(HoverEvent e) + { + base.OnHover(e); + + updateState(); + + return true; + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + + updateState(); + } + + protected override void OnActivated() => updateState(); + + protected override void OnDeactivated() => updateState(); + + private void updateState() + { + if (Active.Value || IsHovered) + { + text.FadeColour(Color4.White, 120, Easing.InQuad); + + if (Active.Value) + text.Font = text.Font.With(weight: FontWeight.Bold); + } + else + { + text.FadeColour(AccentColour, 120, Easing.InQuad); + text.Font = text.Font.With(weight: FontWeight.Medium); + } + } + } + } +} diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 76613c156d..46751eea25 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Profile.Header; +using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Users; namespace osu.Game.Overlays.Profile @@ -18,6 +19,7 @@ namespace osu.Game.Overlays.Profile public class ProfileHeader : OverlayHeader { private UserCoverBackground coverContainer; + private readonly GamemodeControl gamemodeControl; public Bindable User = new Bindable(); @@ -32,12 +34,20 @@ namespace osu.Game.Overlays.Profile TabControl.AddItem("Modding"); centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true); + + Add(gamemodeControl = new GamemodeControl + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Y = 100, + Margin = new MarginPadding { Right = 30 }, + }); } [BackgroundDependencyLoader] private void load(OsuColour colours) { - TabControl.AccentColour = colours.Seafoam; + TabControl.AccentColour = gamemodeControl.AccentColour = colours.Seafoam; } protected override Drawable CreateBackground() => From a0f7f69f463eb8edefd68ed71b94dd74cb8f104d Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 17:51:56 +0300 Subject: [PATCH 02/67] retrieve user's default playmode --- .../Header/Components/GamemodeControl.cs | 64 +++++++++++++++++-- osu.Game/Overlays/Profile/ProfileHeader.cs | 12 +++- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs index 5909082fc8..f66023c958 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Events; using osu.Game.Graphics; @@ -46,7 +47,7 @@ namespace osu.Game.Overlays.Profile.Header.Components public GamemodeControl() { TabContainer.Masking = false; - TabContainer.Spacing = new Vector2(15, 0); + TabContainer.Spacing = new Vector2(10, 0); AutoSizeAxes = Axes.Both; } @@ -54,7 +55,20 @@ namespace osu.Game.Overlays.Profile.Header.Components private void load(RulesetStore rulesets) { foreach (var r in rulesets.AvailableRulesets) - AddItem(r.Name); + AddItem(r.ShortName); + //AddItem(r.Name); + } + + public void SetDefaultGamemode(string gamemode) + { + foreach (GamemodeTabItem i in TabContainer) + { + if (i.Value == gamemode) + { + i.IsDefault = true; + return; + } + } } protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer @@ -66,6 +80,7 @@ namespace osu.Game.Overlays.Profile.Header.Components private class GamemodeTabItem : TabItem { private readonly OsuSpriteText text; + private readonly SpriteIcon icon; private Color4 accentColour; @@ -83,6 +98,22 @@ namespace osu.Game.Overlays.Profile.Header.Components } } + private bool isDefault; + + public bool IsDefault + { + get => isDefault; + set + { + if (isDefault == value) + return; + + isDefault = value; + + icon.FadeTo(isDefault ? 1 : 0, 100, Easing.OutQuint); + } + } + public GamemodeTabItem(string value) : base(value) { @@ -90,13 +121,32 @@ namespace osu.Game.Overlays.Profile.Header.Components Children = new Drawable[] { - text = new OsuSpriteText + new FillFlowContainer { - Margin = new MarginPadding { Bottom = 10 }, + AutoSizeAxes = Axes.Both, Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, - Text = value, - Font = OsuFont.GetFont() + Direction = FillDirection.Horizontal, + Spacing = new Vector2(3, 0), + Children = new Drawable[] + { + text = new OsuSpriteText + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Text = value, + Font = OsuFont.GetFont() + }, + icon = new SpriteIcon + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Alpha = 0, + AlwaysPresent = true, + Icon = FontAwesome.Solid.Star, + Size = new Vector2(12), + }, + } }, new HoverClickSounds() }; @@ -127,6 +177,7 @@ namespace osu.Game.Overlays.Profile.Header.Components if (Active.Value || IsHovered) { text.FadeColour(Color4.White, 120, Easing.InQuad); + icon.FadeColour(Color4.White, 120, Easing.InQuad); if (Active.Value) text.Font = text.Font.With(weight: FontWeight.Bold); @@ -134,6 +185,7 @@ namespace osu.Game.Overlays.Profile.Header.Components else { text.FadeColour(AccentColour, 120, Easing.InQuad); + icon.FadeColour(AccentColour, 120, Easing.InQuad); text.Font = text.Font.With(weight: FontWeight.Medium); } } diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 46751eea25..23a31614a7 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -37,6 +37,7 @@ namespace osu.Game.Overlays.Profile Add(gamemodeControl = new GamemodeControl { + Alpha = 0, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Y = 100, @@ -105,7 +106,16 @@ namespace osu.Game.Overlays.Profile protected override ScreenTitle CreateTitle() => new ProfileHeaderTitle(); - private void updateDisplay(User user) => coverContainer.User = user; + private void updateDisplay(User user) + { + coverContainer.User = user; + + string playMode = user.PlayMode; + + gamemodeControl.Current.Value = playMode; + gamemodeControl.SetDefaultGamemode(playMode); + gamemodeControl.FadeInFromZero(100, Easing.OutQuint); + } private class ProfileHeaderTitle : ScreenTitle { From 367fdcf51987368bf3c7a79988f50af4f4cac599 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 18:07:52 +0300 Subject: [PATCH 03/67] Make GamemodeControl depend on rulesets --- .../Header/Components/GamemodeControl.cs | 24 ++++++++++--------- osu.Game/Overlays/Profile/ProfileHeader.cs | 1 - 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs index f66023c958..d0caeea62e 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs @@ -16,11 +16,11 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header.Components { - public class GamemodeControl : TabControl + public class GamemodeControl : TabControl { - protected override Dropdown CreateDropdown() => null; + protected override Dropdown CreateDropdown() => null; - protected override TabItem CreateTabItem(string value) => new GamemodeTabItem(value) + protected override TabItem CreateTabItem(RulesetInfo value) => new GamemodeTabItem(value) { AccentColour = AccentColour }; @@ -37,9 +37,9 @@ namespace osu.Game.Overlays.Profile.Header.Components accentColour = value; - foreach (TabItem tabItem in TabContainer) + foreach (GamemodeTabItem tabItem in TabContainer) { - ((GamemodeTabItem)tabItem).AccentColour = value; + tabItem.AccentColour = value; } } } @@ -55,17 +55,19 @@ namespace osu.Game.Overlays.Profile.Header.Components private void load(RulesetStore rulesets) { foreach (var r in rulesets.AvailableRulesets) - AddItem(r.ShortName); - //AddItem(r.Name); + { + AddItem(r); + } } public void SetDefaultGamemode(string gamemode) { foreach (GamemodeTabItem i in TabContainer) { - if (i.Value == gamemode) + if (i.Value.ShortName == gamemode) { i.IsDefault = true; + Current.Value = i.Value; return; } } @@ -77,7 +79,7 @@ namespace osu.Game.Overlays.Profile.Header.Components AutoSizeAxes = Axes.Both, }; - private class GamemodeTabItem : TabItem + private class GamemodeTabItem : TabItem { private readonly OsuSpriteText text; private readonly SpriteIcon icon; @@ -114,7 +116,7 @@ namespace osu.Game.Overlays.Profile.Header.Components } } - public GamemodeTabItem(string value) + public GamemodeTabItem(RulesetInfo value) : base(value) { AutoSizeAxes = Axes.Both; @@ -134,7 +136,7 @@ namespace osu.Game.Overlays.Profile.Header.Components { Origin = Anchor.Centre, Anchor = Anchor.Centre, - Text = value, + Text = value.Name, Font = OsuFont.GetFont() }, icon = new SpriteIcon diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 23a31614a7..85541cd0ae 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -112,7 +112,6 @@ namespace osu.Game.Overlays.Profile string playMode = user.PlayMode; - gamemodeControl.Current.Value = playMode; gamemodeControl.SetDefaultGamemode(playMode); gamemodeControl.FadeInFromZero(100, Easing.OutQuint); } From d0d846469a6dcc4fec55767b5252c4eaef1b11f3 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 18:14:03 +0300 Subject: [PATCH 04/67] Move GamemodeTabItem to a distinct class --- .../Header/Components/GamemodeControl.cs | 119 ---------------- .../Header/Components/GamemodeTabItem.cs | 131 ++++++++++++++++++ 2 files changed, 131 insertions(+), 119 deletions(-) create mode 100644 osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs index d0caeea62e..bca4cd0cfa 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs @@ -4,12 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; 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; using osuTK.Graphics; @@ -78,119 +73,5 @@ namespace osu.Game.Overlays.Profile.Header.Components Direction = FillDirection.Horizontal, AutoSizeAxes = Axes.Both, }; - - private class GamemodeTabItem : TabItem - { - private readonly OsuSpriteText text; - private readonly SpriteIcon icon; - - private Color4 accentColour; - - public Color4 AccentColour - { - get => accentColour; - set - { - if (accentColour == value) - return; - - accentColour = value; - - updateState(); - } - } - - private bool isDefault; - - public bool IsDefault - { - get => isDefault; - set - { - if (isDefault == value) - return; - - isDefault = value; - - icon.FadeTo(isDefault ? 1 : 0, 100, Easing.OutQuint); - } - } - - public GamemodeTabItem(RulesetInfo value) - : base(value) - { - AutoSizeAxes = Axes.Both; - - Children = new Drawable[] - { - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(3, 0), - Children = new Drawable[] - { - text = new OsuSpriteText - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Text = value.Name, - Font = OsuFont.GetFont() - }, - icon = new SpriteIcon - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Alpha = 0, - AlwaysPresent = true, - Icon = FontAwesome.Solid.Star, - Size = new Vector2(12), - }, - } - }, - new HoverClickSounds() - }; - } - - protected override bool OnHover(HoverEvent e) - { - base.OnHover(e); - - updateState(); - - return true; - } - - protected override void OnHoverLost(HoverLostEvent e) - { - base.OnHoverLost(e); - - updateState(); - } - - protected override void OnActivated() => updateState(); - - protected override void OnDeactivated() => updateState(); - - private void updateState() - { - if (Active.Value || IsHovered) - { - text.FadeColour(Color4.White, 120, Easing.InQuad); - icon.FadeColour(Color4.White, 120, Easing.InQuad); - - if (Active.Value) - text.Font = text.Font.With(weight: FontWeight.Bold); - } - else - { - text.FadeColour(AccentColour, 120, Easing.InQuad); - icon.FadeColour(AccentColour, 120, Easing.InQuad); - text.Font = text.Font.With(weight: FontWeight.Medium); - } - } - } } } diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs new file mode 100644 index 0000000000..b6e27da522 --- /dev/null +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs @@ -0,0 +1,131 @@ +// 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.Sprites; +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; +using osuTK.Graphics; + +namespace osu.Game.Overlays.Profile.Header.Components +{ + public class GamemodeTabItem : TabItem + { + private readonly OsuSpriteText text; + private readonly SpriteIcon icon; + + private Color4 accentColour; + + public Color4 AccentColour + { + get => accentColour; + set + { + if (accentColour == value) + return; + + accentColour = value; + + updateState(); + } + } + + private bool isDefault; + + public bool IsDefault + { + get => isDefault; + set + { + if (isDefault == value) + return; + + isDefault = value; + + icon.FadeTo(isDefault ? 1 : 0, 100, Easing.OutQuint); + } + } + + public GamemodeTabItem(RulesetInfo value) + : base(value) + { + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(3, 0), + Children = new Drawable[] + { + text = new OsuSpriteText + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Text = value.Name, + Font = OsuFont.GetFont() + }, + icon = new SpriteIcon + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Alpha = 0, + AlwaysPresent = true, + Icon = FontAwesome.Solid.Star, + Size = new Vector2(12), + }, + } + }, + new HoverClickSounds() + }; + } + + protected override bool OnHover(HoverEvent e) + { + base.OnHover(e); + + updateState(); + + return true; + } + + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + + updateState(); + } + + protected override void OnActivated() => updateState(); + + protected override void OnDeactivated() => updateState(); + + private void updateState() + { + if (Active.Value || IsHovered) + { + text.FadeColour(Color4.White, 120, Easing.InQuad); + icon.FadeColour(Color4.White, 120, Easing.InQuad); + + if (Active.Value) + text.Font = text.Font.With(weight: FontWeight.Bold); + } + else + { + text.FadeColour(AccentColour, 120, Easing.InQuad); + icon.FadeColour(AccentColour, 120, Easing.InQuad); + text.Font = text.Font.With(weight: FontWeight.Medium); + } + } + } +} From 0c48aec265275d24cef316e072ec1018a7eac30f Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 18:37:31 +0300 Subject: [PATCH 05/67] Split SetDefaultGamemode into two functions --- .../Header/Components/GamemodeControl.cs | 11 +++- .../Header/Components/GamemodeTabItem.cs | 54 +++++++++---------- osu.Game/Overlays/Profile/ProfileHeader.cs | 1 + 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs index bca4cd0cfa..59c8ec8ecb 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs @@ -59,9 +59,16 @@ namespace osu.Game.Overlays.Profile.Header.Components { foreach (GamemodeTabItem i in TabContainer) { - if (i.Value.ShortName == gamemode) + i.IsDefault = i.Value.ShortName == gamemode; + } + } + + public void SelectDefaultGamemode() + { + foreach (GamemodeTabItem i in TabContainer) + { + if (i.IsDefault) { - i.IsDefault = true; Current.Value = i.Value; return; } diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs index b6e27da522..688109ad2f 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs @@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Profile.Header.Components isDefault = value; - icon.FadeTo(isDefault ? 1 : 0, 100, Easing.OutQuint); + icon.FadeTo(isDefault ? 1 : 0, 200, Easing.OutQuint); } } @@ -59,34 +59,34 @@ namespace osu.Game.Overlays.Profile.Header.Components Children = new Drawable[] { - new FillFlowContainer + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(3, 0), + Children = new Drawable[] { - AutoSizeAxes = Axes.Both, - Origin = Anchor.BottomLeft, - Anchor = Anchor.BottomLeft, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(3, 0), - Children = new Drawable[] + text = new OsuSpriteText { - text = new OsuSpriteText - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Text = value.Name, - Font = OsuFont.GetFont() - }, - icon = new SpriteIcon - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Alpha = 0, - AlwaysPresent = true, - Icon = FontAwesome.Solid.Star, - Size = new Vector2(12), - }, - } - }, - new HoverClickSounds() + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Text = value.Name, + Font = OsuFont.GetFont() + }, + icon = new SpriteIcon + { + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Alpha = 0, + AlwaysPresent = true, + Icon = FontAwesome.Solid.Star, + Size = new Vector2(12), + }, + } + }, + new HoverClickSounds() }; } diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index 85541cd0ae..b0c1f9a587 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -113,6 +113,7 @@ namespace osu.Game.Overlays.Profile string playMode = user.PlayMode; gamemodeControl.SetDefaultGamemode(playMode); + gamemodeControl.SelectDefaultGamemode(); gamemodeControl.FadeInFromZero(100, Easing.OutQuint); } From 8dea191998e901c60b1867bd893bcad44c76e958 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 18:37:41 +0300 Subject: [PATCH 06/67] Add a testcase --- .../Visual/Online/TestSceneGamemodeControl.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs b/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs new file mode 100644 index 0000000000..02eaef09b8 --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.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.Allocation; +using osu.Framework.Graphics; +using osu.Framework.MathUtils; +using osu.Game.Graphics; +using osu.Game.Overlays.Profile.Header.Components; +using osuTK.Graphics; +using System; +using System.Collections.Generic; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneGamemodeControl : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(GamemodeControl), + typeof(GamemodeTabItem), + }; + + private readonly GamemodeControl control; + + public TestSceneGamemodeControl() + { + Child = control = new GamemodeControl + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; + + AddStep("set osu! as default", () => control.SetDefaultGamemode("osu")); + AddStep("set mania as default", () => control.SetDefaultGamemode("mania")); + AddStep("set taiko as default", () => control.SetDefaultGamemode("taiko")); + AddStep("set catch as default", () => control.SetDefaultGamemode("fruits")); + AddStep("select default gamemode", () => control.SelectDefaultGamemode()); + + AddStep("set random colour", () => control.AccentColour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + control.AccentColour = colours.Seafoam; + } + } +} From 8260b61db5ecc418a937a83303b49bcdd245570c Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 19:02:09 +0300 Subject: [PATCH 07/67] Fix CI issues --- .../Profile/Header/Components/GamemodeControl.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs index 59c8ec8ecb..3beee674fd 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs @@ -32,9 +32,9 @@ namespace osu.Game.Overlays.Profile.Header.Components accentColour = value; - foreach (GamemodeTabItem tabItem in TabContainer) + foreach (TabItem tabItem in TabContainer) { - tabItem.AccentColour = value; + ((GamemodeTabItem)tabItem).AccentColour = value; } } } @@ -57,19 +57,19 @@ namespace osu.Game.Overlays.Profile.Header.Components public void SetDefaultGamemode(string gamemode) { - foreach (GamemodeTabItem i in TabContainer) + foreach (TabItem tabItem in TabContainer) { - i.IsDefault = i.Value.ShortName == gamemode; + ((GamemodeTabItem)tabItem).IsDefault = ((GamemodeTabItem)tabItem).Value.ShortName == gamemode; } } public void SelectDefaultGamemode() { - foreach (GamemodeTabItem i in TabContainer) + foreach (TabItem tabItem in TabContainer) { - if (i.IsDefault) + if (((GamemodeTabItem)tabItem).IsDefault) { - Current.Value = i.Value; + Current.Value = ((GamemodeTabItem)tabItem).Value; return; } } From e9403bf2f7a59987bfccc8a97c692d1519f19e21 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 19:33:55 +0300 Subject: [PATCH 08/67] Move GamemodeControl to UserProfileOverlay --- .../Visual/Online/TestSceneGamemodeControl.cs | 8 ------- .../Header/Components/GamemodeControl.cs | 5 +++- osu.Game/Overlays/Profile/ProfileHeader.cs | 24 ++----------------- osu.Game/Overlays/UserProfileOverlay.cs | 20 ++++++++++++++-- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs b/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs index 02eaef09b8..7e3ddbfd3d 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs @@ -1,10 +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.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.MathUtils; -using osu.Game.Graphics; using osu.Game.Overlays.Profile.Header.Components; using osuTK.Graphics; using System; @@ -38,11 +36,5 @@ namespace osu.Game.Tests.Visual.Online AddStep("set random colour", () => control.AccentColour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)); } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - control.AccentColour = colours.Seafoam; - } } } diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs index 3beee674fd..56f84741f3 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs +++ b/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics; using osu.Game.Rulesets; using osuTK; using osuTK.Graphics; @@ -47,12 +48,14 @@ namespace osu.Game.Overlays.Profile.Header.Components } [BackgroundDependencyLoader] - private void load(RulesetStore rulesets) + private void load(RulesetStore rulesets, OsuColour colours) { foreach (var r in rulesets.AvailableRulesets) { AddItem(r); } + + AccentColour = colours.Seafoam; } public void SetDefaultGamemode(string gamemode) diff --git a/osu.Game/Overlays/Profile/ProfileHeader.cs b/osu.Game/Overlays/Profile/ProfileHeader.cs index b0c1f9a587..76613c156d 100644 --- a/osu.Game/Overlays/Profile/ProfileHeader.cs +++ b/osu.Game/Overlays/Profile/ProfileHeader.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Profile.Header; -using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Users; namespace osu.Game.Overlays.Profile @@ -19,7 +18,6 @@ namespace osu.Game.Overlays.Profile public class ProfileHeader : OverlayHeader { private UserCoverBackground coverContainer; - private readonly GamemodeControl gamemodeControl; public Bindable User = new Bindable(); @@ -34,21 +32,12 @@ namespace osu.Game.Overlays.Profile TabControl.AddItem("Modding"); centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true); - - Add(gamemodeControl = new GamemodeControl - { - Alpha = 0, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Y = 100, - Margin = new MarginPadding { Right = 30 }, - }); } [BackgroundDependencyLoader] private void load(OsuColour colours) { - TabControl.AccentColour = gamemodeControl.AccentColour = colours.Seafoam; + TabControl.AccentColour = colours.Seafoam; } protected override Drawable CreateBackground() => @@ -106,16 +95,7 @@ namespace osu.Game.Overlays.Profile protected override ScreenTitle CreateTitle() => new ProfileHeaderTitle(); - private void updateDisplay(User user) - { - coverContainer.User = user; - - string playMode = user.PlayMode; - - gamemodeControl.SetDefaultGamemode(playMode); - gamemodeControl.SelectDefaultGamemode(); - gamemodeControl.FadeInFromZero(100, Easing.OutQuint); - } + private void updateDisplay(User user) => coverContainer.User = user; private class ProfileHeaderTitle : ScreenTitle { diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 8a133a1d1e..f61ca0affc 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -11,6 +11,7 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Profile; +using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Overlays.Profile.Sections; using osu.Game.Users; using osuTK; @@ -25,6 +26,7 @@ namespace osu.Game.Overlays protected ProfileHeader Header; private SectionsContainer sectionsContainer; private ProfileTabControl tabs; + private GamemodeControl gamemodeControl; public const float CONTENT_X_MARGIN = 70; @@ -32,7 +34,8 @@ namespace osu.Game.Overlays public void ShowUser(User user, bool fetchOnline = true) { - if (user == User.SYSTEM_USER) return; + if (user == User.SYSTEM_USER) + return; Show(); @@ -77,7 +80,7 @@ namespace osu.Game.Overlays { Colour = OsuColour.Gray(34), RelativeSizeAxes = Axes.Both - } + }, }); sectionsContainer.SelectedSection.ValueChanged += section => { @@ -118,6 +121,15 @@ namespace osu.Game.Overlays } sectionsContainer.ScrollToTop(); + + Header.Add(gamemodeControl = new GamemodeControl + { + Alpha = 0, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Y = 100, + Margin = new MarginPadding { Right = 30 }, + }); } private void userLoadComplete(User user) @@ -139,6 +151,10 @@ namespace osu.Game.Overlays } } } + + gamemodeControl.SetDefaultGamemode(user.PlayMode); + gamemodeControl.SelectDefaultGamemode(); + gamemodeControl.FadeInFromZero(100, Easing.OutQuint); } private class ProfileTabControl : PageTabControl From 54800aa4dfb932bb751366f967251f5b07423a30 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 19:45:46 +0300 Subject: [PATCH 09/67] make the variable local --- osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs b/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs index 7e3ddbfd3d..a2a75566d5 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs @@ -18,10 +18,10 @@ namespace osu.Game.Tests.Visual.Online typeof(GamemodeTabItem), }; - private readonly GamemodeControl control; - public TestSceneGamemodeControl() { + GamemodeControl control; + Child = control = new GamemodeControl { Anchor = Anchor.Centre, @@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.Online AddStep("set mania as default", () => control.SetDefaultGamemode("mania")); AddStep("set taiko as default", () => control.SetDefaultGamemode("taiko")); AddStep("set catch as default", () => control.SetDefaultGamemode("fruits")); - AddStep("select default gamemode", () => control.SelectDefaultGamemode()); + AddStep("select default gamemode", control.SelectDefaultGamemode); AddStep("set random colour", () => control.AccentColour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)); } From 05aeb6697393cf6dcbd0cf14afc25c957991c24f Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 20:20:07 +0300 Subject: [PATCH 10/67] Fix possible crash due to null user or playmode --- osu.Game/Overlays/UserProfileOverlay.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index f61ca0affc..58d1fe4046 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -152,8 +152,9 @@ namespace osu.Game.Overlays } } - gamemodeControl.SetDefaultGamemode(user.PlayMode); + gamemodeControl.SetDefaultGamemode(user?.PlayMode ?? "osu"); gamemodeControl.SelectDefaultGamemode(); + gamemodeControl.FadeInFromZero(100, Easing.OutQuint); } From e20a8992655f86b57ed442fda10c011435773482 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Tue, 4 Jun 2019 21:46:43 +0300 Subject: [PATCH 11/67] remove excessive null check --- osu.Game/Overlays/UserProfileOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 58d1fe4046..1d8775ad04 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -152,7 +152,7 @@ namespace osu.Game.Overlays } } - gamemodeControl.SetDefaultGamemode(user?.PlayMode ?? "osu"); + gamemodeControl.SetDefaultGamemode(user.PlayMode ?? "osu"); gamemodeControl.SelectDefaultGamemode(); gamemodeControl.FadeInFromZero(100, Easing.OutQuint); From 923f9fb6cdb1b2480420c43448ff048596023ffe Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 7 Jun 2019 01:43:26 +0300 Subject: [PATCH 12/67] Naming adjustments --- .../Visual/Online/TestSceneGamemodeControl.cs | 40 ------------------- .../Online/TestSceneProfileRulesetSelector.cs | 40 +++++++++++++++++++ ...deControl.cs => ProfileRulesetSelector.cs} | 14 +++---- .../{GamemodeTabItem.cs => RulesetTabItem.cs} | 4 +- osu.Game/Overlays/UserProfileOverlay.cs | 10 ++--- 5 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs create mode 100644 osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs rename osu.Game/Overlays/Profile/Header/Components/{GamemodeControl.cs => ProfileRulesetSelector.cs} (82%) rename osu.Game/Overlays/Profile/Header/Components/{GamemodeTabItem.cs => RulesetTabItem.cs} (97%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs b/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs deleted file mode 100644 index a2a75566d5..0000000000 --- a/osu.Game.Tests/Visual/Online/TestSceneGamemodeControl.cs +++ /dev/null @@ -1,40 +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.Graphics; -using osu.Framework.MathUtils; -using osu.Game.Overlays.Profile.Header.Components; -using osuTK.Graphics; -using System; -using System.Collections.Generic; - -namespace osu.Game.Tests.Visual.Online -{ - public class TestSceneGamemodeControl : OsuTestScene - { - public override IReadOnlyList RequiredTypes => new[] - { - typeof(GamemodeControl), - typeof(GamemodeTabItem), - }; - - public TestSceneGamemodeControl() - { - GamemodeControl control; - - Child = control = new GamemodeControl - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }; - - AddStep("set osu! as default", () => control.SetDefaultGamemode("osu")); - AddStep("set mania as default", () => control.SetDefaultGamemode("mania")); - AddStep("set taiko as default", () => control.SetDefaultGamemode("taiko")); - AddStep("set catch as default", () => control.SetDefaultGamemode("fruits")); - AddStep("select default gamemode", control.SelectDefaultGamemode); - - AddStep("set random colour", () => control.AccentColour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)); - } - } -} diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs new file mode 100644 index 0000000000..687cbbebad --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs @@ -0,0 +1,40 @@ +// 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.MathUtils; +using osu.Game.Overlays.Profile.Header.Components; +using osuTK.Graphics; +using System; +using System.Collections.Generic; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneProfileRulesetSelector : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(ProfileRulesetSelector), + typeof(RulesetTabItem), + }; + + public TestSceneProfileRulesetSelector() + { + ProfileRulesetSelector selector; + + Child = selector = new ProfileRulesetSelector + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; + + AddStep("set osu! as default", () => selector.SetDefaultGamemode("osu")); + AddStep("set mania as default", () => selector.SetDefaultGamemode("mania")); + AddStep("set taiko as default", () => selector.SetDefaultGamemode("taiko")); + AddStep("set catch as default", () => selector.SetDefaultGamemode("fruits")); + AddStep("select default gamemode", selector.SelectDefaultGamemode); + + AddStep("set random colour", () => selector.AccentColour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)); + } + } +} diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs similarity index 82% rename from osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs rename to osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs index 56f84741f3..b189878b0d 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeControl.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs @@ -12,11 +12,11 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header.Components { - public class GamemodeControl : TabControl + public class ProfileRulesetSelector : TabControl { protected override Dropdown CreateDropdown() => null; - protected override TabItem CreateTabItem(RulesetInfo value) => new GamemodeTabItem(value) + protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value) { AccentColour = AccentColour }; @@ -35,12 +35,12 @@ namespace osu.Game.Overlays.Profile.Header.Components foreach (TabItem tabItem in TabContainer) { - ((GamemodeTabItem)tabItem).AccentColour = value; + ((RulesetTabItem)tabItem).AccentColour = value; } } } - public GamemodeControl() + public ProfileRulesetSelector() { TabContainer.Masking = false; TabContainer.Spacing = new Vector2(10, 0); @@ -62,7 +62,7 @@ namespace osu.Game.Overlays.Profile.Header.Components { foreach (TabItem tabItem in TabContainer) { - ((GamemodeTabItem)tabItem).IsDefault = ((GamemodeTabItem)tabItem).Value.ShortName == gamemode; + ((RulesetTabItem)tabItem).IsDefault = ((RulesetTabItem)tabItem).Value.ShortName == gamemode; } } @@ -70,9 +70,9 @@ namespace osu.Game.Overlays.Profile.Header.Components { foreach (TabItem tabItem in TabContainer) { - if (((GamemodeTabItem)tabItem).IsDefault) + if (((RulesetTabItem)tabItem).IsDefault) { - Current.Value = ((GamemodeTabItem)tabItem).Value; + Current.Value = ((RulesetTabItem)tabItem).Value; return; } } diff --git a/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs similarity index 97% rename from osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs rename to osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs index 688109ad2f..0a6f2f5123 100644 --- a/osu.Game/Overlays/Profile/Header/Components/GamemodeTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs @@ -15,7 +15,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header.Components { - public class GamemodeTabItem : TabItem + public class RulesetTabItem : TabItem { private readonly OsuSpriteText text; private readonly SpriteIcon icon; @@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Profile.Header.Components } } - public GamemodeTabItem(RulesetInfo value) + public RulesetTabItem(RulesetInfo value) : base(value) { AutoSizeAxes = Axes.Both; diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 1d8775ad04..ec81193896 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays protected ProfileHeader Header; private SectionsContainer sectionsContainer; private ProfileTabControl tabs; - private GamemodeControl gamemodeControl; + private ProfileRulesetSelector rulesetSelector; public const float CONTENT_X_MARGIN = 70; @@ -122,7 +122,7 @@ namespace osu.Game.Overlays sectionsContainer.ScrollToTop(); - Header.Add(gamemodeControl = new GamemodeControl + Header.Add(rulesetSelector = new ProfileRulesetSelector { Alpha = 0, Anchor = Anchor.TopRight, @@ -152,10 +152,10 @@ namespace osu.Game.Overlays } } - gamemodeControl.SetDefaultGamemode(user.PlayMode ?? "osu"); - gamemodeControl.SelectDefaultGamemode(); + rulesetSelector.SetDefaultGamemode(user.PlayMode ?? "osu"); + rulesetSelector.SelectDefaultGamemode(); - gamemodeControl.FadeInFromZero(100, Easing.OutQuint); + rulesetSelector.FadeInFromZero(100, Easing.OutQuint); } private class ProfileTabControl : PageTabControl From d1d3cfa991b6a3c9c64b5b82128ecebfe7180fa4 Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Sat, 8 Jun 2019 11:55:52 +0300 Subject: [PATCH 13/67] Remove ruleset selector from the user overlay --- osu.Game/Overlays/UserProfileOverlay.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index ec81193896..70ce83806e 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -11,7 +11,6 @@ using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests; using osu.Game.Overlays.Profile; -using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Overlays.Profile.Sections; using osu.Game.Users; using osuTK; @@ -26,7 +25,6 @@ namespace osu.Game.Overlays protected ProfileHeader Header; private SectionsContainer sectionsContainer; private ProfileTabControl tabs; - private ProfileRulesetSelector rulesetSelector; public const float CONTENT_X_MARGIN = 70; @@ -121,15 +119,6 @@ namespace osu.Game.Overlays } sectionsContainer.ScrollToTop(); - - Header.Add(rulesetSelector = new ProfileRulesetSelector - { - Alpha = 0, - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Y = 100, - Margin = new MarginPadding { Right = 30 }, - }); } private void userLoadComplete(User user) @@ -151,11 +140,6 @@ namespace osu.Game.Overlays } } } - - rulesetSelector.SetDefaultGamemode(user.PlayMode ?? "osu"); - rulesetSelector.SelectDefaultGamemode(); - - rulesetSelector.FadeInFromZero(100, Easing.OutQuint); } private class ProfileTabControl : PageTabControl From 3fc604b60a6a2ee39b99c06beb3b0d3d6fb944fd Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Mon, 10 Jun 2019 13:18:38 +0300 Subject: [PATCH 14/67] Add Availability to BeatmapSetOnlineInfo --- osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs | 16 +++++++++++++++- .../API/Requests/Responses/APIBeatmapSet.cs | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs index 0ccc9a924c..e88def6321 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs @@ -65,6 +65,11 @@ namespace osu.Game.Beatmaps /// The amount of people who have favourited this beatmap set. /// public int FavouriteCount { get; set; } + + /// + /// The availability of this beatmap set. + /// + public BeatmapSetOnlineAvailability Availability { get; set; } } public class BeatmapSetOnlineCovers @@ -73,7 +78,7 @@ namespace osu.Game.Beatmaps [JsonProperty(@"cover@2x")] public string Cover { get; set; } - + public string CardLowRes { get; set; } [JsonProperty(@"card@2x")] @@ -84,4 +89,13 @@ namespace osu.Game.Beatmaps [JsonProperty(@"list@2x")] public string List { get; set; } } + + public class BeatmapSetOnlineAvailability + { + [JsonProperty(@"download_disabled")] + public bool DownloadDisabled { get; set; } + + [JsonProperty(@"more_information")] + public string ExternalLink { get; set; } + } } diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs index 1abb7c1a7d..2b8a783e2e 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs @@ -60,6 +60,12 @@ namespace osu.Game.Online.API.Requests.Responses set => Author.Id = value; } + [JsonProperty(@"availability")] + private BeatmapSetOnlineAvailability availability { get; set; } + + [JsonProperty(@"download_unavailable")] + private bool test { get; set; } + [JsonProperty(@"beatmaps")] private IEnumerable beatmaps { get; set; } @@ -83,6 +89,7 @@ namespace osu.Game.Online.API.Requests.Responses Submitted = submitted, Ranked = ranked, LastUpdated = lastUpdated, + Availability = availability, }, Beatmaps = beatmaps?.Select(b => b.ToBeatmap(rulesets)).ToList(), }; From adbf4d374e6f90f5a53e3abde23fc9b14f994bad Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Mon, 10 Jun 2019 14:15:49 +0300 Subject: [PATCH 15/67] Redirecting ShowBeatmapSet to FetchAndShowBeatmapSet --- osu.Game/Overlays/BeatmapSetOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 3ed398d31a..b7331f551e 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -120,8 +120,8 @@ namespace osu.Game.Overlays public void ShowBeatmapSet(BeatmapSetInfo set) { - beatmapSet.Value = set; - Show(); + // Re-fetching is the correct way forward. + FetchAndShowBeatmapSet((int)set.OnlineBeatmapSetID); scroll.ScrollTo(0); } } From 3202110b80d805aed875587ac4935af6ea268cab Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Mon, 10 Jun 2019 20:17:44 +0300 Subject: [PATCH 16/67] Add a container for Beatmap Availability --- .../API/Requests/Responses/APIBeatmapSet.cs | 3 - .../BeatmapSet/BeatmapNotAvailable.cs | 69 +++++++++++++++++++ osu.Game/Overlays/BeatmapSet/Header.cs | 62 ++++++++++++----- 3 files changed, 112 insertions(+), 22 deletions(-) create mode 100644 osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs diff --git a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs index 2b8a783e2e..82af723a9a 100644 --- a/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs +++ b/osu.Game/Online/API/Requests/Responses/APIBeatmapSet.cs @@ -63,9 +63,6 @@ namespace osu.Game.Online.API.Requests.Responses [JsonProperty(@"availability")] private BeatmapSetOnlineAvailability availability { get; set; } - [JsonProperty(@"download_unavailable")] - private bool test { get; set; } - [JsonProperty(@"beatmaps")] private IEnumerable beatmaps { get; set; } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs new file mode 100644 index 0000000000..15463b353a --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -0,0 +1,69 @@ +// 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.Text; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.BeatmapSet +{ + public class BeatmapNotAvailable : Container + { + private LinkFlowContainer linkContainer; + + public override void Show() + { + AutoSizeAxes = Axes.Both; + Margin = new MarginPadding() { Top = 10 }; + + Children = new Drawable[] + { + new Box + { + Colour = Color4.Black.Opacity(0.6f), + RelativeSizeAxes = Axes.Both, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Margin = new MarginPadding() { Top = 10, Left = 5, Right = 20 }, + + Children = new Drawable[] + { + new OsuSpriteText + { + Margin = new MarginPadding() { Bottom = 10, Horizontal = 5 }, + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium), + Text = "This beatmap is currently not available for download.", + Colour = Color4.Orange, + }, + linkContainer = new LinkFlowContainer(text => text.Font = OsuFont.GetFont(size: 14)) + { + Direction = FillDirection.Full, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Bottom = 10, Horizontal = 5 }, + }, + }, + }, + }; + + base.Show(); + } + + public string Link + { + set => linkContainer.AddLink("Check here for more information.", value); + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index a0f71d05c0..0b24a8cdd8 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; +using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.BeatmapSet.Buttons; @@ -32,6 +33,7 @@ namespace osu.Game.Overlays.BeatmapSet private readonly UpdateableBeatmapSetCover cover; private readonly OsuSpriteText title, artist; private readonly AuthorInfo author; + private readonly BeatmapNotAvailable unavailableContainer; private readonly FillFlowContainer downloadButtonsContainer; private readonly BeatmapSetOnlineStatusPill onlineStatusPill; public Details Details; @@ -134,6 +136,7 @@ namespace osu.Game.Overlays.BeatmapSet Margin = new MarginPadding { Top = 20 }, Child = author = new AuthorInfo(), }, + unavailableContainer = new BeatmapNotAvailable(), new Container { RelativeSizeAxes = Axes.X, @@ -207,6 +210,18 @@ namespace osu.Game.Overlays.BeatmapSet downloadButtonsContainer.FadeOut(transition_duration); favouriteButton.FadeOut(transition_duration); } + + if (setInfo.NewValue?.OnlineInfo.Availability?.DownloadDisabled ?? false) + { + this.ResizeHeightTo(460, transition_duration / 2); + unavailableContainer.Show(); + unavailableContainer.Link = setInfo.NewValue.OnlineInfo.Availability.ExternalLink; + } + else + { + this.ResizeHeightTo(400, transition_duration / 2); + unavailableContainer.Hide(); + } updateDownloadButtons(); }, true); @@ -216,28 +231,37 @@ namespace osu.Game.Overlays.BeatmapSet { if (BeatmapSet.Value == null) return; - switch (State.Value) + if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) { - case DownloadState.LocallyAvailable: - // temporary for UX until new design is implemented. - downloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) - { - Width = 50, - RelativeSizeAxes = Axes.Y - }; - break; + downloadButtonsContainer.RemoveAll(x => true); + return; + } - case DownloadState.Downloading: - case DownloadState.Downloaded: - // temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design. - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); - break; + else + { + switch (State.Value) + { + case DownloadState.LocallyAvailable: + // temporary for UX until new design is implemented. + downloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) + { + Width = 50, + RelativeSizeAxes = Axes.Y + }; + break; - default: - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); - if (BeatmapSet.Value.OnlineInfo.HasVideo) - downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); - break; + case DownloadState.Downloading: + case DownloadState.Downloaded: + // temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design. + downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + break; + + default: + downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + if (BeatmapSet.Value.OnlineInfo.HasVideo) + downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); + break; + } } } } From 70fdd4ba5b4fe1cafca5dbbe84d1eca9e6cf4c57 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Mon, 10 Jun 2019 21:13:37 +0300 Subject: [PATCH 17/67] Disable download button + Fix AppVeyor Errors --- osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs | 2 +- .../BeatmapSet/BeatmapNotAvailable.cs | 10 ++--- osu.Game/Overlays/BeatmapSet/Header.cs | 44 +++++++++---------- osu.Game/Overlays/BeatmapSetOverlay.cs | 2 +- osu.Game/Overlays/Direct/DownloadButton.cs | 6 +++ 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs index e88def6321..ea3f0b61b9 100644 --- a/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs +++ b/osu.Game/Beatmaps/BeatmapSetOnlineInfo.cs @@ -78,7 +78,7 @@ namespace osu.Game.Beatmaps [JsonProperty(@"cover@2x")] public string Cover { get; set; } - + public string CardLowRes { get; set; } [JsonProperty(@"card@2x")] diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 15463b353a..b893fd0703 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -1,9 +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.Text; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -11,7 +8,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; -using osuTK; using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet @@ -23,7 +19,7 @@ namespace osu.Game.Overlays.BeatmapSet public override void Show() { AutoSizeAxes = Axes.Both; - Margin = new MarginPadding() { Top = 10 }; + Margin = new MarginPadding { Top = 10 }; Children = new Drawable[] { @@ -36,13 +32,13 @@ namespace osu.Game.Overlays.BeatmapSet { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, - Margin = new MarginPadding() { Top = 10, Left = 5, Right = 20 }, + Margin = new MarginPadding { Top = 10, Left = 5, Right = 20 }, Children = new Drawable[] { new OsuSpriteText { - Margin = new MarginPadding() { Bottom = 10, Horizontal = 5 }, + Margin = new MarginPadding { Bottom = 10, Horizontal = 5 }, Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium), Text = "This beatmap is currently not available for download.", Colour = Color4.Orange, diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 0b24a8cdd8..9a4e7d4754 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.BeatmapSet.Buttons; @@ -210,7 +209,7 @@ namespace osu.Game.Overlays.BeatmapSet downloadButtonsContainer.FadeOut(transition_duration); favouriteButton.FadeOut(transition_duration); } - + if (setInfo.NewValue?.OnlineInfo.Availability?.DownloadDisabled ?? false) { this.ResizeHeightTo(460, transition_duration / 2); @@ -237,31 +236,28 @@ namespace osu.Game.Overlays.BeatmapSet return; } - else + switch (State.Value) { - switch (State.Value) - { - case DownloadState.LocallyAvailable: - // temporary for UX until new design is implemented. - downloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) - { - Width = 50, - RelativeSizeAxes = Axes.Y - }; - break; + case DownloadState.LocallyAvailable: + // temporary for UX until new design is implemented. + downloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) + { + Width = 50, + RelativeSizeAxes = Axes.Y + }; + break; - case DownloadState.Downloading: - case DownloadState.Downloaded: - // temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design. - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); - break; + case DownloadState.Downloading: + case DownloadState.Downloaded: + // temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design. + downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + break; - default: - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); - if (BeatmapSet.Value.OnlineInfo.HasVideo) - downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); - break; - } + default: + downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + if (BeatmapSet.Value.OnlineInfo.HasVideo) + downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); + break; } } } diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index b7331f551e..8d3d78e79a 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -121,7 +121,7 @@ namespace osu.Game.Overlays public void ShowBeatmapSet(BeatmapSetInfo set) { // Re-fetching is the correct way forward. - FetchAndShowBeatmapSet((int)set.OnlineBeatmapSetID); + FetchAndShowBeatmapSet(set.OnlineBeatmapSetID ?? 0); scroll.ScrollTo(0); } } diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 3f44d854e5..deccf819ea 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -77,6 +77,12 @@ namespace osu.Game.Overlays.Direct { this.colours = colours; + if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) + { + button.Enabled.Value = false; + button.TooltipText = "Unavailable"; + } + button.Action = () => { switch (State.Value) From 75716af25e67f997a669096e0cddc012c6b5e881 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Mon, 10 Jun 2019 21:14:12 +0300 Subject: [PATCH 18/67] Forgot to return --- osu.Game/Overlays/Direct/DownloadButton.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index deccf819ea..33e09e95aa 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -81,6 +81,7 @@ namespace osu.Game.Overlays.Direct { button.Enabled.Value = false; button.TooltipText = "Unavailable"; + return; } button.Action = () => From fc3e1e6a8686ccb1a8a85af180f3da3302910ade Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Mon, 10 Jun 2019 21:50:08 +0300 Subject: [PATCH 19/67] Fix issue --- osu.Game/Overlays/BeatmapSetOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 8d3d78e79a..6bd2e1b72e 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -121,7 +121,7 @@ namespace osu.Game.Overlays public void ShowBeatmapSet(BeatmapSetInfo set) { // Re-fetching is the correct way forward. - FetchAndShowBeatmapSet(set.OnlineBeatmapSetID ?? 0); + FetchAndShowBeatmapSet(set?.OnlineBeatmapSetID ?? 0); scroll.ScrollTo(0); } } From 94a7794ff71382d93cd28397aecb74d8ae95697a Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Mon, 10 Jun 2019 21:54:33 +0300 Subject: [PATCH 20/67] Fix issue --- osu.Game/Overlays/BeatmapSetOverlay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 8d3d78e79a..6bd2e1b72e 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -121,7 +121,7 @@ namespace osu.Game.Overlays public void ShowBeatmapSet(BeatmapSetInfo set) { // Re-fetching is the correct way forward. - FetchAndShowBeatmapSet(set.OnlineBeatmapSetID ?? 0); + FetchAndShowBeatmapSet(set?.OnlineBeatmapSetID ?? 0); scroll.ScrollTo(0); } } From 130ff5688694921246ee1dba0faaac987c4b46b3 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 11 Jun 2019 12:29:42 +0300 Subject: [PATCH 21/67] Move logic into BeatmapNotAvailable --- .../BeatmapSet/BeatmapNotAvailable.cs | 54 ++++++++++++++++--- osu.Game/Overlays/BeatmapSet/Header.cs | 36 +++++-------- 2 files changed, 59 insertions(+), 31 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index b893fd0703..c111861206 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -5,6 +5,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; @@ -14,9 +15,36 @@ namespace osu.Game.Overlays.BeatmapSet { public class BeatmapNotAvailable : Container { - private LinkFlowContainer linkContainer; + private BeatmapSetInfo beatmapSet; - public override void Show() + public BeatmapSetInfo BeatmapSet + { + get => beatmapSet; + set + { + if (value == beatmapSet) return; + + beatmapSet = value; + + if (beatmapSet?.OnlineInfo.Availability != null) + { + Header?.ResizeHeightTo(450, 500); + Show(); + } + else + { + Header?.ResizeHeightTo(400, 500); + Hide(); + } + } + } + + public Header Header; + + private readonly OsuSpriteText text; + private readonly LinkFlowContainer link; + + public BeatmapNotAvailable() { AutoSizeAxes = Axes.Both; Margin = new MarginPadding { Top = 10 }; @@ -36,14 +64,13 @@ namespace osu.Game.Overlays.BeatmapSet Children = new Drawable[] { - new OsuSpriteText + text = new OsuSpriteText { Margin = new MarginPadding { Bottom = 10, Horizontal = 5 }, Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium), - Text = "This beatmap is currently not available for download.", Colour = Color4.Orange, }, - linkContainer = new LinkFlowContainer(text => text.Font = OsuFont.GetFont(size: 14)) + link = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, @@ -54,12 +81,25 @@ namespace osu.Game.Overlays.BeatmapSet }, }; + Hide(); + } + + public override void Show() + { + text.Text = BeatmapSet.OnlineInfo.Availability.DownloadDisabled + ? "This beatmap is currently not available for download." + : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder."; + + link.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink); + base.Show(); } - public string Link + public override void Hide() { - set => linkContainer.AddLink("Check here for more information.", value); + link.RemoveAll(x => true); + + base.Hide(); } } } diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 9a4e7d4754..a53b4a2e68 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -32,10 +32,10 @@ namespace osu.Game.Overlays.BeatmapSet private readonly UpdateableBeatmapSetCover cover; private readonly OsuSpriteText title, artist; private readonly AuthorInfo author; - private readonly BeatmapNotAvailable unavailableContainer; - private readonly FillFlowContainer downloadButtonsContainer; + private readonly BeatmapNotAvailable beatmapNotAvailable; private readonly BeatmapSetOnlineStatusPill onlineStatusPill; public Details Details; + public FillFlowContainer DownloadButtonsContainer; public readonly BeatmapPicker Picker; @@ -135,7 +135,7 @@ namespace osu.Game.Overlays.BeatmapSet Margin = new MarginPadding { Top = 20 }, Child = author = new AuthorInfo(), }, - unavailableContainer = new BeatmapNotAvailable(), + beatmapNotAvailable = new BeatmapNotAvailable { Header = this }, new Container { RelativeSizeAxes = Axes.X, @@ -144,7 +144,7 @@ namespace osu.Game.Overlays.BeatmapSet Children = new Drawable[] { favouriteButton = new FavouriteButton(), - downloadButtonsContainer = new FillFlowContainer + DownloadButtonsContainer = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = buttons_height + buttons_spacing }, @@ -192,7 +192,7 @@ namespace osu.Game.Overlays.BeatmapSet BeatmapSet.BindValueChanged(setInfo => { - Picker.BeatmapSet = author.BeatmapSet = Details.BeatmapSet = setInfo.NewValue; + Picker.BeatmapSet = author.BeatmapSet = beatmapNotAvailable.BeatmapSet = Details.BeatmapSet = setInfo.NewValue; title.Text = setInfo.NewValue?.Metadata.Title ?? string.Empty; artist.Text = setInfo.NewValue?.Metadata.Artist ?? string.Empty; @@ -201,27 +201,15 @@ namespace osu.Game.Overlays.BeatmapSet if (setInfo.NewValue != null) { - downloadButtonsContainer.FadeIn(transition_duration); + DownloadButtonsContainer.FadeIn(transition_duration); favouriteButton.FadeIn(transition_duration); } else { - downloadButtonsContainer.FadeOut(transition_duration); + DownloadButtonsContainer.FadeOut(transition_duration); favouriteButton.FadeOut(transition_duration); } - if (setInfo.NewValue?.OnlineInfo.Availability?.DownloadDisabled ?? false) - { - this.ResizeHeightTo(460, transition_duration / 2); - unavailableContainer.Show(); - unavailableContainer.Link = setInfo.NewValue.OnlineInfo.Availability.ExternalLink; - } - else - { - this.ResizeHeightTo(400, transition_duration / 2); - unavailableContainer.Hide(); - } - updateDownloadButtons(); }, true); } @@ -232,7 +220,7 @@ namespace osu.Game.Overlays.BeatmapSet if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) { - downloadButtonsContainer.RemoveAll(x => true); + DownloadButtonsContainer.RemoveAll(x => true); return; } @@ -240,7 +228,7 @@ namespace osu.Game.Overlays.BeatmapSet { case DownloadState.LocallyAvailable: // temporary for UX until new design is implemented. - downloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) + DownloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) { Width = 50, RelativeSizeAxes = Axes.Y @@ -250,13 +238,13 @@ namespace osu.Game.Overlays.BeatmapSet case DownloadState.Downloading: case DownloadState.Downloaded: // temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design. - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + DownloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); break; default: - downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + DownloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); if (BeatmapSet.Value.OnlineInfo.HasVideo) - downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); + DownloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); break; } } From 13cd22e397f336eeb86b1be076f4cf6aabbafc85 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 11 Jun 2019 14:58:46 +0300 Subject: [PATCH 22/67] Test scene for BeatmapNotAvailable --- .../Online/TestSceneBeatmapNotAvailable.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs new file mode 100644 index 0000000000..bd4570470d --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs @@ -0,0 +1,54 @@ +// 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.Overlays.BeatmapSet; + +namespace osu.Game.Tests.Visual.Online +{ + [TestFixture] + public class TestSceneBeatmapNotAvailable : OsuTestScene + { + public TestSceneBeatmapNotAvailable() + { + var container = new BeatmapNotAvailable(); + + Add(container); + + AddAssert("is container hidden", () => container.Alpha == 0); + AddStep("set undownloadable beatmapset", () => container.BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = true, + ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", + }, + }, + }); + + AddAssert("is container visible", () => container.Alpha == 1); + AddStep("set downloadable beatmapset", () => container.BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = false, + ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", + }, + }, + }); + + AddAssert("is container still visible", () => container.Alpha == 1); + AddStep("set normal beatmapset", () => container.BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo(), + }); + + AddAssert("is container hidden", () => container.Alpha == 0); + } + } +} From 35cc45c9d9dff91795a90ef8785aa3bf99fe7228 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Tue, 11 Jun 2019 23:11:03 +0300 Subject: [PATCH 23/67] Small update --- osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs index bd4570470d..e2a5ab1e35 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs @@ -1,13 +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 NUnit.Framework; using osu.Game.Beatmaps; using osu.Game.Overlays.BeatmapSet; namespace osu.Game.Tests.Visual.Online { - [TestFixture] public class TestSceneBeatmapNotAvailable : OsuTestScene { public TestSceneBeatmapNotAvailable() From efd9766fb301121f46776b1d4a64b7ce849b53c1 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 12 Jun 2019 17:37:34 +0300 Subject: [PATCH 24/67] Make Header accessible by BeatmapSetOverlay --- osu.Game/Overlays/BeatmapSetOverlay.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 6bd2e1b72e..f0525aa843 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays public const float X_PADDING = 40; public const float RIGHT_WIDTH = 275; - private readonly Header header; + public readonly Header Header; private RulesetStore rulesets; @@ -60,7 +60,7 @@ namespace osu.Game.Overlays Direction = FillDirection.Vertical, Children = new Drawable[] { - header = new Header(), + Header = new Header(), info = new Info(), scores = new ScoresContainer(), }, @@ -68,10 +68,10 @@ namespace osu.Game.Overlays }, }; - header.BeatmapSet.BindTo(beatmapSet); + Header.BeatmapSet.BindTo(beatmapSet); info.BeatmapSet.BindTo(beatmapSet); - header.Picker.Beatmap.ValueChanged += b => + Header.Picker.Beatmap.ValueChanged += b => { info.Beatmap = b.NewValue; scores.Beatmap = b.NewValue; @@ -103,7 +103,7 @@ namespace osu.Game.Overlays req.Success += res => { beatmapSet.Value = res.ToBeatmapSet(rulesets); - header.Picker.Beatmap.Value = header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId); + Header.Picker.Beatmap.Value = Header.BeatmapSet.Value.Beatmaps.First(b => b.OnlineBeatmapID == beatmapId); }; API.Queue(req); Show(); From a069a3029e995ad200694abd1588c2053d59ffea Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 12 Jun 2019 18:07:57 +0300 Subject: [PATCH 25/67] Make DownloadButton accessible by DirectPanel --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 4 +++- osu.Game/Overlays/Direct/DirectListPanel.cs | 4 +++- osu.Game/Overlays/Direct/DirectPanel.cs | 1 + osu.Game/Overlays/Direct/DownloadButton.cs | 7 ++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 5756a4593d..9e7aa5372b 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -25,9 +25,11 @@ namespace osu.Game.Overlays.Direct private const float vertical_padding = 5; private FillFlowContainer bottomPanel, statusContainer; + private DownloadButton downloadButton; private PlayButton playButton; private Box progressBar; + public override DownloadButton DownloadButton => downloadButton; protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; @@ -155,7 +157,7 @@ namespace osu.Game.Overlays.Direct }, }, }, - new DownloadButton(SetInfo) + downloadButton = new DownloadButton(SetInfo) { Size = new Vector2(50, 30), Margin = new MarginPadding(horizontal_padding), diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index b731e95d54..076fed19bd 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -27,11 +27,13 @@ namespace osu.Game.Overlays.Direct private const float height = 70; private FillFlowContainer statusContainer; + private DownloadButton downloadButton; private PlayButton playButton; private Box progressBar; protected override bool FadePlayButton => false; + public override DownloadButton DownloadButton => downloadButton; protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; @@ -149,7 +151,7 @@ namespace osu.Game.Overlays.Direct Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, AutoSizeAxes = Axes.Both, - Child = new DownloadButton(SetInfo) + Child = downloadButton = new DownloadButton(SetInfo) { Size = new Vector2(height - vertical_padding * 3), Margin = new MarginPadding { Left = vertical_padding * 2, Right = vertical_padding }, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index f413dc3771..c9fe4aaa05 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -34,6 +34,7 @@ namespace osu.Game.Overlays.Direct public PreviewTrack Preview => PlayButton.Preview; public Bindable PreviewPlaying => PlayButton.Playing; + public abstract DownloadButton DownloadButton { get; } protected abstract PlayButton PlayButton { get; } protected abstract Box PreviewBar { get; } diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 33e09e95aa..10e6f8a6e1 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.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.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; @@ -26,6 +27,8 @@ namespace osu.Game.Overlays.Direct private readonly OsuAnimatedButton button; + public readonly BindableBool Enabled = new BindableBool(true); + public DownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) : base(beatmapSet) { @@ -62,6 +65,8 @@ namespace osu.Game.Overlays.Direct } } }; + + Enabled.BindTo(button.Enabled); } protected override void LoadComplete() @@ -79,7 +84,7 @@ namespace osu.Game.Overlays.Direct if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) { - button.Enabled.Value = false; + Enabled.Value = false; button.TooltipText = "Unavailable"; return; } From c5c6f6b9e05ee517fc6483344d3125d675ba6ee4 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 12 Jun 2019 18:36:47 +0300 Subject: [PATCH 26/67] Allow for not refetching in ShowBeatmapSet (will be used for tests) --- osu.Game/Overlays/BeatmapSetOverlay.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index f0525aa843..a44a7fa45f 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -118,10 +118,17 @@ namespace osu.Game.Overlays Show(); } - public void ShowBeatmapSet(BeatmapSetInfo set) + public void ShowBeatmapSet(BeatmapSetInfo set, bool refetch = true) { // Re-fetching is the correct way forward. - FetchAndShowBeatmapSet(set?.OnlineBeatmapSetID ?? 0); + if (refetch) + FetchAndShowBeatmapSet(set?.OnlineBeatmapSetID ?? 0); + else + { + beatmapSet.Value = set; + Show(); + } + scroll.ScrollTo(0); } } From 744f32ab35dc7a397a4ebb8954152c80bdb3b6f3 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 12 Jun 2019 19:11:05 +0300 Subject: [PATCH 27/67] Fix little bug --- osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index c111861206..b9c0a1af39 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -26,6 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; + removeLinks(); if (beatmapSet?.OnlineInfo.Availability != null) { Header?.ResizeHeightTo(450, 500); @@ -95,11 +96,6 @@ namespace osu.Game.Overlays.BeatmapSet base.Show(); } - public override void Hide() - { - link.RemoveAll(x => true); - - base.Hide(); - } + private void removeLinks() => link?.RemoveAll(x => true); } } From 1a50544c9465ec75278420b8d0c22666612be8c1 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 12 Jun 2019 20:42:52 +0300 Subject: [PATCH 28/67] Add tests for undownloadable / parts-removed beatmapsets --- .../Online/TestSceneBeatmapSetOverlay.cs | 306 +++++++++++++++++- .../Visual/Online/TestSceneDirectPanel.cs | 43 ++- .../BeatmapSet/BeatmapNotAvailable.cs | 1 + 3 files changed, 342 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 5910da7b88..5e7ccc7ed4 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -39,6 +39,7 @@ namespace osu.Game.Tests.Visual.Online typeof(Info), typeof(PreviewButton), typeof(SuccessRate), + typeof(BeatmapNotAvailable), }; public TestSceneBeatmapSetOverlay() @@ -49,6 +50,7 @@ namespace osu.Game.Tests.Visual.Online [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { + var osu = rulesets.GetRuleset(0); var mania = rulesets.GetRuleset(3); var taiko = rulesets.GetRuleset(1); @@ -225,7 +227,7 @@ namespace osu.Game.Tests.Visual.Online }, }, }, - }); + }, false); }); AddStep(@"show second", () => @@ -396,9 +398,309 @@ namespace osu.Game.Tests.Visual.Online }, }, }, - }); + }, false); }); + AddStep(@"show parts-removed", () => + { + overlay.ShowBeatmapSet(new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"Sakura Kagetsu", + Artist = @"AKITO", + Source = @"DJMAX", + Tags = @"J-Trance Pasonia", + Author = new User + { + Username = @"Kharl", + Id = 452, + }, + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = false, + ExternalLink = @"https://gist.githubusercontent.com/peppy/079dc3f77e316f9cd40077d411319a72/raw", + }, + Preview = @"https://b.ppy.sh/preview/119.mp3", + PlayCount = 626927, + FavouriteCount = 157, + Submitted = new DateTime(2007, 10, 24), + Ranked = new DateTime(2008, 4, 21), + Status = BeatmapSetOnlineStatus.Ranked, + BPM = 138, + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/119/covers/cover.jpg?1539847784", + }, + }, + Beatmaps = new List + { + new BeatmapInfo + { + StarDifficulty = 1.51, + Version = "Easy", + Ruleset = osu, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 2, + OverallDifficulty = 1, + ApproachRate = 1, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 126000, + CircleCount = 371, + SliderCount = 35, + PlayCount = 84498, + PassCount = 37482, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 2.23, + Version = "Normal", + Ruleset = osu, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 5, + DrainRate = 4, + OverallDifficulty = 3, + ApproachRate = 3, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 126000, + CircleCount = 98, + SliderCount = 28, + PlayCount = 86427, + PassCount = 23273, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 2.83, + Version = "Hard", + Ruleset = osu, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 6, + DrainRate = 6, + OverallDifficulty = 6, + ApproachRate = 6, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 126000, + CircleCount = 139, + SliderCount = 37, + PlayCount = 206523, + PassCount = 44366, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 4.26, + Version = "Pasonia's Insane", + Ruleset = osu, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 6, + DrainRate = 6, + OverallDifficulty = 6, + ApproachRate = 6, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 126000, + CircleCount = 371, + SliderCount = 35, + PlayCount = 249479, + PassCount = 14042, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + }, + }, false); + }); + + AddStep(@"show undownloadable", () => + { + overlay.ShowBeatmapSet(new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = @"China Express", + Artist = @"Ryu*", + Source = @"REFLEC BEAT", + Tags = @"konami bemani lincle link iidx iidx18 iidx19 resort anthem plus la cataline mmzz", + Author = new User + { + Username = @"yeahyeahyeahhh", + Id = 58042, + }, + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = true, + ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", + }, + Preview = @"https://b.ppy.sh/preview/53853.mp3", + PlayCount = 436213, + FavouriteCount = 105, + Submitted = new DateTime(2012, 7, 1), + Ranked = new DateTime(2012, 7, 18), + Status = BeatmapSetOnlineStatus.Ranked, + BPM = 171, + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/53853/covers/cover.jpg?1456498562", + }, + }, + Beatmaps = new List + { + new BeatmapInfo + { + StarDifficulty = 1.85, + Version = "Easy", + Ruleset = osu, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 3, + DrainRate = 2, + OverallDifficulty = 2, + ApproachRate = 3, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 95000, + CircleCount = 49, + SliderCount = 60, + PlayCount = 20308, + PassCount = 10233, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 2.36, + Version = "Normal", + Ruleset = osu, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 3, + DrainRate = 2, + OverallDifficulty = 2, + ApproachRate = 5, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 96000, + CircleCount = 86, + SliderCount = 67, + PlayCount = 54015, + PassCount = 25603, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 4.42, + Version = "Hyper", + Ruleset = osu, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 7, + OverallDifficulty = 6, + ApproachRate = 8, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 96000, + CircleCount = 215, + SliderCount = 120, + PlayCount = 111400, + PassCount = 12583, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + new BeatmapInfo + { + StarDifficulty = 5.05, + Version = "Another", + Ruleset = osu, + BaseDifficulty = new BeatmapDifficulty + { + CircleSize = 4, + DrainRate = 7, + OverallDifficulty = 9, + ApproachRate = 9, + }, + OnlineInfo = new BeatmapOnlineInfo + { + Length = 96000, + CircleCount = 250, + SliderCount = 75, + PlayCount = 228253, + PassCount = 53037, + }, + Metrics = new BeatmapMetrics + { + Ratings = Enumerable.Range(0, 11), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + }, + }, + }, + }, false); + }); + + AddAssert(@"is download button removed", () => overlay.Header.DownloadButtonsContainer.Count == 0); + AddStep(@"hide", overlay.Hide); AddStep(@"show without reload", overlay.Show); } diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs index 8b67892fbb..a2767611ac 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs @@ -6,7 +6,9 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Beatmaps; using osu.Game.Overlays.Direct; +using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; using osuTK; @@ -21,12 +23,34 @@ namespace osu.Game.Tests.Visual.Online typeof(IconPill) }; + private BeatmapSetInfo getBeatmapSet(RulesetInfo ruleset, bool downloadable) + { + var beatmap = CreateWorkingBeatmap(ruleset).BeatmapSetInfo; + beatmap.OnlineInfo.HasVideo = true; + beatmap.OnlineInfo.HasStoryboard = true; + + beatmap.OnlineInfo.Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = !downloadable, + ExternalLink = "http://localhost", + }; + + return beatmap; + } + [BackgroundDependencyLoader] private void load() { - var beatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo); - beatmap.BeatmapSetInfo.OnlineInfo.HasVideo = true; - beatmap.BeatmapSetInfo.OnlineInfo.HasStoryboard = true; + var ruleset = new OsuRuleset().RulesetInfo; + + var normal = CreateWorkingBeatmap(ruleset).BeatmapSetInfo; + normal.OnlineInfo.HasVideo = true; + normal.OnlineInfo.HasStoryboard = true; + + var downloadable = getBeatmapSet(ruleset, true); + var undownloadable = getBeatmapSet(ruleset, false); + + DirectPanel undownloadableGridPanel, undownloadableListPanel; Child = new FillFlowContainer { @@ -37,10 +61,17 @@ namespace osu.Game.Tests.Visual.Online Spacing = new Vector2(0, 20), Children = new Drawable[] { - new DirectGridPanel(beatmap.BeatmapSetInfo), - new DirectListPanel(beatmap.BeatmapSetInfo) - } + new DirectGridPanel(normal), + new DirectGridPanel(downloadable), + undownloadableGridPanel = new DirectGridPanel(undownloadable), + new DirectListPanel(normal), + new DirectListPanel(downloadable), + undownloadableListPanel = new DirectListPanel(undownloadable), + }, }; + + AddAssert("is download button disabled on last grid panel", () => !undownloadableGridPanel.DownloadButton.Enabled.Value); + AddAssert("is download button disabled on last list panel", () => !undownloadableListPanel.DownloadButton.Enabled.Value); } } } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index b9c0a1af39..31ed0d9396 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -27,6 +27,7 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; removeLinks(); + if (beatmapSet?.OnlineInfo.Availability != null) { Header?.ResizeHeightTo(450, 500); From 155f7c7e03541a3e8f825a6c6ce229f015c0d78d Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 13 Jun 2019 17:32:27 +0300 Subject: [PATCH 29/67] Use OsuTextFlowContainer for multi-lines --- .../BeatmapSet/BeatmapNotAvailable.cs | 26 +++++++------------ osu.Game/Overlays/BeatmapSet/Header.cs | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 31ed0d9396..59ac8ce6e2 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet @@ -29,47 +28,42 @@ namespace osu.Game.Overlays.BeatmapSet removeLinks(); if (beatmapSet?.OnlineInfo.Availability != null) - { - Header?.ResizeHeightTo(450, 500); Show(); - } else - { - Header?.ResizeHeightTo(400, 500); Hide(); - } } } - public Header Header; - - private readonly OsuSpriteText text; + private readonly OsuTextFlowContainer text; private readonly LinkFlowContainer link; public BeatmapNotAvailable() { - AutoSizeAxes = Axes.Both; - Margin = new MarginPadding { Top = 10 }; + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Padding = new MarginPadding { Top = 10, Right = 20 }; Children = new Drawable[] { new Box { - Colour = Color4.Black.Opacity(0.6f), RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(0.6f), }, new FillFlowContainer { - AutoSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Margin = new MarginPadding { Top = 10, Left = 5, Right = 20 }, Children = new Drawable[] { - text = new OsuSpriteText + text = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium)) { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Bottom = 10, Horizontal = 5 }, - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium), Colour = Color4.Orange, }, link = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index a53b4a2e68..0f3ce008cf 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -135,7 +135,7 @@ namespace osu.Game.Overlays.BeatmapSet Margin = new MarginPadding { Top = 20 }, Child = author = new AuthorInfo(), }, - beatmapNotAvailable = new BeatmapNotAvailable { Header = this }, + beatmapNotAvailable = new BeatmapNotAvailable(), new Container { RelativeSizeAxes = Axes.X, From a0609f28d71fc5e5e770ac5c10f064bc1559b339 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 01:43:28 +0300 Subject: [PATCH 30/67] Revert some changes + simplify BeatmapNotAvailable --- .../Online/TestSceneBeatmapSetOverlay.cs | 40 ++++++++----------- .../BeatmapSet/BeatmapNotAvailable.cs | 22 +++++----- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 553be1d38d..c97aa5a13c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -473,9 +473,8 @@ namespace osu.Game.Tests.Visual.Online }, Metrics = new BeatmapMetrics { - Ratings = Enumerable.Range(0, 11), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, new BeatmapInfo @@ -500,9 +499,8 @@ namespace osu.Game.Tests.Visual.Online }, Metrics = new BeatmapMetrics { - Ratings = Enumerable.Range(0, 11), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, new BeatmapInfo @@ -527,9 +525,8 @@ namespace osu.Game.Tests.Visual.Online }, Metrics = new BeatmapMetrics { - Ratings = Enumerable.Range(0, 11), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, new BeatmapInfo @@ -554,9 +551,8 @@ namespace osu.Game.Tests.Visual.Online }, Metrics = new BeatmapMetrics { - Ratings = Enumerable.Range(0, 11), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, }, @@ -623,9 +619,8 @@ namespace osu.Game.Tests.Visual.Online }, Metrics = new BeatmapMetrics { - Ratings = Enumerable.Range(0, 11), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, new BeatmapInfo @@ -650,9 +645,8 @@ namespace osu.Game.Tests.Visual.Online }, Metrics = new BeatmapMetrics { - Ratings = Enumerable.Range(0, 11), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, new BeatmapInfo @@ -677,9 +671,8 @@ namespace osu.Game.Tests.Visual.Online }, Metrics = new BeatmapMetrics { - Ratings = Enumerable.Range(0, 11), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, new BeatmapInfo @@ -704,9 +697,8 @@ namespace osu.Game.Tests.Visual.Online }, Metrics = new BeatmapMetrics { - Ratings = Enumerable.Range(0, 11), - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6), + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), }, }, }, diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 59ac8ce6e2..6472077c8b 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet @@ -25,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; - removeLinks(); + link?.Clear(); if (beatmapSet?.OnlineInfo.Availability != null) Show(); @@ -34,9 +35,11 @@ namespace osu.Game.Overlays.BeatmapSet } } - private readonly OsuTextFlowContainer text; + private readonly OsuSpriteText text; private readonly LinkFlowContainer link; + private BeatmapSetOnlineAvailability availability => BeatmapSet?.OnlineInfo.Availability; + public BeatmapNotAvailable() { RelativeSizeAxes = Axes.X; @@ -56,14 +59,14 @@ namespace osu.Game.Overlays.BeatmapSet AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Margin = new MarginPadding { Top = 10, Left = 5, Right = 20 }, - Children = new Drawable[] { - text = new OsuTextFlowContainer(t => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium)) + text = new OsuSpriteText { RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, + AllowMultiline = true, Margin = new MarginPadding { Bottom = 10, Horizontal = 5 }, + Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium), Colour = Color4.Orange, }, link = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) @@ -76,21 +79,18 @@ namespace osu.Game.Overlays.BeatmapSet }, }, }; - - Hide(); } public override void Show() { - text.Text = BeatmapSet.OnlineInfo.Availability.DownloadDisabled + text.Text = availability.DownloadDisabled ? "This beatmap is currently not available for download." : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder."; - link.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink); + if (!string.IsNullOrEmpty(availability.ExternalLink)) + link.AddLink("Check here for more information.", availability.ExternalLink); base.Show(); } - - private void removeLinks() => link?.RemoveAll(x => true); } } From 387644214390e440ce99ab8294022d8b51b7df10 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 03:37:08 +0300 Subject: [PATCH 31/67] More simplifies + fix test --- .../Visual/Online/TestSceneBeatmapSetOverlay.cs | 13 ++++++++++++- .../Overlays/BeatmapSet/BeatmapNotAvailable.cs | 17 +++++++---------- osu.Game/Overlays/BeatmapSet/Header.cs | 4 ++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index c97aa5a13c..2e68be981c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -242,6 +242,8 @@ namespace osu.Game.Tests.Visual.Online }, false); }); + downloadAssert(true); + AddStep(@"show second", () => { overlay.ShowBeatmapSet(new BeatmapSetInfo @@ -408,6 +410,8 @@ namespace osu.Game.Tests.Visual.Online }, }, false); }); + + downloadAssert(true); } [Test] @@ -559,6 +563,8 @@ namespace osu.Game.Tests.Visual.Online }, false); }); + downloadAssert(true); + AddStep(@"show undownloadable", () => { overlay.ShowBeatmapSet(new BeatmapSetInfo @@ -705,7 +711,12 @@ namespace osu.Game.Tests.Visual.Online }, false); }); - AddAssert(@"is download button removed", () => overlay.Header.DownloadButtonsContainer.Any()); + downloadAssert(false); + } + + private void downloadAssert(bool shown) + { + AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsContainer.Any() == shown); } [Test] diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 6472077c8b..23d7faefc1 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -22,16 +22,12 @@ namespace osu.Game.Overlays.BeatmapSet get => beatmapSet; set { - if (value == beatmapSet) return; + if (value == beatmapSet) + return; beatmapSet = value; - link?.Clear(); - - if (beatmapSet?.OnlineInfo.Availability != null) - Show(); - else - Hide(); + updateText(); } } @@ -81,16 +77,17 @@ namespace osu.Game.Overlays.BeatmapSet }; } - public override void Show() + private void updateText() { + if (availability == null) + return; + text.Text = availability.DownloadDisabled ? "This beatmap is currently not available for download." : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder."; if (!string.IsNullOrEmpty(availability.ExternalLink)) link.AddLink("Check here for more information.", availability.ExternalLink); - - base.Show(); } } } diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 0f3ce008cf..0439ee4797 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -220,7 +220,7 @@ namespace osu.Game.Overlays.BeatmapSet if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) { - DownloadButtonsContainer.RemoveAll(x => true); + DownloadButtonsContainer.Clear(); return; } @@ -228,7 +228,7 @@ namespace osu.Game.Overlays.BeatmapSet { case DownloadState.LocallyAvailable: // temporary for UX until new design is implemented. - DownloadButtonsContainer.Child = new osu.Game.Overlays.Direct.DownloadButton(BeatmapSet.Value) + DownloadButtonsContainer.Child = new Direct.DownloadButton(BeatmapSet.Value) { Width = 50, RelativeSizeAxes = Axes.Y From 6e282941822a10b8263d725f3446f674dc27b63a Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 04:27:31 +0300 Subject: [PATCH 32/67] Fix another test --- .../Visual/Online/TestSceneBeatmapNotAvailable.cs | 1 - osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs index e2a5ab1e35..22e3e63c28 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs @@ -14,7 +14,6 @@ namespace osu.Game.Tests.Visual.Online Add(container); - AddAssert("is container hidden", () => container.Alpha == 0); AddStep("set undownloadable beatmapset", () => container.BeatmapSet = new BeatmapSetInfo { OnlineInfo = new BeatmapSetOnlineInfo diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 23d7faefc1..48f80fc812 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -27,7 +27,11 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; - updateText(); + var unavailable = availability != null; + this.FadeTo(unavailable ? 1 : 0); + + if (unavailable) + updateText(); } } @@ -79,9 +83,6 @@ namespace osu.Game.Overlays.BeatmapSet private void updateText() { - if (availability == null) - return; - text.Text = availability.DownloadDisabled ? "This beatmap is currently not available for download." : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder."; From 46003365812c03baf5cd8224705b6a9f05b6702d Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 14:43:18 +0300 Subject: [PATCH 33/67] Use TextFlowContainer + small changes --- .../BeatmapSet/BeatmapNotAvailable.cs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 48f80fc812..979d0b6fa2 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Sprites; using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet @@ -27,18 +26,17 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; - var unavailable = availability != null; + bool unavailable = BeatmapSet?.OnlineInfo.Availability != null; this.FadeTo(unavailable ? 1 : 0); + linkContainer.Clear(); if (unavailable) updateText(); } } - private readonly OsuSpriteText text; - private readonly LinkFlowContainer link; - - private BeatmapSetOnlineAvailability availability => BeatmapSet?.OnlineInfo.Availability; + private readonly TextFlowContainer textContainer; + private readonly LinkFlowContainer linkContainer; public BeatmapNotAvailable() { @@ -61,15 +59,16 @@ namespace osu.Game.Overlays.BeatmapSet Margin = new MarginPadding { Top = 10, Left = 5, Right = 20 }, Children = new Drawable[] { - text = new OsuSpriteText + textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium)) { + + Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, - AllowMultiline = true, + AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Bottom = 10, Horizontal = 5 }, - Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium), Colour = Color4.Orange, }, - link = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) + linkContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, @@ -83,12 +82,12 @@ namespace osu.Game.Overlays.BeatmapSet private void updateText() { - text.Text = availability.DownloadDisabled + textContainer.Text = BeatmapSet.OnlineInfo.Availability.DownloadDisabled ? "This beatmap is currently not available for download." : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder."; - if (!string.IsNullOrEmpty(availability.ExternalLink)) - link.AddLink("Check here for more information.", availability.ExternalLink); + if (!string.IsNullOrEmpty(BeatmapSet.OnlineInfo.Availability.ExternalLink)) + linkContainer.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink); } } } From 475b40cc0295192cae8346cb7050766deb495076 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 14:47:29 +0300 Subject: [PATCH 34/67] Remove empty line --- osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 979d0b6fa2..34be01543b 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -61,7 +61,6 @@ namespace osu.Game.Overlays.BeatmapSet { textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium)) { - Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, From a6c268ef5ca84f4a64e736ab924a8a81e89f0ed6 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 15:05:53 +0300 Subject: [PATCH 35/67] Move the horizontal margin into the sprite text itself --- osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 34be01543b..cb9284a295 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -59,20 +59,20 @@ namespace osu.Game.Overlays.BeatmapSet Margin = new MarginPadding { Top = 10, Left = 5, Right = 20 }, Children = new Drawable[] { - textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium)) + textContainer = new TextFlowContainer(t => { t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium); t.Margin = new MarginPadding { Horizontal = 5 }; }) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = 10, Horizontal = 5 }, + Margin = new MarginPadding { Bottom = 10 }, Colour = Color4.Orange, }, - linkContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) + linkContainer = new LinkFlowContainer(t => { t.Font = OsuFont.GetFont(size: 14); t.Margin = new MarginPadding { Horizontal = 5 }; }) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = 10, Horizontal = 5 }, + Margin = new MarginPadding { Bottom = 10 }, }, }, }, From 9f25d3cd72972042881cf6254332425a1a4db3d8 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 17:55:36 +0300 Subject: [PATCH 36/67] More changes and improvements --- .../Online/TestSceneBeatmapNotAvailable.cs | 68 ++++++++++++++++--- .../Online/TestSceneBeatmapSetOverlay.cs | 3 +- .../BeatmapSet/BeatmapNotAvailable.cs | 11 ++- 3 files changed, 63 insertions(+), 19 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs index 22e3e63c28..553b081f28 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs @@ -1,51 +1,97 @@ // 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.Overlays.BeatmapSet; namespace osu.Game.Tests.Visual.Online { + [TestFixture] public class TestSceneBeatmapNotAvailable : OsuTestScene { + BeatmapNotAvailable container; + public TestSceneBeatmapNotAvailable() { - var container = new BeatmapNotAvailable(); + Add(container = new BeatmapNotAvailable()); + } - Add(container); - - AddStep("set undownloadable beatmapset", () => container.BeatmapSet = new BeatmapSetInfo + [Test] + public void TestUndownloadableWithLink() + { + AddStep("set undownloadable beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo { OnlineInfo = new BeatmapSetOnlineInfo { Availability = new BeatmapSetOnlineAvailability { DownloadDisabled = true, - ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", + ExternalLink = @"https://osu.ppy.sh", }, }, }); - AddAssert("is container visible", () => container.Alpha == 1); - AddStep("set downloadable beatmapset", () => container.BeatmapSet = new BeatmapSetInfo + visiblityAssert(true); + } + + [Test] + public void TestUndownloadableNoLink() + { + AddStep("set undownloadable beatmapset without link", () => container.BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = true, + }, + }, + }); + + visiblityAssert(true); + } + + + + [Test] + public void TestPartsRemovedWithLink() + { + AddStep("set parts-removed beatmapset with link", () => container.BeatmapSet = new BeatmapSetInfo { OnlineInfo = new BeatmapSetOnlineInfo { Availability = new BeatmapSetOnlineAvailability { DownloadDisabled = false, - ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", + ExternalLink = @"https://osu.ppy.sh", }, }, }); - AddAssert("is container still visible", () => container.Alpha == 1); + visiblityAssert(true); + } + + [Test] + public void TestNormal() + { AddStep("set normal beatmapset", () => container.BeatmapSet = new BeatmapSetInfo { - OnlineInfo = new BeatmapSetOnlineInfo(), + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = false, + }, + }, }); - AddAssert("is container hidden", () => container.Alpha == 0); + visiblityAssert(false); + } + + private void visiblityAssert(bool shown) + { + AddAssert($"is container {(shown ? "visible" : "hidden")}", () => container.Alpha == (shown ? 1 : 0)); } } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 2e68be981c..e365368c18 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -565,7 +565,7 @@ namespace osu.Game.Tests.Visual.Online downloadAssert(true); - AddStep(@"show undownloadable", () => + AddStep(@"show undownloadable (no link)", () => { overlay.ShowBeatmapSet(new BeatmapSetInfo { @@ -586,7 +586,6 @@ namespace osu.Game.Tests.Visual.Online Availability = new BeatmapSetOnlineAvailability { DownloadDisabled = true, - ExternalLink = @"https://gist.githubusercontent.com/peppy/99e6959772083cdfde8a/raw", }, Preview = @"https://b.ppy.sh/preview/53853.mp3", PlayCount = 436213, diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index cb9284a295..55ad70aec0 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -26,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; - bool unavailable = BeatmapSet?.OnlineInfo.Availability != null; + bool unavailable = (BeatmapSet?.OnlineInfo.Availability?.DownloadDisabled ?? false) || (BeatmapSet?.OnlineInfo.Availability?.ExternalLink != null); this.FadeTo(unavailable ? 1 : 0); linkContainer.Clear(); @@ -56,23 +56,22 @@ namespace osu.Game.Overlays.BeatmapSet RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, - Margin = new MarginPadding { Top = 10, Left = 5, Right = 20 }, + Padding = new MarginPadding(10), Children = new Drawable[] { - textContainer = new TextFlowContainer(t => { t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium); t.Margin = new MarginPadding { Horizontal = 5 }; }) + textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = 10 }, Colour = Color4.Orange, }, - linkContainer = new LinkFlowContainer(t => { t.Font = OsuFont.GetFont(size: 14); t.Margin = new MarginPadding { Horizontal = 5 }; }) + linkContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = 10 }, + Padding = new MarginPadding { Top = 10 }, }, }, }, From 4fba255bd93babdba8f78140e466d898ae6e70b3 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 17:56:40 +0300 Subject: [PATCH 37/67] Remove gap --- osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs index 553b081f28..665be4d075 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs @@ -52,8 +52,6 @@ namespace osu.Game.Tests.Visual.Online visiblityAssert(true); } - - [Test] public void TestPartsRemovedWithLink() { From a9f87e06f82a3a6b960e7f6136845bc378bae6c2 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Wed, 19 Jun 2019 19:08:18 +0300 Subject: [PATCH 38/67] Make field readonly --- osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs index 665be4d075..00ab89389e 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs @@ -10,7 +10,7 @@ namespace osu.Game.Tests.Visual.Online [TestFixture] public class TestSceneBeatmapNotAvailable : OsuTestScene { - BeatmapNotAvailable container; + private readonly BeatmapNotAvailable container; public TestSceneBeatmapNotAvailable() { From eb9022257db7483f0398aabd0ef43b9b8e5c5d7b Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 20 Jun 2019 18:57:52 +0300 Subject: [PATCH 39/67] Update direct panel test --- .../Visual/Online/TestSceneDirectPanel.cs | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs index a2767611ac..9667e5a752 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs @@ -23,16 +23,20 @@ namespace osu.Game.Tests.Visual.Online typeof(IconPill) }; - private BeatmapSetInfo getBeatmapSet(RulesetInfo ruleset, bool downloadable) + private BeatmapSetInfo getUndownloadableBeatmapSet(RulesetInfo ruleset) { var beatmap = CreateWorkingBeatmap(ruleset).BeatmapSetInfo; + beatmap.Metadata.Artist = "test"; + beatmap.Metadata.Title = "undownloadable"; + beatmap.Metadata.AuthorString = "test"; + beatmap.OnlineInfo.HasVideo = true; beatmap.OnlineInfo.HasStoryboard = true; beatmap.OnlineInfo.Availability = new BeatmapSetOnlineAvailability { - DownloadDisabled = !downloadable, - ExternalLink = "http://localhost", + DownloadDisabled = true, + ExternalLink = "http://osu.ppy.sh", }; return beatmap; @@ -47,31 +51,31 @@ namespace osu.Game.Tests.Visual.Online normal.OnlineInfo.HasVideo = true; normal.OnlineInfo.HasStoryboard = true; - var downloadable = getBeatmapSet(ruleset, true); - var undownloadable = getBeatmapSet(ruleset, false); - + var undownloadable = getUndownloadableBeatmapSet(ruleset); DirectPanel undownloadableGridPanel, undownloadableListPanel; - Child = new FillFlowContainer + Child = new BasicScrollContainer { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Padding = new MarginPadding(20), - Spacing = new Vector2(0, 20), - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer { - new DirectGridPanel(normal), - new DirectGridPanel(downloadable), - undownloadableGridPanel = new DirectGridPanel(undownloadable), - new DirectListPanel(normal), - new DirectListPanel(downloadable), - undownloadableListPanel = new DirectListPanel(undownloadable), + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Padding = new MarginPadding(20), + Spacing = new Vector2(0, 20), + Children = new Drawable[] + { + new DirectGridPanel(normal), + new DirectListPanel(normal), + undownloadableGridPanel = new DirectGridPanel(undownloadable), + undownloadableListPanel = new DirectListPanel(undownloadable), + }, }, }; - AddAssert("is download button disabled on last grid panel", () => !undownloadableGridPanel.DownloadButton.Enabled.Value); - AddAssert("is download button disabled on last list panel", () => !undownloadableListPanel.DownloadButton.Enabled.Value); + AddAssert("is download button disabled on second grid panel", () => !undownloadableGridPanel.DownloadButton.Enabled.Value); + AddAssert("is download button disabled on second list panel", () => !undownloadableListPanel.DownloadButton.Enabled.Value); } } } From d75481945379f8861b8e441b3da58c2c2f32eaeb Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 20 Jun 2019 19:09:40 +0300 Subject: [PATCH 40/67] Small changes --- .../Overlays/BeatmapSet/BeatmapNotAvailable.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 55ad70aec0..5eb48220c6 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -16,6 +16,9 @@ namespace osu.Game.Overlays.BeatmapSet { private BeatmapSetInfo beatmapSet; + private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability.DownloadDisabled ?? false; + private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability.ExternalLink); + public BeatmapSetInfo BeatmapSet { get => beatmapSet; @@ -26,12 +29,14 @@ namespace osu.Game.Overlays.BeatmapSet beatmapSet = value; - bool unavailable = (BeatmapSet?.OnlineInfo.Availability?.DownloadDisabled ?? false) || (BeatmapSet?.OnlineInfo.Availability?.ExternalLink != null); - this.FadeTo(unavailable ? 1 : 0); - linkContainer.Clear(); - if (unavailable) + + if (downloadDisabled || hasExternalLink) + { + Show(); updateText(); + } + else Hide(); } } @@ -80,11 +85,11 @@ namespace osu.Game.Overlays.BeatmapSet private void updateText() { - textContainer.Text = BeatmapSet.OnlineInfo.Availability.DownloadDisabled + textContainer.Text = downloadDisabled ? "This beatmap is currently not available for download." : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder."; - if (!string.IsNullOrEmpty(BeatmapSet.OnlineInfo.Availability.ExternalLink)) + if (hasExternalLink) linkContainer.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink); } } From 13578e5c2179352dd2b7f0056e965804ef3530e2 Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Thu, 20 Jun 2019 19:43:31 +0300 Subject: [PATCH 41/67] Add the null conditional operator back --- osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 5eb48220c6..0e51d473a5 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -16,8 +16,8 @@ namespace osu.Game.Overlays.BeatmapSet { private BeatmapSetInfo beatmapSet; - private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability.DownloadDisabled ?? false; - private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability.ExternalLink); + private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability?.DownloadDisabled ?? false; + private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability?.ExternalLink); public BeatmapSetInfo BeatmapSet { From 0cc7a604edb40b3e85cbf5e8c0cda8965380b7ff Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Fri, 21 Jun 2019 14:18:20 +0300 Subject: [PATCH 42/67] Update font sizes --- osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs index 0e51d473a5..44e29a5011 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs @@ -64,14 +64,14 @@ namespace osu.Game.Overlays.BeatmapSet Padding = new MarginPadding(10), Children = new Drawable[] { - textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium)) + textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Medium)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Colour = Color4.Orange, }, - linkContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) + linkContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 10)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, From bd842f2a8c0b2941e04851b5dc3e18510e349787 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Fri, 21 Jun 2019 16:38:16 +0300 Subject: [PATCH 43/67] Update tooltip text --- osu.Game/Overlays/Direct/DownloadButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 10e6f8a6e1..bb2c68a9a1 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -85,7 +85,7 @@ namespace osu.Game.Overlays.Direct if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) { Enabled.Value = false; - button.TooltipText = "Unavailable"; + button.TooltipText = "This beatmap is currently not available for download."; return; } From c76505c9c30530b7680e98d83e50b67ea4e69820 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Tue, 25 Jun 2019 03:21:55 +0300 Subject: [PATCH 44/67] Use test beatmap sets instead of real info --- .../Online/TestSceneBeatmapSetOverlay.cs | 341 +++--------------- 1 file changed, 46 insertions(+), 295 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index e365368c18..5539152598 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -417,305 +417,14 @@ namespace osu.Game.Tests.Visual.Online [Test] public void TestUnavailable() { - AddStep(@"show parts-removed", () => - { - overlay.ShowBeatmapSet(new BeatmapSetInfo - { - Metadata = new BeatmapMetadata - { - Title = @"Sakura Kagetsu", - Artist = @"AKITO", - Source = @"DJMAX", - Tags = @"J-Trance Pasonia", - Author = new User - { - Username = @"Kharl", - Id = 452, - }, - }, - OnlineInfo = new BeatmapSetOnlineInfo - { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = false, - ExternalLink = @"https://gist.githubusercontent.com/peppy/079dc3f77e316f9cd40077d411319a72/raw", - }, - Preview = @"https://b.ppy.sh/preview/119.mp3", - PlayCount = 626927, - FavouriteCount = 157, - Submitted = new DateTime(2007, 10, 24), - Ranked = new DateTime(2008, 4, 21), - Status = BeatmapSetOnlineStatus.Ranked, - BPM = 138, - Covers = new BeatmapSetOnlineCovers - { - Cover = @"https://assets.ppy.sh/beatmaps/119/covers/cover.jpg?1539847784", - }, - }, - Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }, - Beatmaps = new List - { - new BeatmapInfo - { - StarDifficulty = 1.51, - Version = "Easy", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 2, - OverallDifficulty = 1, - ApproachRate = 1, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 126000, - CircleCount = 371, - SliderCount = 35, - PlayCount = 84498, - PassCount = 37482, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 2.23, - Version = "Normal", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 5, - DrainRate = 4, - OverallDifficulty = 3, - ApproachRate = 3, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 126000, - CircleCount = 98, - SliderCount = 28, - PlayCount = 86427, - PassCount = 23273, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 2.83, - Version = "Hard", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 6, - DrainRate = 6, - OverallDifficulty = 6, - ApproachRate = 6, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 126000, - CircleCount = 139, - SliderCount = 37, - PlayCount = 206523, - PassCount = 44366, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 4.26, - Version = "Pasonia's Insane", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 6, - DrainRate = 6, - OverallDifficulty = 6, - ApproachRate = 6, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 126000, - CircleCount = 371, - SliderCount = 35, - PlayCount = 249479, - PassCount = 14042, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - }, - }, false); - }); - + AddStep(@"show parts-removed (has link)", () => overlay.ShowBeatmapSet(getTestUnavailableBeatmapSet(false, true), false)); downloadAssert(true); - AddStep(@"show undownloadable (no link)", () => - { - overlay.ShowBeatmapSet(new BeatmapSetInfo - { - Metadata = new BeatmapMetadata - { - Title = @"China Express", - Artist = @"Ryu*", - Source = @"REFLEC BEAT", - Tags = @"konami bemani lincle link iidx iidx18 iidx19 resort anthem plus la cataline mmzz", - Author = new User - { - Username = @"yeahyeahyeahhh", - Id = 58042, - }, - }, - OnlineInfo = new BeatmapSetOnlineInfo - { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = true, - }, - Preview = @"https://b.ppy.sh/preview/53853.mp3", - PlayCount = 436213, - FavouriteCount = 105, - Submitted = new DateTime(2012, 7, 1), - Ranked = new DateTime(2012, 7, 18), - Status = BeatmapSetOnlineStatus.Ranked, - BPM = 171, - Covers = new BeatmapSetOnlineCovers - { - Cover = @"https://assets.ppy.sh/beatmaps/53853/covers/cover.jpg?1456498562", - }, - }, - Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }, - Beatmaps = new List - { - new BeatmapInfo - { - StarDifficulty = 1.85, - Version = "Easy", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 3, - DrainRate = 2, - OverallDifficulty = 2, - ApproachRate = 3, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 95000, - CircleCount = 49, - SliderCount = 60, - PlayCount = 20308, - PassCount = 10233, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 2.36, - Version = "Normal", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 3, - DrainRate = 2, - OverallDifficulty = 2, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 96000, - CircleCount = 86, - SliderCount = 67, - PlayCount = 54015, - PassCount = 25603, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 4.42, - Version = "Hyper", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 7, - OverallDifficulty = 6, - ApproachRate = 8, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 96000, - CircleCount = 215, - SliderCount = 120, - PlayCount = 111400, - PassCount = 12583, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 5.05, - Version = "Another", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 7, - OverallDifficulty = 9, - ApproachRate = 9, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 96000, - CircleCount = 250, - SliderCount = 75, - PlayCount = 228253, - PassCount = 53037, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - }, - }, false); - }); - + AddStep(@"show undownloadable (no link)", () => overlay.ShowBeatmapSet(getTestUnavailableBeatmapSet(true, false), false)); downloadAssert(false); - } - private void downloadAssert(bool shown) - { - AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsContainer.Any() == shown); + AddStep(@"show undownloadable (has link)", () => overlay.ShowBeatmapSet(getTestUnavailableBeatmapSet(true, true), false)); + downloadAssert(false); } [Test] @@ -729,5 +438,47 @@ namespace osu.Game.Tests.Visual.Online { AddStep(@"show without reload", overlay.Show); } + + private void downloadAssert(bool shown) + { + AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsContainer.Any() == shown); + } + + private BeatmapSetInfo getTestUnavailableBeatmapSet(bool undownloadable, bool hasLink) => new BeatmapSetInfo + { + Metadata = new BeatmapMetadata + { + Title = undownloadable ? "undownloadable" : "parts-removed", + Artist = "test beatmapset", + AuthorString = "test", + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = undownloadable, + ExternalLink = hasLink ? "https://osu.ppy.sh" : null, + }, + Preview = @"https://b.ppy.sh/preview/1.mp3", + Covers = new BeatmapSetOnlineCovers(), + }, + Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }, + Beatmaps = new List + { + new BeatmapInfo + { + StarDifficulty = 1.23, + Version = "Test", + Ruleset = osuRuleset, + BaseDifficulty = new BeatmapDifficulty(), + OnlineInfo = new BeatmapOnlineInfo(), + Metrics = new BeatmapMetrics + { + Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), + Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), + }, + }, + }, + }; } } From 33fbf56b4c9f088bca1e6a35cfd609c3f5f18ed2 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 26 Jun 2019 05:01:29 +0300 Subject: [PATCH 45/67] Remove test beatmapsets and use existing set info --- .../Online/TestSceneBeatmapSetOverlay.cs | 67 ++++--------------- 1 file changed, 12 insertions(+), 55 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 5539152598..db2db2c6c9 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -42,7 +42,6 @@ namespace osu.Game.Tests.Visual.Online typeof(BeatmapNotAvailable), }; - private RulesetInfo osuRuleset; private RulesetInfo taikoRuleset; private RulesetInfo maniaRuleset; @@ -54,7 +53,6 @@ namespace osu.Game.Tests.Visual.Online [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { - osuRuleset = rulesets.GetRuleset(0); taikoRuleset = rulesets.GetRuleset(1); maniaRuleset = rulesets.GetRuleset(3); } @@ -241,10 +239,14 @@ namespace osu.Game.Tests.Visual.Online }, }, false); }); - + downloadAssert(true); + } - AddStep(@"show second", () => + [Test] + public void TestUnavailable() + { + AddStep(@"show undownloadable", () => { overlay.ShowBeatmapSet(new BeatmapSetInfo { @@ -261,6 +263,11 @@ namespace osu.Game.Tests.Visual.Online }, OnlineInfo = new BeatmapSetOnlineInfo { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = true, + ExternalLink = "https://osu.ppy.sh", + }, Preview = @"https://b.ppy.sh/preview/625493.mp3", PlayCount = 22996, FavouriteCount = 58, @@ -410,20 +417,7 @@ namespace osu.Game.Tests.Visual.Online }, }, false); }); - - downloadAssert(true); - } - - [Test] - public void TestUnavailable() - { - AddStep(@"show parts-removed (has link)", () => overlay.ShowBeatmapSet(getTestUnavailableBeatmapSet(false, true), false)); - downloadAssert(true); - - AddStep(@"show undownloadable (no link)", () => overlay.ShowBeatmapSet(getTestUnavailableBeatmapSet(true, false), false)); - downloadAssert(false); - - AddStep(@"show undownloadable (has link)", () => overlay.ShowBeatmapSet(getTestUnavailableBeatmapSet(true, true), false)); + downloadAssert(false); } @@ -443,42 +437,5 @@ namespace osu.Game.Tests.Visual.Online { AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsContainer.Any() == shown); } - - private BeatmapSetInfo getTestUnavailableBeatmapSet(bool undownloadable, bool hasLink) => new BeatmapSetInfo - { - Metadata = new BeatmapMetadata - { - Title = undownloadable ? "undownloadable" : "parts-removed", - Artist = "test beatmapset", - AuthorString = "test", - }, - OnlineInfo = new BeatmapSetOnlineInfo - { - Availability = new BeatmapSetOnlineAvailability - { - DownloadDisabled = undownloadable, - ExternalLink = hasLink ? "https://osu.ppy.sh" : null, - }, - Preview = @"https://b.ppy.sh/preview/1.mp3", - Covers = new BeatmapSetOnlineCovers(), - }, - Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }, - Beatmaps = new List - { - new BeatmapInfo - { - StarDifficulty = 1.23, - Version = "Test", - Ruleset = osuRuleset, - BaseDifficulty = new BeatmapDifficulty(), - OnlineInfo = new BeatmapOnlineInfo(), - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - }, - }; } } From 2e383a1f83597184358478fe5e6abfa23bef6faf Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 26 Jun 2019 05:17:28 +0300 Subject: [PATCH 46/67] Trim whitespaces --- osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index db2db2c6c9..910fc17fc3 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -239,7 +239,7 @@ namespace osu.Game.Tests.Visual.Online }, }, false); }); - + downloadAssert(true); } @@ -417,7 +417,7 @@ namespace osu.Game.Tests.Visual.Online }, }, false); }); - + downloadAssert(false); } From eaf6f6891de34f20d677590457c3e8170509030e Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 26 Jun 2019 05:22:08 +0300 Subject: [PATCH 47/67] Rename to DownloadButtonsContainer --- osu.Game/Overlays/BeatmapSet/Header.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index c2355ad8e0..e17e952df4 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -158,7 +158,7 @@ namespace osu.Game.Overlays.BeatmapSet Children = new Drawable[] { favouriteButton = new FavouriteButton(), - downloadButtonsContainer = new FillFlowContainer + DownloadButtonsContainer = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = buttons_height + buttons_spacing }, @@ -225,7 +225,7 @@ namespace osu.Game.Overlays.BeatmapSet loading.Show(); - downloadButtonsContainer.FadeOut(transition_duration); + DownloadButtonsContainer.FadeOut(transition_duration); favouriteButton.FadeOut(transition_duration); } else @@ -240,7 +240,7 @@ namespace osu.Game.Overlays.BeatmapSet onlineStatusPill.FadeIn(500, Easing.OutQuint); onlineStatusPill.Status = setInfo.NewValue.OnlineInfo.Status; - downloadButtonsContainer.FadeIn(transition_duration); + DownloadButtonsContainer.FadeIn(transition_duration); favouriteButton.FadeIn(transition_duration); updateDownloadButtons(); From 2e49b4ffcd8b6b03d2d8cc1e5db898f1db7081c2 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 26 Jun 2019 18:56:40 +0300 Subject: [PATCH 48/67] Update the component with an abstract RulesetSelector class --- .../Components/ProfileRulesetSelector.cs | 11 +---- .../Header/Components/RulesetTabItem.cs | 46 ++++++++++++------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs index b189878b0d..95065f2c72 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs @@ -12,10 +12,8 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header.Components { - public class ProfileRulesetSelector : TabControl + public class ProfileRulesetSelector : RulesetSelector { - protected override Dropdown CreateDropdown() => null; - protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value) { AccentColour = AccentColour @@ -48,13 +46,8 @@ namespace osu.Game.Overlays.Profile.Header.Components } [BackgroundDependencyLoader] - private void load(RulesetStore rulesets, OsuColour colours) + private void load(OsuColour colours) { - foreach (var r in rulesets.AvailableRulesets) - { - AddItem(r); - } - AccentColour = colours.Seafoam; } diff --git a/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs index 0a6f2f5123..0c49b3179c 100644 --- a/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs @@ -94,7 +94,8 @@ namespace osu.Game.Overlays.Profile.Header.Components { base.OnHover(e); - updateState(); + if (!Active.Value) + hoverAction(); return true; } @@ -103,29 +104,40 @@ namespace osu.Game.Overlays.Profile.Header.Components { base.OnHoverLost(e); - updateState(); + if (!Active.Value) + unhoverAction(); } - protected override void OnActivated() => updateState(); + protected override void OnActivated() + { + hoverAction(); + text.Font = text.Font.With(weight: FontWeight.Bold); + } - protected override void OnDeactivated() => updateState(); + protected override void OnDeactivated() + { + unhoverAction(); + text.Font = text.Font.With(weight: FontWeight.Medium); + } private void updateState() { - if (Active.Value || IsHovered) - { - text.FadeColour(Color4.White, 120, Easing.InQuad); - icon.FadeColour(Color4.White, 120, Easing.InQuad); - - if (Active.Value) - text.Font = text.Font.With(weight: FontWeight.Bold); - } + if (Active.Value) + OnActivated(); else - { - text.FadeColour(AccentColour, 120, Easing.InQuad); - icon.FadeColour(AccentColour, 120, Easing.InQuad); - text.Font = text.Font.With(weight: FontWeight.Medium); - } + OnDeactivated(); + } + + private void hoverAction() + { + text.FadeColour(Color4.White, 120, Easing.InQuad); + icon.FadeColour(Color4.White, 120, Easing.InQuad); + } + + private void unhoverAction() + { + text.FadeColour(AccentColour, 120, Easing.InQuad); + icon.FadeColour(AccentColour, 120, Easing.InQuad); } } } From 9ada4d68b170a75a56e42b63105a76221ade854d Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Wed, 26 Jun 2019 22:42:34 +0300 Subject: [PATCH 49/67] Make fields protected and expose them in tests --- .../Online/TestSceneBeatmapSetOverlay.cs | 11 +++++-- .../Visual/Online/TestSceneDirectPanel.cs | 31 ++++++++++++++++--- osu.Game/Overlays/BeatmapSet/Header.cs | 3 +- osu.Game/Overlays/BeatmapSetOverlay.cs | 2 +- osu.Game/Overlays/Direct/DirectGridPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectListPanel.cs | 2 +- osu.Game/Overlays/Direct/DirectPanel.cs | 3 +- 7 files changed, 41 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 910fc17fc3..e12299f291 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Online [TestFixture] public class TestSceneBeatmapSetOverlay : OsuTestScene { - private readonly BeatmapSetOverlay overlay; + private readonly TestBeatmapSetOverlay overlay; public override IReadOnlyList RequiredTypes => new[] { @@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual.Online public TestSceneBeatmapSetOverlay() { - Add(overlay = new BeatmapSetOverlay()); + Add(overlay = new TestBeatmapSetOverlay()); } [BackgroundDependencyLoader] @@ -435,7 +435,12 @@ namespace osu.Game.Tests.Visual.Online private void downloadAssert(bool shown) { - AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsContainer.Any() == shown); + AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.IsDownloadButtonsShown == shown); + } + + private class TestBeatmapSetOverlay : BeatmapSetOverlay + { + public bool IsDownloadButtonsShown => Header.DownloadButtonsContainer.Any(); } } } diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs index 9667e5a752..7a305f0328 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs @@ -52,7 +52,8 @@ namespace osu.Game.Tests.Visual.Online normal.OnlineInfo.HasStoryboard = true; var undownloadable = getUndownloadableBeatmapSet(ruleset); - DirectPanel undownloadableGridPanel, undownloadableListPanel; + TestDirectGridPanel undownloadableGridPanel; + TestDirectListPanel undownloadableListPanel; Child = new BasicScrollContainer { @@ -68,14 +69,34 @@ namespace osu.Game.Tests.Visual.Online { new DirectGridPanel(normal), new DirectListPanel(normal), - undownloadableGridPanel = new DirectGridPanel(undownloadable), - undownloadableListPanel = new DirectListPanel(undownloadable), + undownloadableGridPanel = new TestDirectGridPanel(undownloadable), + undownloadableListPanel = new TestDirectListPanel(undownloadable), }, }, }; - AddAssert("is download button disabled on second grid panel", () => !undownloadableGridPanel.DownloadButton.Enabled.Value); - AddAssert("is download button disabled on second list panel", () => !undownloadableListPanel.DownloadButton.Enabled.Value); + AddAssert("is download button disabled on second grid panel", () => !undownloadableGridPanel.IsDownloadButtonEnabled); + AddAssert("is download button disabled on second list panel", () => !undownloadableListPanel.IsDownloadButtonEnabled); + } + + private class TestDirectGridPanel : DirectGridPanel + { + public bool IsDownloadButtonEnabled => DownloadButton.Enabled.Value; + + public TestDirectGridPanel(BeatmapSetInfo beatmap) + : base(beatmap) + { + } + } + + private class TestDirectListPanel : DirectListPanel + { + public bool IsDownloadButtonEnabled => DownloadButton.Enabled.Value; + + public TestDirectListPanel(BeatmapSetInfo beatmap) + : base(beatmap) + { + } } } } diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index e17e952df4..b156fe9028 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -34,7 +34,8 @@ namespace osu.Game.Overlays.BeatmapSet private readonly BeatmapNotAvailable beatmapNotAvailable; private readonly BeatmapSetOnlineStatusPill onlineStatusPill; public Details Details; - public FillFlowContainer DownloadButtonsContainer; + + public readonly FillFlowContainer DownloadButtonsContainer; public readonly BeatmapPicker Picker; diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index e9ea8f7a55..821840ef95 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Overlays public const float TOP_PADDING = 25; public const float RIGHT_WIDTH = 275; - public readonly Header Header; + protected readonly Header Header; private RulesetStore rulesets; diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 9e7aa5372b..5ee00d94d4 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Direct private PlayButton playButton; private Box progressBar; - public override DownloadButton DownloadButton => downloadButton; + protected override DownloadButton DownloadButton => downloadButton; protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index 076fed19bd..c701002d2e 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Direct protected override bool FadePlayButton => false; - public override DownloadButton DownloadButton => downloadButton; + protected override DownloadButton DownloadButton => downloadButton; protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index c9fe4aaa05..c918a84ab0 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -34,7 +34,8 @@ namespace osu.Game.Overlays.Direct public PreviewTrack Preview => PlayButton.Preview; public Bindable PreviewPlaying => PlayButton.Playing; - public abstract DownloadButton DownloadButton { get; } + + protected abstract DownloadButton DownloadButton { get; } protected abstract PlayButton PlayButton { get; } protected abstract Box PreviewBar { get; } From 322d92d3e003a67418e281885396fcd21c4204e9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 11:40:22 +0900 Subject: [PATCH 50/67] Rename class to BeatmapAvailability --- ...mapNotAvailable.cs => TestSceneBeatmapAvailability.cs} | 8 ++++---- .../Visual/Online/TestSceneBeatmapSetOverlay.cs | 4 ++-- osu.Game/Online/Chat/ChannelManager.cs | 1 + .../{BeatmapNotAvailable.cs => BeatmapAvailability.cs} | 4 ++-- osu.Game/Overlays/BeatmapSet/Header.cs | 6 +++--- 5 files changed, 12 insertions(+), 11 deletions(-) rename osu.Game.Tests/Visual/Online/{TestSceneBeatmapNotAvailable.cs => TestSceneBeatmapAvailability.cs} (92%) rename osu.Game/Overlays/BeatmapSet/{BeatmapNotAvailable.cs => BeatmapAvailability.cs} (97%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs similarity index 92% rename from osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs rename to osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs index 00ab89389e..fe94165777 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapNotAvailable.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapAvailability.cs @@ -8,13 +8,13 @@ using osu.Game.Overlays.BeatmapSet; namespace osu.Game.Tests.Visual.Online { [TestFixture] - public class TestSceneBeatmapNotAvailable : OsuTestScene + public class TestSceneBeatmapAvailability : OsuTestScene { - private readonly BeatmapNotAvailable container; + private readonly BeatmapAvailability container; - public TestSceneBeatmapNotAvailable() + public TestSceneBeatmapAvailability() { - Add(container = new BeatmapNotAvailable()); + Add(container = new BeatmapAvailability()); } [Test] diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index e12299f291..c069197f94 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.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 NUnit.Framework; @@ -39,7 +39,7 @@ namespace osu.Game.Tests.Visual.Online typeof(Info), typeof(PreviewButton), typeof(SuccessRate), - typeof(BeatmapNotAvailable), + typeof(BeatmapAvailability), }; private RulesetInfo taikoRuleset; diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index 3af11ff20f..f722eb9e41 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -18,6 +18,7 @@ namespace osu.Game.Online.Chat /// /// Manages everything channel related /// + [Cached] public class ChannelManager : PollingComponent { /// diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs b/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs similarity index 97% rename from osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs rename to osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs index 44e29a5011..30c89e23d0 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapNotAvailable.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs @@ -12,7 +12,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.BeatmapSet { - public class BeatmapNotAvailable : Container + public class BeatmapAvailability : Container { private BeatmapSetInfo beatmapSet; @@ -43,7 +43,7 @@ namespace osu.Game.Overlays.BeatmapSet private readonly TextFlowContainer textContainer; private readonly LinkFlowContainer linkContainer; - public BeatmapNotAvailable() + public BeatmapAvailability() { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index b156fe9028..e02bf2be64 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.BeatmapSet private readonly UpdateableBeatmapSetCover cover; private readonly OsuSpriteText title, artist; private readonly AuthorInfo author; - private readonly BeatmapNotAvailable beatmapNotAvailable; + private readonly BeatmapAvailability beatmapAvailability; private readonly BeatmapSetOnlineStatusPill onlineStatusPill; public Details Details; @@ -150,7 +150,7 @@ namespace osu.Game.Overlays.BeatmapSet Margin = new MarginPadding { Top = 20 }, Child = author = new AuthorInfo(), }, - beatmapNotAvailable = new BeatmapNotAvailable(), + beatmapAvailability = new BeatmapAvailability(), new Container { RelativeSizeAxes = Axes.X, @@ -216,7 +216,7 @@ namespace osu.Game.Overlays.BeatmapSet BeatmapSet.BindValueChanged(setInfo => { - Picker.BeatmapSet = author.BeatmapSet = beatmapNotAvailable.BeatmapSet = Details.BeatmapSet = setInfo.NewValue; + Picker.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue; cover.BeatmapSet = setInfo.NewValue; if (setInfo.NewValue == null) From d6da21b0f0c75f6755a648aa88d97a1255f357ac Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:00:31 +0900 Subject: [PATCH 51/67] Tidy up fetch methods Anonymise some test data further --- .../Online/TestSceneBeatmapSetOverlay.cs | 20 ++++++++-------- osu.Game/Overlays/BeatmapSetOverlay.cs | 23 ++++++++----------- osu.Game/Overlays/Direct/DirectPanel.cs | 8 ++++--- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index c069197f94..fad5c56d43 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -76,21 +76,22 @@ namespace osu.Game.Tests.Visual.Online { overlay.ShowBeatmapSet(new BeatmapSetInfo { + OnlineBeatmapSetID = 1235, Metadata = new BeatmapMetadata { - Title = @"Lachryma ", - Artist = @"Kaneko Chiharu", - Source = @"SOUND VOLTEX III GRAVITY WARS", - Tags = @"sdvx grace the 5th kac original song contest konami bemani", + Title = @"an awesome beatmap", + Artist = @"naru narusegawa", + Source = @"hinata sou", + Tags = @"test tag tag more tag", Author = new User { - Username = @"Fresh Chicken", - Id = 3984370, + Username = @"BanchoBot", + Id = 3, }, }, OnlineInfo = new BeatmapSetOnlineInfo { - Preview = @"https://b.ppy.sh/preview/415886.mp3", + Preview = @"https://b.ppy.sh/preview/12345.mp3", PlayCount = 681380, FavouriteCount = 356, Submitted = new DateTime(2016, 2, 10), @@ -237,7 +238,7 @@ namespace osu.Game.Tests.Visual.Online }, }, }, - }, false); + }); }); downloadAssert(true); @@ -250,6 +251,7 @@ namespace osu.Game.Tests.Visual.Online { overlay.ShowBeatmapSet(new BeatmapSetInfo { + OnlineBeatmapSetID = 1234, Metadata = new BeatmapMetadata { Title = @"Soumatou Labyrinth", @@ -415,7 +417,7 @@ namespace osu.Game.Tests.Visual.Online }, }, }, - }, false); + }); }); downloadAssert(false); diff --git a/osu.Game/Overlays/BeatmapSetOverlay.cs b/osu.Game/Overlays/BeatmapSetOverlay.cs index 821840ef95..19f6a3f692 100644 --- a/osu.Game/Overlays/BeatmapSetOverlay.cs +++ b/osu.Game/Overlays/BeatmapSetOverlay.cs @@ -31,8 +31,6 @@ namespace osu.Game.Overlays private RulesetStore rulesets; - private readonly OsuScrollContainer scroll; - private readonly Bindable beatmapSet = new Bindable(); // receive input outside our bounds so we can trigger a close event on ourselves. @@ -40,6 +38,7 @@ namespace osu.Game.Overlays public BeatmapSetOverlay() { + OsuScrollContainer scroll; Info info; ScoresContainer scores; @@ -76,6 +75,8 @@ namespace osu.Game.Overlays { info.Beatmap = b.NewValue; scores.Beatmap = b.NewValue; + + scroll.ScrollToStart(); }; } @@ -119,18 +120,14 @@ namespace osu.Game.Overlays Show(); } - public void ShowBeatmapSet(BeatmapSetInfo set, bool refetch = true) + /// + /// Show an already fully-populated beatmap set. + /// + /// The set to show. + public void ShowBeatmapSet(BeatmapSetInfo set) { - // Re-fetching is the correct way forward. - if (refetch) - FetchAndShowBeatmapSet(set?.OnlineBeatmapSetID ?? 0); - else - { - beatmapSet.Value = set; - Show(); - } - - scroll.ScrollTo(0); + beatmapSet.Value = set; + Show(); } } } diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index c918a84ab0..584b25f83f 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.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; @@ -45,6 +46,8 @@ namespace osu.Game.Overlays.Direct protected DirectPanel(BeatmapSetInfo setInfo) { + Debug.Assert(setInfo.OnlineBeatmapSetID != null); + SetInfo = setInfo; } @@ -119,12 +122,11 @@ namespace osu.Game.Overlays.Direct protected override bool OnClick(ClickEvent e) { - ShowInformation(); + Debug.Assert(SetInfo.OnlineBeatmapSetID != null); + beatmapSetOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value); return true; } - protected void ShowInformation() => beatmapSetOverlay?.ShowBeatmapSet(SetInfo); - protected override void LoadComplete() { base.LoadComplete(); From cc9a7839c9d3242f8c044ea69c4a0861c6639f29 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:04:01 +0900 Subject: [PATCH 52/67] Fix layout regression --- osu.Game/Overlays/BeatmapSet/Header.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index abd643e5a2..bd6900016e 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -102,7 +102,8 @@ namespace osu.Game.Overlays.BeatmapSet }, new Container { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Top = 20, @@ -170,13 +171,14 @@ namespace osu.Game.Overlays.BeatmapSet }, }, }, - loading = new LoadingAnimation - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - } } }, + loading = new LoadingAnimation + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(1.5f), + }, new FillFlowContainer { Anchor = Anchor.BottomRight, From 32c3bee71b88926a115d16c3210abc01f2a8d279 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:11:04 +0900 Subject: [PATCH 53/67] Avoid public exposure --- .../Online/TestSceneBeatmapSetOverlay.cs | 4 ++-- osu.Game/Overlays/BeatmapSet/Header.cs | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index fad5c56d43..e50e30ae1d 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -437,12 +437,12 @@ namespace osu.Game.Tests.Visual.Online private void downloadAssert(bool shown) { - AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.IsDownloadButtonsShown == shown); + AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.DownloadButtonsVisible == shown); } private class TestBeatmapSetOverlay : BeatmapSetOverlay { - public bool IsDownloadButtonsShown => Header.DownloadButtonsContainer.Any(); + public bool DownloadButtonsVisible => Header.DownloadButtonsVisibile; } } } diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index bd6900016e..62384065ec 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.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.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -32,11 +33,12 @@ namespace osu.Game.Overlays.BeatmapSet private readonly UpdateableBeatmapSetCover cover; private readonly OsuSpriteText title, artist; private readonly AuthorInfo author; + private readonly FillFlowContainer downloadButtonsContainer; private readonly BeatmapAvailability beatmapAvailability; private readonly BeatmapSetOnlineStatusPill onlineStatusPill; public Details Details; - public readonly FillFlowContainer DownloadButtonsContainer; + public bool DownloadButtonsVisibile => downloadButtonsContainer.Any(); public readonly BeatmapPicker Picker; @@ -161,7 +163,7 @@ namespace osu.Game.Overlays.BeatmapSet Children = new Drawable[] { favouriteButton = new FavouriteButton(), - DownloadButtonsContainer = new FillFlowContainer + downloadButtonsContainer = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = buttons_height + buttons_spacing }, @@ -229,7 +231,7 @@ namespace osu.Game.Overlays.BeatmapSet loading.Show(); - DownloadButtonsContainer.FadeOut(transition_duration); + downloadButtonsContainer.FadeOut(transition_duration); favouriteButton.FadeOut(transition_duration); } else @@ -244,7 +246,7 @@ namespace osu.Game.Overlays.BeatmapSet onlineStatusPill.FadeIn(500, Easing.OutQuint); onlineStatusPill.Status = setInfo.NewValue.OnlineInfo.Status; - DownloadButtonsContainer.FadeIn(transition_duration); + downloadButtonsContainer.FadeIn(transition_duration); favouriteButton.FadeIn(transition_duration); updateDownloadButtons(); @@ -258,7 +260,7 @@ namespace osu.Game.Overlays.BeatmapSet if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) { - DownloadButtonsContainer.Clear(); + downloadButtonsContainer.Clear(); return; } @@ -266,7 +268,7 @@ namespace osu.Game.Overlays.BeatmapSet { case DownloadState.LocallyAvailable: // temporary for UX until new design is implemented. - DownloadButtonsContainer.Child = new Direct.DownloadButton(BeatmapSet.Value) + downloadButtonsContainer.Child = new Direct.DownloadButton(BeatmapSet.Value) { Width = 50, RelativeSizeAxes = Axes.Y @@ -276,13 +278,13 @@ namespace osu.Game.Overlays.BeatmapSet case DownloadState.Downloading: case DownloadState.Downloaded: // temporary to avoid showing two buttons for maps with novideo. will be fixed in new beatmap overlay design. - DownloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); break; default: - DownloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); + downloadButtonsContainer.Child = new DownloadButton(BeatmapSet.Value); if (BeatmapSet.Value.OnlineInfo.HasVideo) - DownloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); + downloadButtonsContainer.Add(new DownloadButton(BeatmapSet.Value, true)); break; } } From a4929f19e572d47fbd5b3888647e935d6428f298 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:17:28 +0900 Subject: [PATCH 54/67] Adjust background colour of non-loaded beatmap set cover to play better with black foreground elements --- osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs index c7c4c1fb1e..16eecb7198 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs @@ -2,9 +2,10 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osuTK.Graphics; +using osu.Game.Graphics; namespace osu.Game.Beatmaps.Drawables { @@ -49,7 +50,7 @@ namespace osu.Game.Beatmaps.Drawables Child = new Box { RelativeSizeAxes = Axes.Both, - Colour = Color4.Black, + Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.1f)), }; } From c49b8b1883037ca6970dd7dc20ee3dd1ac2075bb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:19:49 +0900 Subject: [PATCH 55/67] Remove accidental change --- osu.Game/Online/Chat/ChannelManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Online/Chat/ChannelManager.cs b/osu.Game/Online/Chat/ChannelManager.cs index f722eb9e41..3af11ff20f 100644 --- a/osu.Game/Online/Chat/ChannelManager.cs +++ b/osu.Game/Online/Chat/ChannelManager.cs @@ -18,7 +18,6 @@ namespace osu.Game.Online.Chat /// /// Manages everything channel related /// - [Cached] public class ChannelManager : PollingComponent { /// From cd6f452bfabd710b4ab50d52d13e2e7eb7f302f1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:22:38 +0900 Subject: [PATCH 56/67] Remove weird download button exposure --- osu.Game/Overlays/Direct/DirectGridPanel.cs | 5 ++--- osu.Game/Overlays/Direct/DirectListPanel.cs | 5 ++--- osu.Game/Overlays/Direct/DirectPanel.cs | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 5ee00d94d4..571fb40d39 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -25,11 +25,10 @@ namespace osu.Game.Overlays.Direct private const float vertical_padding = 5; private FillFlowContainer bottomPanel, statusContainer; - private DownloadButton downloadButton; + protected DownloadButton DownloadButton; private PlayButton playButton; private Box progressBar; - protected override DownloadButton DownloadButton => downloadButton; protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; @@ -157,7 +156,7 @@ namespace osu.Game.Overlays.Direct }, }, }, - downloadButton = new DownloadButton(SetInfo) + DownloadButton = new DownloadButton(SetInfo) { Size = new Vector2(50, 30), Margin = new MarginPadding(horizontal_padding), diff --git a/osu.Game/Overlays/Direct/DirectListPanel.cs b/osu.Game/Overlays/Direct/DirectListPanel.cs index c701002d2e..6f3b5bc5f1 100644 --- a/osu.Game/Overlays/Direct/DirectListPanel.cs +++ b/osu.Game/Overlays/Direct/DirectListPanel.cs @@ -27,13 +27,12 @@ namespace osu.Game.Overlays.Direct private const float height = 70; private FillFlowContainer statusContainer; - private DownloadButton downloadButton; + protected DownloadButton DownloadButton; private PlayButton playButton; private Box progressBar; protected override bool FadePlayButton => false; - protected override DownloadButton DownloadButton => downloadButton; protected override PlayButton PlayButton => playButton; protected override Box PreviewBar => progressBar; @@ -151,7 +150,7 @@ namespace osu.Game.Overlays.Direct Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, AutoSizeAxes = Axes.Both, - Child = downloadButton = new DownloadButton(SetInfo) + Child = DownloadButton = new DownloadButton(SetInfo) { Size = new Vector2(height - vertical_padding * 3), Margin = new MarginPadding { Left = vertical_padding * 2, Right = vertical_padding }, diff --git a/osu.Game/Overlays/Direct/DirectPanel.cs b/osu.Game/Overlays/Direct/DirectPanel.cs index 584b25f83f..8199d80528 100644 --- a/osu.Game/Overlays/Direct/DirectPanel.cs +++ b/osu.Game/Overlays/Direct/DirectPanel.cs @@ -36,7 +36,6 @@ namespace osu.Game.Overlays.Direct public PreviewTrack Preview => PlayButton.Preview; public Bindable PreviewPlaying => PlayButton.Playing; - protected abstract DownloadButton DownloadButton { get; } protected abstract PlayButton PlayButton { get; } protected abstract Box PreviewBar { get; } From be901294f7b0361c978d2590367b76b41cc3caec Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:33:14 +0900 Subject: [PATCH 57/67] Simplify text layout --- .../BeatmapSet/BeatmapAvailability.cs | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs b/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs index 30c89e23d0..00cc2ec605 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs @@ -19,29 +19,7 @@ namespace osu.Game.Overlays.BeatmapSet private bool downloadDisabled => BeatmapSet?.OnlineInfo.Availability?.DownloadDisabled ?? false; private bool hasExternalLink => !string.IsNullOrEmpty(BeatmapSet?.OnlineInfo.Availability?.ExternalLink); - public BeatmapSetInfo BeatmapSet - { - get => beatmapSet; - set - { - if (value == beatmapSet) - return; - - beatmapSet = value; - - linkContainer.Clear(); - - if (downloadDisabled || hasExternalLink) - { - Show(); - updateText(); - } - else Hide(); - } - } - - private readonly TextFlowContainer textContainer; - private readonly LinkFlowContainer linkContainer; + private readonly LinkFlowContainer textContainer; public BeatmapAvailability() { @@ -64,33 +42,51 @@ namespace osu.Game.Overlays.BeatmapSet Padding = new MarginPadding(10), Children = new Drawable[] { - textContainer = new TextFlowContainer(t => t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Medium)) + textContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) { Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Colour = Color4.Orange, - }, - linkContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 10)) - { - Direction = FillDirection.Full, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Top = 10 }, }, }, }, }; } + public BeatmapSetInfo BeatmapSet + { + get => beatmapSet; + set + { + if (value == beatmapSet) + return; + + beatmapSet = value; + + if (downloadDisabled || hasExternalLink) + { + Show(); + updateText(); + } + else + Hide(); + } + } + private void updateText() { - textContainer.Text = downloadDisabled + textContainer.Clear(); + + textContainer.AddParagraph(downloadDisabled ? "This beatmap is currently not available for download." - : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder."; + : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder.", t => t.Colour = Color4.Orange); if (hasExternalLink) - linkContainer.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink); + { + textContainer.NewParagraph(); + textContainer.NewParagraph(); + textContainer.AddLink("Check here for more information.", BeatmapSet.OnlineInfo.Availability.ExternalLink, creationParameters: t => t.Font = OsuFont.GetFont(size: 10)); + } } } } From a5ccfeb18ede010a35591e0e4e89ec1f00c3616b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:34:22 +0900 Subject: [PATCH 58/67] Remove unnecessary fill flow --- .../Overlays/BeatmapSet/BeatmapAvailability.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs b/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs index 00cc2ec605..896c646552 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapAvailability.cs @@ -34,21 +34,12 @@ namespace osu.Game.Overlays.BeatmapSet RelativeSizeAxes = Axes.Both, Colour = Color4.Black.Opacity(0.6f), }, - new FillFlowContainer + textContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) { + Direction = FillDirection.Full, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, Padding = new MarginPadding(10), - Children = new Drawable[] - { - textContainer = new LinkFlowContainer(t => t.Font = OsuFont.GetFont(size: 14)) - { - Direction = FillDirection.Full, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - }, - }, }, }; } @@ -56,6 +47,7 @@ namespace osu.Game.Overlays.BeatmapSet public BeatmapSetInfo BeatmapSet { get => beatmapSet; + set { if (value == beatmapSet) @@ -76,7 +68,6 @@ namespace osu.Game.Overlays.BeatmapSet private void updateText() { textContainer.Clear(); - textContainer.AddParagraph(downloadDisabled ? "This beatmap is currently not available for download." : "Portions of this beatmap have been removed at the request of the creator or a third-party rights holder.", t => t.Colour = Color4.Orange); From 3294464bc6e2d03b167ea238f5209cf9a780d159 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 12:47:05 +0900 Subject: [PATCH 59/67] Fix typo in variable --- osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs | 2 +- osu.Game/Overlays/BeatmapSet/Header.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index e50e30ae1d..00dc143019 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -442,7 +442,7 @@ namespace osu.Game.Tests.Visual.Online private class TestBeatmapSetOverlay : BeatmapSetOverlay { - public bool DownloadButtonsVisible => Header.DownloadButtonsVisibile; + public bool DownloadButtonsVisible => Header.DownloadButtonsVisible; } } } diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 62384065ec..1c1167d08e 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -38,7 +38,7 @@ namespace osu.Game.Overlays.BeatmapSet private readonly BeatmapSetOnlineStatusPill onlineStatusPill; public Details Details; - public bool DownloadButtonsVisibile => downloadButtonsContainer.Any(); + public bool DownloadButtonsVisible => downloadButtonsContainer.Any(); public readonly BeatmapPicker Picker; From c1277b5db2137bf0f3e601db70c88207ddb44688 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 27 Jun 2019 13:35:14 +0900 Subject: [PATCH 60/67] Test the download button directly for safety --- .../Online/TestSceneDirectDownloadButton.cs | 95 +++++++++++++++++++ .../Visual/Online/TestSceneDirectPanel.cs | 29 +----- osu.Game/Overlays/Direct/DirectGridPanel.cs | 3 +- osu.Game/Overlays/Direct/DownloadButton.cs | 13 +-- 4 files changed, 102 insertions(+), 38 deletions(-) create mode 100644 osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs new file mode 100644 index 0000000000..4c97c00a59 --- /dev/null +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs @@ -0,0 +1,95 @@ +// 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 NUnit.Framework; +using osu.Framework.Graphics; +using osu.Game.Beatmaps; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Osu; +using osuTK; +using DownloadButton = osu.Game.Overlays.Direct.DownloadButton; + +namespace osu.Game.Tests.Visual.Online +{ + public class TestSceneDirectDownloadButton : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(DownloadButton) + }; + + private TestDownloadButton downloadButton; + + [Test] + public void TestDownloadableBeatmap() + { + createButton(true); + assertEnabled(true); + } + + [Test] + public void TestUndownloadableBeatmap() + { + createButton(false); + assertEnabled(false); + } + + private void assertEnabled(bool enabled) + { + AddAssert($"button {(enabled ? "enabled" : "disabled")}", () => downloadButton.DownloadAllowed == enabled); + } + + private void createButton(bool downloadable) + { + AddStep("create button", () => + { + Child = downloadButton = new TestDownloadButton(downloadable ? getDownloadableBeatmapSet() : getUndownloadableBeatmapSet()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(75, 50), + }; + }); + } + + private BeatmapSetInfo getDownloadableBeatmapSet() + { + var normal = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo; + normal.OnlineInfo.HasVideo = true; + normal.OnlineInfo.HasStoryboard = true; + + return normal; + } + + private BeatmapSetInfo getUndownloadableBeatmapSet() + { + var beatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).BeatmapSetInfo; + beatmap.Metadata.Artist = "test"; + beatmap.Metadata.Title = "undownloadable"; + beatmap.Metadata.AuthorString = "test"; + + beatmap.OnlineInfo.HasVideo = true; + beatmap.OnlineInfo.HasStoryboard = true; + + beatmap.OnlineInfo.Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = true, + ExternalLink = "http://osu.ppy.sh", + }; + + return beatmap; + } + + private class TestDownloadButton : DownloadButton + { + public new bool DownloadAllowed => base.DownloadAllowed; + + public TestDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) + : base(beatmapSet, noVideo) + { + } + } + } +} diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs index 7a305f0328..051724579b 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs @@ -52,8 +52,6 @@ namespace osu.Game.Tests.Visual.Online normal.OnlineInfo.HasStoryboard = true; var undownloadable = getUndownloadableBeatmapSet(ruleset); - TestDirectGridPanel undownloadableGridPanel; - TestDirectListPanel undownloadableListPanel; Child = new BasicScrollContainer { @@ -69,34 +67,11 @@ namespace osu.Game.Tests.Visual.Online { new DirectGridPanel(normal), new DirectListPanel(normal), - undownloadableGridPanel = new TestDirectGridPanel(undownloadable), - undownloadableListPanel = new TestDirectListPanel(undownloadable), + new DirectGridPanel(undownloadable), + new DirectListPanel(undownloadable), }, }, }; - - AddAssert("is download button disabled on second grid panel", () => !undownloadableGridPanel.IsDownloadButtonEnabled); - AddAssert("is download button disabled on second list panel", () => !undownloadableListPanel.IsDownloadButtonEnabled); - } - - private class TestDirectGridPanel : DirectGridPanel - { - public bool IsDownloadButtonEnabled => DownloadButton.Enabled.Value; - - public TestDirectGridPanel(BeatmapSetInfo beatmap) - : base(beatmap) - { - } - } - - private class TestDirectListPanel : DirectListPanel - { - public bool IsDownloadButtonEnabled => DownloadButton.Enabled.Value; - - public TestDirectListPanel(BeatmapSetInfo beatmap) - : base(beatmap) - { - } } } } diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 571fb40d39..5756a4593d 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -25,7 +25,6 @@ namespace osu.Game.Overlays.Direct private const float vertical_padding = 5; private FillFlowContainer bottomPanel, statusContainer; - protected DownloadButton DownloadButton; private PlayButton playButton; private Box progressBar; @@ -156,7 +155,7 @@ namespace osu.Game.Overlays.Direct }, }, }, - DownloadButton = new DownloadButton(SetInfo) + new DownloadButton(SetInfo) { Size = new Vector2(50, 30), Margin = new MarginPadding(horizontal_padding), diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 1225eef8d8..25cdddd3ae 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -2,7 +2,6 @@ // 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.Shapes; using osu.Framework.Graphics.Sprites; @@ -17,19 +16,17 @@ namespace osu.Game.Overlays.Direct { public class DownloadButton : BeatmapDownloadTrackingComposite { + protected bool DownloadAllowed => button.Enabled.Value; + private readonly bool noVideo; private readonly SpriteIcon icon; private readonly SpriteIcon checkmark; private readonly Box background; private OsuColour colours; - private readonly ShakeContainer shakeContainer; - private readonly OsuAnimatedButton button; - public readonly BindableBool Enabled = new BindableBool(true); - public DownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) : base(beatmapSet) { @@ -66,8 +63,6 @@ namespace osu.Game.Overlays.Direct } } }; - - Enabled.BindTo(button.Enabled); } protected override void LoadComplete() @@ -78,14 +73,14 @@ namespace osu.Game.Overlays.Direct FinishTransforms(true); } - [BackgroundDependencyLoader(permitNulls: true)] + [BackgroundDependencyLoader(true)] private void load(OsuColour colours, OsuGame game, BeatmapManager beatmaps) { this.colours = colours; if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false) { - Enabled.Value = false; + button.Enabled.Value = false; button.TooltipText = "This beatmap is currently not available for download."; return; } From 9e2e393ab7a29172bc8ae53c42373740e9703365 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 27 Jun 2019 13:38:21 +0900 Subject: [PATCH 61/67] DownloadAllowed -> DownloadEnabled --- .../Visual/Online/TestSceneDirectDownloadButton.cs | 7 +++---- osu.Game/Overlays/Direct/DownloadButton.cs | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs index 4c97c00a59..ceb19a3ec6 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectDownloadButton.cs @@ -6,10 +6,9 @@ using System.Collections.Generic; using NUnit.Framework; using osu.Framework.Graphics; using osu.Game.Beatmaps; -using osu.Game.Rulesets; +using osu.Game.Overlays.Direct; using osu.Game.Rulesets.Osu; using osuTK; -using DownloadButton = osu.Game.Overlays.Direct.DownloadButton; namespace osu.Game.Tests.Visual.Online { @@ -38,7 +37,7 @@ namespace osu.Game.Tests.Visual.Online private void assertEnabled(bool enabled) { - AddAssert($"button {(enabled ? "enabled" : "disabled")}", () => downloadButton.DownloadAllowed == enabled); + AddAssert($"button {(enabled ? "enabled" : "disabled")}", () => downloadButton.DownloadEnabled == enabled); } private void createButton(bool downloadable) @@ -84,7 +83,7 @@ namespace osu.Game.Tests.Visual.Online private class TestDownloadButton : DownloadButton { - public new bool DownloadAllowed => base.DownloadAllowed; + public new bool DownloadEnabled => base.DownloadEnabled; public TestDownloadButton(BeatmapSetInfo beatmapSet, bool noVideo = false) : base(beatmapSet, noVideo) diff --git a/osu.Game/Overlays/Direct/DownloadButton.cs b/osu.Game/Overlays/Direct/DownloadButton.cs index 25cdddd3ae..81709187e7 100644 --- a/osu.Game/Overlays/Direct/DownloadButton.cs +++ b/osu.Game/Overlays/Direct/DownloadButton.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Direct { public class DownloadButton : BeatmapDownloadTrackingComposite { - protected bool DownloadAllowed => button.Enabled.Value; + protected bool DownloadEnabled => button.Enabled.Value; private readonly bool noVideo; private readonly SpriteIcon icon; From e78ecb9757e431cc8c536d881e7635e22805b864 Mon Sep 17 00:00:00 2001 From: iiSaLMaN Date: Thu, 27 Jun 2019 07:48:57 +0300 Subject: [PATCH 62/67] More anonymising in tests --- .../Online/TestSceneBeatmapSetOverlay.cs | 303 +++--------------- .../Visual/Online/TestSceneDirectPanel.cs | 53 ++- 2 files changed, 82 insertions(+), 274 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs index 00dc143019..c494f5ef33 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapSetOverlay.cs @@ -92,144 +92,37 @@ namespace osu.Game.Tests.Visual.Online OnlineInfo = new BeatmapSetOnlineInfo { Preview = @"https://b.ppy.sh/preview/12345.mp3", - PlayCount = 681380, - FavouriteCount = 356, - Submitted = new DateTime(2016, 2, 10), - Ranked = new DateTime(2016, 6, 19), - Status = BeatmapSetOnlineStatus.Ranked, - BPM = 236, + PlayCount = 123, + FavouriteCount = 456, + Submitted = DateTime.Now, + Ranked = DateTime.Now, + BPM = 111, HasVideo = true, - Covers = new BeatmapSetOnlineCovers - { - Cover = @"https://assets.ppy.sh/beatmaps/415886/covers/cover.jpg?1465651778", - }, + HasStoryboard = true, + Covers = new BeatmapSetOnlineCovers(), }, Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }, Beatmaps = new List { new BeatmapInfo { - StarDifficulty = 1.36, - Version = @"BASIC", + StarDifficulty = 9.99, + Version = @"TEST", Ruleset = maniaRuleset, BaseDifficulty = new BeatmapDifficulty { - CircleSize = 4, - DrainRate = 6.5f, - OverallDifficulty = 6.5f, - ApproachRate = 5, + CircleSize = 1, + DrainRate = 2.3f, + OverallDifficulty = 4.5f, + ApproachRate = 6, }, OnlineInfo = new BeatmapOnlineInfo { - Length = 115000, - CircleCount = 265, - SliderCount = 71, - PlayCount = 47906, - PassCount = 19899, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 2.22, - Version = @"NOVICE", - Ruleset = maniaRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 7, - OverallDifficulty = 7, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 118000, - CircleCount = 592, - SliderCount = 62, - PlayCount = 162021, - PassCount = 72116, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 3.49, - Version = @"ADVANCED", - Ruleset = maniaRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 7.5f, - OverallDifficulty = 7.5f, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 118000, - CircleCount = 1042, - SliderCount = 79, - PlayCount = 225178, - PassCount = 73001, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 4.24, - Version = @"EXHAUST", - Ruleset = maniaRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 8, - OverallDifficulty = 8, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 118000, - CircleCount = 1352, - SliderCount = 69, - PlayCount = 131545, - PassCount = 42703, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 5.26, - Version = @"GRAVITY", - Ruleset = maniaRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 4, - DrainRate = 8.5f, - OverallDifficulty = 8.5f, - ApproachRate = 5, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 118000, - CircleCount = 1730, - SliderCount = 115, - PlayCount = 117673, - PassCount = 24241, + Length = 456000, + CircleCount = 111, + SliderCount = 12, + PlayCount = 222, + PassCount = 21, }, Metrics = new BeatmapMetrics { @@ -245,7 +138,7 @@ namespace osu.Game.Tests.Visual.Online } [Test] - public void TestUnavailable() + public void TestAvailability() { AddStep(@"show undownloadable", () => { @@ -254,13 +147,14 @@ namespace osu.Game.Tests.Visual.Online OnlineBeatmapSetID = 1234, Metadata = new BeatmapMetadata { - Title = @"Soumatou Labyrinth", - Artist = @"Yunomi with Momobako&miko", - Tags = @"mmbk.com yuzu__rinrin charlotte", + Title = @"undownloadable beatmap", + Artist = @"no one", + Source = @"some source", + Tags = @"another test tag tag more test tags", Author = new User { - Username = @"komasy", - Id = 1980256, + Username = @"BanchoBot", + Id = 3, }, }, OnlineInfo = new BeatmapSetOnlineInfo @@ -270,145 +164,38 @@ namespace osu.Game.Tests.Visual.Online DownloadDisabled = true, ExternalLink = "https://osu.ppy.sh", }, - Preview = @"https://b.ppy.sh/preview/625493.mp3", - PlayCount = 22996, - FavouriteCount = 58, - Submitted = new DateTime(2016, 6, 11), - Ranked = new DateTime(2016, 7, 12), - Status = BeatmapSetOnlineStatus.Pending, - BPM = 160, - HasVideo = false, - Covers = new BeatmapSetOnlineCovers - { - Cover = @"https://assets.ppy.sh/beatmaps/625493/covers/cover.jpg?1499167472", - }, + Preview = @"https://b.ppy.sh/preview/1234.mp3", + PlayCount = 123, + FavouriteCount = 456, + Submitted = DateTime.Now, + Ranked = DateTime.Now, + BPM = 111, + HasVideo = true, + HasStoryboard = true, + Covers = new BeatmapSetOnlineCovers(), }, Metrics = new BeatmapSetMetrics { Ratings = Enumerable.Range(0, 11).ToArray() }, Beatmaps = new List { new BeatmapInfo { - StarDifficulty = 1.40, - Version = @"yzrin's Kantan", + StarDifficulty = 5.67, + Version = @"ANOTHER TEST", Ruleset = taikoRuleset, BaseDifficulty = new BeatmapDifficulty { - CircleSize = 2, - DrainRate = 7, - OverallDifficulty = 3, - ApproachRate = 10, + CircleSize = 9, + DrainRate = 8, + OverallDifficulty = 7, + ApproachRate = 6, }, OnlineInfo = new BeatmapOnlineInfo { - Length = 193000, - CircleCount = 262, - SliderCount = 0, - PlayCount = 3952, - PassCount = 1373, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 2.23, - Version = @"Futsuu", - Ruleset = taikoRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 2, - DrainRate = 6, - OverallDifficulty = 4, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - CircleCount = 464, - SliderCount = 0, - PlayCount = 4833, - PassCount = 920, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 3.19, - Version = @"Muzukashii", - Ruleset = taikoRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 2, - DrainRate = 6, - OverallDifficulty = 5, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - CircleCount = 712, - SliderCount = 0, - PlayCount = 4405, - PassCount = 854, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 3.97, - Version = @"Charlotte's Oni", - Ruleset = taikoRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 5, - DrainRate = 6, - OverallDifficulty = 5.5f, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - CircleCount = 943, - SliderCount = 0, - PlayCount = 3950, - PassCount = 693, - }, - Metrics = new BeatmapMetrics - { - Fails = Enumerable.Range(1, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(-2, 100).Select(i => i % 12 - 6).ToArray(), - }, - }, - new BeatmapInfo - { - StarDifficulty = 5.08, - Version = @"Labyrinth Oni", - Ruleset = taikoRuleset, - BaseDifficulty = new BeatmapDifficulty - { - CircleSize = 5, - DrainRate = 5, - OverallDifficulty = 6, - ApproachRate = 10, - }, - OnlineInfo = new BeatmapOnlineInfo - { - Length = 193000, - CircleCount = 1068, - SliderCount = 0, - PlayCount = 5856, - PassCount = 1207, + Length = 123000, + CircleCount = 123, + SliderCount = 45, + PlayCount = 567, + PassCount = 89, }, Metrics = new BeatmapMetrics { diff --git a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs index 7a305f0328..027d9a3a75 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneDirectPanel.cs @@ -10,6 +10,7 @@ using osu.Game.Beatmaps; using osu.Game.Overlays.Direct; using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; +using osu.Game.Users; using osuTK; namespace osu.Game.Tests.Visual.Online @@ -23,24 +24,44 @@ namespace osu.Game.Tests.Visual.Online typeof(IconPill) }; - private BeatmapSetInfo getUndownloadableBeatmapSet(RulesetInfo ruleset) + private BeatmapSetInfo getUndownloadableBeatmapSet(RulesetInfo ruleset) => new BeatmapSetInfo { - var beatmap = CreateWorkingBeatmap(ruleset).BeatmapSetInfo; - beatmap.Metadata.Artist = "test"; - beatmap.Metadata.Title = "undownloadable"; - beatmap.Metadata.AuthorString = "test"; - - beatmap.OnlineInfo.HasVideo = true; - beatmap.OnlineInfo.HasStoryboard = true; - - beatmap.OnlineInfo.Availability = new BeatmapSetOnlineAvailability + OnlineBeatmapSetID = 123, + Metadata = new BeatmapMetadata { - DownloadDisabled = true, - ExternalLink = "http://osu.ppy.sh", - }; - - return beatmap; - } + Title = "undownloadable beatmap", + Artist = "test", + Source = "more tests", + Author = new User + { + Username = "BanchoBot", + Id = 3, + }, + }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Availability = new BeatmapSetOnlineAvailability + { + DownloadDisabled = true, + }, + Preview = @"https://b.ppy.sh/preview/12345.mp3", + PlayCount = 123, + FavouriteCount = 456, + BPM = 111, + HasVideo = true, + HasStoryboard = true, + Covers = new BeatmapSetOnlineCovers(), + }, + Beatmaps = new List + { + new BeatmapInfo + { + Ruleset = ruleset, + Version = "Test", + StarDifficulty = 6.42, + } + } + }; [BackgroundDependencyLoader] private void load() From 803198ff209b1591868dc4c94cb129d6486fdeec Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 27 Jun 2019 14:53:18 +0900 Subject: [PATCH 63/67] Gamemode -> Ruleset --- .../Online/TestSceneProfileRulesetSelector.cs | 14 ++++++++----- .../Components/ProfileRulesetSelector.cs | 20 +++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs index 687cbbebad..37adc6eb68 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs @@ -7,6 +7,10 @@ using osu.Game.Overlays.Profile.Header.Components; using osuTK.Graphics; using System; using System.Collections.Generic; +using osu.Game.Rulesets.Catch; +using osu.Game.Rulesets.Mania; +using osu.Game.Rulesets.Osu; +using osu.Game.Rulesets.Taiko; namespace osu.Game.Tests.Visual.Online { @@ -28,11 +32,11 @@ namespace osu.Game.Tests.Visual.Online Origin = Anchor.Centre, }; - AddStep("set osu! as default", () => selector.SetDefaultGamemode("osu")); - AddStep("set mania as default", () => selector.SetDefaultGamemode("mania")); - AddStep("set taiko as default", () => selector.SetDefaultGamemode("taiko")); - AddStep("set catch as default", () => selector.SetDefaultGamemode("fruits")); - AddStep("select default gamemode", selector.SelectDefaultGamemode); + 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("select default ruleset", selector.SelectDefaultRuleset); AddStep("set random colour", () => selector.AccentColour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)); } diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs index 95065f2c72..87b785b906 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs @@ -14,11 +14,6 @@ namespace osu.Game.Overlays.Profile.Header.Components { public class ProfileRulesetSelector : RulesetSelector { - protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value) - { - AccentColour = AccentColour - }; - private Color4 accentColour = Color4.White; public Color4 AccentColour @@ -51,16 +46,21 @@ namespace osu.Game.Overlays.Profile.Header.Components AccentColour = colours.Seafoam; } - public void SetDefaultGamemode(string gamemode) + protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value) { + AccentColour = AccentColour + }; + + public void SetDefaultRuleset(RulesetInfo ruleset) + { + // Todo: This method shouldn't exist, but bindables don't provide the concept of observing a change to the default value foreach (TabItem tabItem in TabContainer) - { - ((RulesetTabItem)tabItem).IsDefault = ((RulesetTabItem)tabItem).Value.ShortName == gamemode; - } + ((RulesetTabItem)tabItem).IsDefault = ((RulesetTabItem)tabItem).Value.ID == ruleset.ID; } - public void SelectDefaultGamemode() + public void SelectDefaultRuleset() { + // Todo: This method shouldn't exist, but bindables don't provide the concept of observing a change to the default value foreach (TabItem tabItem in TabContainer) { if (((RulesetTabItem)tabItem).IsDefault) From 7f5587d894d7fe5ac805d349c781374c65060175 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 27 Jun 2019 14:54:31 +0900 Subject: [PATCH 64/67] RulesetTabItem -> ProfileRulesetTabItem --- .../Visual/Online/TestSceneProfileRulesetSelector.cs | 2 +- .../Header/Components/ProfileRulesetSelector.cs | 10 +++++----- .../{RulesetTabItem.cs => ProfileRulesetTabItem.cs} | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename osu.Game/Overlays/Profile/Header/Components/{RulesetTabItem.cs => ProfileRulesetTabItem.cs} (97%) diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs index 37adc6eb68..ce484f72bb 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs @@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Online public override IReadOnlyList RequiredTypes => new[] { typeof(ProfileRulesetSelector), - typeof(RulesetTabItem), + typeof(ProfileRulesetTabItem), }; public TestSceneProfileRulesetSelector() diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs index 87b785b906..cea16a918b 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs @@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Profile.Header.Components foreach (TabItem tabItem in TabContainer) { - ((RulesetTabItem)tabItem).AccentColour = value; + ((ProfileRulesetTabItem)tabItem).AccentColour = value; } } } @@ -46,7 +46,7 @@ namespace osu.Game.Overlays.Profile.Header.Components AccentColour = colours.Seafoam; } - protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value) + protected override TabItem CreateTabItem(RulesetInfo value) => new ProfileRulesetTabItem(value) { AccentColour = AccentColour }; @@ -55,7 +55,7 @@ namespace osu.Game.Overlays.Profile.Header.Components { // Todo: This method shouldn't exist, but bindables don't provide the concept of observing a change to the default value foreach (TabItem tabItem in TabContainer) - ((RulesetTabItem)tabItem).IsDefault = ((RulesetTabItem)tabItem).Value.ID == ruleset.ID; + ((ProfileRulesetTabItem)tabItem).IsDefault = ((ProfileRulesetTabItem)tabItem).Value.ID == ruleset.ID; } public void SelectDefaultRuleset() @@ -63,9 +63,9 @@ namespace osu.Game.Overlays.Profile.Header.Components // Todo: This method shouldn't exist, but bindables don't provide the concept of observing a change to the default value foreach (TabItem tabItem in TabContainer) { - if (((RulesetTabItem)tabItem).IsDefault) + if (((ProfileRulesetTabItem)tabItem).IsDefault) { - Current.Value = ((RulesetTabItem)tabItem).Value; + Current.Value = ((ProfileRulesetTabItem)tabItem).Value; return; } } diff --git a/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs similarity index 97% rename from osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs rename to osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs index 0c49b3179c..a1ee8a09a7 100644 --- a/osu.Game/Overlays/Profile/Header/Components/RulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs @@ -15,7 +15,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header.Components { - public class RulesetTabItem : TabItem + public class ProfileRulesetTabItem : TabItem { private readonly OsuSpriteText text; private readonly SpriteIcon icon; @@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Profile.Header.Components } } - public RulesetTabItem(RulesetInfo value) + public ProfileRulesetTabItem(RulesetInfo value) : base(value) { AutoSizeAxes = Axes.Both; From b397652af4a08870262c94eaf41d83b9e59f1ea0 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 27 Jun 2019 15:02:26 +0900 Subject: [PATCH 65/67] Remove ability to set arbitrary accent colours --- .../Online/TestSceneProfileRulesetSelector.cs | 4 --- .../Components/ProfileRulesetSelector.cs | 32 ++++++------------- .../Components/ProfileRulesetTabItem.cs | 2 +- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs index ce484f72bb..c344cb9598 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileRulesetSelector.cs @@ -2,9 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Graphics; -using osu.Framework.MathUtils; using osu.Game.Overlays.Profile.Header.Components; -using osuTK.Graphics; using System; using System.Collections.Generic; using osu.Game.Rulesets.Catch; @@ -37,8 +35,6 @@ namespace osu.Game.Tests.Visual.Online AddStep("set taiko as default", () => selector.SetDefaultRuleset(new TaikoRuleset().RulesetInfo)); AddStep("set catch as default", () => selector.SetDefaultRuleset(new CatchRuleset().RulesetInfo)); AddStep("select default ruleset", selector.SelectDefaultRuleset); - - AddStep("set random colour", () => selector.AccentColour = new Color4(RNG.NextSingle(), RNG.NextSingle(), RNG.NextSingle(), 1)); } } } diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs index cea16a918b..b6112a6501 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetSelector.cs @@ -16,23 +16,6 @@ namespace osu.Game.Overlays.Profile.Header.Components { private Color4 accentColour = Color4.White; - public Color4 AccentColour - { - get => accentColour; - set - { - if (accentColour == value) - return; - - accentColour = value; - - foreach (TabItem tabItem in TabContainer) - { - ((ProfileRulesetTabItem)tabItem).AccentColour = value; - } - } - } - public ProfileRulesetSelector() { TabContainer.Masking = false; @@ -43,13 +26,11 @@ namespace osu.Game.Overlays.Profile.Header.Components [BackgroundDependencyLoader] private void load(OsuColour colours) { - AccentColour = colours.Seafoam; - } + accentColour = colours.Seafoam; - protected override TabItem CreateTabItem(RulesetInfo value) => new ProfileRulesetTabItem(value) - { - AccentColour = AccentColour - }; + foreach (TabItem tabItem in TabContainer) + ((ProfileRulesetTabItem)tabItem).AccentColour = accentColour; + } public void SetDefaultRuleset(RulesetInfo ruleset) { @@ -71,6 +52,11 @@ namespace osu.Game.Overlays.Profile.Header.Components } } + protected override TabItem CreateTabItem(RulesetInfo value) => new ProfileRulesetTabItem(value) + { + AccentColour = accentColour + }; + protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer { Direction = FillDirection.Horizontal, diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs index a1ee8a09a7..63f7783451 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs @@ -15,7 +15,7 @@ using osuTK.Graphics; namespace osu.Game.Overlays.Profile.Header.Components { - public class ProfileRulesetTabItem : TabItem + public class ProfileRulesetTabItem : TabItem, IHasAccentColour { private readonly OsuSpriteText text; private readonly SpriteIcon icon; From 25499f74a721e7040f79e6182d6292ae996cdb27 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 15:31:36 +0900 Subject: [PATCH 66/67] Remove redundant font set --- .../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 63f7783451..fdd05705a9 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.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 osu.Framework.Graphics; @@ -73,7 +73,6 @@ namespace osu.Game.Overlays.Profile.Header.Components Origin = Anchor.Centre, Anchor = Anchor.Centre, Text = value.Name, - Font = OsuFont.GetFont() }, icon = new SpriteIcon { From d6c28dc6d71e79baa30d9ebb220386e1abab407a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 27 Jun 2019 15:31:47 +0900 Subject: [PATCH 67/67] Simplify and fix state management --- .../Components/ProfileRulesetTabItem.cs | 49 ++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs index fdd05705a9..b5170ea3a2 100644 --- a/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.cs +++ b/osu.Game/Overlays/Profile/Header/Components/ProfileRulesetTabItem.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 osu.Framework.Graphics; @@ -92,51 +92,34 @@ namespace osu.Game.Overlays.Profile.Header.Components protected override bool OnHover(HoverEvent e) { base.OnHover(e); - - if (!Active.Value) - hoverAction(); - + updateState(); return true; } protected override void OnHoverLost(HoverLostEvent e) { base.OnHoverLost(e); - - if (!Active.Value) - unhoverAction(); + updateState(); } - protected override void OnActivated() - { - hoverAction(); - text.Font = text.Font.With(weight: FontWeight.Bold); - } + protected override void OnActivated() => updateState(); - protected override void OnDeactivated() - { - unhoverAction(); - text.Font = text.Font.With(weight: FontWeight.Medium); - } + protected override void OnDeactivated() => updateState(); private void updateState() { - if (Active.Value) - OnActivated(); + text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); + + if (IsHovered || Active.Value) + { + text.FadeColour(Color4.White, 120, Easing.InQuad); + icon.FadeColour(Color4.White, 120, Easing.InQuad); + } else - OnDeactivated(); - } - - private void hoverAction() - { - text.FadeColour(Color4.White, 120, Easing.InQuad); - icon.FadeColour(Color4.White, 120, Easing.InQuad); - } - - private void unhoverAction() - { - text.FadeColour(AccentColour, 120, Easing.InQuad); - icon.FadeColour(AccentColour, 120, Easing.InQuad); + { + text.FadeColour(AccentColour, 120, Easing.InQuad); + icon.FadeColour(AccentColour, 120, Easing.InQuad); + } } } }