1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 10:15:16 +08:00

Merge pull request #694 from peppy/general-fixes

Set a sane default transform direction.
This commit is contained in:
Dan Balasescu 2017-05-02 11:51:19 +09:00 committed by GitHub
commit 3604c3562a
7 changed files with 63 additions and 18 deletions

@ -1 +1 @@
Subproject commit fc93e11439b8b391d9e01e208368d96ba85bfa26 Subproject commit b25ed4291bb8a8a38faf404c68b3f97efc9d3413

View File

@ -22,5 +22,15 @@ namespace osu.Game.Database
public int PreviewTime { get; set; } public int PreviewTime { get; set; }
public string AudioFile { get; set; } public string AudioFile { get; set; }
public string BackgroundFile { get; set; } public string BackgroundFile { get; set; }
public string[] SearchableTerms => new[]
{
Artist,
ArtistUnicode,
Title,
TitleUnicode,
Source,
Tags
};
} }
} }

View File

@ -15,7 +15,7 @@ using osu.Framework.Localisation;
namespace osu.Game.Overlays.Music namespace osu.Game.Overlays.Music
{ {
internal class PlaylistItem : Container internal class PlaylistItem : Container, IFilterable
{ {
private const float fade_duration = 100; private const float fade_duration = 100;
@ -56,6 +56,8 @@ namespace osu.Game.Overlays.Music
{ {
BeatmapMetadata metadata = BeatmapSetInfo.Metadata; BeatmapMetadata metadata = BeatmapSetInfo.Metadata;
FilterTerms = metadata.SearchableTerms;
Children = new Drawable[] Children = new Drawable[]
{ {
handle = new TextAwesome handle = new TextAwesome
@ -115,5 +117,21 @@ namespace osu.Game.Overlays.Music
OnSelect?.Invoke(BeatmapSetInfo); OnSelect?.Invoke(BeatmapSetInfo);
return true; return true;
} }
public string[] FilterTerms { get; private set; }
private bool matching = true;
public bool MatchingCurrentFilter
{
set
{
if (matching == value) return;
matching = value;
FadeTo(matching ? 1 : 0, 200);
}
}
} }
} }

View File

@ -29,6 +29,10 @@ namespace osu.Game.Overlays.Music
public Action<BeatmapSetInfo> OnSelect; public Action<BeatmapSetInfo> OnSelect;
private readonly SearchContainer search;
public void Filter(string searchTerm) => search.SearchTerm = searchTerm;
public BeatmapSetInfo SelectedItem public BeatmapSetInfo SelectedItem
{ {
get { return items.Children.FirstOrDefault(i => i.Selected)?.BeatmapSetInfo; } get { return items.Children.FirstOrDefault(i => i.Selected)?.BeatmapSetInfo; }
@ -48,14 +52,36 @@ namespace osu.Game.Overlays.Music
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
items = new FillFlowContainer<PlaylistItem> search = new SearchContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
items = new ItemSearchContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
}, },
}
}
}, },
}, },
}; };
} }
private class ItemSearchContainer : FillFlowContainer<PlaylistItem>, IHasFilterableChildren
{
public string[] FilterTerms => new string[] { };
public bool MatchingCurrentFilter { set { } }
public IEnumerable<IFilterable> FilterableChildren => Children;
public ItemSearchContainer()
{
LayoutDuration = 200;
LayoutEasing = EasingTypes.OutQuint;
}
}
} }
} }

View File

@ -74,7 +74,7 @@ namespace osu.Game.Overlays.Music
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
ExitRequested = () => State = Visibility.Hidden, ExitRequested = () => State = Visibility.Hidden,
FilterChanged = filterChanged, FilterChanged = search => list.Filter(search),
Padding = new MarginPadding(10), Padding = new MarginPadding(10),
}, },
}, },
@ -86,11 +86,6 @@ namespace osu.Game.Overlays.Music
beatmapBacking.BindTo(game.Beatmap); beatmapBacking.BindTo(game.Beatmap);
} }
private void filterChanged(string newValue)
{
// TODO: implement
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();

View File

@ -260,7 +260,7 @@ namespace osu.Game.Overlays
} }
private WorkingBeatmap current; private WorkingBeatmap current;
private TransformDirection queuedDirection; private TransformDirection queuedDirection = TransformDirection.Next;
private void beatmapChanged(WorkingBeatmap beatmap) private void beatmapChanged(WorkingBeatmap beatmap)
{ {
@ -270,6 +270,7 @@ namespace osu.Game.Overlays
current = beatmapBacking.Value; current = beatmapBacking.Value;
updateDisplay(beatmapBacking, audioEquals ? TransformDirection.None : queuedDirection); updateDisplay(beatmapBacking, audioEquals ? TransformDirection.None : queuedDirection);
queuedDirection = TransformDirection.Next;
} }
private ScheduledDelegate pendingBeatmapSwitch; private ScheduledDelegate pendingBeatmapSwitch;

View File

@ -27,13 +27,8 @@ namespace osu.Game.Screens.Select
bool match = hasCurrentMode; bool match = hasCurrentMode;
match &= string.IsNullOrEmpty(SearchText) if (!string.IsNullOrEmpty(SearchText))
|| (set.Metadata.Artist ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1 match &= set.Metadata.SearchableTerms.Any(term => term.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0);
|| (set.Metadata.ArtistUnicode ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1
|| (set.Metadata.Title ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1
|| (set.Metadata.TitleUnicode ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1
|| (set.Metadata.Tags ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1
|| (set.Metadata.Source ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1;
switch (g.State) switch (g.State)
{ {