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