mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 07:22:54 +08:00
Check id for genre/language instead and fallback to name if not defined
This commit is contained in:
parent
1d39e8d0ce
commit
e1e6d76f30
@ -54,6 +54,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
overlay.ShowBeatmapSet(new APIBeatmapSet
|
||||
{
|
||||
Genre = new BeatmapSetOnlineGenre { Id = 15, Name = "Future genre" },
|
||||
Language = new BeatmapSetOnlineLanguage { Id = 15, Name = "Future language" },
|
||||
OnlineID = 1235,
|
||||
Title = @"an awesome beatmap",
|
||||
Artist = @"naru narusegawa",
|
||||
|
@ -46,6 +46,7 @@ using osu.Game.Online;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.BeatmapListing;
|
||||
using osu.Game.Overlays.Music;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
@ -357,11 +358,11 @@ namespace osu.Game
|
||||
break;
|
||||
|
||||
case LinkAction.FilterBeatmapSetGenre:
|
||||
FilterBeatmapSetGenre(argString);
|
||||
FilterBeatmapSetGenre((SearchGenre)link.Argument);
|
||||
break;
|
||||
|
||||
case LinkAction.FilterBeatmapSetLanguage:
|
||||
FilterBeatmapSetLanguage(argString);
|
||||
FilterBeatmapSetLanguage((SearchLanguage)link.Argument);
|
||||
break;
|
||||
|
||||
case LinkAction.OpenEditorTimestamp:
|
||||
@ -468,9 +469,9 @@ namespace osu.Game
|
||||
/// <param name="query">The query to search for.</param>
|
||||
public void SearchBeatmapSet(string query) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithSearch(query));
|
||||
|
||||
public void FilterBeatmapSetGenre(string genre) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithGenreFilter(genre));
|
||||
public void FilterBeatmapSetGenre(SearchGenre genre) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithGenreFilter(genre));
|
||||
|
||||
public void FilterBeatmapSetLanguage(string language) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithLanguageFilter(language));
|
||||
public void FilterBeatmapSetLanguage(SearchLanguage language) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithLanguageFilter(language));
|
||||
|
||||
/// <summary>
|
||||
/// Show a wiki's page as an overlay
|
||||
|
@ -6,7 +6,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
@ -146,11 +145,11 @@ namespace osu.Game.Overlays.BeatmapListing
|
||||
public void Search(string query)
|
||||
=> Schedule(() => searchControl.Query.Value = query);
|
||||
|
||||
public void FilterGenre(string genre)
|
||||
=> Schedule(() => searchControl.Genre.Value = genre.DehumanizeTo<SearchGenre>());
|
||||
public void FilterGenre(SearchGenre genre)
|
||||
=> Schedule(() => searchControl.Genre.Value = genre);
|
||||
|
||||
public void FilterLanguage(string language)
|
||||
=> Schedule(() => searchControl.Language.Value = language.DehumanizeTo<SearchLanguage>());
|
||||
public void FilterLanguage(SearchLanguage language)
|
||||
=> Schedule(() => searchControl.Language.Value = language);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
|
@ -110,13 +110,13 @@ namespace osu.Game.Overlays
|
||||
ScrollFlow.ScrollToStart();
|
||||
}
|
||||
|
||||
public void ShowWithGenreFilter(string genre)
|
||||
public void ShowWithGenreFilter(SearchGenre genre)
|
||||
{
|
||||
ShowWithSearch(string.Empty);
|
||||
filterControl.FilterGenre(genre);
|
||||
}
|
||||
|
||||
public void ShowWithLanguageFilter(string language)
|
||||
public void ShowWithLanguageFilter(SearchLanguage language)
|
||||
{
|
||||
ShowWithSearch(string.Empty);
|
||||
filterControl.FilterLanguage(language);
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -34,7 +35,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
public Info()
|
||||
{
|
||||
MetadataSection source, tags, genre, language;
|
||||
MetadataSection source, tags;
|
||||
MetadataSectionGenre genre;
|
||||
MetadataSectionLanguage language;
|
||||
OsuSpriteText notRankedPlaceholder;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -76,7 +79,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Full,
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
source = new MetadataSectionSource(),
|
||||
genre = new MetadataSectionGenre { Width = 0.5f },
|
||||
@ -120,8 +123,8 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
source.Text = b.NewValue?.Source ?? string.Empty;
|
||||
tags.Text = b.NewValue?.Tags ?? string.Empty;
|
||||
genre.Text = b.NewValue?.Genre.Name ?? string.Empty;
|
||||
language.Text = b.NewValue?.Language.Name ?? string.Empty;
|
||||
genre.Text = b.NewValue?.Genre ?? new BeatmapSetOnlineGenre { Id = 1 };
|
||||
language.Text = b.NewValue?.Language ?? new BeatmapSetOnlineLanguage { Id = 1 };
|
||||
bool setHasLeaderboard = b.NewValue?.Status > 0;
|
||||
successRate.Alpha = setHasLeaderboard ? 1 : 0;
|
||||
notRankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1;
|
||||
|
@ -2,24 +2,29 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using Humanizer;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Overlays.BeatmapListing;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public partial class MetadataSectionGenre : MetadataSection
|
||||
public partial class MetadataSectionGenre : MetadataSection<BeatmapSetOnlineGenre>
|
||||
{
|
||||
public MetadataSectionGenre(Action<string>? searchAction = null)
|
||||
public MetadataSectionGenre(Action<BeatmapSetOnlineGenre>? searchAction = null)
|
||||
: base(MetadataType.Genre, searchAction)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void AddMetadata(string text, LinkFlowContainer loaded)
|
||||
protected override void AddMetadata(BeatmapSetOnlineGenre text, LinkFlowContainer loaded)
|
||||
{
|
||||
loaded.AddLink(text.DehumanizeTo<SearchGenre>().GetLocalisableDescription(), LinkAction.FilterBeatmapSetGenre, text);
|
||||
var genre = (SearchGenre)text.Id;
|
||||
|
||||
if (Enum.IsDefined(genre))
|
||||
loaded.AddLink(genre.GetLocalisableDescription(), LinkAction.FilterBeatmapSetGenre, genre);
|
||||
else
|
||||
loaded.AddText(text.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,24 +2,29 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using Humanizer;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Overlays.BeatmapListing;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public partial class MetadataSectionLanguage : MetadataSection
|
||||
public partial class MetadataSectionLanguage : MetadataSection<BeatmapSetOnlineLanguage>
|
||||
{
|
||||
public MetadataSectionLanguage(Action<string>? searchAction = null)
|
||||
public MetadataSectionLanguage(Action<BeatmapSetOnlineLanguage>? searchAction = null)
|
||||
: base(MetadataType.Language, searchAction)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void AddMetadata(string text, LinkFlowContainer loaded)
|
||||
protected override void AddMetadata(BeatmapSetOnlineLanguage text, LinkFlowContainer loaded)
|
||||
{
|
||||
loaded.AddLink(text.DehumanizeTo<SearchLanguage>().GetLocalisableDescription(), LinkAction.FilterBeatmapSetLanguage, text);
|
||||
var language = (SearchLanguage)text.Id;
|
||||
|
||||
if (Enum.IsDefined(language))
|
||||
loaded.AddLink(language.GetLocalisableDescription(), LinkAction.FilterBeatmapSetLanguage, language);
|
||||
else
|
||||
loaded.AddText(text.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user