mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:53:51 +08:00
Integration
This commit is contained in:
parent
87b8015e8f
commit
677b8afc1f
@ -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 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ namespace osu.Game.Screens.Select
|
||||
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 @@ namespace osu.Game.Screens.Select
|
||||
},
|
||||
};
|
||||
|
||||
tabs.ItemChanged += (sender, e) =>
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
modsCheckbox.Action += (sender, e) =>
|
||||
{
|
||||
|
||||
};
|
||||
tabs.ItemChanged += (sender, e) => invokeOnFilter();
|
||||
modsCheckbox.Action += (sender, e) => invokeOnFilter();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user