1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 04:42:58 +08:00

Fix naming and xmldocs in new beatmap search result structures

This commit is contained in:
Bartłomiej Dach 2021-06-26 20:31:26 +02:00
parent 709e555566
commit b56dd7ff25
2 changed files with 32 additions and 15 deletions

View File

@ -26,8 +26,6 @@ namespace osu.Game.Overlays.BeatmapListing
{ {
/// <summary> /// <summary>
/// Fired when a search finishes. /// 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> /// </summary>
public Action<SearchResult> SearchFinished; public Action<SearchResult> SearchFinished;
@ -216,7 +214,7 @@ namespace osu.Game.Overlays.BeatmapListing
lastResponse = response; lastResponse = response;
getSetsRequest = null; getSetsRequest = null;
// check if an non-supporter user used supporter-only filters // check if a non-supporter used supporter-only filters
if (!api.LocalUser.Value.IsSupporter) if (!api.LocalUser.Value.IsSupporter)
{ {
List<LocalisableString> filters = new List<LocalisableString>(); List<LocalisableString> filters = new List<LocalisableString>();
@ -229,7 +227,7 @@ namespace osu.Game.Overlays.BeatmapListing
if (filters.Any()) if (filters.Any())
{ {
SearchFinished?.Invoke(SearchResult.SupporterOnlyFilter(filters)); SearchFinished?.Invoke(SearchResult.SupporterOnlyFilters(filters));
return; return;
} }
} }
@ -260,21 +258,40 @@ namespace osu.Game.Overlays.BeatmapListing
base.Dispose(isDisposing); base.Dispose(isDisposing);
} }
/// <summary>
/// Indicates the type of result of a user-requested beatmap search.
/// </summary>
public enum SearchResultType public enum SearchResultType
{ {
// returned with Results /// <summary>
/// Actual results have been returned from API.
/// </summary>
ResultsReturned, ResultsReturned,
// non-supporter user applied supporter-only filters
SupporterOnlyFilter /// <summary>
/// The user is not a supporter, but used supporter-only search filters.
/// </summary>
SupporterOnlyFilters
} }
// Results only valid when Type == ResultsReturned /// <summary>
// Filters only valid when Type == SupporterOnlyFilter /// Describes the result of a user-requested beatmap search.
/// </summary>
public struct SearchResult public struct SearchResult
{ {
public SearchResultType Type { get; private set; } public SearchResultType Type { get; private set; }
/// <summary>
/// Contains the beatmap sets returned from API.
/// Valid for read if and only if <see cref="Type"/> is <see cref="SearchResultType.ResultsReturned"/>.
/// </summary>
public List<BeatmapSetInfo> Results { get; private set; } public List<BeatmapSetInfo> Results { get; private set; }
public List<LocalisableString> Filters { get; private set; }
/// <summary>
/// Contains the names of supporter-only filters requested by the user.
/// Valid for read if and only if <see cref="Type"/> is <see cref="SearchResultType.SupporterOnlyFilters"/>.
/// </summary>
public List<LocalisableString> SupporterOnlyFiltersUsed { get; private set; }
public static SearchResult ResultsReturned(List<BeatmapSetInfo> results) => new SearchResult public static SearchResult ResultsReturned(List<BeatmapSetInfo> results) => new SearchResult
{ {
@ -282,10 +299,10 @@ namespace osu.Game.Overlays.BeatmapListing
Results = results Results = results
}; };
public static SearchResult SupporterOnlyFilter(List<LocalisableString> filters) => new SearchResult public static SearchResult SupporterOnlyFilters(List<LocalisableString> filters) => new SearchResult
{ {
Type = SearchResultType.SupporterOnlyFilter, Type = SearchResultType.SupporterOnlyFilters,
Filters = filters SupporterOnlyFiltersUsed = filters
}; };
} }
} }

View File

@ -123,9 +123,9 @@ namespace osu.Game.Overlays
private void onSearchFinished(BeatmapListingFilterControl.SearchResult searchResult) private void onSearchFinished(BeatmapListingFilterControl.SearchResult searchResult)
{ {
// non-supporter user used supporter-only filters // non-supporter user used supporter-only filters
if (searchResult.Type == BeatmapListingFilterControl.SearchResultType.SupporterOnlyFilter) if (searchResult.Type == BeatmapListingFilterControl.SearchResultType.SupporterOnlyFilters)
{ {
supporterRequiredContent.UpdateText(searchResult.Filters); supporterRequiredContent.UpdateText(searchResult.SupporterOnlyFiltersUsed);
addContentToPlaceholder(supporterRequiredContent); addContentToPlaceholder(supporterRequiredContent);
return; return;
} }