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