From 3888911eee7882f5131aa44b25bfcef29640a9d0 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 16 Feb 2020 14:19:49 +0300 Subject: [PATCH 01/30] Implement BeatmapSearchFilter component --- .../TestSceneBeatmapSearchFilter.cs | 55 +++++++++ .../BeatmapListing/BeatmapSearchFilter.cs | 104 ++++++++++++++++++ .../BeatmapSearchRulesetFilter.cs | 36 ++++++ 3 files changed, 195 insertions(+) create mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs create mode 100644 osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs create mode 100644 osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilter.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs new file mode 100644 index 0000000000..e25b047fd0 --- /dev/null +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs @@ -0,0 +1,55 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Online.API.Requests; +using osu.Game.Overlays; +using osu.Game.Overlays.BeatmapListing; +using osuTK; + +namespace osu.Game.Tests.Visual.UserInterface +{ + public class TestSceneBeatmapSearchFilter : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(BeatmapSearchFilter<>), + typeof(BeatmapSearchRulesetFilter) + }; + + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + + private readonly FillFlowContainer resizableContainer; + + public TestSceneBeatmapSearchFilter() + { + Add(resizableContainer = new FillFlowContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AutoSizeAxes = Axes.Y, + Width = 600, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 10), + Children = new Drawable[] + { + new BeatmapSearchRulesetFilter(), + new BeatmapSearchFilter(), + } + }); + } + + [Test] + public void TestResize() + { + AddStep("Resize to 100px", () => resizableContainer.ResizeWidthTo(100, 1000)); + AddStep("Resize to 600px", () => resizableContainer.ResizeWidthTo(600, 1000)); + } + } +} diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs new file mode 100644 index 0000000000..bf9d48fa3e --- /dev/null +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs @@ -0,0 +1,104 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Allocation; +using osu.Framework.Extensions; +using osu.Framework.Graphics; +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 osuTK; +using osuTK.Graphics; +using osu.Framework.Graphics.Containers; + +namespace osu.Game.Overlays.BeatmapListing +{ + public class BeatmapSearchFilter : TabControl + { + public BeatmapSearchFilter() + { + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + + if (typeof(T).IsEnum) + { + foreach (var val in (T[])Enum.GetValues(typeof(T))) + AddItem(val); + } + } + + protected override Dropdown CreateDropdown() => null; + + protected override TabItem CreateTabItem(T value) => new FilterTabItem(value); + + protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Full, + Spacing = new Vector2(10), + AllowMultiline = true, + }; + + protected class FilterTabItem : TabItem + { + [Resolved] + private OverlayColourProvider colourProvider { get; set; } + + private readonly OsuSpriteText text; + + public FilterTabItem(T value) + : base(value) + { + AutoSizeAxes = Axes.Both; + AddRangeInternal(new Drawable[] + { + text = new OsuSpriteText + { + Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular), + Text = GetText(value) + }, + new HoverClickSounds() + }); + + Enabled.Value = true; + } + + [BackgroundDependencyLoader] + private void load() + { + updateState(); + } + + protected virtual string GetText(T value) => (value as Enum)?.GetDescription() ?? value.ToString(); + + 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() + { + text.Font = text.Font.With(weight: Active.Value ? FontWeight.Medium : FontWeight.Regular); + text.FadeColour(Active.Value ? Color4.White : getStateColour(), 200, Easing.OutQuint); + } + + private Color4 getStateColour() => IsHovered ? colourProvider.Light1 : colourProvider.Light3; + } + } +} diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilter.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilter.cs new file mode 100644 index 0000000000..ffe5693eeb --- /dev/null +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilter.cs @@ -0,0 +1,36 @@ +// 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.Game.Rulesets; +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Overlays.BeatmapListing +{ + public class BeatmapSearchRulesetFilter : BeatmapSearchFilter + { + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + AddItem(new RulesetInfo + { + Name = @"Any" + }); + + foreach (var r in rulesets.AvailableRulesets) + AddItem(r); + } + + protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value); + + private class RulesetTabItem : FilterTabItem + { + public RulesetTabItem(RulesetInfo value) + : base(value) + { + } + + protected override string GetText(RulesetInfo value) => value.Name; + } + } +} From a71e410e5d622bba24979f76e9eed58230601260 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 16 Feb 2020 15:04:21 +0300 Subject: [PATCH 02/30] Make the filter autosized --- .../UserInterface/TestSceneBeatmapSearchFilter.cs | 15 ++------------- .../BeatmapListing/BeatmapSearchFilter.cs | 9 ++------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs index e25b047fd0..a237a8a5b5 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -25,16 +24,13 @@ namespace osu.Game.Tests.Visual.UserInterface [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); - private readonly FillFlowContainer resizableContainer; - public TestSceneBeatmapSearchFilter() { - Add(resizableContainer = new FillFlowContainer + Add(new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AutoSizeAxes = Axes.Y, - Width = 600, + AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), Children = new Drawable[] @@ -44,12 +40,5 @@ namespace osu.Game.Tests.Visual.UserInterface } }); } - - [Test] - public void TestResize() - { - AddStep("Resize to 100px", () => resizableContainer.ResizeWidthTo(100, 1000)); - AddStep("Resize to 600px", () => resizableContainer.ResizeWidthTo(600, 1000)); - } } } diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs index bf9d48fa3e..6cd941495f 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs @@ -12,7 +12,6 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osuTK; using osuTK.Graphics; -using osu.Framework.Graphics.Containers; namespace osu.Game.Overlays.BeatmapListing { @@ -20,8 +19,7 @@ namespace osu.Game.Overlays.BeatmapListing { public BeatmapSearchFilter() { - AutoSizeAxes = Axes.Y; - RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Both; if (typeof(T).IsEnum) { @@ -36,11 +34,8 @@ namespace osu.Game.Overlays.BeatmapListing protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - Direction = FillDirection.Full, + AutoSizeAxes = Axes.Both, Spacing = new Vector2(10), - AllowMultiline = true, }; protected class FilterTabItem : TabItem From 54a3705bdbaa2c1aac1af0a20303a10f8ffe806f Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 16 Feb 2020 16:26:18 +0300 Subject: [PATCH 03/30] Remove font weight changes on selection --- osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs index 6cd941495f..acae5ce117 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs @@ -87,11 +87,7 @@ namespace osu.Game.Overlays.BeatmapListing protected override void OnDeactivated() => updateState(); - private void updateState() - { - text.Font = text.Font.With(weight: Active.Value ? FontWeight.Medium : FontWeight.Regular); - text.FadeColour(Active.Value ? Color4.White : getStateColour(), 200, Easing.OutQuint); - } + private void updateState() => text.FadeColour(Active.Value ? Color4.White : getStateColour(), 200, Easing.OutQuint); private Color4 getStateColour() => IsHovered ? colourProvider.Light1 : colourProvider.Light3; } From e62fec58c1846fdfb6df580f3be6d792a2e9dc40 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 16 Feb 2020 16:38:05 +0300 Subject: [PATCH 04/30] Add ability to override text size --- .../TestSceneBeatmapSearchFilter.cs | 1 + .../BeatmapListing/BeatmapSearchFilter.cs | 4 +++- .../SmallBeatmapSearchFilter.cs | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs index a237a8a5b5..b82ad86fb8 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs @@ -37,6 +37,7 @@ namespace osu.Game.Tests.Visual.UserInterface { new BeatmapSearchRulesetFilter(), new BeatmapSearchFilter(), + new SmallBeatmapSearchFilter() } }); } diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs index acae5ce117..57e8282798 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs @@ -40,6 +40,8 @@ namespace osu.Game.Overlays.BeatmapListing protected class FilterTabItem : TabItem { + protected virtual float TextSize() => 13; + [Resolved] private OverlayColourProvider colourProvider { get; set; } @@ -53,7 +55,7 @@ namespace osu.Game.Overlays.BeatmapListing { text = new OsuSpriteText { - Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular), + Font = OsuFont.GetFont(size: TextSize(), weight: FontWeight.Regular), Text = GetText(value) }, new HoverClickSounds() diff --git a/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs new file mode 100644 index 0000000000..ca387f08cf --- /dev/null +++ b/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs @@ -0,0 +1,22 @@ +// 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.UserInterface; + +namespace osu.Game.Overlays.BeatmapListing +{ + public class SmallBeatmapSearchFilter : BeatmapSearchFilter + { + protected override TabItem CreateTabItem(T value) => new SmallTabItem(value); + + protected class SmallTabItem : FilterTabItem + { + public SmallTabItem(T value) + : base(value) + { + } + + protected override float TextSize() => 10; + } + } +} From c85a8a14cc629bd919f4c692b9f6eff4eb6093b4 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 00:08:28 +0300 Subject: [PATCH 05/30] Use property instead of function to set text size --- osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs | 4 ++-- osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs index 57e8282798..825d157918 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs @@ -40,7 +40,7 @@ namespace osu.Game.Overlays.BeatmapListing protected class FilterTabItem : TabItem { - protected virtual float TextSize() => 13; + protected virtual float TextSize => 13; [Resolved] private OverlayColourProvider colourProvider { get; set; } @@ -55,7 +55,7 @@ namespace osu.Game.Overlays.BeatmapListing { text = new OsuSpriteText { - Font = OsuFont.GetFont(size: TextSize(), weight: FontWeight.Regular), + Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Regular), Text = GetText(value) }, new HoverClickSounds() diff --git a/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs index ca387f08cf..b5d2ad5d4e 100644 --- a/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs +++ b/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.BeatmapListing { } - protected override float TextSize() => 10; + protected override float TextSize => 10; } } } From ea285fd005f07cf42f3f0e06bd4c57e749818136 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 00:44:55 +0300 Subject: [PATCH 06/30] Refactor with including headers --- .../TestSceneBeatmapSearchFilter.cs | 26 ++- .../BeatmapListing/BeatmapSearchFilter.cs | 97 ------------ .../BeatmapListing/BeatmapSearchFilterRow.cs | 149 ++++++++++++++++++ .../BeatmapSearchRulesetFilter.cs | 36 ----- .../BeatmapSearchRulesetFilterRow.cs | 46 ++++++ .../BeatmapSearchSmallFilterRow.cs | 32 ++++ .../SmallBeatmapSearchFilter.cs | 22 --- 7 files changed, 246 insertions(+), 162 deletions(-) delete mode 100644 osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs create mode 100644 osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs delete mode 100644 osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilter.cs create mode 100644 osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs create mode 100644 osu.Game/Overlays/BeatmapListing/BeatmapSearchSmallFilterRow.cs delete mode 100644 osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs index b82ad86fb8..30cd34be50 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -17,29 +18,40 @@ namespace osu.Game.Tests.Visual.UserInterface { public override IReadOnlyList RequiredTypes => new[] { - typeof(BeatmapSearchFilter<>), - typeof(BeatmapSearchRulesetFilter) + typeof(BeatmapSearchFilterRow<>), + typeof(BeatmapSearchRulesetFilterRow), + typeof(BeatmapSearchSmallFilterRow<>), }; [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + private readonly FillFlowContainer resizableContainer; + public TestSceneBeatmapSearchFilter() { - Add(new FillFlowContainer + Add(resizableContainer = new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), Children = new Drawable[] { - new BeatmapSearchRulesetFilter(), - new BeatmapSearchFilter(), - new SmallBeatmapSearchFilter() + new BeatmapSearchRulesetFilterRow(), + new BeatmapSearchFilterRow("Categories"), + new BeatmapSearchSmallFilterRow("Header Name") } }); } + + [Test] + public void TestResize() + { + AddStep("Resize to 0.3", () => resizableContainer.ResizeWidthTo(0.3f, 1000)); + AddStep("Resize to 1", () => resizableContainer.ResizeWidthTo(1, 1000)); + } } } diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs deleted file mode 100644 index 825d157918..0000000000 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilter.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Framework.Allocation; -using osu.Framework.Extensions; -using osu.Framework.Graphics; -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 osuTK; -using osuTK.Graphics; - -namespace osu.Game.Overlays.BeatmapListing -{ - public class BeatmapSearchFilter : TabControl - { - public BeatmapSearchFilter() - { - AutoSizeAxes = Axes.Both; - - if (typeof(T).IsEnum) - { - foreach (var val in (T[])Enum.GetValues(typeof(T))) - AddItem(val); - } - } - - protected override Dropdown CreateDropdown() => null; - - protected override TabItem CreateTabItem(T value) => new FilterTabItem(value); - - protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer - { - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(10), - }; - - protected class FilterTabItem : TabItem - { - protected virtual float TextSize => 13; - - [Resolved] - private OverlayColourProvider colourProvider { get; set; } - - private readonly OsuSpriteText text; - - public FilterTabItem(T value) - : base(value) - { - AutoSizeAxes = Axes.Both; - AddRangeInternal(new Drawable[] - { - text = new OsuSpriteText - { - Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Regular), - Text = GetText(value) - }, - new HoverClickSounds() - }); - - Enabled.Value = true; - } - - [BackgroundDependencyLoader] - private void load() - { - updateState(); - } - - protected virtual string GetText(T value) => (value as Enum)?.GetDescription() ?? value.ToString(); - - 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() => text.FadeColour(Active.Value ? Color4.White : getStateColour(), 200, Easing.OutQuint); - - private Color4 getStateColour() => IsHovered ? colourProvider.Light1 : colourProvider.Light3; - } - } -} diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs new file mode 100644 index 0000000000..05578a36b5 --- /dev/null +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs @@ -0,0 +1,149 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using JetBrains.Annotations; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Extensions; +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 osuTK; +using osuTK.Graphics; + +namespace osu.Game.Overlays.BeatmapListing +{ + public class BeatmapSearchFilterRow : CompositeDrawable, IHasCurrentValue + { + private readonly BindableWithCurrent current = new BindableWithCurrent(); + + public Bindable Current + { + get => current.Current; + set => current.Current = value; + } + + public BeatmapSearchFilterRow(string headerName) + { + AutoSizeAxes = Axes.Y; + RelativeSizeAxes = Axes.X; + AddInternal(new FillFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + Spacing = new Vector2(0, 7), + Children = new Drawable[] + { + new Container + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + AutoSizeAxes = Axes.Y, + Width = 100, + Child = new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = OsuFont.GetFont(size: 10), + Text = headerName.ToUpper() + } + }, + CreateFilter().With(f => + { + f.Anchor = Anchor.CentreLeft; + f.Origin = Anchor.CentreLeft; + f.Current = current; + }) + } + }); + } + + [NotNull] + protected virtual BeatmapSearchFilter CreateFilter() => new BeatmapSearchFilter(); + + protected class BeatmapSearchFilter : TabControl + { + public BeatmapSearchFilter() + { + AutoSizeAxes = Axes.Both; + + if (typeof(T).IsEnum) + { + foreach (var val in (T[])Enum.GetValues(typeof(T))) + AddItem(val); + } + } + + protected override Dropdown CreateDropdown() => null; + + protected override TabItem CreateTabItem(T value) => new FilterTabItem(value); + + protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer + { + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(10), + }; + + protected class FilterTabItem : TabItem + { + protected virtual float TextSize => 13; + + [Resolved] + private OverlayColourProvider colourProvider { get; set; } + + private readonly OsuSpriteText text; + + public FilterTabItem(T value) + : base(value) + { + AutoSizeAxes = Axes.Both; + AddRangeInternal(new Drawable[] + { + text = new OsuSpriteText + { + Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Regular), + Text = GetText(value) + }, + new HoverClickSounds() + }); + + Enabled.Value = true; + } + + [BackgroundDependencyLoader] + private void load() + { + updateState(); + } + + protected virtual string GetText(T value) => (value as Enum)?.GetDescription() ?? value.ToString(); + + 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() => text.FadeColour(Active.Value ? Color4.White : getStateColour(), 200, Easing.OutQuint); + + private Color4 getStateColour() => IsHovered ? colourProvider.Light1 : colourProvider.Light3; + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilter.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilter.cs deleted file mode 100644 index ffe5693eeb..0000000000 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilter.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Framework.Allocation; -using osu.Game.Rulesets; -using osu.Framework.Graphics.UserInterface; - -namespace osu.Game.Overlays.BeatmapListing -{ - public class BeatmapSearchRulesetFilter : BeatmapSearchFilter - { - [BackgroundDependencyLoader] - private void load(RulesetStore rulesets) - { - AddItem(new RulesetInfo - { - Name = @"Any" - }); - - foreach (var r in rulesets.AvailableRulesets) - AddItem(r); - } - - protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value); - - private class RulesetTabItem : FilterTabItem - { - public RulesetTabItem(RulesetInfo value) - : base(value) - { - } - - protected override string GetText(RulesetInfo value) => value.Name; - } - } -} diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs new file mode 100644 index 0000000000..d30364ab0d --- /dev/null +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs @@ -0,0 +1,46 @@ +// 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.UserInterface; +using osu.Game.Rulesets; + +namespace osu.Game.Overlays.BeatmapListing +{ + public class BeatmapSearchRulesetFilterRow : BeatmapSearchFilterRow + { + public BeatmapSearchRulesetFilterRow() + : base(@"Mode") + { + } + + protected override BeatmapSearchFilter CreateFilter() => new RulesetFilter(); + + private class RulesetFilter : BeatmapSearchFilter + { + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + AddItem(new RulesetInfo + { + Name = @"Any" + }); + + foreach (var r in rulesets.AvailableRulesets) + AddItem(r); + } + + protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value); + + private class RulesetTabItem : FilterTabItem + { + public RulesetTabItem(RulesetInfo value) + : base(value) + { + } + + protected override string GetText(RulesetInfo value) => value.Name; + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchSmallFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchSmallFilterRow.cs new file mode 100644 index 0000000000..6daa7cb0e0 --- /dev/null +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchSmallFilterRow.cs @@ -0,0 +1,32 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Overlays.BeatmapListing +{ + public class BeatmapSearchSmallFilterRow : BeatmapSearchFilterRow + { + public BeatmapSearchSmallFilterRow(string headerName) + : base(headerName) + { + } + + protected override BeatmapSearchFilter CreateFilter() => new SmallBeatmapSearchFilter(); + + private class SmallBeatmapSearchFilter : BeatmapSearchFilter + { + protected override TabItem CreateTabItem(T value) => new SmallTabItem(value); + + private class SmallTabItem : FilterTabItem + { + public SmallTabItem(T value) + : base(value) + { + } + + protected override float TextSize => 10; + } + } + } +} diff --git a/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs b/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs deleted file mode 100644 index b5d2ad5d4e..0000000000 --- a/osu.Game/Overlays/BeatmapListing/SmallBeatmapSearchFilter.cs +++ /dev/null @@ -1,22 +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.UserInterface; - -namespace osu.Game.Overlays.BeatmapListing -{ - public class SmallBeatmapSearchFilter : BeatmapSearchFilter - { - protected override TabItem CreateTabItem(T value) => new SmallTabItem(value); - - protected class SmallTabItem : FilterTabItem - { - public SmallTabItem(T value) - : base(value) - { - } - - protected override float TextSize => 10; - } - } -} From a9f366fda3a74c2054d450251f9bbaf07f34f37d Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 02:20:53 +0300 Subject: [PATCH 07/30] Implement OverlaySortTabControl component --- .../Online/TestSceneCommentsContainer.cs | 2 +- .../Visual/Online/TestSceneCommentsHeader.cs | 2 +- osu.Game/Overlays/Comments/CommentsHeader.cs | 33 ++-- osu.Game/Overlays/Comments/SortTabControl.cs | 110 ------------- osu.Game/Overlays/OverlaySortTabControl.cs | 147 ++++++++++++++++++ 5 files changed, 159 insertions(+), 135 deletions(-) delete mode 100644 osu.Game/Overlays/Comments/SortTabControl.cs create mode 100644 osu.Game/Overlays/OverlaySortTabControl.cs diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs index 2a43ba3f99..ece280659c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online typeof(CommentsHeader), typeof(DrawableComment), typeof(HeaderButton), - typeof(SortTabControl), + typeof(OverlaySortTabControl<>), typeof(ShowChildrenButton), typeof(DeletedCommentsCounter), typeof(VotePill), diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs index a60f220e4b..c688d600a3 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsHeader.cs @@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual.Online { typeof(CommentsHeader), typeof(HeaderButton), - typeof(SortTabControl), + typeof(OverlaySortTabControl<>), }; [Cached] diff --git a/osu.Game/Overlays/Comments/CommentsHeader.cs b/osu.Game/Overlays/Comments/CommentsHeader.cs index ad80e67330..1aa40201f1 100644 --- a/osu.Game/Overlays/Comments/CommentsHeader.cs +++ b/osu.Game/Overlays/Comments/CommentsHeader.cs @@ -16,8 +16,6 @@ namespace osu.Game.Overlays.Comments { public class CommentsHeader : CompositeDrawable { - private const int font_size = 14; - public readonly Bindable Sort = new Bindable(); public readonly BindableBool ShowDeleted = new BindableBool(); @@ -40,29 +38,11 @@ namespace osu.Game.Overlays.Comments Padding = new MarginPadding { Horizontal = 50 }, Children = new Drawable[] { - new FillFlowContainer + new OverlaySortTabControl { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(10, 0), Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Children = new Drawable[] - { - new OsuSpriteText - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Font = OsuFont.GetFont(size: font_size), - Text = @"Sort by" - }, - new SortTabControl - { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Current = Sort - } - } + Current = Sort }, new ShowDeletedButton { @@ -106,7 +86,7 @@ namespace osu.Game.Overlays.Comments { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, - Font = OsuFont.GetFont(size: font_size), + Font = OsuFont.GetFont(size: 12), Text = @"Show deleted" } }, @@ -126,4 +106,11 @@ namespace osu.Game.Overlays.Comments } } } + + public enum CommentsSortCriteria + { + New, + Old, + Top + } } diff --git a/osu.Game/Overlays/Comments/SortTabControl.cs b/osu.Game/Overlays/Comments/SortTabControl.cs deleted file mode 100644 index 700d63351f..0000000000 --- a/osu.Game/Overlays/Comments/SortTabControl.cs +++ /dev/null @@ -1,110 +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.Containers; -using osu.Framework.Graphics; -using osu.Framework.Graphics.UserInterface; -using osu.Framework.Graphics.Sprites; -using osu.Game.Graphics; -using osuTK; -using osu.Game.Graphics.UserInterface; -using osu.Framework.Input.Events; -using osu.Framework.Bindables; -using osu.Framework.Allocation; -using osu.Game.Graphics.Sprites; -using osuTK.Graphics; - -namespace osu.Game.Overlays.Comments -{ - public class SortTabControl : OsuTabControl - { - protected override Dropdown CreateDropdown() => null; - - protected override TabItem CreateTabItem(CommentsSortCriteria value) => new SortTabItem(value); - - protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5, 0), - }; - - public SortTabControl() - { - AutoSizeAxes = Axes.Both; - } - - private class SortTabItem : TabItem - { - public SortTabItem(CommentsSortCriteria value) - : base(value) - { - AutoSizeAxes = Axes.Both; - Child = new TabButton(value) { Active = { BindTarget = Active } }; - } - - protected override void OnActivated() - { - } - - protected override void OnDeactivated() - { - } - - private class TabButton : HeaderButton - { - public readonly BindableBool Active = new BindableBool(); - - [Resolved] - private OverlayColourProvider colourProvider { get; set; } - - private readonly SpriteText text; - - public TabButton(CommentsSortCriteria value) - { - Add(text = new OsuSpriteText - { - Font = OsuFont.GetFont(size: 14), - Text = value.ToString() - }); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - Active.BindValueChanged(active => - { - updateBackgroundState(); - - text.Font = text.Font.With(weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium); - text.Colour = active.NewValue ? colourProvider.Light1 : Color4.White; - }, true); - } - - protected override bool OnHover(HoverEvent e) - { - updateBackgroundState(); - return true; - } - - protected override void OnHoverLost(HoverLostEvent e) => updateBackgroundState(); - - private void updateBackgroundState() - { - if (Active.Value || IsHovered) - ShowBackground(); - else - HideBackground(); - } - } - } - } - - public enum CommentsSortCriteria - { - New, - Old, - Top - } -} diff --git a/osu.Game/Overlays/OverlaySortTabControl.cs b/osu.Game/Overlays/OverlaySortTabControl.cs new file mode 100644 index 0000000000..0b91de2682 --- /dev/null +++ b/osu.Game/Overlays/OverlaySortTabControl.cs @@ -0,0 +1,147 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osuTK; +using osu.Game.Graphics.UserInterface; +using osu.Framework.Input.Events; +using osu.Framework.Bindables; +using osu.Framework.Allocation; +using osu.Game.Graphics.Sprites; +using osuTK.Graphics; +using osu.Game.Overlays.Comments; +using JetBrains.Annotations; + +namespace osu.Game.Overlays +{ + public class OverlaySortTabControl : CompositeDrawable, IHasCurrentValue + { + private readonly BindableWithCurrent current = new BindableWithCurrent(); + + public Bindable Current + { + get => current.Current; + set => current.Current = value; + } + + public OverlaySortTabControl() + { + AutoSizeAxes = Axes.Both; + AddInternal(new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(10, 0), + Children = new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Font = OsuFont.GetFont(size: 12), + Text = @"Sort by" + }, + CreateControl().With(c => + { + c.Anchor = Anchor.CentreLeft; + c.Origin = Anchor.CentreLeft; + c.Current = current; + }) + } + }); + } + + [NotNull] + protected virtual SortTabControl CreateControl() => new SortTabControl(); + + protected class SortTabControl : OsuTabControl + { + protected override Dropdown CreateDropdown() => null; + + protected override TabItem CreateTabItem(T value) => new SortTabItem(value); + + protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5, 0), + }; + + public SortTabControl() + { + AutoSizeAxes = Axes.Both; + } + + protected class SortTabItem : TabItem + { + public SortTabItem(T value) + : base(value) + { + AutoSizeAxes = Axes.Both; + Child = new TabButton(value) { Active = { BindTarget = Active } }; + } + + protected override void OnActivated() + { + } + + protected override void OnDeactivated() + { + } + + private class TabButton : HeaderButton + { + public readonly BindableBool Active = new BindableBool(); + + [Resolved] + private OverlayColourProvider colourProvider { get; set; } + + private readonly SpriteText text; + + public TabButton(T value) + { + Add(text = new OsuSpriteText + { + Font = OsuFont.GetFont(size: 12), + Text = value.ToString() + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + Active.BindValueChanged(_ => updateState(), true); + } + + protected override bool OnHover(HoverEvent e) + { + updateHoverState(); + return true; + } + + protected override void OnHoverLost(HoverLostEvent e) => updateHoverState(); + + private void updateState() + { + updateHoverState(); + text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); + } + + private void updateHoverState() + { + if (Active.Value || IsHovered) + ShowBackground(); + else + HideBackground(); + + text.Colour = Active.Value && !IsHovered ? colourProvider.Light1 : Color4.White; + } + } + } + } + } +} From 2ba0bd872bd41428a9da62a020be1d231f73a321 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 02:35:46 +0300 Subject: [PATCH 08/30] Implement basic BeatmapListingSortTabControl --- .../TestSceneBeatmapListingSort.cs | 33 +++++++++++++++++++ .../BeatmapListingSortTabControl.cs | 24 ++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs create mode 100644 osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs new file mode 100644 index 0000000000..28549f4306 --- /dev/null +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs @@ -0,0 +1,33 @@ +// 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 osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Game.Overlays; +using osu.Game.Overlays.BeatmapListing; + +namespace osu.Game.Tests.Visual.UserInterface +{ + public class TestSceneBeatmapListingSort : OsuTestScene + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(BeatmapListingSortTabControl), + typeof(OverlaySortTabControl<>), + }; + + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + + public TestSceneBeatmapListingSort() + { + Add(new BeatmapListingSortTabControl + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }); + } + } +} diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs new file mode 100644 index 0000000000..0a002325e7 --- /dev/null +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Overlays.BeatmapListing +{ + public class BeatmapListingSortTabControl : OverlaySortTabControl + { + public BeatmapListingSortTabControl() + { + Current.Value = BeatmapSortCriteria.Ranked; + } + } + + public enum BeatmapSortCriteria + { + Title, + Artist, + Difficulty, + Ranked, + Rating, + Plays, + Favourites, + } +} From fe7923b7e824449c0d06baf2a6729ccf935ae4ed Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 03:38:14 +0300 Subject: [PATCH 09/30] Add SortDirection Bindable and refactor to make everything work --- .../TestSceneBeatmapListingSort.cs | 30 +++++- .../BeatmapListingSortTabControl.cs | 95 +++++++++++++++++++ osu.Game/Overlays/OverlaySortTabControl.cs | 53 +++++++---- 3 files changed, 161 insertions(+), 17 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs index 28549f4306..40c694e224 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs @@ -5,8 +5,11 @@ using System; using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Sprites; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapListing; +using osuTK; namespace osu.Game.Tests.Visual.UserInterface { @@ -20,14 +23,39 @@ namespace osu.Game.Tests.Visual.UserInterface [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + private readonly FillFlowContainer placeholder; + private readonly BeatmapListingSortTabControl control; public TestSceneBeatmapListingSort() { - Add(new BeatmapListingSortTabControl + Add(control = new BeatmapListingSortTabControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, }); + + Add(placeholder = new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, 5), + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + control.SortDirection.BindValueChanged(_ => updateBindablesVisual()); + control.Current.BindValueChanged(_ => updateBindablesVisual(), true); + } + + private void updateBindablesVisual() + { + placeholder.Clear(); + + placeholder.Add(new OsuSpriteText { Text = $"Current: {control.Current.Value}" }); + placeholder.Add(new OsuSpriteText { Text = $"Sort direction: {control.SortDirection.Value}" }); } } } diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs index 0a002325e7..3f69c76da7 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs @@ -1,14 +1,109 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Graphics; +using osuTK.Graphics; +using osuTK; +using osu.Framework.Input.Events; + namespace osu.Game.Overlays.BeatmapListing { public class BeatmapListingSortTabControl : OverlaySortTabControl { + public readonly Bindable SortDirection = new Bindable(Overlays.SortDirection.Descending); + public BeatmapListingSortTabControl() { Current.Value = BeatmapSortCriteria.Ranked; } + + protected override SortTabControl CreateControl() => new BeatmapSortTabControl + { + SortDirection = { BindTarget = SortDirection } + }; + + private class BeatmapSortTabControl : SortTabControl + { + public readonly Bindable SortDirection = new Bindable(); + + protected override TabItem CreateTabItem(BeatmapSortCriteria value) => new BeatmapSortTabItem(value) + { + SortDirection = { BindTarget = SortDirection } + }; + + private class BeatmapSortTabItem : SortTabItem + { + public readonly Bindable SortDirection = new Bindable(); + + public BeatmapSortTabItem(BeatmapSortCriteria value) + : base(value) + { + } + + protected override TabButton CreateTabButton(BeatmapSortCriteria value) => new BeatmapTabButton(value) + { + Active = { BindTarget = Active }, + SortDirection = { BindTarget = SortDirection } + }; + + private class BeatmapTabButton : TabButton + { + public readonly Bindable SortDirection = new Bindable(); + + protected override Color4 ContentColour + { + set + { + base.ContentColour = value; + icon.Colour = value; + } + } + + private readonly SpriteIcon icon; + + public BeatmapTabButton(BeatmapSortCriteria value) + : base(value) + { + Add(icon = new SpriteIcon + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AlwaysPresent = true, + Alpha = 0, + Size = new Vector2(6) + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + SortDirection.BindValueChanged(direction => + { + icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown; + icon.Margin = direction.NewValue == Overlays.SortDirection.Ascending ? new MarginPadding { Top = 1 } : new MarginPadding { Top = 2 }; + }, true); + } + + protected override void UpdateState() + { + base.UpdateState(); + icon.FadeTo(Active.Value || IsHovered ? 1 : 0, 200, Easing.OutQuint); + } + + protected override bool OnClick(ClickEvent e) + { + if (Active.Value) + SortDirection.Value = SortDirection.Value == Overlays.SortDirection.Ascending ? Overlays.SortDirection.Descending : Overlays.SortDirection.Ascending; + + return base.OnClick(e); + } + } + } + } } public enum BeatmapSortCriteria diff --git a/osu.Game/Overlays/OverlaySortTabControl.cs b/osu.Game/Overlays/OverlaySortTabControl.cs index 0b91de2682..487dd70db9 100644 --- a/osu.Game/Overlays/OverlaySortTabControl.cs +++ b/osu.Game/Overlays/OverlaySortTabControl.cs @@ -82,9 +82,15 @@ namespace osu.Game.Overlays : base(value) { AutoSizeAxes = Axes.Both; - Child = new TabButton(value) { Active = { BindTarget = Active } }; + Child = CreateTabButton(value); } + [NotNull] + protected virtual TabButton CreateTabButton(T value) => new TabButton(value) + { + Active = { BindTarget = Active } + }; + protected override void OnActivated() { } @@ -93,52 +99,67 @@ namespace osu.Game.Overlays { } - private class TabButton : HeaderButton + protected class TabButton : HeaderButton { public readonly BindableBool Active = new BindableBool(); + protected override Container Content => content; + + protected virtual Color4 ContentColour + { + set => text.Colour = value; + } + [Resolved] private OverlayColourProvider colourProvider { get; set; } private readonly SpriteText text; + private readonly FillFlowContainer content; public TabButton(T value) { - Add(text = new OsuSpriteText + base.Content.Add(content = new FillFlowContainer { - Font = OsuFont.GetFont(size: 12), - Text = value.ToString() + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(3, 0), + Children = new Drawable[] + { + text = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 12), + Text = value.ToString() + } + } }); } protected override void LoadComplete() { base.LoadComplete(); - Active.BindValueChanged(_ => updateState(), true); + Active.BindValueChanged(_ => UpdateState(), true); } protected override bool OnHover(HoverEvent e) { - updateHoverState(); + UpdateState(); return true; } - protected override void OnHoverLost(HoverLostEvent e) => updateHoverState(); + protected override void OnHoverLost(HoverLostEvent e) => UpdateState(); - private void updateState() - { - updateHoverState(); - text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); - } - - private void updateHoverState() + protected virtual void UpdateState() { if (Active.Value || IsHovered) ShowBackground(); else HideBackground(); - text.Colour = Active.Value && !IsHovered ? colourProvider.Light1 : Color4.White; + ContentColour = Active.Value && !IsHovered ? colourProvider.Light1 : Color4.White; + + text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); } } } From d985a22f7758b8de3651f15141178b6a5140a53a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 03:52:26 +0300 Subject: [PATCH 10/30] Add missing blank line --- .../Visual/UserInterface/TestSceneBeatmapListingSort.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs index 40c694e224..4638b2bb54 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs @@ -23,6 +23,7 @@ namespace osu.Game.Tests.Visual.UserInterface [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + private readonly FillFlowContainer placeholder; private readonly BeatmapListingSortTabControl control; From 480e5677edaa8cb93201042b8a1158bb3f4e9d51 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 04:29:41 +0300 Subject: [PATCH 11/30] Use OverlayColourProvider for CounterPill in profile overlay --- .../Visual/Online/TestSceneProfileCounterPill.cs | 5 +++++ osu.Game/Overlays/Profile/Sections/CounterPill.cs | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs b/osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs index 468239cf08..5e2b125521 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneProfileCounterPill.cs @@ -4,8 +4,10 @@ using System; using System.Collections.Generic; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Game.Overlays; using osu.Game.Overlays.Profile.Sections; namespace osu.Game.Tests.Visual.Online @@ -17,6 +19,9 @@ namespace osu.Game.Tests.Visual.Online typeof(CounterPill) }; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Red); + private readonly CounterPill pill; private readonly BindableInt value = new BindableInt(); diff --git a/osu.Game/Overlays/Profile/Sections/CounterPill.cs b/osu.Game/Overlays/Profile/Sections/CounterPill.cs index bd760c4139..52adefa4ad 100644 --- a/osu.Game/Overlays/Profile/Sections/CounterPill.cs +++ b/osu.Game/Overlays/Profile/Sections/CounterPill.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; using osu.Framework.Bindables; using osu.Game.Graphics.Sprites; +using osu.Framework.Allocation; namespace osu.Game.Overlays.Profile.Sections { @@ -16,9 +17,10 @@ namespace osu.Game.Overlays.Profile.Sections public readonly BindableInt Current = new BindableInt(); - private readonly OsuSpriteText counter; + private OsuSpriteText counter; - public CounterPill() + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) { AutoSizeAxes = Axes.Both; Alpha = 0; @@ -28,14 +30,15 @@ namespace osu.Game.Overlays.Profile.Sections new Box { RelativeSizeAxes = Axes.Both, - Colour = OsuColour.Gray(0.05f) + Colour = colourProvider.Background6 }, counter = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Margin = new MarginPadding { Horizontal = 10, Vertical = 5 }, - Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold) + Font = OsuFont.GetFont(weight: FontWeight.Bold), + Colour = colourProvider.Foreground1 } }; } @@ -54,7 +57,7 @@ namespace osu.Game.Overlays.Profile.Sections return; } - counter.Text = value.NewValue.ToString(); + counter.Text = value.NewValue.ToString("N0"); this.FadeIn(duration, Easing.OutQuint); } } From b1e7d1f99588c865e49cf41459e787fabcb288c1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Feb 2020 11:09:33 +0900 Subject: [PATCH 12/30] Slight rewording --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 67027bb9f3..e6d297c47f 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ Rhythm is just a *click* away. The future of [osu!](https://osu.ppy.sh) and the ## Status -This project is still heavily under development, but is in a state where users are encouraged to try it out and keep it installed alongside the stable *osu!* client. It will continue to evolve over the coming months and hopefully bring some new unique features to the table. +This project under heavy development, but is in a stable state. Users are encouraged to try it out and keep it installed alongside the stable *osu!* client. It will continue to evolve to the point of eventually replacing the existing stable client as an update. -We are accepting bug reports (please report with as much detail as possible). Feature requests are welcome as long as you read and understand the contribution guidelines listed below. +We are accepting bug reports (please report with as much detail as possible). Feature requests are also welcome, but understand that our focus is on completing the game to feature parity before adding new features. Detailed changelogs are published on the [official osu! site](https://osu.ppy.sh/home/changelog). From 8b2b159a0c4b93a0eb844c8b75d7616d21f66f39 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Feb 2020 11:09:46 +0900 Subject: [PATCH 13/30] Link to details on project management --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6d297c47f..0a3ed7f0e7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This project under heavy development, but is in a stable state. Users are encour We are accepting bug reports (please report with as much detail as possible). Feature requests are also welcome, but understand that our focus is on completing the game to feature parity before adding new features. -Detailed changelogs are published on the [official osu! site](https://osu.ppy.sh/home/changelog). +Detailed changelogs are published on the [official osu! site](https://osu.ppy.sh/home/changelog). You can also learn more about our approach to [project management](https://github.com/ppy/osu/wiki/Project-management). ## Requirements From 2c3e510051b76a11b514d2879e83c935b168c5ef Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Feb 2020 11:10:26 +0900 Subject: [PATCH 14/30] Link directly to lazer changelog now that this is supported by osu-web --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a3ed7f0e7..3f50c39cfe 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This project under heavy development, but is in a stable state. Users are encour We are accepting bug reports (please report with as much detail as possible). Feature requests are also welcome, but understand that our focus is on completing the game to feature parity before adding new features. -Detailed changelogs are published on the [official osu! site](https://osu.ppy.sh/home/changelog). You can also learn more about our approach to [project management](https://github.com/ppy/osu/wiki/Project-management). +Detailed release changelogs are available on the [official osu! site](https://osu.ppy.sh/home/changelog/lazer). You can also learn more about our approach to [project management](https://github.com/ppy/osu/wiki/Project-management). ## Requirements From 7e052e9894f5448b5cb7c4b16c38e97e75d54f95 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Feb 2020 12:49:47 +0900 Subject: [PATCH 15/30] Update README.md Co-Authored-By: Dan Balasescu --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f50c39cfe..90ec1d0b39 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Rhythm is just a *click* away. The future of [osu!](https://osu.ppy.sh) and the ## Status -This project under heavy development, but is in a stable state. Users are encouraged to try it out and keep it installed alongside the stable *osu!* client. It will continue to evolve to the point of eventually replacing the existing stable client as an update. +This project is under heavy development, but is in a stable state. Users are encouraged to try it out and keep it installed alongside the stable *osu!* client. It will continue to evolve to the point of eventually replacing the existing stable client as an update. We are accepting bug reports (please report with as much detail as possible). Feature requests are also welcome, but understand that our focus is on completing the game to feature parity before adding new features. From c78534d14e1e6455ace738296fb7b657887853eb Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 10:07:32 +0300 Subject: [PATCH 16/30] Fix possible error in SpotlightsLayout --- osu.Game/Overlays/Rankings/SpotlightsLayout.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs index 33811cc982..e609fa1487 100644 --- a/osu.Game/Overlays/Rankings/SpotlightsLayout.cs +++ b/osu.Game/Overlays/Rankings/SpotlightsLayout.cs @@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Rankings private void getSpotlights() { spotlightsRequest = new GetSpotlightsRequest(); - spotlightsRequest.Success += response => selector.Spotlights = response.Spotlights; + spotlightsRequest.Success += response => Schedule(() => selector.Spotlights = response.Spotlights); api.Queue(spotlightsRequest); } @@ -151,11 +151,11 @@ namespace osu.Game.Overlays.Rankings protected override void Dispose(bool isDisposing) { - base.Dispose(isDisposing); - spotlightsRequest?.Cancel(); getRankingsRequest?.Cancel(); cancellationToken?.Cancel(); + + base.Dispose(isDisposing); } } } From f9145ce5b47555072d215c712809be66695952b1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 17 Feb 2020 17:02:19 +0900 Subject: [PATCH 17/30] Fix playlist items added with the wrong IDs --- osu.Game/Screens/Select/MatchSongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index a115ab9841..2f3674642e 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -62,7 +62,7 @@ namespace osu.Game.Screens.Select { PlaylistItem item = new PlaylistItem { - ID = (Playlist.LastOrDefault()?.ID + 1) ?? 0, + ID = Playlist.Count == 0 ? 0 : Playlist.Max(p => p.ID) + 1 }; populateItemFromCurrent(item); From 84ea279c947b03be9ace0d9bd23e157983a648cd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 17 Feb 2020 17:04:58 +0900 Subject: [PATCH 18/30] Add test --- .../Multiplayer/TestSceneMatchSongSelect.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSongSelect.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSongSelect.cs index 5820da811d..2c6f34d8a6 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSongSelect.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSongSelect.cs @@ -134,6 +134,22 @@ namespace osu.Game.Tests.Visual.Multiplayer AddAssert("playlist has 2 items", () => Room.Playlist.Count == 2); } + [Test] + public void TestAddItemAfterRearrangement() + { + AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem()); + AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem()); + AddStep("rearrange", () => + { + var item = Room.Playlist[0]; + Room.Playlist.RemoveAt(0); + Room.Playlist.Add(item); + }); + + AddStep("create new item", () => songSelect.BeatmapDetails.CreateNewItem()); + AddAssert("new item has id 2", () => Room.Playlist.Last().ID == 2); + } + private class TestMatchSongSelect : MatchSongSelect { public new MatchBeatmapDetailArea BeatmapDetails => (MatchBeatmapDetailArea)base.BeatmapDetails; From 6ce25b39371522dbacc491ffae5c8e805fbd822b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2020 08:10:20 +0000 Subject: [PATCH 19/30] Bump Sentry from 2.0.2 to 2.0.3 Bumps [Sentry](https://github.com/getsentry/sentry-dotnet) from 2.0.2 to 2.0.3. - [Release notes](https://github.com/getsentry/sentry-dotnet/releases) - [Commits](https://github.com/getsentry/sentry-dotnet/compare/2.0.2...2.0.3) Signed-off-by: dependabot-preview[bot] --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 6dcb529dc4..5e78c69f4d 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -24,7 +24,7 @@ - + From 328ab8ba78eb4b14165ebe7d198373892de09269 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2020 08:10:37 +0000 Subject: [PATCH 20/30] Bump ppy.osu.Framework.NativeLibs from 2019.1104.0 to 2020.213.0 Bumps [ppy.osu.Framework.NativeLibs](https://github.com/ppy/osu-framework) from 2019.1104.0 to 2020.213.0. - [Release notes](https://github.com/ppy/osu-framework/releases) - [Commits](https://github.com/ppy/osu-framework/compare/2019.1104.0...2020.213.0) Signed-off-by: dependabot-preview[bot] --- osu.iOS.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.iOS.props b/osu.iOS.props index 946d039195..351126e3b9 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -87,6 +87,6 @@ - + From 7c5ae75c0c8986377d0d856e05931ada0576bbf8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 17 Feb 2020 18:19:41 +0900 Subject: [PATCH 21/30] Add link to blog faq --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 90ec1d0b39..df4cabc24f 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,11 @@ Rhythm is just a *click* away. The future of [osu!](https://osu.ppy.sh) and the This project is under heavy development, but is in a stable state. Users are encouraged to try it out and keep it installed alongside the stable *osu!* client. It will continue to evolve to the point of eventually replacing the existing stable client as an update. -We are accepting bug reports (please report with as much detail as possible). Feature requests are also welcome, but understand that our focus is on completing the game to feature parity before adding new features. +We are accepting bug reports (please report with as much detail as possible). Feature requests are also welcome, but understand that our focus is on completing the game to feature parity before adding new features. A few resources are available as starting points to getting involved and understanding the project: -Detailed release changelogs are available on the [official osu! site](https://osu.ppy.sh/home/changelog/lazer). You can also learn more about our approach to [project management](https://github.com/ppy/osu/wiki/Project-management). +- Detailed release changelogs are available on the [official osu! site](https://osu.ppy.sh/home/changelog/lazer). +- You can learn more about our approach to [project management](https://github.com/ppy/osu/wiki/Project-management). +- Read peppy's [latest blog post](https://blog.ppy.sh/a-definitive-lazer-faq/) exploring where lazer is currently and the roadmap going forward. ## Requirements From ede85d7be471724397377bf145f015738739609c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Feb 2020 00:59:08 +0900 Subject: [PATCH 22/30] Restructure readme to better define prerequisites that are required for development only --- README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index df4cabc24f..6071e3f473 100644 --- a/README.md +++ b/README.md @@ -21,19 +21,9 @@ We are accepting bug reports (please report with as much detail as possible). Fe - You can learn more about our approach to [project management](https://github.com/ppy/osu/wiki/Project-management). - Read peppy's [latest blog post](https://blog.ppy.sh/a-definitive-lazer-faq/) exploring where lazer is currently and the roadmap going forward. -## Requirements - -- A desktop platform with the [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download) or higher installed. -- When running on Linux, please have a system-wide FFmpeg installation available to support video decoding. -- When running on Windows 7 or 8.1, **[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/install/dependencies?tabs=netcore31&pivots=os-windows)** may be required to correctly run .NET Core applications if your operating system is not up-to-date with the latest service packs. -- When developing with mobile, [Xamarin](https://docs.microsoft.com/en-us/xamarin/) is required, which is shipped together with Visual Studio or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/). -- When working with the codebase, we recommend using an IDE with intelligent code completion and syntax highlighting, such as [Visual Studio 2019+](https://visualstudio.microsoft.com/vs/), [JetBrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/). - ## Running osu! -### Releases - -If you are not interested in developing the game, you can still consume our [binary releases](https://github.com/ppy/osu/releases). +If you are looking to install or test osu! without setting up a development environment, you can consume our [binary releases](https://github.com/ppy/osu/releases). Handy links below will download the latest version for your operating system of choice: **Latest build:** @@ -41,9 +31,19 @@ If you are not interested in developing the game, you can still consume our [bin | ------------- | ------------- | ------------- | ------------- | - **Linux** users are recommended to self-compile until we have official deployment in place. +- When running on Windows 7 or 8.1, **[additional prerequisites](https://docs.microsoft.com/en-us/dotnet/core/install/dependencies?tabs=netcore31&pivots=os-windows)** may be required to correctly run .NET Core applications if your operating system is not up-to-date with the latest service packs. If your platform is not listed above, there is still a chance you can manually build it by following the instructions below. +## Developing or debugging + +Please make sure you have the following preqreuisites: + +- A desktop platform with the [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download) or higher installed. +- When developing with mobile, [Xamarin](https://docs.microsoft.com/en-us/xamarin/) is required, which is shipped together with Visual Studio or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/). +- When working with the codebase, we recommend using an IDE with intelligent code completion and syntax highlighting, such as [Visual Studio 2019+](https://visualstudio.microsoft.com/vs/), [JetBrains Rider](https://www.jetbrains.com/rider/) or [Visual Studio Code](https://code.visualstudio.com/). +- When running on Linux, please have a system-wide FFmpeg installation available to support video decoding. + ### Downloading the source code Clone the repository: From 19872d9e24009e29ae27f547d8ee568268f26b16 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 22:05:10 +0300 Subject: [PATCH 23/30] Simplify test scene --- .../TestSceneBeatmapListingSort.cs | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs index 4638b2bb54..a5fa085abf 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapListingSort.cs @@ -24,39 +24,32 @@ namespace osu.Game.Tests.Visual.UserInterface [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); - private readonly FillFlowContainer placeholder; - private readonly BeatmapListingSortTabControl control; - public TestSceneBeatmapListingSort() { + BeatmapListingSortTabControl control; + OsuSpriteText current; + OsuSpriteText direction; + Add(control = new BeatmapListingSortTabControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, }); - Add(placeholder = new FillFlowContainer + Add(new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 5), + Children = new Drawable[] + { + current = new OsuSpriteText(), + direction = new OsuSpriteText() + } }); - } - protected override void LoadComplete() - { - base.LoadComplete(); - - control.SortDirection.BindValueChanged(_ => updateBindablesVisual()); - control.Current.BindValueChanged(_ => updateBindablesVisual(), true); - } - - private void updateBindablesVisual() - { - placeholder.Clear(); - - placeholder.Add(new OsuSpriteText { Text = $"Current: {control.Current.Value}" }); - placeholder.Add(new OsuSpriteText { Text = $"Sort direction: {control.SortDirection.Value}" }); + control.SortDirection.BindValueChanged(sortDirection => direction.Text = $"Sort direction: {sortDirection.NewValue}", true); + control.Current.BindValueChanged(criteria => current.Text = $"Criteria: {criteria.NewValue}", true); } } } From 519548c99f5c1349bb3c774406897e0f14168e42 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 22:06:46 +0300 Subject: [PATCH 24/30] Remove not necessary icon margin changes --- osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs index 3f69c76da7..d6841da408 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs @@ -84,7 +84,6 @@ namespace osu.Game.Overlays.BeatmapListing SortDirection.BindValueChanged(direction => { icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown; - icon.Margin = direction.NewValue == Overlays.SortDirection.Ascending ? new MarginPadding { Top = 1 } : new MarginPadding { Top = 2 }; }, true); } From bce9e7a356912cd7eb7c1d4fd6a35a6cc2ad1163 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 22:32:58 +0300 Subject: [PATCH 25/30] Remove too much nesting for OverlaySortTabControl class --- .../BeatmapListingSortTabControl.cs | 112 ++++++------- osu.Game/Overlays/OverlaySortTabControl.cs | 150 +++++++++--------- 2 files changed, 131 insertions(+), 131 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs b/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs index d6841da408..cb41b33bc4 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapListingSortTabControl.cs @@ -33,74 +33,74 @@ namespace osu.Game.Overlays.BeatmapListing { SortDirection = { BindTarget = SortDirection } }; + } - private class BeatmapSortTabItem : SortTabItem + private class BeatmapSortTabItem : SortTabItem + { + public readonly Bindable SortDirection = new Bindable(); + + public BeatmapSortTabItem(BeatmapSortCriteria value) + : base(value) { - public readonly Bindable SortDirection = new Bindable(); + } - public BeatmapSortTabItem(BeatmapSortCriteria value) - : base(value) + protected override TabButton CreateTabButton(BeatmapSortCriteria value) => new BeatmapTabButton(value) + { + Active = { BindTarget = Active }, + SortDirection = { BindTarget = SortDirection } + }; + } + + private class BeatmapTabButton : TabButton + { + public readonly Bindable SortDirection = new Bindable(); + + protected override Color4 ContentColour + { + set { + base.ContentColour = value; + icon.Colour = value; } + } - protected override TabButton CreateTabButton(BeatmapSortCriteria value) => new BeatmapTabButton(value) + private readonly SpriteIcon icon; + + public BeatmapTabButton(BeatmapSortCriteria value) + : base(value) + { + Add(icon = new SpriteIcon { - Active = { BindTarget = Active }, - SortDirection = { BindTarget = SortDirection } - }; + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + AlwaysPresent = true, + Alpha = 0, + Size = new Vector2(6) + }); + } - private class BeatmapTabButton : TabButton + protected override void LoadComplete() + { + base.LoadComplete(); + + SortDirection.BindValueChanged(direction => { - public readonly Bindable SortDirection = new Bindable(); + icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown; + }, true); + } - protected override Color4 ContentColour - { - set - { - base.ContentColour = value; - icon.Colour = value; - } - } + protected override void UpdateState() + { + base.UpdateState(); + icon.FadeTo(Active.Value || IsHovered ? 1 : 0, 200, Easing.OutQuint); + } - private readonly SpriteIcon icon; + protected override bool OnClick(ClickEvent e) + { + if (Active.Value) + SortDirection.Value = SortDirection.Value == Overlays.SortDirection.Ascending ? Overlays.SortDirection.Descending : Overlays.SortDirection.Ascending; - public BeatmapTabButton(BeatmapSortCriteria value) - : base(value) - { - Add(icon = new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AlwaysPresent = true, - Alpha = 0, - Size = new Vector2(6) - }); - } - - protected override void LoadComplete() - { - base.LoadComplete(); - - SortDirection.BindValueChanged(direction => - { - icon.Icon = direction.NewValue == Overlays.SortDirection.Ascending ? FontAwesome.Solid.CaretUp : FontAwesome.Solid.CaretDown; - }, true); - } - - protected override void UpdateState() - { - base.UpdateState(); - icon.FadeTo(Active.Value || IsHovered ? 1 : 0, 200, Easing.OutQuint); - } - - protected override bool OnClick(ClickEvent e) - { - if (Active.Value) - SortDirection.Value = SortDirection.Value == Overlays.SortDirection.Ascending ? Overlays.SortDirection.Descending : Overlays.SortDirection.Ascending; - - return base.OnClick(e); - } - } + return base.OnClick(e); } } } diff --git a/osu.Game/Overlays/OverlaySortTabControl.cs b/osu.Game/Overlays/OverlaySortTabControl.cs index 487dd70db9..5a713ab08e 100644 --- a/osu.Game/Overlays/OverlaySortTabControl.cs +++ b/osu.Game/Overlays/OverlaySortTabControl.cs @@ -75,93 +75,93 @@ namespace osu.Game.Overlays { AutoSizeAxes = Axes.Both; } + } - protected class SortTabItem : TabItem + protected class SortTabItem : TabItem + { + public SortTabItem(T value) + : base(value) { - public SortTabItem(T value) - : base(value) + AutoSizeAxes = Axes.Both; + Child = CreateTabButton(value); + } + + [NotNull] + protected virtual TabButton CreateTabButton(T value) => new TabButton(value) + { + Active = { BindTarget = Active } + }; + + protected override void OnActivated() + { + } + + protected override void OnDeactivated() + { + } + } + + protected class TabButton : HeaderButton + { + public readonly BindableBool Active = new BindableBool(); + + protected override Container Content => content; + + protected virtual Color4 ContentColour + { + set => text.Colour = value; + } + + [Resolved] + private OverlayColourProvider colourProvider { get; set; } + + private readonly SpriteText text; + private readonly FillFlowContainer content; + + public TabButton(T value) + { + base.Content.Add(content = new FillFlowContainer { - AutoSizeAxes = Axes.Both; - Child = CreateTabButton(value); - } - - [NotNull] - protected virtual TabButton CreateTabButton(T value) => new TabButton(value) - { - Active = { BindTarget = Active } - }; - - protected override void OnActivated() - { - } - - protected override void OnDeactivated() - { - } - - protected class TabButton : HeaderButton - { - public readonly BindableBool Active = new BindableBool(); - - protected override Container Content => content; - - protected virtual Color4 ContentColour + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(3, 0), + Children = new Drawable[] { - set => text.Colour = value; - } - - [Resolved] - private OverlayColourProvider colourProvider { get; set; } - - private readonly SpriteText text; - private readonly FillFlowContainer content; - - public TabButton(T value) - { - base.Content.Add(content = new FillFlowContainer + text = new OsuSpriteText { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(3, 0), - Children = new Drawable[] - { - text = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 12), - Text = value.ToString() - } - } - }); + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Font = OsuFont.GetFont(size: 12), + Text = value.ToString() + } } + }); + } - protected override void LoadComplete() - { - base.LoadComplete(); - Active.BindValueChanged(_ => UpdateState(), true); - } + protected override void LoadComplete() + { + base.LoadComplete(); + Active.BindValueChanged(_ => UpdateState(), true); + } - protected override bool OnHover(HoverEvent e) - { - UpdateState(); - return true; - } + protected override bool OnHover(HoverEvent e) + { + UpdateState(); + return true; + } - protected override void OnHoverLost(HoverLostEvent e) => UpdateState(); + protected override void OnHoverLost(HoverLostEvent e) => UpdateState(); - protected virtual void UpdateState() - { - if (Active.Value || IsHovered) - ShowBackground(); - else - HideBackground(); + protected virtual void UpdateState() + { + if (Active.Value || IsHovered) + ShowBackground(); + else + HideBackground(); - ContentColour = Active.Value && !IsHovered ? colourProvider.Light1 : Color4.White; + ContentColour = Active.Value && !IsHovered ? colourProvider.Light1 : Color4.White; - text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); - } - } + text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); } } } From ea99b613c9c499fc21b038fe808ca57dafa07d5c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 23:41:07 +0300 Subject: [PATCH 26/30] Use GridContainer for layout --- .../BeatmapListing/BeatmapSearchFilterRow.cs | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs index 05578a36b5..0c4f63baca 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs @@ -32,33 +32,37 @@ namespace osu.Game.Overlays.BeatmapListing { AutoSizeAxes = Axes.Y; RelativeSizeAxes = Axes.X; - AddInternal(new FillFlowContainer + AddInternal(new GridContainer { AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, - Spacing = new Vector2(0, 7), - Children = new Drawable[] + ColumnDimensions = new[] { - new Container + new Dimension(GridSizeMode.Absolute, size: 100), + new Dimension() + }, + RowDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize) + }, + Content = new[] + { + new Drawable[] { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - AutoSizeAxes = Axes.Y, - Width = 100, - Child = new OsuSpriteText + new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Font = OsuFont.GetFont(size: 10), Text = headerName.ToUpper() - } - }, - CreateFilter().With(f => - { - f.Anchor = Anchor.CentreLeft; - f.Origin = Anchor.CentreLeft; - f.Current = current; - }) + }, + CreateFilter().With(f => + { + f.Anchor = Anchor.CentreLeft; + f.Origin = Anchor.CentreLeft; + f.Current = current; + }) + } } }); } From ae942388a2aeb83bf382701e83cc06f7f6c9f65e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 23:56:35 +0300 Subject: [PATCH 27/30] Move OsuTabDropdown to it's own file --- .../Graphics/UserInterface/OsuTabControl.cs | 97 +--------------- .../Graphics/UserInterface/OsuTabDropdown.cs | 107 ++++++++++++++++++ 2 files changed, 108 insertions(+), 96 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/OsuTabDropdown.cs diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 9fa6085035..6c883d9893 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -39,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface private readonly Box strip; - protected override Dropdown CreateDropdown() => new OsuTabDropdown(); + protected override Dropdown CreateDropdown() => new OsuTabDropdown(); protected override TabItem CreateTabItem(T value) => new OsuTabItem(value); @@ -180,100 +180,5 @@ namespace osu.Game.Graphics.UserInterface protected override void OnDeactivated() => fadeInactive(); } - - // todo: this needs to go - private class OsuTabDropdown : OsuDropdown - { - public OsuTabDropdown() - { - RelativeSizeAxes = Axes.X; - } - - protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu(); - - protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight - }; - - private class OsuTabDropdownMenu : OsuDropdownMenu - { - public OsuTabDropdownMenu() - { - Anchor = Anchor.TopRight; - Origin = Anchor.TopRight; - - BackgroundColour = Color4.Black.Opacity(0.7f); - MaxHeight = 400; - } - - protected override DrawableDropdownMenuItem CreateDrawableDropdownMenuItem(MenuItem item) => new DrawableOsuTabDropdownMenuItem(item) { AccentColour = AccentColour }; - - private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem - { - public DrawableOsuTabDropdownMenuItem(MenuItem item) - : base(item) - { - ForegroundColourHover = Color4.Black; - } - } - } - - protected class OsuTabDropdownHeader : OsuDropdownHeader - { - public override Color4 AccentColour - { - get => base.AccentColour; - set - { - base.AccentColour = value; - Foreground.Colour = value; - } - } - - public OsuTabDropdownHeader() - { - RelativeSizeAxes = Axes.None; - AutoSizeAxes = Axes.X; - - BackgroundColour = Color4.Black.Opacity(0.5f); - - Background.Height = 0.5f; - Background.CornerRadius = 5; - Background.Masking = true; - - Foreground.RelativeSizeAxes = Axes.None; - Foreground.AutoSizeAxes = Axes.X; - Foreground.RelativeSizeAxes = Axes.Y; - Foreground.Margin = new MarginPadding(5); - - Foreground.Children = new Drawable[] - { - new SpriteIcon - { - Icon = FontAwesome.Solid.EllipsisH, - Size = new Vector2(14), - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - } - }; - - Padding = new MarginPadding { Left = 5, Right = 5 }; - } - - protected override bool OnHover(HoverEvent e) - { - Foreground.Colour = BackgroundColour; - return base.OnHover(e); - } - - protected override void OnHoverLost(HoverLostEvent e) - { - Foreground.Colour = BackgroundColourHover; - base.OnHoverLost(e); - } - } - } } } diff --git a/osu.Game/Graphics/UserInterface/OsuTabDropdown.cs b/osu.Game/Graphics/UserInterface/OsuTabDropdown.cs new file mode 100644 index 0000000000..24b9ca8d90 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuTabDropdown.cs @@ -0,0 +1,107 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osuTK; +using osuTK.Graphics; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input.Events; + +namespace osu.Game.Graphics.UserInterface +{ + public class OsuTabDropdown : OsuDropdown + { + public OsuTabDropdown() + { + RelativeSizeAxes = Axes.X; + } + + protected override DropdownMenu CreateMenu() => new OsuTabDropdownMenu(); + + protected override DropdownHeader CreateHeader() => new OsuTabDropdownHeader + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight + }; + + private class OsuTabDropdownMenu : OsuDropdownMenu + { + public OsuTabDropdownMenu() + { + Anchor = Anchor.TopRight; + Origin = Anchor.TopRight; + + BackgroundColour = Color4.Black.Opacity(0.7f); + MaxHeight = 400; + } + + protected override DrawableDropdownMenuItem CreateDrawableDropdownMenuItem(MenuItem item) => new DrawableOsuTabDropdownMenuItem(item) { AccentColour = AccentColour }; + + private class DrawableOsuTabDropdownMenuItem : DrawableOsuDropdownMenuItem + { + public DrawableOsuTabDropdownMenuItem(MenuItem item) + : base(item) + { + ForegroundColourHover = Color4.Black; + } + } + } + + protected class OsuTabDropdownHeader : OsuDropdownHeader + { + public override Color4 AccentColour + { + get => base.AccentColour; + set + { + base.AccentColour = value; + Foreground.Colour = value; + } + } + + public OsuTabDropdownHeader() + { + RelativeSizeAxes = Axes.None; + AutoSizeAxes = Axes.X; + + BackgroundColour = Color4.Black.Opacity(0.5f); + + Background.Height = 0.5f; + Background.CornerRadius = 5; + Background.Masking = true; + + Foreground.RelativeSizeAxes = Axes.None; + Foreground.AutoSizeAxes = Axes.X; + Foreground.RelativeSizeAxes = Axes.Y; + Foreground.Margin = new MarginPadding(5); + + Foreground.Children = new Drawable[] + { + new SpriteIcon + { + Icon = FontAwesome.Solid.EllipsisH, + Size = new Vector2(14), + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + } + }; + + Padding = new MarginPadding { Left = 5, Right = 5 }; + } + + protected override bool OnHover(HoverEvent e) + { + Foreground.Colour = BackgroundColour; + return base.OnHover(e); + } + + protected override void OnHoverLost(HoverLostEvent e) + { + Foreground.Colour = BackgroundColourHover; + base.OnHoverLost(e); + } + } + } +} From 410686c8b9dfbe393f23b3bbc1cefb21c499da40 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 18 Feb 2020 01:04:25 +0300 Subject: [PATCH 28/30] Use dropdown in BeatmapSearchFilterRow --- .../TestSceneBeatmapSearchFilter.cs | 5 +- .../BeatmapListing/BeatmapSearchFilterRow.cs | 46 ++++++++++++++----- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs index 30cd34be50..7b4424e568 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs @@ -7,6 +7,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Containers; using osu.Game.Online.API.Requests; using osu.Game.Overlays; using osu.Game.Overlays.BeatmapListing; @@ -26,11 +27,11 @@ namespace osu.Game.Tests.Visual.UserInterface [Cached] private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); - private readonly FillFlowContainer resizableContainer; + private readonly ReverseChildIDFillFlowContainer resizableContainer; public TestSceneBeatmapSearchFilter() { - Add(resizableContainer = new FillFlowContainer + Add(resizableContainer = new ReverseChildIDFillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs index 0c4f63baca..8be0fca629 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs @@ -51,15 +51,13 @@ namespace osu.Game.Overlays.BeatmapListing { new OsuSpriteText { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, Font = OsuFont.GetFont(size: 10), Text = headerName.ToUpper() }, CreateFilter().With(f => { - f.Anchor = Anchor.CentreLeft; - f.Origin = Anchor.CentreLeft; f.Current = current; }) } @@ -74,7 +72,12 @@ namespace osu.Game.Overlays.BeatmapListing { public BeatmapSearchFilter() { - AutoSizeAxes = Axes.Both; + Anchor = Anchor.BottomLeft; + Origin = Anchor.BottomLeft; + RelativeSizeAxes = Axes.X; + Height = 15; + + TabContainer.Spacing = new Vector2(10, 0); if (typeof(T).IsEnum) { @@ -83,16 +86,16 @@ namespace osu.Game.Overlays.BeatmapListing } } - protected override Dropdown CreateDropdown() => null; + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + ((FilterDropdown)Dropdown).AccentColour = colourProvider.Light2; + } + + protected override Dropdown CreateDropdown() => new FilterDropdown(); protected override TabItem CreateTabItem(T value) => new FilterTabItem(value); - protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer - { - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(10), - }; - protected class FilterTabItem : TabItem { protected virtual float TextSize => 13; @@ -106,6 +109,8 @@ namespace osu.Game.Overlays.BeatmapListing : base(value) { AutoSizeAxes = Axes.Both; + Anchor = Anchor.BottomLeft; + Origin = Anchor.BottomLeft; AddRangeInternal(new Drawable[] { text = new OsuSpriteText @@ -148,6 +153,23 @@ namespace osu.Game.Overlays.BeatmapListing private Color4 getStateColour() => IsHovered ? colourProvider.Light1 : colourProvider.Light3; } + + private class FilterDropdown : OsuTabDropdown + { + protected override DropdownHeader CreateHeader() => new FilterHeader + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight + }; + + private class FilterHeader : OsuTabDropdownHeader + { + public FilterHeader() + { + Background.Height = 1; + } + } + } } } } From 316c6b2a945ad9c7524d53e23de15eb0b29a87ec Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 18 Feb 2020 01:17:12 +0300 Subject: [PATCH 29/30] Simplify RulesetInfo string presentation --- .../BeatmapListing/BeatmapSearchFilterRow.cs | 4 +--- .../BeatmapListing/BeatmapSearchRulesetFilterRow.cs | 13 ------------- osu.Game/Rulesets/RulesetInfo.cs | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs index 8be0fca629..2c046a2bbf 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs @@ -116,7 +116,7 @@ namespace osu.Game.Overlays.BeatmapListing text = new OsuSpriteText { Font = OsuFont.GetFont(size: TextSize, weight: FontWeight.Regular), - Text = GetText(value) + Text = (value as Enum)?.GetDescription() ?? value.ToString() }, new HoverClickSounds() }); @@ -130,8 +130,6 @@ namespace osu.Game.Overlays.BeatmapListing updateState(); } - protected virtual string GetText(T value) => (value as Enum)?.GetDescription() ?? value.ToString(); - protected override bool OnHover(HoverEvent e) { base.OnHover(e); diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs index d30364ab0d..eebd896cf9 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchRulesetFilterRow.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Framework.Graphics.UserInterface; using osu.Game.Rulesets; namespace osu.Game.Overlays.BeatmapListing @@ -29,18 +28,6 @@ namespace osu.Game.Overlays.BeatmapListing foreach (var r in rulesets.AvailableRulesets) AddItem(r); } - - protected override TabItem CreateTabItem(RulesetInfo value) => new RulesetTabItem(value); - - private class RulesetTabItem : FilterTabItem - { - public RulesetTabItem(RulesetInfo value) - : base(value) - { - } - - protected override string GetText(RulesetInfo value) => value.Name; - } } } } diff --git a/osu.Game/Rulesets/RulesetInfo.cs b/osu.Game/Rulesets/RulesetInfo.cs index ececc18c96..afd499cb9e 100644 --- a/osu.Game/Rulesets/RulesetInfo.cs +++ b/osu.Game/Rulesets/RulesetInfo.cs @@ -50,6 +50,6 @@ namespace osu.Game.Rulesets } } - public override string ToString() => $"{Name} ({ShortName}) ID: {ID}"; + public override string ToString() => Name ?? $"{Name} ({ShortName}) ID: {ID}"; } } From a4891c13e460d1df77e4d2c26ec55fdb4572bd88 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 18 Feb 2020 09:17:04 +0900 Subject: [PATCH 30/30] Fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Bartłomiej Dach --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6071e3f473..6cc110280c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ If your platform is not listed above, there is still a chance you can manually b ## Developing or debugging -Please make sure you have the following preqreuisites: +Please make sure you have the following prerequisites: - A desktop platform with the [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download) or higher installed. - When developing with mobile, [Xamarin](https://docs.microsoft.com/en-us/xamarin/) is required, which is shipped together with Visual Studio or [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac/).