2017-03-14 08:58:34 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-07-18 07:55:21 +00:00
|
|
|
|
using System.Linq;
|
2017-03-14 10:38:06 +00:00
|
|
|
|
using OpenTK.Input;
|
|
|
|
|
using osu.Framework.Allocation;
|
2017-11-25 18:30:05 +00:00
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2017-03-14 10:38:06 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-03-23 10:35:46 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-03-14 08:58:34 +00:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2017-03-14 10:38:06 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2017-12-25 15:37:50 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2017-03-14 10:38:06 +00:00
|
|
|
|
using osu.Game.Overlays.Mods;
|
2017-03-14 14:18:40 +00:00
|
|
|
|
using osu.Game.Screens.Edit;
|
2017-03-14 08:58:34 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
2017-04-11 05:01:47 +00:00
|
|
|
|
using osu.Game.Screens.Ranking;
|
2017-03-14 08:58:34 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class PlaySongSelect : SongSelect
|
|
|
|
|
{
|
|
|
|
|
private OsuScreen player;
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly ModSelectOverlay modSelect;
|
2017-03-23 05:29:23 +00:00
|
|
|
|
private readonly BeatmapDetailArea beatmapDetails;
|
2017-08-04 07:34:11 +00:00
|
|
|
|
private bool removeAutoModOnResume;
|
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
|
|
|
|
{
|
2017-03-23 10:32:58 +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-11-25 18:30:05 +00:00
|
|
|
|
private SampleChannel sampleConfirm;
|
|
|
|
|
|
2017-12-25 15:37:50 +00:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
|
private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay)
|
2017-03-14 13:51:26 +00:00
|
|
|
|
{
|
2017-11-27 09:20:13 +00:00
|
|
|
|
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
|
2017-11-25 18:30:05 +00:00
|
|
|
|
|
2017-09-20 05:31:17 +00:00
|
|
|
|
Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue);
|
2017-03-14 11:38:21 +00:00
|
|
|
|
|
2017-03-14 13:13:57 +00:00
|
|
|
|
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);
|
2017-03-14 14:18:40 +00:00
|
|
|
|
BeatmapOptions.AddButton(@"Edit", @"Beatmap", FontAwesome.fa_pencil, colours.Yellow, () =>
|
|
|
|
|
{
|
|
|
|
|
ValidForResume = false;
|
|
|
|
|
Push(new Editor());
|
|
|
|
|
}, Key.Number3);
|
2017-12-25 15:37:50 +00:00
|
|
|
|
|
|
|
|
|
if (dialogOverlay != null)
|
|
|
|
|
{
|
|
|
|
|
Schedule(() =>
|
|
|
|
|
{
|
|
|
|
|
// if we have no beatmaps but osu-stable is found, let's prompt the user to import.
|
|
|
|
|
if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable)
|
|
|
|
|
dialogOverlay.Push(new ImportFromStablePopup(() => beatmaps.ImportFromStable()));
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-03-14 10:38:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-01 09:22:38 +00:00
|
|
|
|
protected override void UpdateBeatmap(WorkingBeatmap beatmap)
|
2017-03-14 10:38:06 +00:00
|
|
|
|
{
|
2017-09-01 09:22:38 +00:00
|
|
|
|
base.UpdateBeatmap(beatmap);
|
2017-03-15 08:11:08 +00:00
|
|
|
|
|
2017-07-19 06:45:23 +00:00
|
|
|
|
beatmap.Mods.BindTo(modSelect.SelectedMods);
|
2017-05-21 16:00:31 +00:00
|
|
|
|
|
2017-03-23 07:31:08 +00:00
|
|
|
|
beatmapDetails.Beatmap = beatmap;
|
2017-05-21 16:00:31 +00:00
|
|
|
|
|
2017-07-19 06:45:23 +00:00
|
|
|
|
if (beatmap.Track != null)
|
2017-05-21 16:16:54 +00:00
|
|
|
|
beatmap.Track.Looping = true;
|
2017-03-16 03:34:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-14 08:58:34 +00:00
|
|
|
|
protected override void OnResuming(Screen last)
|
|
|
|
|
{
|
|
|
|
|
player = null;
|
2017-05-21 19:33:54 +00:00
|
|
|
|
|
2017-08-04 07:34:11 +00:00
|
|
|
|
if (removeAutoModOnResume)
|
|
|
|
|
{
|
|
|
|
|
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
|
|
|
|
|
modSelect.SelectedMods.Value = modSelect.SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray();
|
2017-08-04 08:20:05 +00:00
|
|
|
|
removeAutoModOnResume = false;
|
2017-08-04 07:34:11 +00:00
|
|
|
|
}
|
2017-07-18 07:55:21 +00:00
|
|
|
|
|
2017-07-19 04:32:16 +00:00
|
|
|
|
Beatmap.Value.Track.Looping = true;
|
2017-05-21 13:57:41 +00:00
|
|
|
|
|
2017-03-14 08:58:34 +00:00
|
|
|
|
base.OnResuming(last);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-06 00:01:44 +00:00
|
|
|
|
protected override void OnSuspending(Screen next)
|
|
|
|
|
{
|
2017-05-06 01:16:48 +00:00
|
|
|
|
modSelect.Hide();
|
2017-05-06 00:01:44 +00:00
|
|
|
|
|
|
|
|
|
base.OnSuspending(next);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 10:35:46 +00:00
|
|
|
|
protected override bool OnExiting(Screen next)
|
|
|
|
|
{
|
|
|
|
|
if (modSelect.State == Visibility.Visible)
|
|
|
|
|
{
|
|
|
|
|
modSelect.Hide();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-21 13:57:41 +00:00
|
|
|
|
if (base.OnExiting(next))
|
|
|
|
|
return true;
|
2017-05-21 14:13:20 +00:00
|
|
|
|
|
2017-07-19 06:45:23 +00:00
|
|
|
|
if (Beatmap.Value.Track != null)
|
2017-07-19 04:32:16 +00:00
|
|
|
|
Beatmap.Value.Track.Looping = false;
|
2017-05-21 13:57:41 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
2017-03-23 10:35:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 08:48:38 +00:00
|
|
|
|
protected override void Start()
|
2017-03-14 08:58:34 +00:00
|
|
|
|
{
|
|
|
|
|
if (player != null) return;
|
|
|
|
|
|
2017-12-15 03:08:11 +00:00
|
|
|
|
// Ctrl+Enter should start map with autoplay enabled.
|
|
|
|
|
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
|
|
|
|
|
{
|
|
|
|
|
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
|
|
|
|
|
var autoType = auto.GetType();
|
|
|
|
|
|
|
|
|
|
var mods = modSelect.SelectedMods.Value;
|
|
|
|
|
if (mods.All(m => m.GetType() != autoType))
|
|
|
|
|
{
|
|
|
|
|
modSelect.SelectedMods.Value = mods.Concat(new[] { auto });
|
|
|
|
|
removeAutoModOnResume = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-18 07:55:21 +00:00
|
|
|
|
|
2017-07-19 04:32:16 +00:00
|
|
|
|
Beatmap.Value.Track.Looping = false;
|
2017-07-20 02:50:31 +00:00
|
|
|
|
Beatmap.Disabled = true;
|
2017-05-21 13:57:41 +00:00
|
|
|
|
|
2017-11-25 18:30:05 +00:00
|
|
|
|
sampleConfirm?.Play();
|
|
|
|
|
|
2017-07-19 04:32:16 +00:00
|
|
|
|
LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player));
|
2017-03-14 08:58:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|