Resolve common/font paths from Interface Assignment

This commit is contained in:
Ottermandias 2023-06-03 15:10:48 +02:00
parent 9255f2bb2b
commit 0404ea6109

View file

@ -16,7 +16,7 @@ public class PathResolver : IDisposable
{ {
private readonly PerformanceTracker _performance; private readonly PerformanceTracker _performance;
private readonly Configuration _config; private readonly Configuration _config;
private readonly CollectionManager _collectionManager; private readonly CollectionManager _collectionManager;
private readonly TempCollectionManager _tempCollections; private readonly TempCollectionManager _tempCollections;
private readonly ResourceLoader _loader; private readonly ResourceLoader _loader;
@ -57,8 +57,7 @@ public class PathResolver : IDisposable
return category switch return category switch
{ {
// Only Interface collection. // Only Interface collection.
ResourceCategory.Ui => (_collectionManager.Active.Interface.ResolvePath(path), ResourceCategory.Ui => ResolveUi(path),
_collectionManager.Active.Interface.ToResolveData()),
// Never allow changing scripts. // Never allow changing scripts.
ResourceCategory.UiScript => (null, ResolveData.Invalid), ResourceCategory.UiScript => (null, ResolveData.Invalid),
ResourceCategory.GameScript => (null, ResolveData.Invalid), ResourceCategory.GameScript => (null, ResolveData.Invalid),
@ -68,8 +67,11 @@ public class PathResolver : IDisposable
ResourceCategory.Vfx => Resolve(path, resourceType), ResourceCategory.Vfx => Resolve(path, resourceType),
ResourceCategory.Sound => Resolve(path, resourceType), ResourceCategory.Sound => Resolve(path, resourceType),
// None of these files are ever associated with specific characters, // None of these files are ever associated with specific characters,
// always use the default resolver for now. // always use the default resolver for now,
ResourceCategory.Common => DefaultResolver(path), // except that common/font is conceptually more UI.
ResourceCategory.Common => path.Path.StartsWith("common/font"u8)
? ResolveUi(path)
: DefaultResolver(path),
ResourceCategory.BgCommon => DefaultResolver(path), ResourceCategory.BgCommon => DefaultResolver(path),
ResourceCategory.Bg => DefaultResolver(path), ResourceCategory.Bg => DefaultResolver(path),
ResourceCategory.Cut => DefaultResolver(path), ResourceCategory.Cut => DefaultResolver(path),
@ -137,4 +139,9 @@ public class PathResolver : IDisposable
$"[ResourceLoader] Loaded {gamePath} from file and replaced with IMC from collection {collection.AnonymizedName}."); $"[ResourceLoader] Loaded {gamePath} from file and replaced with IMC from collection {collection.AnonymizedName}.");
} }
} }
/// <summary> Resolve a path from the interface collection. </summary>
private (FullPath?, ResolveData) ResolveUi(Utf8GamePath path)
=> (_collectionManager.Active.Interface.ResolvePath(path),
_collectionManager.Active.Interface.ToResolveData());
} }