Merge branch 'master' of github.com:ppy/osu into better-transforms

# Conflicts:
#	osu-framework
This commit is contained in:
Thomas Müller
2017-07-21 11:15:26 +02:00
17 changed files with 185 additions and 105 deletions

View File

@ -25,6 +25,8 @@ namespace osu.Game.Screens.Select
{
public BeatmapInfo SelectedBeatmap => selectedPanel?.Beatmap;
public override bool HandleInput => AllowSelection;
public Action BeatmapsChanged;
public IEnumerable<BeatmapSetInfo> Beatmaps
@ -133,7 +135,7 @@ namespace osu.Game.Screens.Select
public void SelectNext(int direction = 1, bool skipDifficulties = true)
{
if (groups.Count == 0)
if (groups.All(g => g.State == BeatmapGroupState.Hidden))
{
selectedGroup = null;
selectedPanel = null;
@ -228,6 +230,14 @@ namespace osu.Game.Screens.Select
private ScheduledDelegate filterTask;
public bool AllowSelection = true;
public void FlushPendingFilters()
{
if (filterTask?.Completed == false)
Filter(null, false);
}
public void Filter(FilterCriteria newCriteria = null, bool debounce = true)
{
if (newCriteria != null)
@ -259,6 +269,8 @@ namespace osu.Game.Screens.Select
};
filterTask?.Cancel();
filterTask = null;
if (debounce)
filterTask = Scheduler.AddDelayed(perform, 250);
else

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
@ -31,7 +32,7 @@ namespace osu.Game.Screens.Select
public Action OnBack;
public Action OnStart;
private readonly FillFlowContainer buttons;
private readonly FillFlowContainer<FooterButton> buttons;
public OsuLogo StartButton;
@ -43,29 +44,21 @@ namespace osu.Game.Screens.Select
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
/// </param>
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) => buttons.Add(new FooterButton
{
var button = new FooterButton
{
Text = text,
Height = play_song_select_button_height,
Width = play_song_select_button_width,
Depth = depth,
SelectedColour = colour,
DeselectedColour = colour.Opacity(0.5f),
Hotkey = hotkey,
};
Text = text,
Height = play_song_select_button_height,
Width = play_song_select_button_width,
Depth = depth,
SelectedColour = colour,
DeselectedColour = colour.Opacity(0.5f),
Hotkey = hotkey,
Hovered = updateModeLight,
HoverLost = updateModeLight,
Action = action,
});
button.Hovered = () => updateModeLight(button);
button.HoverLost = () => updateModeLight();
button.Action = action;
buttons.Add(button);
}
private void updateModeLight(FooterButton button = null)
{
modeLight.FadeColour(button?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
}
private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
public Footer()
{
@ -111,7 +104,7 @@ namespace osu.Game.Screens.Select
Spacing = new Vector2(padding, 0),
Children = new Drawable[]
{
buttons = new FillFlowContainer
buttons = new FillFlowContainer<FooterButton>
{
Direction = FillDirection.Horizontal,
Spacing = new Vector2(0.2f, 0),

View File

@ -105,6 +105,7 @@ namespace osu.Game.Screens.Select
if (player != null) return;
Beatmap.Value.Track.Looping = false;
Beatmap.Disabled = true;
LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player));
}

View File

@ -32,7 +32,6 @@ namespace osu.Game.Screens.Select
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
private readonly BeatmapCarousel carousel;
private TrackManager trackManager;
private DialogOverlay dialogOverlay;
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
@ -110,7 +109,7 @@ namespace osu.Game.Screens.Select
Origin = Anchor.CentreRight,
SelectionChanged = carouselSelectionChanged,
BeatmapsChanged = carouselBeatmapsLoaded,
StartRequested = carouselRaisedStart
StartRequested = carouselRaisedStart,
});
Add(FilterControl = new FilterControl
{
@ -174,7 +173,6 @@ namespace osu.Game.Screens.Select
database.BeatmapSetAdded += onBeatmapSetAdded;
database.BeatmapSetRemoved += onBeatmapSetRemoved;
trackManager = audio.Track;
dialogOverlay = dialog;
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
@ -185,11 +183,14 @@ namespace osu.Game.Screens.Select
carousel.Beatmaps = database.GetAllWithChildren<BeatmapSetInfo>(b => !b.DeletePending);
Beatmap.ValueChanged += beatmap_ValueChanged;
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled;
carousel.AllowSelection = !Beatmap.Disabled;
}
private void carouselBeatmapsLoaded()
{
if (Beatmap.Value != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false);
else
carousel.SelectNext();
@ -197,13 +198,15 @@ namespace osu.Game.Screens.Select
private void carouselRaisedStart()
{
var pendingSelection = selectionChangedDebounce;
selectionChangedDebounce = null;
// if we have a pending filter operation, we want to run it now.
// it could change selection (ie. if the ruleset has been changed).
carousel.FlushPendingFilters();
if (pendingSelection?.Completed == false)
if (selectionChangedDebounce?.Completed == false)
{
pendingSelection.RunTask();
pendingSelection.Cancel(); // cancel the already scheduled task.
selectionChangedDebounce.RunTask();
selectionChangedDebounce.Cancel(); // cancel the already scheduled task.
selectionChangedDebounce = null;
}
OnSelected();
@ -221,14 +224,26 @@ namespace osu.Game.Screens.Select
{
Action performLoad = delegate
{
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID;
// We may be arriving here due to another component changing the bindable Beatmap.
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
if (beatmap?.Equals(Beatmap.Value.BeatmapInfo) != true)
{
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID;
Beatmap.Value = database.GetWorkingBeatmap(beatmap, Beatmap);
Beatmap.Value = database.GetWorkingBeatmap(beatmap, Beatmap);
ensurePlayingSelected(preview);
}
ensurePlayingSelected(preview);
changeBackground(Beatmap.Value);
};
selectionChangedDebounce?.Cancel();
if (beatmap?.Equals(beatmapNoDebounce) == true)
return;
beatmapNoDebounce = beatmap;
if (beatmap == null)
{
if (!Beatmap.IsDefault)
@ -236,18 +251,13 @@ namespace osu.Game.Screens.Select
}
else
{
selectionChangedDebounce?.Cancel();
if (beatmap.Equals(beatmapNoDebounce))
return;
ruleset.Value = beatmap.Ruleset;
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
sampleChangeDifficulty.Play();
else
sampleChangeBeatmap.Play();
beatmapNoDebounce = beatmap;
if (beatmap == Beatmap.Value.BeatmapInfo)
performLoad();
else
@ -358,10 +368,11 @@ namespace osu.Game.Screens.Select
{
Track track = Beatmap.Value.Track;
trackManager.SetExclusive(track);
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
track.Start();
if (!track.IsRunning)
{
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
track.Start();
}
}
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)