mirror of
https://github.com/Pathoschild/SMAPI.git
synced 2026-10-12 02:08:51 +00:00
rename IContentManager to avoid ambiguity with new base-game interface
This commit is contained in:
@@ -60,7 +60,7 @@ internal class ContentCoordinator : IDisposable
|
||||
private readonly Func<IAssetInfo, AssetOperationGroup?> RequestAssetOperations;
|
||||
|
||||
/// <summary>The loaded content managers (including the <see cref="MainContentManager"/>).</summary>
|
||||
private readonly List<IContentManager> ContentManagers = [];
|
||||
private readonly List<ISmapiContentManager> ContentManagers = [];
|
||||
|
||||
/// <summary>Whether the content coordinator has been disposed.</summary>
|
||||
private bool IsDisposed;
|
||||
@@ -188,7 +188,7 @@ internal class ContentCoordinator : IDisposable
|
||||
/// <param name="modName">The mod display name to show in errors.</param>
|
||||
/// <param name="rootDirectory">The root directory to search for content (or <c>null</c> for the default).</param>
|
||||
/// <param name="gameContentManager">The game content manager used for map tilesheets not provided by the mod.</param>
|
||||
public ModContentManager CreateModContentManager(string name, string modName, string rootDirectory, IContentManager gameContentManager)
|
||||
public ModContentManager CreateModContentManager(string name, string modName, string rootDirectory, ISmapiContentManager gameContentManager)
|
||||
{
|
||||
return this.ContentManagerLock.InWriteLock(() =>
|
||||
{
|
||||
@@ -334,7 +334,7 @@ internal class ContentCoordinator : IDisposable
|
||||
where T : notnull
|
||||
{
|
||||
// get content manager
|
||||
IContentManager? contentManager = this.ContentManagerLock.InReadLock(() =>
|
||||
ISmapiContentManager? contentManager = this.ContentManagerLock.InReadLock(() =>
|
||||
this.ContentManagers.FirstOrDefault(p => p.IsNamespaced && p.Name == contentManagerId)
|
||||
);
|
||||
if (contentManager == null)
|
||||
@@ -352,7 +352,7 @@ internal class ContentCoordinator : IDisposable
|
||||
where T : notnull
|
||||
{
|
||||
// get content manager
|
||||
IContentManager? contentManager = this.ContentManagerLock.InReadLock(() =>
|
||||
ISmapiContentManager? contentManager = this.ContentManagerLock.InReadLock(() =>
|
||||
this.ContentManagers.FirstOrDefault(p => p.IsNamespaced && p.Name == contentManagerId)
|
||||
);
|
||||
if (contentManager == null)
|
||||
@@ -381,14 +381,14 @@ internal class ContentCoordinator : IDisposable
|
||||
/// <param name="predicate">Matches the asset keys to invalidate.</param>
|
||||
/// <param name="dispose">Whether to dispose invalidated assets. This should only be <c>true</c> when they're being invalidated as part of a dispose, to avoid crashing the game.</param>
|
||||
/// <returns>Returns the invalidated asset names.</returns>
|
||||
public IEnumerable<IAssetName> InvalidateCache(Func<IContentManager, string, Type, bool> predicate, bool dispose = false)
|
||||
public IEnumerable<IAssetName> InvalidateCache(Func<ISmapiContentManager, string, Type, bool> predicate, bool dispose = false)
|
||||
{
|
||||
// invalidate cache & track removed assets
|
||||
IDictionary<IAssetName, Type> invalidatedAssets = new Dictionary<IAssetName, Type>();
|
||||
this.ContentManagerLock.InReadLock(() =>
|
||||
{
|
||||
// cached assets
|
||||
foreach (IContentManager contentManager in this.ContentManagers)
|
||||
foreach (ISmapiContentManager contentManager in this.ContentManagers)
|
||||
{
|
||||
foreach ((string key, object asset) in contentManager.GetCachedAssets())
|
||||
{
|
||||
@@ -498,7 +498,7 @@ internal class ContentCoordinator : IDisposable
|
||||
return this.ContentManagerLock.InReadLock(() =>
|
||||
{
|
||||
List<object> values = [];
|
||||
foreach (IContentManager content in this.ContentManagers.Where(p => !p.IsNamespaced && p.IsLoaded(assetName)))
|
||||
foreach (ISmapiContentManager content in this.ContentManagers.Where(p => !p.IsNamespaced && p.IsLoaded(assetName)))
|
||||
{
|
||||
object value = content.LoadExact<object>(assetName, useCache: true);
|
||||
values.Add(value);
|
||||
@@ -542,7 +542,7 @@ internal class ContentCoordinator : IDisposable
|
||||
this.IsDisposed = true;
|
||||
|
||||
this.Monitor.Log("Disposing the content coordinator. Content managers will no longer be usable after this point.");
|
||||
foreach (IContentManager contentManager in this.ContentManagers)
|
||||
foreach (ISmapiContentManager contentManager in this.ContentManagers)
|
||||
contentManager.Dispose();
|
||||
this.ContentManagers.Clear();
|
||||
this.MainContentManager = null!; // instance no longer usable
|
||||
@@ -556,7 +556,7 @@ internal class ContentCoordinator : IDisposable
|
||||
*********/
|
||||
/// <summary>A callback invoked when a content manager is disposed.</summary>
|
||||
/// <param name="contentManager">The content manager being disposed.</param>
|
||||
private void OnDisposing(IContentManager contentManager)
|
||||
private void OnDisposing(ISmapiContentManager contentManager)
|
||||
{
|
||||
if (this.IsDisposed)
|
||||
return;
|
||||
|
||||
@@ -16,7 +16,7 @@ using StardewValley;
|
||||
namespace StardewModdingAPI.Framework.ContentManagers;
|
||||
|
||||
/// <summary>A content manager which handles reading files from a SMAPI mod folder with support for unpacked files.</summary>
|
||||
internal abstract class BaseContentManager : LocalizedContentManager, IContentManager
|
||||
internal abstract class BaseContentManager : LocalizedContentManager, ISmapiContentManager
|
||||
{
|
||||
/*********
|
||||
** Fields
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Framework.ContentManagers;
|
||||
|
||||
/// <summary>A content manager which handles reading files.</summary>
|
||||
internal interface IContentManager : IDisposable
|
||||
/// <summary>A SMAPI content manager which handles reading files with support for managed mod asset keys.</summary>
|
||||
internal interface ISmapiContentManager : IDisposable
|
||||
{
|
||||
/*********
|
||||
** Accessors
|
||||
@@ -39,7 +39,7 @@ internal sealed class ModContentManager : BaseContentManager
|
||||
private readonly string ModName;
|
||||
|
||||
/// <summary>The game content manager used for map tilesheets not provided by the mod.</summary>
|
||||
private readonly IContentManager GameContentManager;
|
||||
private readonly ISmapiContentManager GameContentManager;
|
||||
|
||||
/// <summary>A lookup for files within the <see cref="ContentManager.RootDirectory"/>.</summary>
|
||||
private readonly IFileLookup FileLookup;
|
||||
@@ -64,7 +64,7 @@ internal sealed class ModContentManager : BaseContentManager
|
||||
/// <param name="jsonHelper">Encapsulates SMAPI's JSON file parsing.</param>
|
||||
/// <param name="onDisposing">A callback to invoke when the content manager is being disposed.</param>
|
||||
/// <param name="fileLookup">A lookup for files within the <paramref name="rootDirectory"/>.</param>
|
||||
public ModContentManager(string name, IContentManager gameContentManager, IServiceProvider serviceProvider, string modName, string rootDirectory, CultureInfo currentCulture, ContentCoordinator coordinator, IMonitor monitor, Reflector reflection, JsonHelper jsonHelper, Action<BaseContentManager> onDisposing, IFileLookup fileLookup)
|
||||
public ModContentManager(string name, ISmapiContentManager gameContentManager, IServiceProvider serviceProvider, string modName, string rootDirectory, CultureInfo currentCulture, ContentCoordinator coordinator, IMonitor monitor, Reflector reflection, JsonHelper jsonHelper, Action<BaseContentManager> onDisposing, IFileLookup fileLookup)
|
||||
: base(name, serviceProvider, rootDirectory, currentCulture, coordinator, monitor, reflection, onDisposing, isNamespaced: true)
|
||||
{
|
||||
this.GameContentManager = gameContentManager;
|
||||
|
||||
@@ -18,7 +18,7 @@ internal class GameContentHelper : BaseHelper, IGameContentHelper
|
||||
private readonly ContentCoordinator ContentCore;
|
||||
|
||||
/// <summary>The underlying game content manager.</summary>
|
||||
private readonly IContentManager GameContentManager;
|
||||
private readonly ISmapiContentManager GameContentManager;
|
||||
|
||||
/// <summary>The friendly mod name for use in errors.</summary>
|
||||
private readonly string ModName;
|
||||
@@ -144,7 +144,7 @@ internal class GameContentHelper : BaseHelper, IGameContentHelper
|
||||
}
|
||||
|
||||
/// <summary>Get the underlying game content manager.</summary>
|
||||
internal IContentManager GetUnderlyingContentManager()
|
||||
internal ISmapiContentManager GetUnderlyingContentManager()
|
||||
{
|
||||
return this.GameContentManager;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ internal class ModContentHelper : BaseHelper, IModContentHelper
|
||||
/// <param name="modName">The friendly mod name for use in errors.</param>
|
||||
/// <param name="gameContentManager">The game content manager used for map tilesheets not provided by the mod.</param>
|
||||
/// <param name="reflection">Simplifies access to private code.</param>
|
||||
public ModContentHelper(ContentCoordinator contentCore, string modFolderPath, IModMetadata mod, string modName, IContentManager gameContentManager, Reflector reflection)
|
||||
public ModContentHelper(ContentCoordinator contentCore, string modFolderPath, IModMetadata mod, string modName, ISmapiContentManager gameContentManager, Reflector reflection)
|
||||
: base(mod)
|
||||
{
|
||||
string managedAssetPrefix = contentCore.GetManagedAssetPrefix(mod.Manifest.UniqueID);
|
||||
|
||||
@@ -1390,7 +1390,7 @@ internal class SCore : IDisposable
|
||||
/// <summary>A callback invoked after an asset is fully loaded through a content manager.</summary>
|
||||
/// <param name="contentManager">The content manager through which the asset was loaded.</param>
|
||||
/// <param name="assetName">The asset name that was loaded.</param>
|
||||
private void OnAssetLoaded(IContentManager contentManager, IAssetName assetName)
|
||||
private void OnAssetLoaded(ISmapiContentManager contentManager, IAssetName assetName)
|
||||
{
|
||||
if (this.EventManager.AssetReady.HasListeners)
|
||||
this.EventManager.AssetReady.Raise(new AssetReadyEventArgs(assetName, assetName.GetBaseAssetName()));
|
||||
|
||||
@@ -75,7 +75,7 @@ internal class CoreAssetPropagator
|
||||
/// <param name="ignoreWorld">Whether the in-game world is fully unloaded (e.g. on the title screen), so there's no need to propagate changes into the world.</param>
|
||||
/// <param name="propagatedAssets">A lookup of asset names to whether they've been propagated.</param>
|
||||
/// <param name="changedWarpRoutes">Whether the NPC pathfinding warp route cache was reloaded.</param>
|
||||
public void Propagate(IList<IContentManager> contentManagers, IDictionary<IAssetName, Type> assets, bool ignoreWorld, out Dictionary<IAssetName, bool> propagatedAssets, out bool changedWarpRoutes)
|
||||
public void Propagate(IList<ISmapiContentManager> contentManagers, IDictionary<IAssetName, Type> assets, bool ignoreWorld, out Dictionary<IAssetName, bool> propagatedAssets, out bool changedWarpRoutes)
|
||||
{
|
||||
propagatedAssets = new Dictionary<IAssetName, bool>(assets.Count);
|
||||
|
||||
@@ -191,7 +191,7 @@ internal class CoreAssetPropagator
|
||||
/// <param name="contentManagers">The content managers whose assets to update.</param>
|
||||
/// <param name="ignoreWorld">Whether the in-game world is fully unloaded (e.g. on the title screen), so there's no need to propagate changes into the world.</param>
|
||||
/// <returns>Returns whether any assets were updated.</returns>
|
||||
private bool PropagateTexture(IAssetName assetName, IList<IContentManager> contentManagers, bool ignoreWorld)
|
||||
private bool PropagateTexture(IAssetName assetName, IList<ISmapiContentManager> contentManagers, bool ignoreWorld)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
@@ -230,7 +230,7 @@ internal class CoreAssetPropagator
|
||||
});
|
||||
|
||||
// apply to content managers
|
||||
foreach (IContentManager contentManager in contentManagers)
|
||||
foreach (ISmapiContentManager contentManager in contentManagers)
|
||||
{
|
||||
if (contentManager.IsLoaded(name))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user