1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 00:53:19 +08:00

Merge pull request #1025 from huoyaoyuan/fixes

Implement Ctrl+Enter for Auto in song select.
This commit is contained in:
Dean Herbert 2017-08-04 17:48:47 +09:00 committed by GitHub
commit 5cf8121d29
14 changed files with 65 additions and 30 deletions

View File

@ -84,6 +84,8 @@ namespace osu.Game.Rulesets.Catch
} }
} }
public override Mod GetAutoplayMod() => new ModAutoplay();
public override string Description => "osu!catch"; public override string Description => "osu!catch";
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_fruits_o }; public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_fruits_o };

View File

@ -105,6 +105,8 @@ namespace osu.Game.Rulesets.Mania
} }
} }
public override Mod GetAutoplayMod() => new ModAutoplay();
public override string Description => "osu!mania"; public override string Description => "osu!mania";
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_mania_o }; public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_mania_o };

View File

@ -105,6 +105,8 @@ namespace osu.Game.Rulesets.Osu
} }
} }
public override Mod GetAutoplayMod() => new OsuModAutoplay();
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_osu_o }; public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_osu_o };
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap); public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap);

View File

@ -84,6 +84,8 @@ namespace osu.Game.Rulesets.Taiko
} }
} }
public override Mod GetAutoplayMod() => new TaikoModAutoplay();
public override string Description => "osu!taiko"; public override string Description => "osu!taiko";
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_taiko_o }; public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_taiko_o };

View File

@ -60,6 +60,8 @@ namespace osu.Game.Beatmaps
{ {
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { }; public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
public override Mod GetAutoplayMod() => new ModAutoplay();
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset)
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@ -10,6 +10,9 @@ using System.Linq;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
/// <summary>
/// A textbox which holds focus eagerly.
/// </summary>
public class FocusedTextBox : OsuTextBox public class FocusedTextBox : OsuTextBox
{ {
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255); protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);

View File

@ -8,9 +8,6 @@ using OpenTK.Input;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
/// <summary>
/// A textbox which holds focus eagerly.
/// </summary>
public class SearchTextBox : FocusedTextBox public class SearchTextBox : FocusedTextBox
{ {
protected virtual bool AllowCommit => false; protected virtual bool AllowCommit => false;
@ -46,10 +43,16 @@ namespace osu.Game.Graphics.UserInterface
case Key.Up: case Key.Up:
case Key.Down: case Key.Down:
return false; return false;
}
}
if (!AllowCommit)
{
switch (args.Key)
{
case Key.KeypadEnter: case Key.KeypadEnter:
case Key.Enter: case Key.Enter:
if (!AllowCommit) return false; return false;
break;
} }
} }

View File

@ -19,6 +19,8 @@ namespace osu.Game.Rulesets
public abstract IEnumerable<Mod> GetModsFor(ModType type); public abstract IEnumerable<Mod> GetModsFor(ModType type);
public abstract Mod GetAutoplayMod();
/// <summary> /// <summary>
/// Attempt to create a hit renderer for a beatmap /// Attempt to create a hit renderer for a beatmap
/// </summary> /// </summary>

View File

@ -47,7 +47,7 @@ namespace osu.Game.Screens
} }
} }
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>(); protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
private SampleChannel sampleExit; private SampleChannel sampleExit;
@ -64,7 +64,7 @@ namespace osu.Game.Screens
} }
if (osuGame != null) if (osuGame != null)
ruleset.BindTo(osuGame.Ruleset); Ruleset.BindTo(osuGame.Ruleset);
sampleExit = audio.Sample.Get(@"UI/melodic-1"); sampleExit = audio.Sample.Get(@"UI/melodic-1");
} }
@ -77,7 +77,7 @@ namespace osu.Game.Screens
{ {
// we only want to apply these restrictions when we are inside a screen stack. // we only want to apply these restrictions when we are inside a screen stack.
// the use case for not applying is in visual/unit tests. // the use case for not applying is in visual/unit tests.
ruleset.Disabled = !AllowBeatmapRulesetChange; Ruleset.Disabled = !AllowBeatmapRulesetChange;
Beatmap.Disabled = !AllowBeatmapRulesetChange; Beatmap.Disabled = !AllowBeatmapRulesetChange;
} }
} }

View File

@ -4,7 +4,6 @@
using OpenTK; using OpenTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration; using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -111,13 +110,7 @@ namespace osu.Game.Screens.Play
return; return;
} }
Track track = Beatmap.Value.Track; adjustableSourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock();
if (track != null)
adjustableSourceClock = track;
adjustableSourceClock = (IAdjustableClock)track ?? new StopwatchClock();
decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
var firstObjectTime = HitRenderer.Objects.First().StartTime; var firstObjectTime = HitRenderer.Objects.First().StartTime;

View File

@ -1,12 +1,14 @@
// 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 osu.Framework.Input;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
public class EditSongSelect : SongSelect public class EditSongSelect : SongSelect
{ {
protected override bool ShowFooter => false; protected override bool ShowFooter => false;
protected override void OnSelected() => Exit(); protected override void OnSelected(InputState state) => Exit();
} }
} }

View File

