mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 20:47:25 +08:00
Implement Ctrl+Enter in PlaySongSelect.
This commit is contained in:
parent
cd7c04c54d
commit
9cd895c249
@ -1,14 +1,18 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK.Input;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
@ -18,8 +22,10 @@ namespace osu.Game.Screens.Select
|
||||
public class PlaySongSelect : SongSelect
|
||||
{
|
||||
private OsuScreen player;
|
||||
private UserInputManager input;
|
||||
private readonly ModSelectOverlay modSelect;
|
||||
private readonly BeatmapDetailArea beatmapDetails;
|
||||
private IEnumerable<Mod> originalMods;
|
||||
|
||||
public PlaySongSelect()
|
||||
{
|
||||
@ -40,8 +46,10 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OsuColour colours, UserInputManager input)
|
||||
{
|
||||
this.input = input;
|
||||
|
||||
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);
|
||||
@ -72,6 +80,9 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
player = null;
|
||||
|
||||
modSelect.SelectedMods.Value = originalMods;
|
||||
originalMods = null;
|
||||
|
||||
Beatmap.Track.Looping = true;
|
||||
|
||||
base.OnResuming(last);
|
||||
@ -105,6 +116,15 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
if (player != null) return;
|
||||
|
||||
originalMods = modSelect.SelectedMods.Value;
|
||||
if (input.CurrentState.Keyboard.ControlPressed)
|
||||
if (findAutoMod(originalMods) == null)
|
||||
{
|
||||
var auto = findAutoMod(Ruleset.Value.CreateInstance().GetModsFor(ModType.Special));
|
||||
if (auto != null)
|
||||
modSelect.SelectedMods.Value = originalMods.Concat(new[] { auto });
|
||||
}
|
||||
|
||||
Beatmap.Track.Looping = false;
|
||||
|
||||
LoadComponentAsync(player = new PlayerLoader(new Player
|
||||
@ -112,5 +132,20 @@ namespace osu.Game.Screens.Select
|
||||
Beatmap = Beatmap, //eagerly set this so it's present before push.
|
||||
}), l => Push(player));
|
||||
}
|
||||
|
||||
private Mod findAutoMod(IEnumerable<Mod> mods)
|
||||
{
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
if (mod is ModAutoplay) return mod;
|
||||
var multimod = mod as MultiMod;
|
||||
if (multimod != null)
|
||||
{
|
||||
var find = findAutoMod(multimod.Mods);
|
||||
if (find != null) return find;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
public abstract class SongSelect : OsuScreen
|
||||
{
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
private BeatmapDatabase database;
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||
|
||||
@ -168,7 +168,7 @@ namespace osu.Game.Screens.Select
|
||||
database = beatmaps;
|
||||
|
||||
if (osu != null)
|
||||
ruleset.BindTo(osu.Ruleset);
|
||||
Ruleset.BindTo(osu.Ruleset);
|
||||
|
||||
database.BeatmapSetAdded += onBeatmapSetAdded;
|
||||
database.BeatmapSetRemoved += onBeatmapSetRemoved;
|
||||
|
Loading…
x
Reference in New Issue
Block a user