mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 14:13:18 +08:00
Fixes following recent updates upstream
This commit is contained in:
parent
417933b7ec
commit
f3c5c1f0b8
@ -1,44 +1,46 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
class BeatmapGroup : IStateful<BeatmapGroupState>
|
||||
{
|
||||
public BeatmapPanel SelectedPanel;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when one of our difficulties was selected. Will fire on first expand.
|
||||
/// </summary>
|
||||
public Action<BeatmapGroup, BeatmapInfo> SelectionChanged;
|
||||
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
class BeatmapGroup : IStateful<BeatmapGroupState>
|
||||
{
|
||||
public BeatmapPanel SelectedPanel;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when one of our difficulties was selected. Will fire on first expand.
|
||||
/// </summary>
|
||||
public Action<BeatmapGroup, BeatmapInfo> SelectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when one of our difficulties is clicked when already selected. Should start playing the map.
|
||||
/// </summary>
|
||||
public Action<BeatmapInfo> StartRequested;
|
||||
|
||||
public BeatmapSetHeader Header;
|
||||
|
||||
private BeatmapGroupState state;
|
||||
/// </summary>
|
||||
public Action<BeatmapInfo> StartRequested;
|
||||
|
||||
public BeatmapSetHeader Header;
|
||||
|
||||
private BeatmapGroupState state;
|
||||
|
||||
public List<BeatmapPanel> BeatmapPanels;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet;
|
||||
|
||||
public BeatmapGroupState State
|
||||
{
|
||||
get { return state; }
|
||||
set
|
||||
{
|
||||
state = value;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet;
|
||||
|
||||
public bool Hidden;
|
||||
|
||||
public BeatmapGroupState State
|
||||
{
|
||||
get { return state; }
|
||||
set
|
||||
{
|
||||
state = value;
|
||||
switch (state)
|
||||
{
|
||||
case BeatmapGroupState.Expanded:
|
||||
@ -58,17 +60,17 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
panel.FadeOut(300, EasingTypes.OutQuint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null)
|
||||
{
|
||||
Header = new BeatmapSetHeader(beatmap)
|
||||
{
|
||||
GainedSelection = headerGainedSelection,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapGroup(WorkingBeatmap beatmap, BeatmapSetInfo set = null)
|
||||
{
|
||||
Header = new BeatmapSetHeader(beatmap)
|
||||
{
|
||||
GainedSelection = headerGainedSelection,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
|
||||
BeatmapPanels = beatmap.BeatmapSetInfo.Beatmaps.Select(b => new BeatmapPanel(b)
|
||||
{
|
||||
Alpha = 0,
|
||||
@ -76,12 +78,12 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
StartRequested = p => { StartRequested?.Invoke(p.Beatmap); },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}).ToList();
|
||||
|
||||
BeatmapSet = set;
|
||||
|
||||
BeatmapSet = set;
|
||||
}
|
||||
|
||||
private void headerGainedSelection(BeatmapSetHeader panel)
|
||||
{
|
||||
private void headerGainedSelection(BeatmapSetHeader panel)
|
||||
{
|
||||
State = BeatmapGroupState.Expanded;
|
||||
|
||||
//we want to make sure one of our children is selected in the case none have been selected yet.
|
||||
@ -89,10 +91,10 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
BeatmapPanels.First().State = PanelSelectedState.Selected;
|
||||
else
|
||||
SelectionChanged?.Invoke(this, SelectedPanel.Beatmap);
|
||||
}
|
||||
|
||||
private void panelGainedSelection(BeatmapPanel panel)
|
||||
{
|
||||
}
|
||||
|
||||
private void panelGainedSelection(BeatmapPanel panel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (SelectedPanel == panel) return;
|
||||
@ -100,18 +102,18 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
if (SelectedPanel != null)
|
||||
SelectedPanel.State = PanelSelectedState.NotSelected;
|
||||
SelectedPanel = panel;
|
||||
}
|
||||
finally
|
||||
}
|
||||
finally
|
||||
{
|
||||
State = BeatmapGroupState.Expanded;
|
||||
SelectionChanged?.Invoke(this, panel.Beatmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum BeatmapGroupState
|
||||
{
|
||||
Collapsed,
|
||||
Expanded,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
Action = onOsuLogo,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -101,7 +101,7 @@ namespace osu.Game.Screens.Select
|
||||
yPositions.Add(currentY);
|
||||
panel.MoveToY(currentY, 750, EasingTypes.OutExpo);
|
||||
|
||||
if (advance && panel.IsVisible)
|
||||
if (advance)
|
||||
currentY += panel.DrawHeight + 5;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
movePanel(group.Header, true, ref currentY);
|
||||
movePanel(group.Header, !group.Hidden, ref currentY);
|
||||
|
||||
if (group.State == BeatmapGroupState.Expanded)
|
||||
{
|
||||
@ -133,10 +133,10 @@ namespace osu.Game.Screens.Select
|
||||
panel.MoveToX(-50, 500, EasingTypes.OutExpo);
|
||||
|
||||
//on first display we want to begin hidden under our group's header.
|
||||
if (panel.Alpha == 0)
|
||||
if (panel.Alpha == 0 && !group.Hidden)
|
||||
panel.MoveToY(headerY);
|
||||
|
||||
movePanel(panel, true, ref currentY);
|
||||
movePanel(panel, !group.Hidden, ref currentY);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -32,6 +32,7 @@ using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
using osu.Game.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Threading;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -209,39 +210,50 @@ namespace osu.Game.Screens.Select
|
||||
Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token);
|
||||
}
|
||||
|
||||
private ScheduledDelegate filterTask;
|
||||
|
||||
private void filterChanged()
|
||||
{
|
||||
var search = filter.Search;
|
||||
BeatmapGroup newSelection = null;
|
||||
bool changed = false;
|
||||
foreach (var beatmapGroup in carousel)
|
||||
if (filterTask != null)
|
||||
filterTask.Cancel();
|
||||
filterTask = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
var set = beatmapGroup.BeatmapSet;
|
||||
if (set == null)
|
||||
continue;
|
||||
bool match = string.IsNullOrEmpty(search)
|
||||
|| (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;
|
||||
if (match)
|
||||
filterTask = null;
|
||||
var search = filter.Search;
|
||||
BeatmapGroup newSelection = null;
|
||||
bool changed = false;
|
||||
foreach (var beatmapGroup in carousel)
|
||||
{
|
||||
changed = changed && beatmapGroup.Header.Alpha == 1;
|
||||
beatmapGroup.Header.Alpha = 1;
|
||||
if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
|
||||
newSelection = beatmapGroup;
|
||||
var set = beatmapGroup.BeatmapSet;
|
||||
if (set == null)
|
||||
continue;
|
||||
bool match = string.IsNullOrEmpty(search)
|
||||
|| (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;
|
||||
if (match)
|
||||
{
|
||||
changed = changed && !beatmapGroup.Hidden;
|
||||
beatmapGroup.Hidden = false;
|
||||
beatmapGroup.Header.Alpha = 1;
|
||||
if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
|
||||
newSelection = beatmapGroup;
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = changed && beatmapGroup.Hidden;
|
||||
beatmapGroup.Hidden = true;
|
||||
beatmapGroup.Header.Alpha = 0;
|
||||
beatmapGroup.Header.Masking = false;
|
||||
beatmapGroup.State = BeatmapGroupState.Collapsed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = changed && beatmapGroup.Header.Alpha == 0;
|
||||
beatmapGroup.Header.Alpha = 0;
|
||||
beatmapGroup.State = BeatmapGroupState.Collapsed;
|
||||
}
|
||||
}
|
||||
if (newSelection != null)
|
||||
selectBeatmap(newSelection.BeatmapSet.Beatmaps[0]);
|
||||
if (changed)
|
||||
carousel.InvalidateVisible();
|
||||
if (newSelection != null)
|
||||
selectBeatmap(newSelection.BeatmapSet.Beatmaps[0]);
|
||||
if (changed || true)
|
||||
carousel.InvalidateVisible();
|
||||
}, 250);
|
||||
}
|
||||
|
||||
private void onDatabaseOnBeatmapSetAdded(BeatmapSetInfo s)
|
||||
|
Loading…
Reference in New Issue
Block a user