1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 20:45:46 +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 string AudioFile { 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
{
internal class PlaylistItem : Container
internal class PlaylistItem : Container, IFilterable
{
private const float fade_duration = 100;
@ -56,6 +56,8 @@ namespace osu.Game.Overlays.Music
{
BeatmapMetadata metadata = BeatmapSetInfo.Metadata;
FilterTerms = metadata.SearchableTerms;
Children = new Drawable[]
{
handle = new TextAwesome
@ -115,5 +117,21 @@ namespace osu.Game.Overlays.Music
OnSelect?.Invoke(BeatmapSetInfo);
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;
private readonly SearchContainer search;
public void Filter(string searchTerm) => search.SearchTerm = searchTerm;
public BeatmapSetInfo SelectedItem
{
get { return items.Children.FirstOrDefault(i => i.Selected)?.BeatmapSetInfo; }
@ -48,14 +52,36 @@ namespace osu.Game.Overlays.Music
RelativeSizeAxes = Axes.Both,
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,
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,
AutoSizeAxes = Axes.Y,
ExitRequested = () => State = Visibility.Hidden,
FilterChanged = filterChanged,
FilterChanged = search => list.Filter(search),
Padding = new MarginPadding(10),
},
},
@ -86,11 +86,6 @@ namespace osu.Game.Overlays.Music
beatmapBacking.BindTo(game.Beatmap);
}
private void filterChanged(string newValue)
{
// TODO: implement
}
protected override void LoadComplete()
{
base.LoadComplete();

View File

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

View File

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