using System; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI.Events; using StardewValley; using xTile; namespace StardewModdingAPI { /// Provides an API for loading content assets from the game's Content folder or via . public interface IGameContentHelper : IModLinked { /********* ** Accessors *********/ /// 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 *********/ /// Parse a raw asset name. /// The raw asset name to parse. /// The is null or empty. IAssetName ParseAssetName(string rawName); /// 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 , , dictionaries, and lists; other types may be supported by the game's content pipeline. /// The asset name to load. /// The is empty or contains invalid characters. /// The content asset couldn't be loaded (e.g. because it doesn't exist). T Load(string assetName) where T : notnull; /// 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 , , dictionaries, and lists; other types may be supported by the game's content pipeline. /// The asset name to load. /// The is empty or contains invalid characters. /// The content asset couldn't be loaded (e.g. because it doesn't exist). T Load(IAssetName assetName) where T : notnull; /// 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 assetName); /// 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(IAssetName assetName); /// 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() where T : notnull; /// Remove matching assets from the content cache so they're 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. /// A predicate matching the assets to invalidate. /// Returns whether any cache entries were invalidated. bool InvalidateCache(Func predicate); /// Get a patch helper for arbitrary data. /// The data type. /// The asset data. /// The asset name. This is only used for tracking purposes and has no effect on the patch helper. IAssetData GetPatchHelper(T data, string? assetName = null) where T : notnull; } }