Skip to content

Commit

Permalink
prevent faulty ruleset icons from being used
Browse files Browse the repository at this point in the history
  • Loading branch information
Flutterish committed Jul 30, 2022
1 parent a6f5830 commit 9981788
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.RurusettoAddon/API/APIRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Merge ( APIRuleset other ) {
/// <summary>
/// Creates the dark mode variant of the ruleset logo as a drawable with relative size axes
/// </summary>
public void RequestDarkLogo ( Action<Drawable> success, Action<Drawable>? failure = null ) {
public void RequestDarkLogo ( Action<Drawable> success, Action<Drawable>? failure = null, bool useLocalIcon = true ) {
static Drawable createDefault () {
return new SpriteIcon {
RelativeSizeAxes = Axes.Both,
Expand All @@ -62,7 +62,7 @@ static Drawable createDefault () {
};
}

if ( LocalRulesetInfo != null ) {
if ( LocalRulesetInfo != null && useLocalIcon ) {
var icon = LocalRulesetInfo.CreateInstance()?.CreateIcon();

if ( icon is CompositeDrawable cd && cd.AutoSizeAxes != Axes.None ) {
Expand Down
27 changes: 23 additions & 4 deletions osu.Game.Rulesets.RurusettoAddon/UI/RulesetLogo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using osu.Game.Overlays;
using TagLib.IFD;

namespace osu.Game.Rulesets.RurusettoAddon.UI;

Expand All @@ -24,9 +25,27 @@ private void load ( OverlayColourProvider colours ) {
};

ruleset.RequestDarkLogo( logo => {
AddInternal( logo );
}, fallback => {
AddInternal( fallback );
} );
try {
AddInternal( logo );
}
catch {
RemoveInternal( logo );
ruleset.RequestDarkLogo( AddInternal, AddInternal, useLocalIcon: false );
}
}, fallback => AddInternal( fallback ) );
}

bool subtreeWorks = true;
public override bool UpdateSubTree () {
if ( !subtreeWorks )
return false;

try {
return base.UpdateSubTree();
}
catch {
subtreeWorks = false;
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
<None Remove="Resources\Textures\oh_no.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game" Version="2022.630.0" />
<PackageReference Include="ppy.osu.Game" Version="2022.730.0" />
</ItemGroup>
</Project>

0 comments on commit 9981788

Please sign in to comment.