using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using Microsoft.Xna.Framework.Content; using StardewModdingAPI.Framework.Exceptions; using StardewValley; namespace StardewModdingAPI.Framework.ContentManagers { /// A content manager which handles reading files. internal interface IContentManager : IDisposable { /********* ** Accessors *********/ /// A name for the mod manager. Not guaranteed to be unique. string Name { get; } /// The current language as a constant. LocalizedContentManager.LanguageCode Language { get; } /// The absolute path to the . string FullRootDirectory { get; } /// Whether this content manager is for a mod folder. bool IsModContentManager { get; } /********* ** Methods *********/ /// Load an asset that has been processed by the content pipeline. /// The type of asset to load. /// The asset path relative to the loader root directory, not including the .xnb extension. T Load(string assetName); /// Load an asset that has been processed by the content pipeline. /// The type of asset to load. /// The asset path relative to the loader root directory, not including the .xnb extension. /// The language code for which to load content. T Load(string assetName, LocalizedContentManager.LanguageCode language); /// Inject an asset into the cache. /// The type of asset to inject. /// The asset path relative to the loader root directory, not including the .xnb extension. /// The asset value. void Inject(string assetName, T value); /// Get a copy of the given asset if supported. /// The asset type. /// The asset to clone. T CloneIfPossible(T asset); /// Normalise path separators in a file path. For asset keys, see instead. /// The file path to normalise. [Pure] string NormalisePathSeparators(string path); /// Assert that the given key has a valid format and return a normalised form consistent with the underlying cache. /// The asset key to check. /// The asset key is empty or contains invalid characters. [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local", Justification = "Parameter is only used for assertion checks by design.")] string AssertAndNormaliseAssetName(string assetName); /// Get the current content locale. string GetLocale(); /// The locale for a language. /// The language. string GetLocale(LocalizedContentManager.LanguageCode language); /// Get whether the content manager has already loaded and cached the given asset. /// The asset path relative to the loader root directory, not including the .xnb extension. bool IsLoaded(string assetName); /// Get the cached asset keys. IEnumerable GetAssetKeys(); /// Purge matched assets from the cache. /// Matches the asset keys to invalidate. /// Whether to dispose invalidated assets. This should only be true when they're being invalidated as part of a dispose, to avoid crashing the game. /// Returns the invalidated asset names and types. IEnumerable> InvalidateCache(Func predicate, bool dispose = false); } }