diff --git a/osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs b/osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs index 019f069..4b6d5ee 100644 --- a/osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs +++ b/osu.Game.Rulesets.RurusettoAddon/RulesetDownloadManager.cs @@ -20,6 +20,9 @@ public RulesetDownloadManager ( RurusettoAPI API, Storage storage ) { InstalledRulesets = Array.Empty(); UnimportedRulesets = Array.Empty<(string, string)>(); + InstalledRulesetPaths = new Dictionary(); + InstalledRulesetFilenames = new Dictionary(); + PerformPreCleanup(); } @@ -30,12 +33,16 @@ public RulesetDownloadManager ( RurusettoAPI API, Storage storage, IRulesetStore InstalledRulesets = store.AvailableRulesets.Cast(); Dictionary filenames = new(); + Dictionary paths = new(); foreach ( var i in InstalledRulesets ) { - if ( Path.GetFileName( i.CreateInstance()?.GetType().Assembly.Location ) is string filename ) { + var loc = i.CreateInstance()?.GetType().Assembly.Location; + if ( Path.GetFileName( loc ) is string filename ) { filenames.Add( i, filename ); + paths.Add( i, loc ); } } - InstalledRulesetPaths = filenames; + InstalledRulesetFilenames = filenames; + InstalledRulesetPaths = paths; List<(string filename, string shortname)> unimportedRulesets = new(); foreach ( var i in storage.GetFiles( "./rulesets", "*.dll" ) ) { @@ -51,6 +58,7 @@ public RulesetDownloadManager ( RurusettoAPI API, Storage storage, IRulesetStore } public IDictionary InstalledRulesetPaths { get; private set; } + public IDictionary InstalledRulesetFilenames { get; private set; } public IEnumerable InstalledRulesets { get; private set; } public IEnumerable<(string filename, string shortname)> UnimportedRulesets { get; private set; } @@ -76,7 +84,7 @@ public void BindWith ( string shortName, IBindable bindable ) { public RulesetInfo GetLocalRuleset ( string shortName, string name, string filename ) { if ( !rulesets.TryGetValue( shortName, out var ruleset ) ) { - ruleset = InstalledRulesetPaths.FirstOrDefault( x => + ruleset = InstalledRulesetFilenames.FirstOrDefault( x => x.Value == filename ).Key; @@ -193,7 +201,7 @@ public void RemoveRuleset ( string shortName ) { } var unimported = UnimportedRulesets.Where( x => x.shortname == shortName ); - var installed = InstalledRulesetPaths.Where( x => x.Key.ShortName == shortName ); + var installed = InstalledRulesetFilenames.Where( x => x.Key.ShortName == shortName ); string location; if ( unimported.Any() ) { location = unimported.First().filename;