From 3888911eee7882f5131aa44b25bfcef29640a9d0 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Sun, 16 Feb 2020 14:19:49 +0300 Subject: [PATCH 01/12] 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/12] 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/12] 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/12] 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/12] 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/12] 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 ede85d7be471724397377bf145f015738739609c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 18 Feb 2020 00:59:08 +0900 Subject: [PATCH 07/12] 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 ea99b613c9c499fc21b038fe808ca57dafa07d5c Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 17 Feb 2020 23:41:07 +0300 Subject: [PATCH 08/12] 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 09/12] 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 10/12] 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 11/12] 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 12/12] 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/).