mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 18:27:26 +08:00
add search box and the ability to search
This commit is contained in:
parent
ef02f80881
commit
3c4faae554
@ -1,4 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
@ -10,10 +12,11 @@ using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Overlays.Options
|
||||
{
|
||||
public abstract class OptionsSection : Container
|
||||
public abstract class OptionsSection : Container, IHasFilterableChildren
|
||||
{
|
||||
protected FillFlowContainer FlowContent;
|
||||
protected override Container<Drawable> Content => FlowContent;
|
||||
@ -21,6 +24,16 @@ namespace osu.Game.Overlays.Options
|
||||
public abstract FontAwesome Icon { get; }
|
||||
public abstract string Header { get; }
|
||||
|
||||
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
||||
public string[] FilterTerms => new[] { Header };
|
||||
public bool MatchingCurrentFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
FadeTo(value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly SpriteText headerLabel;
|
||||
|
||||
protected OptionsSection()
|
||||
|
@ -6,10 +6,12 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Overlays.Options
|
||||
{
|
||||
public abstract class OptionsSubsection : FillFlowContainer
|
||||
public abstract class OptionsSubsection : FillFlowContainer, IHasFilterableChildren
|
||||
{
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
@ -17,6 +19,16 @@ namespace osu.Game.Overlays.Options
|
||||
|
||||
protected abstract string Header { get; }
|
||||
|
||||
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
||||
public string[] FilterTerms => new[] { Header };
|
||||
public bool MatchingCurrentFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
FadeTo(value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected OptionsSubsection()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
@ -13,6 +13,7 @@ using System;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays.Options.Sections;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -32,6 +33,7 @@ namespace osu.Game.Overlays
|
||||
private Sidebar sidebar;
|
||||
private SidebarButton[] sidebarButtons;
|
||||
private OptionsSection[] sections;
|
||||
private SearchContainer searchContainer;
|
||||
private float lastKnownScroll;
|
||||
|
||||
public OptionsOverlay()
|
||||
@ -43,6 +45,8 @@ namespace osu.Game.Overlays
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuGame game, OsuColour colours)
|
||||
{
|
||||
OsuTextBox textBox;
|
||||
|
||||
sections = new OptionsSection[]
|
||||
{
|
||||
new GeneralSection(),
|
||||
@ -92,7 +96,13 @@ namespace osu.Game.Overlays
|
||||
TextSize = 18,
|
||||
Margin = new MarginPadding { Left = CONTENT_MARGINS, Bottom = 30 },
|
||||
},
|
||||
new FillFlowContainer
|
||||
textBox = new OsuTextBox
|
||||
{
|
||||
PlaceholderText = "Type to search!",
|
||||
Width = width - CONTENT_MARGINS * 2,
|
||||
Margin = new MarginPadding { Left = CONTENT_MARGINS },
|
||||
},
|
||||
searchContainer = new SearchContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -118,6 +128,8 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
};
|
||||
|
||||
textBox.Current.ValueChanged += newValue => searchContainer.SearchTerm = newValue;
|
||||
|
||||
scrollContainer.Padding = new MarginPadding { Top = game?.Toolbar.DrawHeight ?? 0 };
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user