@ -1,10 +1,12 @@
// 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 osu.Framework.Input;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
public class MatchSongSelect : SongSelect public class MatchSongSelect : SongSelect
{ {
protected override void OnSelected() => Exit(); protected override void OnSelected(InputState state) => Exit();
} }
} }

View File

@ -1,10 +1,12 @@
// 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.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;
@ -20,6 +22,7 @@ namespace osu.Game.Screens.Select
private OsuScreen player; private OsuScreen player;
private readonly ModSelectOverlay modSelect; private readonly ModSelectOverlay modSelect;
private readonly BeatmapDetailArea beatmapDetails; private readonly BeatmapDetailArea beatmapDetails;
private bool removeAutoModOnResume;
public PlaySongSelect() public PlaySongSelect()
{ {
@ -71,6 +74,13 @@ namespace osu.Game.Screens.Select
{ {
player = null; player = null;
if (removeAutoModOnResume)
{
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
modSelect.SelectedMods.Value = modSelect.SelectedMods.Value.Where(m => m.GetType() != autoType).ToArray();
removeAutoModOnResume = false;
}
Beatmap.Value.Track.Looping = true; Beatmap.Value.Track.Looping = true;
base.OnResuming(last); base.OnResuming(last);
@ -100,10 +110,23 @@ namespace osu.Game.Screens.Select
return false; return false;
} }
protected override void OnSelected() protected override void OnSelected(InputState state)
{ {
if (player != null) return; if (player != null) return;
if (state?.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;
}
}
Beatmap.Value.Track.Looping = false; Beatmap.Value.Track.Looping = false;
Beatmap.Disabled = true; Beatmap.Disabled = true;

View File

@ -9,7 +9,6 @@ using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
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.Input;
@ -19,7 +18,6 @@ using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Select.Options; using osu.Game.Screens.Select.Options;
@ -27,7 +25,6 @@ namespace osu.Game.Screens.Select
{ {
public abstract class SongSelect : OsuScreen public abstract class SongSelect : OsuScreen
{ {
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private BeatmapManager manager; private BeatmapManager manager;
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(); protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
@ -109,7 +106,7 @@ namespace osu.Game.Screens.Select
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
SelectionChanged = carouselSelectionChanged, SelectionChanged = carouselSelectionChanged,
BeatmapsChanged = carouselBeatmapsLoaded, BeatmapsChanged = carouselBeatmapsLoaded,
StartRequested = carouselRaisedStart, StartRequested = () => carouselRaisedStart(),
}); });
Add(FilterControl = new FilterControl Add(FilterControl = new FilterControl
{ {
@ -151,7 +148,7 @@ namespace osu.Game.Screens.Select
Add(Footer = new Footer Add(Footer = new Footer
{ {
OnBack = Exit, OnBack = Exit,
OnStart = carouselRaisedStart, OnStart = () => carouselRaisedStart(),
}); });
FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay()); FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay());
@ -173,7 +170,7 @@ namespace osu.Game.Screens.Select
manager = beatmaps; manager = beatmaps;
if (osu != null) if (osu != null)
ruleset.BindTo(osu.Ruleset); Ruleset.BindTo(osu.Ruleset);
manager.BeatmapSetAdded += onBeatmapSetAdded; manager.BeatmapSetAdded += onBeatmapSetAdded;
manager.BeatmapSetRemoved += onBeatmapSetRemoved; manager.BeatmapSetRemoved += onBeatmapSetRemoved;
@ -201,7 +198,7 @@ namespace osu.Game.Screens.Select
carousel.SelectNext(); carousel.SelectNext();
} }
private void carouselRaisedStart() private void carouselRaisedStart(InputState state = null)
{ {
// if we have a pending filter operation, we want to run it now. // if we have a pending filter operation, we want to run it now.
// it could change selection (ie. if the ruleset has been changed). // it could change selection (ie. if the ruleset has been changed).
@ -214,7 +211,7 @@ namespace osu.Game.Screens.Select
selectionChangedDebounce = null; selectionChangedDebounce = null;
} }
OnSelected(); OnSelected(state);
} }
private ScheduledDelegate selectionChangedDebounce; private ScheduledDelegate selectionChangedDebounce;
@ -256,7 +253,7 @@ namespace osu.Game.Screens.Select
} }
else else
{ {
ruleset.Value = beatmap.Ruleset; Ruleset.Value = beatmap.Ruleset;
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
sampleChangeDifficulty.Play(); sampleChangeDifficulty.Play();
@ -278,7 +275,7 @@ namespace osu.Game.Screens.Select
carousel.SelectNextRandom(); carousel.SelectNextRandom();
} }
protected abstract void OnSelected(); protected abstract void OnSelected(InputState state);
private void filterChanged(FilterCriteria criteria, bool debounce = true) private void filterChanged(FilterCriteria criteria, bool debounce = true)
{ {
@ -406,7 +403,7 @@ namespace osu.Game.Screens.Select
{ {
case Key.KeypadEnter: case Key.KeypadEnter:
case Key.Enter: case Key.Enter:
carouselRaisedStart(); carouselRaisedStart(state);
return true; return true;
case Key.Delete: case Key.Delete:
if (state.Keyboard.ShiftPressed) if (state.Keyboard.ShiftPressed)