mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 21:12:55 +08:00
Merge pull request #18935 from peppy/ruleset-guard-icon-creation-failure
Guard against ruleset icon creation failures to avoid whole game death
This commit is contained in:
commit
6a16b84edb
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Development;
|
using osu.Framework.Development;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -28,32 +28,17 @@ namespace osu.Game.Overlays.Settings
|
|||||||
Direction = FillDirection.Vertical;
|
Direction = FillDirection.Vertical;
|
||||||
Padding = new MarginPadding { Top = 20, Bottom = 30, Horizontal = SettingsPanel.CONTENT_MARGINS };
|
Padding = new MarginPadding { Top = 20, Bottom = 30, Horizontal = SettingsPanel.CONTENT_MARGINS };
|
||||||
|
|
||||||
var modes = new List<Drawable>();
|
FillFlowContainer modes;
|
||||||
|
|
||||||
foreach (var ruleset in rulesets.AvailableRulesets)
|
|
||||||
{
|
|
||||||
var icon = new ConstrainedIconContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Icon = ruleset.CreateInstance().CreateIcon(),
|
|
||||||
Colour = Color4.Gray,
|
|
||||||
Size = new Vector2(20),
|
|
||||||
};
|
|
||||||
|
|
||||||
modes.Add(icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
modes = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Direction = FillDirection.Full,
|
Direction = FillDirection.Full,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = modes,
|
|
||||||
Spacing = new Vector2(5),
|
Spacing = new Vector2(5),
|
||||||
Padding = new MarginPadding { Bottom = 10 },
|
Padding = new MarginPadding { Bottom = 10 },
|
||||||
},
|
},
|
||||||
@ -70,6 +55,27 @@ namespace osu.Game.Overlays.Settings
|
|||||||
Origin = Anchor.TopCentre,
|
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
|
private class BuildDisplay : OsuAnimatedButton
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Logging;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets
|
namespace osu.Game.Rulesets
|
||||||
{
|
{
|
||||||
@ -18,8 +19,17 @@ namespace osu.Game.Rulesets
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
foreach (var r in Rulesets.AvailableRulesets)
|
foreach (var ruleset in Rulesets.AvailableRulesets)
|
||||||
AddItem(r);
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
AddItem(ruleset);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Logger.Log($"Could not create ruleset icon for {ruleset.Name}. Please check for an update from the developer.", level: LogLevel.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
@ -14,6 +13,7 @@ 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.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -340,24 +340,28 @@ namespace osu.Game.Screens.Menu
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(RulesetStore rulesets)
|
private void load(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
var modes = new List<Drawable>();
|
|
||||||
|
|
||||||
foreach (var ruleset in rulesets.AvailableRulesets)
|
|
||||||
{
|
|
||||||
var icon = new ConstrainedIconContainer
|
|
||||||
{
|
|
||||||
Icon = ruleset.CreateInstance().CreateIcon(),
|
|
||||||
Size = new Vector2(30),
|
|
||||||
};
|
|
||||||
|
|
||||||
modes.Add(icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
Children = modes;
|
|
||||||
|
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
foreach (var ruleset in rulesets.AvailableRulesets)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var icon = new ConstrainedIconContainer
|
||||||
|
{
|
||||||
|
Icon = ruleset.CreateInstance().CreateIcon(),
|
||||||
|
Size = new Vector2(30),
|
||||||
|
};
|
||||||
|
|
||||||
|
Add(icon);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Logger.Log($"Could not create ruleset icon for {ruleset.Name}. Please check for an update from the developer.", level: LogLevel.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user