Integration

This commit is contained in:
DrabWeb 2017-03-23 01:19:29 -03:00
parent 87b8015e8f
commit 677b8afc1f
4 changed files with 77 additions and 25 deletions

View File

@ -1,17 +1,36 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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<Drawable> 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);
}
}
}

View File

@ -1,12 +1,14 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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<BeatmapDetailTab> tabs;
public Action<BeatmapDetailTab, bool> 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();
}
}

View File

@ -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 },
},
},
},

View File

@ -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;