From 2d42a83bb9bd718bac9e6ce5c5dce41632f6f455 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sat, 1 Feb 2020 11:24:29 -0800 Subject: [PATCH 01/12] Fix mod select overlay overflowing toolbar at max ui scale --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 4 +-- osu.Game/Screens/Select/SongSelect.cs | 41 +++++++++++++++------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 38f5d54714..af772bc2fa 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -66,7 +66,6 @@ namespace osu.Game.Overlays.Mods Waves.ThirdWaveColour = OsuColour.FromHex(@"005774"); Waves.FourthWaveColour = OsuColour.FromHex(@"003a4e"); - Height = 510; Padding = new MarginPadding { Horizontal = -OsuScreen.HORIZONTAL_OVERFLOW_PADDING }; Children = new Drawable[] @@ -85,8 +84,7 @@ namespace osu.Game.Overlays.Mods new Triangles { TriangleScale = 5, - RelativeSizeAxes = Axes.X, - Height = Height, //set the height from the start to ensure correct triangle density. + RelativeSizeAxes = Axes.Both, ColourLight = new Color4(53, 66, 82, 255), ColourDark = new Color4(41, 54, 70, 255), }, diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index f9f015643d..8647012ee7 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -221,23 +221,38 @@ namespace osu.Game.Screens.Select if (ShowFooter) { - AddRangeInternal(new[] + AddRangeInternal(new Drawable[] { - FooterPanels = new Container + new GridContainer // used for max width implementation { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Bottom = Footer.HEIGHT }, - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + RowDimensions = new[] { - BeatmapOptions = new BeatmapOptionsOverlay(), - ModSelect = new ModSelectOverlay + new Dimension(), + new Dimension(GridSizeMode.Relative, 1f, maxSize: 560), + }, + Content = new[] + { + null, + new Drawable[] { - RelativeSizeAxes = Axes.X, - Origin = Anchor.BottomCentre, - Anchor = Anchor.BottomCentre, + FooterPanels = new Container + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Bottom = Footer.HEIGHT }, + Children = new Drawable[] + { + BeatmapOptions = new BeatmapOptionsOverlay(), + ModSelect = new ModSelectOverlay + { + RelativeSizeAxes = Axes.Both, + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + } + } + } } } }, From 609ee260302563751370d7e47ad5939cb887e673 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sat, 1 Feb 2020 11:41:41 -0800 Subject: [PATCH 02/12] Fix mod select overlay not showing up in test --- .../Visual/UserInterface/TestSceneModSelectOverlay.cs | 1 - osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 ++ osu.Game/Screens/Select/SongSelect.cs | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs index 12ee4ceb2e..dfc684d376 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSelectOverlay.cs @@ -60,7 +60,6 @@ namespace osu.Game.Tests.Visual.UserInterface { modSelect = new TestModSelectOverlay { - RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, }, diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index af772bc2fa..2868fe1d79 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -66,6 +66,8 @@ namespace osu.Game.Overlays.Mods Waves.ThirdWaveColour = OsuColour.FromHex(@"005774"); Waves.FourthWaveColour = OsuColour.FromHex(@"003a4e"); + RelativeSizeAxes = Axes.Both; + Padding = new MarginPadding { Horizontal = -OsuScreen.HORIZONTAL_OVERFLOW_PADDING }; Children = new Drawable[] diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 8647012ee7..3f80c90b9d 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -247,7 +247,6 @@ namespace osu.Game.Screens.Select BeatmapOptions = new BeatmapOptionsOverlay(), ModSelect = new ModSelectOverlay { - RelativeSizeAxes = Axes.Both, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, } From 583fee074fa2ef266f5595501646c7b383b1a0fa Mon Sep 17 00:00:00 2001 From: Joehu Date: Sat, 1 Feb 2020 11:50:24 -0800 Subject: [PATCH 03/12] Fix mod select not showing up in mod settings test --- osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs index e2ce2341e5..ba0970e123 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneModSettings.cs @@ -74,7 +74,6 @@ namespace osu.Game.Tests.Visual.UserInterface Child = modSelect = new TestModSelectOverlay { - RelativeSizeAxes = Axes.X, Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, }; From 032c2c2afe281d1a68e86612096ff5a6dbd9bd75 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 3 Feb 2020 14:16:26 +0300 Subject: [PATCH 04/12] Refactor BeatmapRulesetSelector --- .../Online/TestSceneBeatmapRulesetSelector.cs | 4 + .../BeatmapSet/BeatmapRulesetSelector.cs | 17 +- .../BeatmapSet/BeatmapRulesetTabItem.cs | 150 ++++++------------ osu.Game/Overlays/BeatmapSet/Header.cs | 6 +- osu.Game/Overlays/OverlayRulesetTabItem.cs | 16 +- 5 files changed, 65 insertions(+), 128 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs index 1f8df438fb..8b077c8de3 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneBeatmapRulesetSelector.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.UserInterface; using osu.Game.Beatmaps; +using osu.Game.Overlays; using osu.Game.Overlays.BeatmapSet; using osu.Game.Rulesets; using System; @@ -21,6 +22,9 @@ namespace osu.Game.Tests.Visual.Online typeof(BeatmapRulesetTabItem), }; + [Cached] + private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + private readonly TestRulesetSelector selector; public TestSceneBeatmapRulesetSelector() diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs index a0bedc848e..005d21726b 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs @@ -2,17 +2,14 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; -using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.UserInterface; using osu.Game.Beatmaps; using osu.Game.Rulesets; -using osuTK; using System.Linq; namespace osu.Game.Overlays.BeatmapSet { - public class BeatmapRulesetSelector : RulesetSelector + public class BeatmapRulesetSelector : OverlayRulesetSelector { private readonly Bindable beatmapSet = new Bindable(); @@ -28,21 +25,9 @@ namespace osu.Game.Overlays.BeatmapSet } } - public BeatmapRulesetSelector() - { - AutoSizeAxes = Axes.Both; - } - protected override TabItem CreateTabItem(RulesetInfo value) => new BeatmapRulesetTabItem(value) { BeatmapSet = { BindTarget = beatmapSet } }; - - protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(10, 0), - }; } } diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs index cdea49afe7..3e473df621 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs @@ -3,143 +3,87 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.UserInterface; -using osu.Framework.Input.Events; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets; -using osuTK; -using osuTK.Graphics; using System.Linq; namespace osu.Game.Overlays.BeatmapSet { - public class BeatmapRulesetTabItem : TabItem + public class BeatmapRulesetTabItem : OverlayRulesetTabItem { - private readonly OsuSpriteText name, count; - private readonly Box bar; - public readonly Bindable BeatmapSet = new Bindable(); public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree; + [Resolved] + private OverlayColourProvider colourProvider { get; set; } + + private OsuSpriteText count; + private Container countContainer; + public BeatmapRulesetTabItem(RulesetInfo value) : base(value) { - AutoSizeAxes = Axes.Both; + } - FillFlowContainer nameContainer; - - Children = new Drawable[] + [BackgroundDependencyLoader] + private void load() + { + Content.Add(countContainer = new Container { - nameContainer = new FillFlowContainer + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Masking = true, + CornerRadius = 4f, + Children = new Drawable[] { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Horizontal, - Margin = new MarginPadding { Bottom = 7.5f }, - Spacing = new Vector2(2.5f), - Children = new Drawable[] + new Box { - name = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Text = value.Name, - Font = OsuFont.Default.With(size: 18), - }, - new Container - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - AutoSizeAxes = Axes.Both, - Masking = true, - CornerRadius = 4f, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = Color4.Black.Opacity(0.5f), - }, - count = new OsuSpriteText - { - Alpha = 0, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Margin = new MarginPadding { Horizontal = 5f }, - Font = OsuFont.Default.With(weight: FontWeight.SemiBold), - } - } - } + RelativeSizeAxes = Axes.Both, + Colour = colourProvider.Background6 + }, + count = new OsuSpriteText + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Margin = new MarginPadding { Horizontal = 5f }, + Font = OsuFont.Default.With(weight: FontWeight.SemiBold), + Colour = colourProvider.Foreground1, } - }, - bar = new Box - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativeSizeAxes = Axes.X, - }, - new HoverClickSounds(), - }; + } + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); BeatmapSet.BindValueChanged(setInfo => { var beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.Equals(Value)) ?? 0; count.Text = beatmapsCount.ToString(); - count.Alpha = beatmapsCount > 0 ? 1f : 0f; + countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0); Enabled.Value = beatmapsCount > 0; }, true); - Enabled.BindValueChanged(v => nameContainer.Alpha = v.NewValue ? 1f : 0.5f, true); + Enabled.BindValueChanged(enabled => + { + if (enabled.NewValue) + { + UpdateState(); + return; + } + + AccentColour = colourProvider.Foreground1; + }, true); } - - [Resolved] - private OsuColour colour { get; set; } - - protected override void LoadComplete() - { - base.LoadComplete(); - - count.Colour = colour.Gray9; - bar.Colour = colour.Blue; - - updateState(); - } - - private void updateState() - { - var isHoveredOrActive = IsHovered || Active.Value; - - bar.ResizeHeightTo(isHoveredOrActive ? 4 : 0, 200, Easing.OutQuint); - - name.Colour = isHoveredOrActive ? colour.GrayE : colour.GrayC; - name.Font = name.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Regular); - } - - #region Hovering and activation logic - - protected override void OnActivated() => updateState(); - - protected override void OnDeactivated() => updateState(); - - protected override bool OnHover(HoverEvent e) - { - updateState(); - return false; - } - - protected override void OnHoverLost(HoverLostEvent e) => updateState(); - - #endregion } } diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index 7b42e7e459..c787df01ae 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -74,7 +74,7 @@ namespace osu.Game.Overlays.BeatmapSet new Container { RelativeSizeAxes = Axes.X, - Height = tabs_height, + AutoSizeAxes = Axes.Y, Children = new Drawable[] { tabsBg = new Box @@ -84,8 +84,8 @@ namespace osu.Game.Overlays.BeatmapSet RulesetSelector = new BeatmapRulesetSelector { Current = ruleset, - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, } }, }, diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index f8a9d14f62..5e6ac57886 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -64,29 +64,33 @@ namespace osu.Game.Overlays [BackgroundDependencyLoader] private void load() { - updateState(); + UpdateState(); } protected override bool OnHover(HoverEvent e) { base.OnHover(e); - updateState(); + UpdateState(); return true; } protected override void OnHoverLost(HoverLostEvent e) { base.OnHoverLost(e); - updateState(); + UpdateState(); } - protected override void OnActivated() => updateState(); + protected override void OnActivated() => UpdateState(); - protected override void OnDeactivated() => updateState(); + protected override void OnDeactivated() => UpdateState(); - private void updateState() + protected void UpdateState() { text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); + + if (!Enabled.Value) + return; + AccentColour = IsHovered || Active.Value ? Color4.White : colourProvider.Highlight1; } } From fa453bc3e158d3a604407d1a44fc1f09a5aed600 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 3 Feb 2020 14:35:07 +0300 Subject: [PATCH 05/12] Refactor beatmap header --- .../Overlays/BeatmapSet/BeatmapSetHeader.cs | 34 +++ osu.Game/Overlays/BeatmapSet/Header.cs | 248 +++++++++--------- 2 files changed, 151 insertions(+), 131 deletions(-) create mode 100644 osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs new file mode 100644 index 0000000000..bf9f3ccc17 --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs @@ -0,0 +1,34 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; +using osu.Game.Rulesets; + +namespace osu.Game.Overlays.BeatmapSet +{ + public class BeatmapSetHeader : OverlayHeader + { + public readonly Bindable Ruleset = new Bindable(); + public BeatmapRulesetSelector RulesetSelector; + + protected override ScreenTitle CreateTitle() => new BeatmapHeaderTitle(); + + protected override Drawable CreateTitleContent() => RulesetSelector = new BeatmapRulesetSelector + { + Current = Ruleset + }; + + private class BeatmapHeaderTitle : ScreenTitle + { + public BeatmapHeaderTitle() + { + Title = @"beatmap"; + Section = @"info"; + } + + protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/changelog"); + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/Header.cs b/osu.Game/Overlays/BeatmapSet/Header.cs index c787df01ae..7c5c5a9d55 100644 --- a/osu.Game/Overlays/BeatmapSet/Header.cs +++ b/osu.Game/Overlays/BeatmapSet/Header.cs @@ -26,11 +26,9 @@ namespace osu.Game.Overlays.BeatmapSet public class Header : BeatmapDownloadTrackingComposite { private const float transition_duration = 200; - private const float tabs_height = 50; private const float buttons_height = 45; private const float buttons_spacing = 5; - private readonly Box tabsBg; private readonly UpdateableBeatmapSetCover cover; private readonly OsuSpriteText title, artist; private readonly AuthorInfo author; @@ -41,14 +39,13 @@ namespace osu.Game.Overlays.BeatmapSet public bool DownloadButtonsVisible => downloadButtonsContainer.Any(); - public readonly BeatmapRulesetSelector RulesetSelector; + public BeatmapRulesetSelector RulesetSelector => beatmapSetHeader.RulesetSelector; public readonly BeatmapPicker Picker; private readonly FavouriteButton favouriteButton; - private readonly FillFlowContainer fadeContent; - private readonly LoadingAnimation loading; + private readonly BeatmapSetHeader beatmapSetHeader; [Cached(typeof(IBindable))] private readonly Bindable ruleset = new Bindable(); @@ -69,154 +66,145 @@ namespace osu.Game.Overlays.BeatmapSet Offset = new Vector2(0f, 1f), }; - InternalChildren = new Drawable[] + InternalChild = new FillFlowContainer { - new Container + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Children = new Drawable[] + beatmapSetHeader = new BeatmapSetHeader { - tabsBg = new Box - { - RelativeSizeAxes = Axes.Both, - }, - RulesetSelector = new BeatmapRulesetSelector - { - Current = ruleset, - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - } + Ruleset = { BindTarget = ruleset }, }, - }, - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Top = tabs_height }, - Children = new Drawable[] + new Container { - new Container + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + new Container { - cover = new UpdateableBeatmapSetCover + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Masking = true, - }, - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.3f), Color4.Black.Opacity(0.8f)), - }, - }, - }, - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Padding = new MarginPadding - { - Top = 20, - Bottom = 30, - Left = BeatmapSetOverlay.X_PADDING, - Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH, - }, - Children = new Drawable[] - { - fadeContent = new FillFlowContainer - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Children = new Drawable[] + cover = new UpdateableBeatmapSetCover { - new Container + RelativeSizeAxes = Axes.Both, + Masking = true, + }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.3f), Color4.Black.Opacity(0.8f)), + }, + }, + }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding + { + Top = 20, + Bottom = 30, + Left = BeatmapSetOverlay.X_PADDING, + Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH, + }, + Children = new Drawable[] + { + fadeContent = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Children = new Drawable[] { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Child = Picker = new BeatmapPicker(), - }, - new FillFlowContainer - { - Direction = FillDirection.Horizontal, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] + new Container { - title = new OsuSpriteText - { - Font = OsuFont.GetFont(size: 37, weight: FontWeight.Bold, italics: true) - }, - externalLink = new ExternalLinkButton - { - Anchor = Anchor.BottomLeft, - Origin = Anchor.BottomLeft, - Margin = new MarginPadding { Left = 3, Bottom = 4 }, //To better lineup with the font - }, - } - }, - artist = new OsuSpriteText { Font = OsuFont.GetFont(size: 25, weight: FontWeight.SemiBold, italics: true) }, - new Container - { - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding { Top = 20 }, - Child = author = new AuthorInfo(), - }, - beatmapAvailability = new BeatmapAvailability(), - new Container - { - RelativeSizeAxes = Axes.X, - Height = buttons_height, - Margin = new MarginPadding { Top = 10 }, - Children = new Drawable[] + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Child = Picker = new BeatmapPicker(), + }, + new FillFlowContainer { - favouriteButton = new FavouriteButton + Direction = FillDirection.Horizontal, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] { - BeatmapSet = { BindTarget = BeatmapSet } - }, - downloadButtonsContainer = new FillFlowContainer + title = new OsuSpriteText + { + Font = OsuFont.GetFont(size: 37, weight: FontWeight.Bold, italics: true) + }, + externalLink = new ExternalLinkButton + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Margin = new MarginPadding { Left = 3, Bottom = 4 }, //To better lineup with the font + }, + } + }, + artist = new OsuSpriteText { Font = OsuFont.GetFont(size: 25, weight: FontWeight.SemiBold, italics: true) }, + new Container + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Margin = new MarginPadding { Top = 20 }, + Child = author = new AuthorInfo(), + }, + beatmapAvailability = new BeatmapAvailability(), + new Container + { + RelativeSizeAxes = Axes.X, + Height = buttons_height, + Margin = new MarginPadding { Top = 10 }, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Left = buttons_height + buttons_spacing }, - Spacing = new Vector2(buttons_spacing), + favouriteButton = new FavouriteButton + { + BeatmapSet = { BindTarget = BeatmapSet } + }, + downloadButtonsContainer = new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = buttons_height + buttons_spacing }, + Spacing = new Vector2(buttons_spacing), + }, }, }, }, }, - }, - } - }, - loading = new LoadingAnimation - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Scale = new Vector2(1.5f), - }, - new FillFlowContainer - { - Anchor = Anchor.BottomRight, - Origin = Anchor.BottomRight, - AutoSizeAxes = Axes.Both, - Margin = new MarginPadding { Top = BeatmapSetOverlay.TOP_PADDING, Right = BeatmapSetOverlay.X_PADDING }, - Direction = FillDirection.Vertical, - Spacing = new Vector2(10), - Children = new Drawable[] + } + }, + loading = new LoadingAnimation { - onlineStatusPill = new BeatmapSetOnlineStatusPill + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(1.5f), + }, + new FillFlowContainer + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Top = BeatmapSetOverlay.TOP_PADDING, Right = BeatmapSetOverlay.X_PADDING }, + Direction = FillDirection.Vertical, + Spacing = new Vector2(10), + Children = new Drawable[] { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - TextSize = 14, - TextPadding = new MarginPadding { Horizontal = 25, Vertical = 8 } + onlineStatusPill = new BeatmapSetOnlineStatusPill + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + TextSize = 14, + TextPadding = new MarginPadding { Horizontal = 25, Vertical = 8 } + }, + Details = new Details(), }, - Details = new Details(), }, }, }, - }, + } }; Picker.Beatmap.ValueChanged += b => @@ -229,8 +217,6 @@ namespace osu.Game.Overlays.BeatmapSet [BackgroundDependencyLoader] private void load(OsuColour colours) { - tabsBg.Colour = colours.Gray3; - State.BindValueChanged(_ => updateDownloadButtons()); BeatmapSet.BindValueChanged(setInfo => From 2abcc6ad69c4c9c64ebb15f227ff77e3463c1f06 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 3 Feb 2020 15:25:07 +0300 Subject: [PATCH 06/12] Simplify counter addition in BeatmapRulesetTabItem --- osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs index 3e473df621..df159977e6 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs @@ -34,7 +34,7 @@ namespace osu.Game.Overlays.BeatmapSet [BackgroundDependencyLoader] private void load() { - Content.Add(countContainer = new Container + Add(countContainer = new Container { AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, From 4abd9cb89ae3fc3c5bf13a633a35a622a67656c5 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Mon, 3 Feb 2020 21:45:10 +0300 Subject: [PATCH 07/12] Move Enabled/Disabled state logic to the OverlayRulesetTabItem --- .../BeatmapSet/BeatmapRulesetTabItem.cs | 13 ---------- osu.Game/Overlays/OverlayRulesetTabItem.cs | 26 +++++++++---------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs index df159977e6..cb258edced 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapRulesetTabItem.cs @@ -18,8 +18,6 @@ namespace osu.Game.Overlays.BeatmapSet { public readonly Bindable BeatmapSet = new Bindable(); - public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree; - [Resolved] private OverlayColourProvider colourProvider { get; set; } @@ -73,17 +71,6 @@ namespace osu.Game.Overlays.BeatmapSet Enabled.Value = beatmapsCount > 0; }, true); - - Enabled.BindValueChanged(enabled => - { - if (enabled.NewValue) - { - UpdateState(); - return; - } - - AccentColour = colourProvider.Foreground1; - }, true); } } } diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 5e6ac57886..1f0beffe78 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -17,6 +17,8 @@ namespace osu.Game.Overlays { public class OverlayRulesetTabItem : TabItem { + public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree; + private Color4 accentColour; protected virtual Color4 AccentColour @@ -61,37 +63,35 @@ namespace osu.Game.Overlays Enabled.Value = true; } - [BackgroundDependencyLoader] - private void load() + protected override void LoadComplete() { - UpdateState(); + base.LoadComplete(); + Enabled.BindValueChanged(_ => updateState(), true); } protected override bool OnHover(HoverEvent e) { base.OnHover(e); - UpdateState(); + updateState(); return true; } protected override void OnHoverLost(HoverLostEvent e) { base.OnHoverLost(e); - UpdateState(); + updateState(); } - protected override void OnActivated() => UpdateState(); + protected override void OnActivated() => updateState(); - protected override void OnDeactivated() => UpdateState(); + protected override void OnDeactivated() => updateState(); - protected void UpdateState() + private void updateState() { text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); - - if (!Enabled.Value) - return; - - AccentColour = IsHovered || Active.Value ? Color4.White : colourProvider.Highlight1; + AccentColour = IsHovered || Active.Value ? Color4.White : getStateColour(); } + + private Color4 getStateColour() => Enabled.Value ? colourProvider.Highlight1 : colourProvider.Foreground1; } } From fe078c244d2d0e11fd449355cefd9ed6f2233c1e Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 4 Feb 2020 00:43:04 +0300 Subject: [PATCH 08/12] Expose TabControlOverlayHeader.Current value --- osu.Game/Overlays/Changelog/ChangelogHeader.cs | 18 +++++++++--------- osu.Game/Overlays/ChangelogOverlay.cs | 2 +- osu.Game/Overlays/News/NewsHeader.cs | 10 +++++----- osu.Game/Overlays/NewsOverlay.cs | 2 +- osu.Game/Overlays/TabControlOverlayHeader.cs | 17 +++++++++++++++-- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogHeader.cs b/osu.Game/Overlays/Changelog/ChangelogHeader.cs index 4165a180da..8663ec586b 100644 --- a/osu.Game/Overlays/Changelog/ChangelogHeader.cs +++ b/osu.Game/Overlays/Changelog/ChangelogHeader.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Changelog { public class ChangelogHeader : BreadcrumbControlOverlayHeader { - public readonly Bindable Current = new Bindable(); + public readonly Bindable Build = new Bindable(); public Action ListingSelected; @@ -25,18 +25,18 @@ namespace osu.Game.Overlays.Changelog public ChangelogHeader() { TabControl.AddItem(listing_string); - TabControl.Current.ValueChanged += e => + Current.ValueChanged += e => { if (e.NewValue == listing_string) ListingSelected?.Invoke(); }; - Current.ValueChanged += showBuild; + Build.ValueChanged += showBuild; Streams.Current.ValueChanged += e => { - if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Current.Value?.UpdateStream)) - Current.Value = e.NewValue.LatestBuild; + if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Build.Value?.UpdateStream)) + Build.Value = e.NewValue.LatestBuild; }; } @@ -50,7 +50,7 @@ namespace osu.Game.Overlays.Changelog if (e.NewValue != null) { TabControl.AddItem(e.NewValue.ToString()); - TabControl.Current.Value = e.NewValue.ToString(); + Current.Value = e.NewValue.ToString(); updateCurrentStream(); @@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Changelog } else { - TabControl.Current.Value = listing_string; + Current.Value = listing_string; Streams.Current.Value = null; title.Version = null; } @@ -86,10 +86,10 @@ namespace osu.Game.Overlays.Changelog private void updateCurrentStream() { - if (Current.Value == null) + if (Build.Value == null) return; - Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Current.Value.UpdateStream.Name); + Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Build.Value.UpdateStream.Name); } private class ChangelogHeaderTitle : ScreenTitle diff --git a/osu.Game/Overlays/ChangelogOverlay.cs b/osu.Game/Overlays/ChangelogOverlay.cs index 90ba206077..6a8cb29d3e 100644 --- a/osu.Game/Overlays/ChangelogOverlay.cs +++ b/osu.Game/Overlays/ChangelogOverlay.cs @@ -78,7 +78,7 @@ namespace osu.Game.Overlays sampleBack = audio.Samples.Get(@"UI/generic-select-soft"); - Header.Current.BindTo(Current); + Header.Build.BindTo(Current); Current.BindValueChanged(e => { diff --git a/osu.Game/Overlays/News/NewsHeader.cs b/osu.Game/Overlays/News/NewsHeader.cs index b525ba7a82..b55e3ffba0 100644 --- a/osu.Game/Overlays/News/NewsHeader.cs +++ b/osu.Game/Overlays/News/NewsHeader.cs @@ -14,7 +14,7 @@ namespace osu.Game.Overlays.News private NewsHeaderTitle title; - public readonly Bindable Current = new Bindable(null); + public readonly Bindable Post = new Bindable(null); public Action ShowFrontPage; @@ -22,13 +22,13 @@ namespace osu.Game.Overlays.News { TabControl.AddItem(front_page_string); - TabControl.Current.ValueChanged += e => + Current.ValueChanged += e => { if (e.NewValue == front_page_string) ShowFrontPage?.Invoke(); }; - Current.ValueChanged += showPost; + Post.ValueChanged += showPost; } private void showPost(ValueChangedEvent e) @@ -39,13 +39,13 @@ namespace osu.Game.Overlays.News if (e.NewValue != null) { TabControl.AddItem(e.NewValue); - TabControl.Current.Value = e.NewValue; + Current.Value = e.NewValue; title.IsReadingPost = true; } else { - TabControl.Current.Value = front_page_string; + Current.Value = front_page_string; title.IsReadingPost = false; } } diff --git a/osu.Game/Overlays/NewsOverlay.cs b/osu.Game/Overlays/NewsOverlay.cs index 6dde300556..71c205ff63 100644 --- a/osu.Game/Overlays/NewsOverlay.cs +++ b/osu.Game/Overlays/NewsOverlay.cs @@ -60,7 +60,7 @@ namespace osu.Game.Overlays }, }; - header.Current.BindTo(Current); + header.Post.BindTo(Current); Current.TriggerChange(); } diff --git a/osu.Game/Overlays/TabControlOverlayHeader.cs b/osu.Game/Overlays/TabControlOverlayHeader.cs index b410739b25..dff5a17bd8 100644 --- a/osu.Game/Overlays/TabControlOverlayHeader.cs +++ b/osu.Game/Overlays/TabControlOverlayHeader.cs @@ -3,6 +3,7 @@ using JetBrains.Annotations; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -17,10 +18,18 @@ namespace osu.Game.Overlays /// An overlay header which contains a . /// /// The type of item to be represented by tabs. - public abstract class TabControlOverlayHeader : OverlayHeader + public abstract class TabControlOverlayHeader : OverlayHeader, IHasCurrentValue { protected OsuTabControl TabControl; + private readonly BindableWithCurrent current = new BindableWithCurrent(); + + public Bindable Current + { + get => current.Current; + set => current.Current = value; + } + private readonly Box controlBackground; protected TabControlOverlayHeader() @@ -35,7 +44,11 @@ namespace osu.Game.Overlays { RelativeSizeAxes = Axes.Both, }, - TabControl = CreateTabControl().With(control => control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }) + TabControl = CreateTabControl().With(control => + { + control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }; + control.Current = current; + }) } }); } From 5950ba3656914e9c667ebd6764ca55905935745a Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 4 Feb 2020 00:55:41 +0300 Subject: [PATCH 09/12] Change the order of colour check --- osu.Game/Overlays/OverlayRulesetTabItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 1f0beffe78..67c458cc5c 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -89,9 +89,9 @@ namespace osu.Game.Overlays private void updateState() { text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium); - AccentColour = IsHovered || Active.Value ? Color4.White : getStateColour(); + AccentColour = Enabled.Value ? getActiveColour() : colourProvider.Foreground1; } - private Color4 getStateColour() => Enabled.Value ? colourProvider.Highlight1 : colourProvider.Foreground1; + private Color4 getActiveColour() => IsHovered || Active.Value ? Color4.White : colourProvider.Highlight1; } } From 22e3150f685a6916f0ddc2d689023cb32361598e Mon Sep 17 00:00:00 2001 From: Joehu Date: Mon, 3 Feb 2020 17:21:06 -0800 Subject: [PATCH 10/12] Fix comment and remove magic numbers --- osu.Game/Overlays/Mods/ModSelectOverlay.cs | 2 ++ osu.Game/Screens/Select/SongSelect.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index 2868fe1d79..0813e57dae 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -30,6 +30,8 @@ namespace osu.Game.Overlays.Mods { public class ModSelectOverlay : WaveOverlayContainer { + public const float HEIGHT = 510; + protected readonly TriangleButton DeselectAllButton; protected readonly TriangleButton CustomiseButton; protected readonly TriangleButton CloseButton; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 3f80c90b9d..a5dce9a065 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -223,13 +223,13 @@ namespace osu.Game.Screens.Select { AddRangeInternal(new Drawable[] { - new GridContainer // used for max width implementation + new GridContainer // used for max height implementation { RelativeSizeAxes = Axes.Both, RowDimensions = new[] { new Dimension(), - new Dimension(GridSizeMode.Relative, 1f, maxSize: 560), + new Dimension(GridSizeMode.Relative, 1f, maxSize: ModSelectOverlay.HEIGHT + Footer.HEIGHT), }, Content = new[] { From 68b3dc01df65551e900bc3762a18c371a841b33d Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 4 Feb 2020 12:53:57 +0900 Subject: [PATCH 11/12] Move property override below ctor --- osu.Game/Overlays/OverlayRulesetTabItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/OverlayRulesetTabItem.cs b/osu.Game/Overlays/OverlayRulesetTabItem.cs index 67c458cc5c..9b4dd5ba1e 100644 --- a/osu.Game/Overlays/OverlayRulesetTabItem.cs +++ b/osu.Game/Overlays/OverlayRulesetTabItem.cs @@ -17,8 +17,6 @@ namespace osu.Game.Overlays { public class OverlayRulesetTabItem : TabItem { - public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree; - private Color4 accentColour; protected virtual Color4 AccentColour @@ -69,6 +67,8 @@ namespace osu.Game.Overlays Enabled.BindValueChanged(_ => updateState(), true); } + public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree; + protected override bool OnHover(HoverEvent e) { base.OnHover(e); From bc9b499de010fc6f311908db0745d928c153caaf Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 4 Feb 2020 12:55:09 +0900 Subject: [PATCH 12/12] Make selector only privately-settable --- osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs index bf9f3ccc17..e5e3e276d5 100644 --- a/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs +++ b/osu.Game/Overlays/BeatmapSet/BeatmapSetHeader.cs @@ -11,7 +11,8 @@ namespace osu.Game.Overlays.BeatmapSet public class BeatmapSetHeader : OverlayHeader { public readonly Bindable Ruleset = new Bindable(); - public BeatmapRulesetSelector RulesetSelector; + + public BeatmapRulesetSelector RulesetSelector { get; private set; } protected override ScreenTitle CreateTitle() => new BeatmapHeaderTitle();