using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using StardewValley; namespace StardewModdingAPI { /// Provides an API for loading content assets. public interface IContentHelper : IModLinked { /********* ** Accessors *********/ /// Interceptors which provide the initial versions of matching content assets. IList AssetLoaders { get; } /// Interceptors which edit matching content assets after they're loaded. IList AssetEditors { get; } /// The game's current locale code (like pt-BR). string CurrentLocale { get; } /// The game's current locale as an enum value. LocalizedContentManager.LanguageCode CurrentLocaleConstant { get; } /********* ** Public methods *********/ /// Load content from the game folder or mod folder (if not already cached), and return it. When loading a .png file, this must be called outside the game's draw loop. /// The expected data type. The main supported types are and dictionaries; other types may be supported by the game's content pipeline. /// The asset key to fetch (if the is ), or the local path to a content file relative to the mod folder. /// Where to search for a matching content asset. /// The is empty or contains invalid characters. /// The content asset couldn't be loaded (e.g. because it doesn't exist). T Load(string key, ContentSource source = ContentSource.ModFolder); /// Get the underlying key in the game's content cache for an asset. This can be used to load custom map tilesheets, but should be avoided when you can use the content API instead. This does not validate whether the asset exists. /// The asset key to fetch (if the is ), or the local path to a content file relative to the mod folder. /// Where to search for a matching content asset. /// The is empty or contains invalid characters. string GetActualAssetKey(string key, ContentSource source = ContentSource.ModFolder); /// Remove an asset from the content cache so it's reloaded on the next request. This will reload core game assets if needed, but references to the former asset will still show the previous content. /// The asset key to invalidate in the content folder. /// The is empty or contains invalid characters. /// Returns whether the given asset key was cached. bool InvalidateCache(string key); /// Remove all assets of the given type from the cache so they're reloaded on the next request. This can be a very expensive operation and should only be used in very specific cases. This will reload core game assets if needed, but references to the former assets will still show the previous content. /// The asset type to remove from the cache. /// Returns whether any assets were invalidated. bool InvalidateCache(); } }