mirror of
https://github.com/ppy/osu.git
synced 2026-06-03 18:03:55 +08:00
Use fallback icon if ruleset is not found
This commit is contained in:
@@ -12,6 +12,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
@@ -50,6 +51,9 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
private TrianglesV2 triangles = null!;
|
||||
|
||||
[Resolved]
|
||||
private IRulesetStore rulesets { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||
|
||||
@@ -215,7 +219,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
Debug.Assert(Item != null);
|
||||
var beatmap = (BeatmapInfo)Item.Model;
|
||||
|
||||
difficultyIcon.Icon = beatmap.Ruleset.CreateInstance().CreateIcon();
|
||||
difficultyIcon.Icon = getRulesetIcon(beatmap.Ruleset);
|
||||
|
||||
localRank.Beatmap = beatmap;
|
||||
difficultyText.Text = beatmap.DifficultyName;
|
||||
@@ -225,6 +229,16 @@ namespace osu.Game.Screens.SelectV2
|
||||
updateKeyCount();
|
||||
}
|
||||
|
||||
private Drawable getRulesetIcon(RulesetInfo rulesetInfo)
|
||||
{
|
||||
var rulesetInstance = rulesets.GetRuleset(rulesetInfo.ShortName)?.CreateInstance();
|
||||
|
||||
if (rulesetInstance is null)
|
||||
return new SpriteIcon { Icon = FontAwesome.Regular.QuestionCircle };
|
||||
|
||||
return rulesetInstance.CreateIcon();
|
||||
}
|
||||
|
||||
protected override void FreeAfterUse()
|
||||
{
|
||||
base.FreeAfterUse();
|
||||
|
||||
Reference in New Issue
Block a user