mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 05:42:54 +08:00
Merge pull request #1 from peppy/song-select-filtering-fixes
Fixes inconsistencies and shortcomings of filtering.
This commit is contained in:
commit
5136d10e0e
@ -1 +1 @@
|
||||
Subproject commit 4880e5425cfa277be56ef87ec4d79a250ecb6d17
|
||||
Subproject commit 16a01c7381e3ee8ef6b4fe863ba9232deba04c29
|
@ -38,25 +38,22 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
get { return state; }
|
||||
set
|
||||
{
|
||||
Header.Alpha = value == BeatmapGroupState.Hidden ? 0 : 1;
|
||||
switch (value)
|
||||
{
|
||||
case BeatmapGroupState.Expanded:
|
||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||
panel.FadeIn(250);
|
||||
|
||||
Header.State = PanelSelectedState.Selected;
|
||||
if (SelectedPanel != null)
|
||||
SelectedPanel.State = PanelSelectedState.Selected;
|
||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||
panel.State = panel == SelectedPanel ? PanelSelectedState.Selected : PanelSelectedState.NotSelected;
|
||||
break;
|
||||
case BeatmapGroupState.Collapsed:
|
||||
case BeatmapGroupState.Hidden:
|
||||
Header.State = PanelSelectedState.NotSelected;
|
||||
if (SelectedPanel != null)
|
||||
SelectedPanel.State = PanelSelectedState.NotSelected;
|
||||
|
||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||
panel.FadeOut(300, EasingTypes.OutQuint);
|
||||
panel.State = PanelSelectedState.Hidden;
|
||||
break;
|
||||
case BeatmapGroupState.Hidden:
|
||||
Header.State = PanelSelectedState.Hidden;
|
||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||
panel.State = PanelSelectedState.Hidden;
|
||||
break;
|
||||
}
|
||||
state = value;
|
||||
|
@ -2,14 +2,11 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
@ -17,7 +14,6 @@ using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Modes;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
@ -33,6 +29,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
protected override void Selected()
|
||||
{
|
||||
base.Selected();
|
||||
|
||||
GainedSelection?.Invoke(this);
|
||||
|
||||
background.ColourInfo = ColourInfo.GradientVertical(
|
||||
|
@ -68,12 +68,6 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
FadeInFromZero(250);
|
||||
}
|
||||
|
||||
protected override void Selected()
|
||||
{
|
||||
base.Selected();
|
||||
|
@ -55,6 +55,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case PanelSelectedState.Hidden:
|
||||
case PanelSelectedState.NotSelected:
|
||||
Deselected();
|
||||
break;
|
||||
@ -62,6 +63,11 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
Selected();
|
||||
break;
|
||||
}
|
||||
|
||||
if (state == PanelSelectedState.Hidden)
|
||||
FadeOut(300, EasingTypes.OutQuint);
|
||||
else
|
||||
FadeIn(250);
|
||||
}
|
||||
|
||||
private PanelSelectedState state = PanelSelectedState.NotSelected;
|
||||
@ -112,6 +118,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
enum PanelSelectedState
|
||||
{
|
||||
Hidden,
|
||||
NotSelected,
|
||||
Selected
|
||||
}
|
||||
|
@ -97,10 +97,10 @@ namespace osu.Game.Screens.Select
|
||||
computeYPositions();
|
||||
}
|
||||
|
||||
private void movePanel(Panel panel, bool advance, ref float currentY)
|
||||
private void movePanel(Panel panel, bool advance, bool animated, ref float currentY)
|
||||
{
|
||||
yPositions.Add(currentY);
|
||||
panel.MoveToY(currentY, 750, EasingTypes.OutExpo);
|
||||
panel.MoveToY(currentY, animated && (panel.IsOnScreen || panel.State != PanelSelectedState.Hidden) ? 750 : 0, EasingTypes.OutExpo);
|
||||
|
||||
if (advance)
|
||||
currentY += panel.DrawHeight + 5;
|
||||
@ -110,7 +110,7 @@ namespace osu.Game.Screens.Select
|
||||
/// Computes the target Y positions for every panel in the carousel.
|
||||
/// </summary>
|
||||
/// <returns>The Y position of the currently selected panel.</returns>
|
||||
private float computeYPositions()
|
||||
private float computeYPositions(bool animated = true)
|
||||
{
|
||||
yPositions.Clear();
|
||||
|
||||
@ -119,7 +119,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
movePanel(group.Header, group.State != BeatmapGroupState.Hidden, ref currentY);
|
||||
movePanel(group.Header, group.State != BeatmapGroupState.Hidden, animated, ref currentY);
|
||||
|
||||
if (group.State == BeatmapGroupState.Expanded)
|
||||
{
|
||||
@ -137,7 +137,7 @@ namespace osu.Game.Screens.Select
|
||||
if (panel.Alpha == 0)
|
||||
panel.MoveToY(headerY);
|
||||
|
||||
movePanel(panel, true, ref currentY);
|
||||
movePanel(panel, true, animated, ref currentY);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -147,7 +147,7 @@ namespace osu.Game.Screens.Select
|
||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||
{
|
||||
panel.MoveToX(0, 500, EasingTypes.OutExpo);
|
||||
movePanel(panel, false, ref currentY);
|
||||
movePanel(panel, false, animated, ref currentY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,30 +158,30 @@ namespace osu.Game.Screens.Select
|
||||
return selectedY;
|
||||
}
|
||||
|
||||
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||
public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true)
|
||||
{
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
if (panel != null)
|
||||
{
|
||||
SelectGroup(group, panel);
|
||||
SelectGroup(group, panel, animated);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectGroup(BeatmapGroup group, BeatmapPanel panel)
|
||||
public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true)
|
||||
{
|
||||
if (SelectedGroup != null && SelectedGroup != group)
|
||||
if (SelectedGroup != null && SelectedGroup != group && SelectedGroup.State != BeatmapGroupState.Hidden)
|
||||
SelectedGroup.State = BeatmapGroupState.Collapsed;
|
||||
|
||||
SelectedGroup = group;
|
||||
panel.State = PanelSelectedState.Selected;
|
||||
SelectedPanel = panel;
|
||||
|
||||
float selectedY = computeYPositions();
|
||||
ScrollTo(selectedY);
|
||||
float selectedY = computeYPositions(animated);
|
||||
ScrollTo(selectedY, animated);
|
||||
}
|
||||
|
||||
private static float offsetX(float dist, float halfHeight)
|
||||
@ -246,18 +246,12 @@ namespace osu.Game.Screens.Select
|
||||
for (int i = firstIndex; i < lastIndex; ++i)
|
||||
{
|
||||
Panel p = Lifetime[i];
|
||||
p.IsOnScreen = true;
|
||||
if (p.State != PanelSelectedState.Hidden)
|
||||
p.IsOnScreen = true; //we don't want to update the on-screen state of hidden pannels as they have incorrect (stacked) y values.
|
||||
updatePanel(p, halfHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public void InvalidateVisible()
|
||||
{
|
||||
Lifetime.StartIndex = 0;
|
||||
Lifetime.EndIndex = groups.Count - 1;
|
||||
computeYPositions();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
int direction = 0;
|
||||
@ -281,23 +275,35 @@ namespace osu.Game.Screens.Select
|
||||
break;
|
||||
}
|
||||
|
||||
if (direction != 0)
|
||||
{
|
||||
int index = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction;
|
||||
if (direction == 0)
|
||||
return base.OnKeyDown(state, args);
|
||||
|
||||
if (!skipDifficulties && index >= 0 && index < SelectedGroup.BeatmapPanels.Count)
|
||||
if (!skipDifficulties)
|
||||
{
|
||||
int i = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction;
|
||||
|
||||
if (i >= 0 && i < SelectedGroup.BeatmapPanels.Count)
|
||||
{
|
||||
//changing difficulty panel, not set.
|
||||
SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[index]);
|
||||
else
|
||||
{
|
||||
index = (groups.IndexOf(SelectedGroup) + direction + groups.Count) % groups.Count;
|
||||
SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap);
|
||||
}
|
||||
|
||||
SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[i]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
int startIndex = groups.IndexOf(SelectedGroup);
|
||||
int index = startIndex;
|
||||
|
||||
do
|
||||
{
|
||||
index = (index + direction + groups.Count) % groups.Count;
|
||||
if (groups[index].State != BeatmapGroupState.Hidden)
|
||||
{
|
||||
SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap);
|
||||
return true;
|
||||
}
|
||||
} while (index != startIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SelectRandom()
|
||||
|
@ -146,7 +146,7 @@ namespace osu.Game.Screens.Select
|
||||
Position = wedged_container_start_position,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
FilterChanged = filterChanged,
|
||||
Exit = () => Exit(),
|
||||
Exit = Exit,
|
||||
},
|
||||
beatmapInfoWedge = new BeatmapInfoWedge
|
||||
{
|
||||
@ -198,7 +198,6 @@ namespace osu.Game.Screens.Select
|
||||
filterTask = null;
|
||||
var search = filter.Search;
|
||||
BeatmapGroup newSelection = null;
|
||||
bool changed = false;
|
||||
foreach (var beatmapGroup in carousel)
|
||||
{
|
||||
var set = beatmapGroup.BeatmapSet;
|
||||
@ -209,21 +208,17 @@ namespace osu.Game.Screens.Select
|
||||
|| (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;
|
||||
if (match)
|
||||
{
|
||||
changed |= beatmapGroup.State != BeatmapGroupState.Hidden;
|
||||
beatmapGroup.State = BeatmapGroupState.Collapsed;
|
||||
if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
|
||||
newSelection = beatmapGroup;
|
||||
}
|
||||
else
|
||||
{
|
||||
changed |= beatmapGroup.State == BeatmapGroupState.Hidden;
|
||||
beatmapGroup.State = BeatmapGroupState.Hidden;
|
||||
}
|
||||
}
|
||||
if (newSelection != null)
|
||||
selectBeatmap(newSelection.BeatmapSet.Beatmaps[0]);
|
||||
if (changed)
|
||||
carousel.InvalidateVisible();
|
||||
carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false);
|
||||
}, 250);
|
||||
}
|
||||
|
||||
@ -320,11 +315,9 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
//todo: change background in selectionChanged instead; support per-difficulty backgrounds.
|
||||
changeBackground(beatmap);
|
||||
selectBeatmap(beatmap.BeatmapInfo);
|
||||
carousel.SelectBeatmap(beatmap.BeatmapInfo);
|
||||
}
|
||||
|
||||
private void selectBeatmap(BeatmapInfo beatmap) => carousel.SelectBeatmap(beatmap);
|
||||
|
||||
/// <summary>
|
||||
/// selection has been changed as the result of interaction with the carousel.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user