mirror of https://github.com/ppy/osu
fixed code
This commit is contained in:
parent
0d17fb4259
commit
27735eeedb
|
@ -25,8 +25,9 @@ namespace osu.Game.Overlays.BeatmapListing
|
|||
public class BeatmapListingFilterControl : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Fired when a search finishes. Contains only new items in the case of pagination.
|
||||
/// Fired with BeatmapListingSearchControl when non-supporter user used supporter-only filters.
|
||||
/// Fired when a search finishes.
|
||||
/// SearchFinished.Type = ResultsReturned when results returned. Contains only new items in the case of pagination.
|
||||
/// SearchFinished.Type = SupporterOnlyFilter when a non-supporter user applied supporter-only filters.
|
||||
/// </summary>
|
||||
public Action<SearchResult> SearchFinished;
|
||||
|
||||
|
@ -216,7 +217,7 @@ private void performRequest()
|
|||
getSetsRequest = null;
|
||||
|
||||
// check if an non-supporter user used supporter-only filters
|
||||
if (!api.LocalUser.Value.IsSupporter && (searchControl.Ranks.Any() || searchControl.Played.Value != SearchPlayed.Any))
|
||||
if (!api.LocalUser.Value.IsSupporter)
|
||||
{
|
||||
List<LocalisableString> filters = new List<LocalisableString>();
|
||||
|
||||
|
@ -226,12 +227,14 @@ private void performRequest()
|
|||
if (searchControl.Ranks.Any())
|
||||
filters.Add(BeatmapsStrings.ListingSearchFiltersRank);
|
||||
|
||||
SearchFinished?.Invoke(SearchResult.SupporterOnlyFilter(filters));
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchFinished?.Invoke(SearchResult.ResultsReturned(sets));
|
||||
if (filters.Any())
|
||||
{
|
||||
SearchFinished?.Invoke(SearchResult.SupporterOnlyFilter(filters));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SearchFinished?.Invoke(SearchResult.ResultsReturned(sets));
|
||||
};
|
||||
|
||||
api.Queue(getSetsRequest);
|
||||
|
@ -259,10 +262,14 @@ protected override void Dispose(bool isDisposing)
|
|||
|
||||
public enum SearchResultType
|
||||
{
|
||||
// returned with Results
|
||||
ResultsReturned,
|
||||
// non-supporter user applied supporter-only filters
|
||||
SupporterOnlyFilter
|
||||
}
|
||||
|
||||
// Results only valid when Type == ResultsReturned
|
||||
// Filters only valid when Type == SupporterOnlyFilter
|
||||
public struct SearchResult
|
||||
{
|
||||
public SearchResultType Type { get; private set; }
|
||||
|
|
|
@ -256,7 +256,7 @@ private void load(TextureStore textures)
|
|||
// using string literals as there's no proper processing for LocalizeStrings yet
|
||||
public class SupporterRequiredDrawable : CompositeDrawable
|
||||
{
|
||||
private OsuSpriteText filtersText;
|
||||
private LinkFlowContainer supporterRequiredText;
|
||||
|
||||
public SupporterRequiredDrawable()
|
||||
{
|
||||
|
@ -275,7 +275,7 @@ private void load(TextureStore textures)
|
|||
RelativeSizeAxes = Axes.Y,
|
||||
AutoSizeAxes = Axes.X,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
|
@ -285,39 +285,31 @@ private void load(TextureStore textures)
|
|||
FillMode = FillMode.Fit,
|
||||
Texture = textures.Get(@"Online/supporter-required"),
|
||||
},
|
||||
createSupporterText(),
|
||||
supporterRequiredText = new LinkFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Margin = new MarginPadding { Bottom = 10 },
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateText(List<LocalisableString> filters)
|
||||
{
|
||||
// use string literals for now
|
||||
filtersText.Text = BeatmapsStrings.ListingSearchSupporterFilterQuoteDefault(string.Join(" and ", filters), "").ToString();
|
||||
}
|
||||
supporterRequiredText.Clear();
|
||||
|
||||
private Drawable createSupporterText()
|
||||
{
|
||||
LinkFlowContainer supporterRequiredText = new LinkFlowContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Margin = new MarginPadding { Bottom = 10 },
|
||||
};
|
||||
|
||||
filtersText = (OsuSpriteText)supporterRequiredText.AddText(
|
||||
"_",
|
||||
supporterRequiredText.AddText(
|
||||
BeatmapsStrings.ListingSearchSupporterFilterQuoteDefault(string.Join(" and ", filters), "").ToString(),
|
||||
t =>
|
||||
{
|
||||
t.Font = OsuFont.GetFont(size: 16);
|
||||
t.Colour = Colour4.White;
|
||||
}
|
||||
).First();
|
||||
);
|
||||
|
||||
supporterRequiredText.AddLink(BeatmapsStrings.ListingSearchSupporterFilterQuoteLinkText.ToString(), @"/store/products/supporter-tag");
|
||||
|
||||
return supporterRequiredText;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue