mirror of
https://github.com/ppy/osu.git
synced 2025-03-16 00:37:19 +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>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
@ -18,8 +22,10 @@ namespace osu.Game.Screens.Select
|
|||||||
public class PlaySongSelect : SongSelect
|
public class PlaySongSelect : SongSelect
|
||||||
{
|
{
|
||||||
private OsuScreen player;
|
private OsuScreen player;
|
||||||
|
private UserInputManager input;
|
||||||
private readonly ModSelectOverlay modSelect;
|
private readonly ModSelectOverlay modSelect;
|
||||||
private readonly BeatmapDetailArea beatmapDetails;
|
private readonly BeatmapDetailArea beatmapDetails;
|
||||||
|
private IEnumerable<Mod> originalMods;
|
||||||
|
|
||||||
public PlaySongSelect()
|
public PlaySongSelect()
|
||||||
{
|
{
|
||||||
@ -40,8 +46,10 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[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);
|
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(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1);
|
||||||
@ -72,6 +80,9 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
player = null;
|
player = null;
|
||||||
|
|
||||||
|
modSelect.SelectedMods.Value = originalMods;
|
||||||
|
originalMods = null;
|
||||||
|
|
||||||
Beatmap.Track.Looping = true;
|
Beatmap.Track.Looping = true;
|
||||||
|
|
||||||
base.OnResuming(last);
|
base.OnResuming(last);
|
||||||
@ -105,6 +116,15 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
if (player != null) return;
|
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;
|
Beatmap.Track.Looping = false;
|
||||||
|
|
||||||
LoadComponentAsync(player = new PlayerLoader(new Player
|
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.
|
Beatmap = Beatmap, //eagerly set this so it's present before push.
|
||||||
}), l => Push(player));
|
}), 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
|
public abstract class SongSelect : OsuScreen
|
||||||
{
|
{
|
||||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||||
private BeatmapDatabase database;
|
private BeatmapDatabase database;
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ namespace osu.Game.Screens.Select
|
|||||||
database = beatmaps;
|
database = beatmaps;
|
||||||
|
|
||||||
if (osu != null)
|
if (osu != null)
|
||||||
ruleset.BindTo(osu.Ruleset);
|
Ruleset.BindTo(osu.Ruleset);
|
||||||
|
|
||||||
database.BeatmapSetAdded += onBeatmapSetAdded;
|
database.BeatmapSetAdded += onBeatmapSetAdded;
|
||||||
database.BeatmapSetRemoved += onBeatmapSetRemoved;
|
database.BeatmapSetRemoved += onBeatmapSetRemoved;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user