mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Implement filtering with strings
This commit is contained in:
@ -16,10 +16,11 @@ using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
using System.Collections;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
class CarouselContainer : ScrollContainer
|
||||
class CarouselContainer : ScrollContainer, IEnumerable<BeatmapGroup>
|
||||
{
|
||||
private Container<Panel> scrollableContent;
|
||||
private List<BeatmapGroup> groups = new List<BeatmapGroup>();
|
||||
@ -27,29 +28,29 @@ namespace osu.Game.Screens.Select
|
||||
public BeatmapGroup SelectedGroup { get; private set; }
|
||||
public BeatmapPanel SelectedPanel { get; private set; }
|
||||
|
||||
private List<float> yPositions = new List<float>();
|
||||
private CarouselLifetimeList<Panel> Lifetime;
|
||||
|
||||
public CarouselContainer()
|
||||
{
|
||||
DistanceDecayJump = 0.01;
|
||||
|
||||
Add(scrollableContent = new Container<Panel>(Lifetime = new CarouselLifetimeList<Panel>(DepthComparer))
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
});
|
||||
}
|
||||
|
||||
internal class CarouselLifetimeList<T> : LifetimeList<Panel>
|
||||
{
|
||||
public CarouselLifetimeList(IComparer<Panel> comparer)
|
||||
: base(comparer)
|
||||
{
|
||||
}
|
||||
|
||||
public int StartIndex;
|
||||
private List<float> yPositions = new List<float>();
|
||||
private CarouselLifetimeList<Panel> Lifetime;
|
||||
|
||||
public CarouselContainer()
|
||||
{
|
||||
DistanceDecayJump = 0.01;
|
||||
|
||||
Add(scrollableContent = new Container<Panel>(Lifetime = new CarouselLifetimeList<Panel>(DepthComparer))
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
});
|
||||
}
|
||||
|
||||
internal class CarouselLifetimeList<T> : LifetimeList<Panel>
|
||||
{
|
||||
public CarouselLifetimeList(IComparer<Panel> comparer)
|
||||
: base(comparer)
|
||||
{
|
||||
}
|
||||
|
||||
public int StartIndex;
|
||||
public int EndIndex;
|
||||
|
||||
|
||||
public override bool Update(FrameTimeInfo time)
|
||||
{
|
||||
bool anyAliveChanged = false;
|
||||
@ -75,9 +76,9 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
return anyAliveChanged;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void AddGroup(BeatmapGroup group)
|
||||
{
|
||||
group.State = BeatmapGroupState.Collapsed;
|
||||
@ -100,7 +101,7 @@ namespace osu.Game.Screens.Select
|
||||
yPositions.Add(currentY);
|
||||
panel.MoveToY(currentY, 750, EasingTypes.OutExpo);
|
||||
|
||||
if (advance)
|
||||
if (advance && panel.IsVisible)
|
||||
currentY += panel.DrawHeight + 5;
|
||||
}
|
||||
|
||||
@ -200,7 +201,9 @@ namespace osu.Game.Screens.Select
|
||||
/// <param name="halfHeight">Half the draw height of the carousel container.</param>
|
||||
private void updatePanel(Panel p, float halfHeight)
|
||||
{
|
||||
float panelDrawY = p.Position.Y - Current + p.DrawHeight / 2;
|
||||
var height = p.IsVisible ? p.DrawHeight : 0;
|
||||
|
||||
float panelDrawY = p.Position.Y - Current + height / 2;
|
||||
float dist = Math.Abs(1f - panelDrawY / halfHeight);
|
||||
|
||||
// Setting the origin position serves as an additive position on top of potential
|
||||
@ -222,11 +225,11 @@ namespace osu.Game.Screens.Select
|
||||
float drawHeight = DrawHeight;
|
||||
float halfHeight = drawHeight / 2;
|
||||
|
||||
foreach (Panel p in Lifetime.AliveItems)
|
||||
{
|
||||
float panelPosY = p.Position.Y;
|
||||
p.IsOnScreen = panelPosY >= Current - p.DrawHeight && panelPosY <= Current + drawHeight;
|
||||
updatePanel(p, halfHeight);
|
||||
foreach (Panel p in Lifetime.AliveItems)
|
||||
{
|
||||
float panelPosY = p.Position.Y;
|
||||
p.IsOnScreen = panelPosY >= Current - p.DrawHeight && panelPosY <= Current + drawHeight;
|
||||
updatePanel(p, halfHeight);
|
||||
}
|
||||
|
||||
// Determine range of indices for items that are now definitely on screen to be added
|
||||
@ -247,6 +250,13 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
public void InvalidateVisible()
|
||||
{
|
||||
Lifetime.StartIndex = 0;
|
||||
Lifetime.EndIndex = groups.Count - 1;
|
||||
computeYPositions();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
int direction = 0;
|
||||
@ -288,5 +298,15 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
public IEnumerator<BeatmapGroup> GetEnumerator()
|
||||
{
|
||||
return groups.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user