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