osu/osu.Game/Screens/Select/PlaySongSelect.cs

94 lines
3.0 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-03-14 10:38:06 +00:00
using OpenTK.Input;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2017-03-14 10:38:06 +00:00
using osu.Framework.Graphics.Primitives;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
2017-03-14 10:38:06 +00:00
using osu.Game.Graphics;
using osu.Game.Overlays.Mods;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Play;
2017-04-11 05:01:47 +00:00
using osu.Game.Screens.Ranking;
namespace osu.Game.Screens.Select
{
public class PlaySongSelect : SongSelect
{
private OsuScreen player;
private readonly ModSelectOverlay modSelect;
2017-03-23 05:29:23 +00:00
private readonly BeatmapDetailArea beatmapDetails;
2017-03-14 10:38:06 +00:00
2017-03-15 02:10:59 +00:00
public PlaySongSelect()
2017-03-14 10:38:06 +00:00
{
FooterPanels.Add(modSelect = new ModSelectOverlay
2017-03-14 10:38:06 +00:00
{
RelativeSizeAxes = Axes.X,
Origin = Anchor.BottomCentre,
Anchor = Anchor.BottomCentre,
});
2017-03-15 08:11:08 +00:00
2017-03-23 04:19:29 +00:00
LeftContent.Add(beatmapDetails = new BeatmapDetailArea
2017-03-15 08:11:08 +00:00
{
RelativeSizeAxes = Axes.Both,
2017-03-23 07:36:52 +00:00
Padding = new MarginPadding { Top = 10, Right = 5 },
2017-03-15 08:11:08 +00:00
});
2017-04-11 05:01:47 +00:00
beatmapDetails.Leaderboard.ScoreSelected += s => Push(new Results(s));
2017-03-14 13:51:26 +00:00
}
2017-03-14 10:38:06 +00:00
2017-03-14 13:51:26 +00:00
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2017-03-14 12:18:14 +00:00
Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue);
BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2);
BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, () =>
{
ValidForResume = false;
Push(new Editor());
}, Key.Number3);
2017-03-14 10:38:06 +00:00
}
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
{
beatmap?.Mods.BindTo(modSelect.SelectedMods);
2017-03-15 08:11:08 +00:00
beatmapDetails.Beatmap = beatmap;
base.OnBeatmapChanged(beatmap);
}
protected override void OnResuming(Screen last)
{
player = null;
base.OnResuming(last);
}
protected override bool OnExiting(Screen next)
{
if (modSelect.State == Visibility.Visible)
{
modSelect.Hide();
return true;
}
return base.OnExiting(next);
}
2017-03-14 14:22:23 +00:00
protected override void OnSelected()
{
if (player != null) return;
2017-04-02 06:56:12 +00:00
LoadComponentAsync(player = new PlayerLoader(new Player
{
Beatmap = Beatmap, //eagerly set this so it's present before push.
2017-04-02 06:56:12 +00:00
}), l => Push(player));
}
}
}