From c173c4b7eeecb67c60026e7470ef2a360e7843da Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 00:22:31 -0300 Subject: [PATCH 01/14] Tab control --- .../Tests/TestCaseBeatmapDetailArea.cs | 27 ++++ .../osu.Desktop.VisualTests.csproj | 1 + .../Graphics/UserInterface/OsuTabControl.cs | 4 +- .../UserInterface/OsuTabControlCheckBox.cs | 134 ++++++++++++++++++ osu.Game/Screens/Select/BeatmapDetailArea.cs | 27 ++++ .../Select/BeatmapDetailAreaTabControl.cs | 75 ++++++++++ osu.Game/osu.Game.csproj | 3 + 7 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs create mode 100644 osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs create mode 100644 osu.Game/Screens/Select/BeatmapDetailArea.cs create mode 100644 osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs new file mode 100644 index 0000000000..59859f3f29 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Screens.Testing; +using osu.Game.Screens.Select; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseBeatmapDetailArea : TestCase + { + public override string Description => @"Beatmap details in song select"; + + public override void Reset() + { + base.Reset(); + + Add(new BeatmapDetailArea + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(550f, 450f), + }); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index b67b4c4bb3..9ca82c9867 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -206,6 +206,7 @@ + diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 8283c1baa0..ad8c17587a 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -28,6 +28,8 @@ namespace osu.Game.Graphics.UserInterface public OsuTabControl() { + TabContainer.Spacing = new Vector2(10f, 0f); + if (!typeof(T).IsEnum) throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument"); @@ -142,7 +144,7 @@ namespace osu.Game.Graphics.UserInterface { text = new OsuSpriteText { - Margin = new MarginPadding(5), + Margin = new MarginPadding { Top = 5, Bottom = 5 }, Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, TextSize = 14, diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs new file mode 100644 index 0000000000..7d86136fd5 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs @@ -0,0 +1,134 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using OpenTK; +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Configuration; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Graphics.UserInterface +{ + /// + /// A checkbox styled to be placed in line with an + /// + public class OsuTabControlCheckBox : CheckBox + { + private const float transition_length = 500; + + public event EventHandler Action; + + private Color4 accentColour; + public Color4 AccentColour + { + get { return accentColour; } + set + { + accentColour = value; + + if (State == CheckBoxState.Unchecked) + { + text.Colour = accentColour; + icon.Colour = accentColour; + } + } + } + + public string Text + { + get { return text.Text; } + set { text.Text = value; } + } + + private Box box; + private SpriteText text; + private TextAwesome icon; + + private void fadeIn() + { + box.FadeIn(transition_length, EasingTypes.OutQuint); + text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint); + } + + private void fadeOut() + { + box.FadeOut(transition_length, EasingTypes.OutQuint); + text.FadeColour(accentColour, transition_length, EasingTypes.OutQuint); + } + + protected override void OnChecked() + { + fadeIn(); + icon.Icon = FontAwesome.fa_check_circle_o; + Action?.Invoke(this, State); + } + + protected override void OnUnchecked() + { + fadeOut(); + icon.Icon = FontAwesome.fa_circle_o; + Action?.Invoke(this, State); + } + + protected override bool OnHover(InputState state) + { + fadeIn(); + return base.OnHover(state); + } + + protected override void OnHoverLost(InputState state) + { + if (State == CheckBoxState.Unchecked) + fadeOut(); + + base.OnHoverLost(state); + } + + public OsuTabControlCheckBox() + { + AutoSizeAxes = Axes.Both; + + Children = new Drawable[] + { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Top = 5, Bottom = 5, }, + Spacing = new Vector2(5f, 0f), + Direction = FillDirection.Horizontal, + Children = new Drawable[] + { + text = new OsuSpriteText + { + TextSize = 14, + Font = @"Exo2.0-Bold", + }, + icon = new TextAwesome + { + TextSize = 14, + Icon = FontAwesome.fa_circle_o, + Shadow = true, + }, + }, + }, + box = new Box + { + RelativeSizeAxes = Axes.X, + Height = 1, + Alpha = 0, + Colour = Color4.White, + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + } + }; + } + } +} diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs new file mode 100644 index 0000000000..f576e47780 --- /dev/null +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; + +namespace osu.Game.Screens.Select +{ + public class BeatmapDetailArea : Container + { + public BeatmapDetailArea() + { + Children = new Drawable[] + { + new BeatmapDetailAreaTabControl + { + RelativeSizeAxes = Axes.X, + }, + new Container + { + Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT }, + }, + }; + } + } +} diff --git a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs new file mode 100644 index 0000000000..be3fd43184 --- /dev/null +++ b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs @@ -0,0 +1,75 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK.Graphics; +using osu.Framework.Allocation; +using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Screens.Select +{ + public class BeatmapDetailAreaTabControl : Container + { + public static readonly float HEIGHT = 24; + private OsuTabControlCheckBox modsCheckbox; + private OsuTabControl tabs; + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + modsCheckbox.AccentColour = tabs.AccentColour = colour.YellowLight; + } + + public BeatmapDetailAreaTabControl() + { + Height = HEIGHT; + + Children = new Drawable[] + { + new Box + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + Height = 1, + Colour = Color4.White.Opacity(0.2f), + }, + tabs = new OsuTabControl + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + RelativeSizeAxes = Axes.Both, + }, + modsCheckbox = new OsuTabControlCheckBox + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Text = @"Mods", + }, + }; + + tabs.ItemChanged += (sender, e) => + { + + }; + + modsCheckbox.Action += (sender, e) => + { + + }; + } + } + + public enum BeatmapDetailTab + { + Details, + Local, + Country, + Global, + Friends + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index bfb787cd51..25c96966d9 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -362,6 +362,9 @@ + + + From 87b8015e8f08a4836023382b5b5c024d7f3511d9 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 00:29:28 -0300 Subject: [PATCH 02/14] Cleanup --- .../UserInterface/OsuTabControlCheckBox.cs | 51 +++++++++++-------- osu.Game/Screens/Select/BeatmapDetailArea.cs | 10 ++-- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs index 7d86136fd5..dbdef991f7 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs @@ -22,22 +22,24 @@ namespace osu.Game.Graphics.UserInterface /// public class OsuTabControlCheckBox : CheckBox { - private const float transition_length = 500; + private Box box; + private SpriteText text; + private TextAwesome icon; public event EventHandler Action; - private Color4 accentColour; + private Color4? accentColour; public Color4 AccentColour { - get { return accentColour; } + get { return accentColour.GetValueOrDefault(); } set { accentColour = value; - if (State == CheckBoxState.Unchecked) + if (State != CheckBoxState.Checked) { - text.Colour = accentColour; - icon.Colour = accentColour; + text.Colour = AccentColour; + icon.Colour = AccentColour; } } } @@ -48,22 +50,6 @@ namespace osu.Game.Graphics.UserInterface set { text.Text = value; } } - private Box box; - private SpriteText text; - private TextAwesome icon; - - private void fadeIn() - { - box.FadeIn(transition_length, EasingTypes.OutQuint); - text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint); - } - - private void fadeOut() - { - box.FadeOut(transition_length, EasingTypes.OutQuint); - text.FadeColour(accentColour, transition_length, EasingTypes.OutQuint); - } - protected override void OnChecked() { fadeIn(); @@ -78,6 +64,20 @@ namespace osu.Game.Graphics.UserInterface Action?.Invoke(this, State); } + private const float transition_length = 500; + + private void fadeIn() + { + box.FadeIn(transition_length, EasingTypes.OutQuint); + text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint); + } + + private void fadeOut() + { + box.FadeOut(transition_length, EasingTypes.OutQuint); + text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint); + } + protected override bool OnHover(InputState state) { fadeIn(); @@ -92,6 +92,13 @@ namespace osu.Game.Graphics.UserInterface base.OnHoverLost(state); } + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + if (accentColour == null) + AccentColour = colours.Blue; + } + public OsuTabControlCheckBox() { AutoSizeAxes = Axes.Both; diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index f576e47780..27706a4112 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -9,19 +9,23 @@ namespace osu.Game.Screens.Select { public class BeatmapDetailArea : Container { + private Container content; + protected override Container Content => content; + public BeatmapDetailArea() { - Children = new Drawable[] + AddInternal(new Drawable[] { new BeatmapDetailAreaTabControl { RelativeSizeAxes = Axes.X, }, - new Container + content = new Container { + RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT }, }, - }; + }); } } } From 677b8afc1f16c8a44acdda432735c2d507009dd2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 01:19:29 -0300 Subject: [PATCH 03/14] Integration --- osu.Game/Screens/Select/BeatmapDetailArea.cs | 61 +++++++++++++++++++ .../Select/BeatmapDetailAreaTabControl.cs | 20 +++--- .../Select/Leaderboards/Leaderboard.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 19 ++---- 4 files changed, 77 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 27706a4112..ff66605c76 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -1,17 +1,36 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Framework.Graphics.Transforms; +using osu.Game.Beatmaps; +using osu.Game.Online.API.Requests; +using osu.Game.Screens.Select.Leaderboards; namespace osu.Game.Screens.Select { public class BeatmapDetailArea : Container { + private const float transition_duration = 500; + private Container content; protected override Container Content => content; + public readonly Container Details; //todo: replace with a real details view when added + public readonly Leaderboard Leaderboard; + + private OsuGame game; + + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGame game) + { + this.game = game; + } + public BeatmapDetailArea() { AddInternal(new Drawable[] @@ -19,6 +38,21 @@ namespace osu.Game.Screens.Select new BeatmapDetailAreaTabControl { RelativeSizeAxes = Axes.X, + OnFilter = (tab, mods) => + { + switch (tab) + { + case BeatmapDetailTab.Details: + Details.FadeIn(transition_duration, EasingTypes.OutQuint); + Leaderboard.FadeOut(transition_duration, EasingTypes.OutQuint); + break; + + default: + Details.FadeOut(transition_duration, EasingTypes.OutQuint); + Leaderboard.FadeIn(transition_duration, EasingTypes.OutQuint); + break; + } + }, }, content = new Container { @@ -26,6 +60,33 @@ namespace osu.Game.Screens.Select Padding = new MarginPadding { Top = BeatmapDetailAreaTabControl.HEIGHT }, }, }); + + Add(new Drawable[] + { + Details = new Container + { + RelativeSizeAxes = Axes.Both, + }, + Leaderboard = new Leaderboard + { + RelativeSizeAxes = Axes.Both, + } + }); + } + + private GetScoresRequest getScoresRequest; + public void PresentScores(WorkingBeatmap beatmap) + { + if (game == null) return; + + Leaderboard.Scores = null; + getScoresRequest?.Cancel(); + + if (beatmap?.BeatmapInfo == null) return; + + getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo); + getScoresRequest.Success += r => Leaderboard.Scores = r.Scores; + game.API.Queue(getScoresRequest); } } } diff --git a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs index be3fd43184..1345fc7a6a 100644 --- a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs +++ b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs @@ -1,12 +1,14 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; @@ -18,6 +20,13 @@ namespace osu.Game.Screens.Select private OsuTabControlCheckBox modsCheckbox; private OsuTabControl tabs; + public Action OnFilter; //passed the selected tab and if mods is checked + + private void invokeOnFilter() + { + OnFilter?.Invoke(tabs.SelectedItem, modsCheckbox.State == CheckBoxState.Checked); + } + [BackgroundDependencyLoader] private void load(OsuColour colour) { @@ -52,15 +61,8 @@ namespace osu.Game.Screens.Select }, }; - tabs.ItemChanged += (sender, e) => - { - - }; - - modsCheckbox.Action += (sender, e) => - { - - }; + tabs.ItemChanged += (sender, e) => invokeOnFilter(); + modsCheckbox.Action += (sender, e) => invokeOnFilter(); } } diff --git a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs index 20e6db6241..18691f011f 100644 --- a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs +++ b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs @@ -74,7 +74,7 @@ namespace osu.Game.Screens.Select.Leaderboards RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(0f, 5f), - Padding = new MarginPadding(5), + Padding = new MarginPadding { Top = 10, Bottom = 5 }, }, }, }, diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index c5c8543e6b..7d73b17c8e 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -20,7 +20,7 @@ namespace osu.Game.Screens.Select { private OsuScreen player; private ModSelectOverlay modSelect; - private Leaderboard leaderboard; + private BeatmapDetailArea beatmapDetails; public PlaySongSelect() { @@ -32,9 +32,10 @@ namespace osu.Game.Screens.Select Margin = new MarginPadding { Bottom = 50 } }); - LeftContent.Add(leaderboard = new Leaderboard + LeftContent.Add(beatmapDetails = new BeatmapDetailArea { RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Top = 5, Right = 5 }, }); } @@ -58,23 +59,11 @@ namespace osu.Game.Screens.Select { beatmap?.Mods.BindTo(modSelect.SelectedMods); - updateLeaderboard(beatmap); + beatmapDetails.PresentScores(beatmap); base.OnBeatmapChanged(beatmap); } - private void updateLeaderboard(WorkingBeatmap beatmap) - { - leaderboard.Scores = null; - getScoresRequest?.Cancel(); - - if (beatmap?.BeatmapInfo == null) return; - - getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo); - getScoresRequest.Success += r => leaderboard.Scores = r.Scores; - Game.API.Queue(getScoresRequest); - } - protected override void OnResuming(Screen last) { player = null; From 8c99a8b103ab757f6bb580c2ce9c8156a404673b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 01:25:30 -0300 Subject: [PATCH 04/14] Remove visual test(pretty useless) --- .../Tests/TestCaseBeatmapDetailArea.cs | 27 ------------------- .../osu.Desktop.VisualTests.csproj | 1 - 2 files changed, 28 deletions(-) delete mode 100644 osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs deleted file mode 100644 index 59859f3f29..0000000000 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using OpenTK; -using osu.Framework.Graphics; -using osu.Framework.Screens.Testing; -using osu.Game.Screens.Select; - -namespace osu.Desktop.VisualTests.Tests -{ - internal class TestCaseBeatmapDetailArea : TestCase - { - public override string Description => @"Beatmap details in song select"; - - public override void Reset() - { - base.Reset(); - - Add(new BeatmapDetailArea - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Size = new Vector2(550f, 450f), - }); - } - } -} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 9ca82c9867..b67b4c4bb3 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -206,7 +206,6 @@ - From 67421cdf1c01577bab21da404b9c77e2298f336b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 01:34:06 -0300 Subject: [PATCH 05/14] Even though it was 5 minutes ago what was I thinking --- .../Tests/TestCaseBeatmapDetailArea.cs | 27 +++++++++++++++++++ .../osu.Desktop.VisualTests.csproj | 1 + .../UserInterface/OsuTabControlCheckBox.cs | 1 - osu.Game/Screens/Select/BeatmapDetailArea.cs | 1 - 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs new file mode 100644 index 0000000000..bb7df19202 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Screens.Testing; +using osu.Game.Screens.Select; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseBeatmapDetailArea : TestCase + { + public override string Description => @"Beatmap details in song select"; + + public override void Reset() + { + base.Reset(); + + Add(new BeatmapDetailArea + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(550f, 450f), + }); + } + } +} \ No newline at end of file diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index b67b4c4bb3..9ca82c9867 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -206,6 +206,7 @@ + diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs index dbdef991f7..1ae3698b9f 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs @@ -5,7 +5,6 @@ using System; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index ff66605c76..5943a0d0ad 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; From b8b45262c5d0f3a1647b83dfe2356b9117910073 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 01:35:55 -0300 Subject: [PATCH 06/14] Formatting --- osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs | 2 +- osu.Game/Screens/Select/PlaySongSelect.cs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs index 1ae3698b9f..a09173f6e2 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs @@ -17,7 +17,7 @@ using osu.Game.Graphics.Sprites; namespace osu.Game.Graphics.UserInterface { /// - /// A checkbox styled to be placed in line with an + /// A checkbox styled to be placed in line with an /// public class OsuTabControlCheckBox : CheckBox { diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 7d73b17c8e..aa3b660479 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -8,11 +8,9 @@ using osu.Framework.Graphics.Primitives; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics; -using osu.Game.Online.API.Requests; using osu.Game.Overlays.Mods; using osu.Game.Screens.Edit; using osu.Game.Screens.Play; -using osu.Game.Screens.Select.Leaderboards; namespace osu.Game.Screens.Select { @@ -53,8 +51,6 @@ namespace osu.Game.Screens.Select }, Key.Number3); } - private GetScoresRequest getScoresRequest; - protected override void OnBeatmapChanged(WorkingBeatmap beatmap) { beatmap?.Mods.BindTo(modSelect.SelectedMods); From b8129526a43e0fe326c5d9f10e53e987101a5724 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 02:29:23 -0300 Subject: [PATCH 07/14] Typo --- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 707b1f0f10..9ba289a4f6 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -18,7 +18,7 @@ namespace osu.Game.Screens.Select { private OsuScreen player; private readonly ModSelectOverlay modSelect; - private readonly Leaderboard beatmapDetails; + private readonly BeatmapDetailArea beatmapDetails; public PlaySongSelect() { From 88d878e1d5c19b8a7b981a5668cd33d54b5f1f3e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 02:47:27 -0300 Subject: [PATCH 08/14] Formatting --- osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs | 6 +++--- osu.Game/Screens/Select/BeatmapDetailArea.cs | 2 +- osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs index a09173f6e2..7dc1212318 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControlCheckBox.cs @@ -21,9 +21,9 @@ namespace osu.Game.Graphics.UserInterface /// public class OsuTabControlCheckBox : CheckBox { - private Box box; - private SpriteText text; - private TextAwesome icon; + private readonly Box box; + private readonly SpriteText text; + private readonly TextAwesome icon; public event EventHandler Action; diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 5943a0d0ad..30a6420e68 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -16,7 +16,7 @@ namespace osu.Game.Screens.Select { private const float transition_duration = 500; - private Container content; + private readonly Container content; protected override Container Content => content; public readonly Container Details; //todo: replace with a real details view when added diff --git a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs index 1345fc7a6a..c85f223649 100644 --- a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs +++ b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs @@ -17,8 +17,8 @@ namespace osu.Game.Screens.Select public class BeatmapDetailAreaTabControl : Container { public static readonly float HEIGHT = 24; - private OsuTabControlCheckBox modsCheckbox; - private OsuTabControl tabs; + private readonly OsuTabControlCheckBox modsCheckbox; + private readonly OsuTabControl tabs; public Action OnFilter; //passed the selected tab and if mods is checked From 022fd625df41aa266068cc35fc9268686ecb3eaa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 16:28:40 +0900 Subject: [PATCH 09/14] Remove transitions for now If you want to add transitions, the containers should be IStateful so we can discern their state for later use (because I switched to Show/Hide I can use IsPresent for now). We should probably look at moving the VisibilityState portion of OverlayContainer into a new StatefulContainer class or similar, so it can be used in situations like this. --- osu.Game/Screens/Select/BeatmapDetailArea.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 30a6420e68..ad1ee36ced 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.Transforms; using osu.Game.Beatmaps; using osu.Game.Online.API.Requests; using osu.Game.Screens.Select.Leaderboards; @@ -14,8 +13,6 @@ namespace osu.Game.Screens.Select { public class BeatmapDetailArea : Container { - private const float transition_duration = 500; - private readonly Container content; protected override Container Content => content; @@ -42,13 +39,12 @@ namespace osu.Game.Screens.Select switch (tab) { case BeatmapDetailTab.Details: - Details.FadeIn(transition_duration, EasingTypes.OutQuint); - Leaderboard.FadeOut(transition_duration, EasingTypes.OutQuint); + Details.Show(); + Leaderboard.Hide(); break; - default: - Details.FadeOut(transition_duration, EasingTypes.OutQuint); - Leaderboard.FadeIn(transition_duration, EasingTypes.OutQuint); + Details.Hide(); + Leaderboard.Show(); break; } }, From a561611125f2e02fd78e2dce2666150644aae3c2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 16:29:10 +0900 Subject: [PATCH 10/14] Set default tab to global scores. This will need to be saved to the config file eventually. --- osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs index c85f223649..9dc8de96d1 100644 --- a/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs +++ b/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs @@ -63,6 +63,8 @@ namespace osu.Game.Screens.Select tabs.ItemChanged += (sender, e) => invokeOnFilter(); modsCheckbox.Action += (sender, e) => invokeOnFilter(); + + tabs.SelectedItem = BeatmapDetailTab.Global; } } From 3ae7d0cb98c5c169f361e823155ec26308e0344f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 16:31:08 +0900 Subject: [PATCH 11/14] Better handle the passing of Beatmap and updating of scores. PresentScores was dangerous as it could potentially bring up unsafe threading scenarios. This ensures everything will work well in all cases. --- osu.Game/Screens/Select/BeatmapDetailArea.cs | 37 ++++++++++++++++---- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index ad1ee36ced..2291e65de8 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -21,10 +21,18 @@ namespace osu.Game.Screens.Select private OsuGame game; - [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuGame game) + private WorkingBeatmap beatmap; + public WorkingBeatmap Beatmap { - this.game = game; + get + { + return beatmap; + } + set + { + beatmap = value; + if (IsLoaded) Schedule(updateScores); + } } public BeatmapDetailArea() @@ -47,6 +55,9 @@ namespace osu.Game.Screens.Select Leaderboard.Show(); break; } + + //for now let's always update scores. + updateScores(); }, }, content = new Container @@ -69,15 +80,27 @@ namespace osu.Game.Screens.Select }); } - private GetScoresRequest getScoresRequest; - public void PresentScores(WorkingBeatmap beatmap) + protected override void LoadComplete() { - if (game == null) return; + base.LoadComplete(); + updateScores(); + } + + [BackgroundDependencyLoader(permitNulls: true)] + private void load(OsuGame game) + { + this.game = game; + } + + private GetScoresRequest getScoresRequest; + private void updateScores() + { + if (game == null || !IsLoaded) return; Leaderboard.Scores = null; getScoresRequest?.Cancel(); - if (beatmap?.BeatmapInfo == null) return; + if (beatmap?.BeatmapInfo == null || !Leaderboard.IsPresent) return; getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo); getScoresRequest.Success += r => Leaderboard.Scores = r.Scores; diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 9ba289a4f6..9259d33268 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select { beatmap?.Mods.BindTo(modSelect.SelectedMods); - beatmapDetails.PresentScores(beatmap); + beatmapDetails.Beatmap = beatmap; base.OnBeatmapChanged(beatmap); } From 6bcbd116c8dd2853641cbfb3ea69a0bde73fded4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 16:32:35 +0900 Subject: [PATCH 12/14] Only get APIAccess from DI (it's all we need). --- osu.Game/Screens/Select/BeatmapDetailArea.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetailArea.cs b/osu.Game/Screens/Select/BeatmapDetailArea.cs index 2291e65de8..21e4d643f2 100644 --- a/osu.Game/Screens/Select/BeatmapDetailArea.cs +++ b/osu.Game/Screens/Select/BeatmapDetailArea.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Game.Beatmaps; +using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Screens.Select.Leaderboards; @@ -19,7 +20,7 @@ namespace osu.Game.Screens.Select public readonly Container Details; //todo: replace with a real details view when added public readonly Leaderboard Leaderboard; - private OsuGame game; + private APIAccess api; private WorkingBeatmap beatmap; public WorkingBeatmap Beatmap @@ -87,24 +88,24 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader(permitNulls: true)] - private void load(OsuGame game) + private void load(APIAccess api) { - this.game = game; + this.api = api; } private GetScoresRequest getScoresRequest; private void updateScores() { - if (game == null || !IsLoaded) return; + if (!IsLoaded) return; Leaderboard.Scores = null; getScoresRequest?.Cancel(); - if (beatmap?.BeatmapInfo == null || !Leaderboard.IsPresent) return; + if (api == null || beatmap?.BeatmapInfo == null || !Leaderboard.IsPresent) return; getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo); getScoresRequest.Success += r => Leaderboard.Scores = r.Scores; - game.API.Queue(getScoresRequest); + api.Queue(getScoresRequest); } } } From 644e9ae9d5a03be12a0104380a0aa0f20f10d93f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 16:36:52 +0900 Subject: [PATCH 13/14] Increase padding to make flyte happy. --- osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 9259d33268..e3a6371c27 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -33,7 +33,7 @@ namespace osu.Game.Screens.Select LeftContent.Add(beatmapDetails = new BeatmapDetailArea { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Top = 5, Right = 5 }, + Padding = new MarginPadding { Top = 10, Right = 5 }, }); } From 1766497728d25d6980cb98d4783e14351c00fe8b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 23 Mar 2017 16:53:39 +0900 Subject: [PATCH 14/14] Update framework. --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 06e426da03..34c9f17a6a 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 06e426da039f7bb54aedf5d82c21b8d858a0310e +Subproject commit 34c9f17a6ac6fa5e9fd5569f9e119331316c1313