From 677b8afc1f16c8a44acdda432735c2d507009dd2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 23 Mar 2017 01:19:29 -0300 Subject: [PATCH] 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 @@ public BeatmapDetailArea() 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 @@ public BeatmapDetailArea() 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 @@ public class BeatmapDetailAreaTabControl : Container 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 @@ public BeatmapDetailAreaTabControl() }, }; - 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 @@ public Leaderboard() 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 @@ public class PlaySongSelect : SongSelect { private OsuScreen player; private ModSelectOverlay modSelect; - private Leaderboard leaderboard; + private BeatmapDetailArea beatmapDetails; public PlaySongSelect() { @@ -32,9 +32,10 @@ public PlaySongSelect() 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 @@ protected override void OnBeatmapChanged(WorkingBeatmap beatmap) { 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;