Skip to content

Commit

Permalink
Ensure icon is loaded inside try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Jun 29, 2022
1 parent e3eba58 commit 87e3b44
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions osu.Game/Overlays/Settings/SettingsFooter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#nullable disable

using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Development;
using osu.Framework.Graphics;
Expand All @@ -29,39 +28,17 @@ private void load(OsuGameBase game, RulesetStore rulesets)
Direction = FillDirection.Vertical;
Padding = new MarginPadding { Top = 20, Bottom = 30, Horizontal = SettingsPanel.CONTENT_MARGINS };

var modes = new List<Drawable>();

foreach (var ruleset in rulesets.AvailableRulesets)
{
try
{
var icon = new ConstrainedIconContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Icon = ruleset.CreateInstance().CreateIcon(),
Colour = Color4.Gray,
Size = new Vector2(20),
};

modes.Add(icon);
}
catch
{
Logger.Log($"Could not create ruleset icon for {ruleset.Name}. Please check for an update from the developer.", level: LogLevel.Error);
}
}
FillFlowContainer modes;

Children = new Drawable[]
{
new FillFlowContainer
modes = new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Direction = FillDirection.Full,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = modes,
Spacing = new Vector2(5),
Padding = new MarginPadding { Bottom = 10 },
},
Expand All @@ -78,6 +55,27 @@ private void load(OsuGameBase game, RulesetStore rulesets)
Origin = Anchor.TopCentre,
}
};

foreach (var ruleset in rulesets.AvailableRulesets)
{
try
{
var icon = new ConstrainedIconContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Icon = ruleset.CreateInstance().CreateIcon(),
Colour = Color4.Gray,
Size = new Vector2(20),
};

modes.Add(icon);
}
catch
{
Logger.Log($"Could not create ruleset icon for {ruleset.Name}. Please check for an update from the developer.", level: LogLevel.Error);
}
}
}

private class BuildDisplay : OsuAnimatedButton
Expand Down

0 comments on commit 87e3b44

Please sign in to comment.