using System; using System.Collections.Generic; 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 can be targeted by managed asset keys (e.g. to load assets from a mod folder). bool IsNamespaced { 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. /// The language code for which to load content. /// Whether to read/write the loaded asset to the asset cache. T Load(string assetName, LocalizedContentManager.LanguageCode language, bool useCache); /// Perform any cleanup needed when the locale changes. void OnLocaleChanged(); /// Normalize path separators in a file path. For asset keys, see instead. /// The file path to normalize. [Pure] string NormalizePathSeparators(string path); /// Assert that the given key has a valid format and return a normalized form consistent with the underlying cache. /// The asset key to check. /// The asset key is empty or contains invalid characters. string AssertAndNormalizeAssetName(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 instances. IDictionary InvalidateCache(Func predicate, bool dispose = false); } }