/// <summary>Stores a mod logo in the cache with the given fileName.</summary> public static bool SaveModLogo(int modId, string fileName, LogoSize size, Texture2D logoTexture) { Debug.Assert(!String.IsNullOrEmpty(fileName)); Debug.Assert(logoTexture != null); bool success = false; string logoFilePath = CacheClient.GenerateModLogoFilePath(modId, size); byte[] imageData = logoTexture.EncodeToPNG(); // write file if (LocalDataStorage.WriteFile(logoFilePath, imageData)) { success = true; // - Update the versioning info - var versionInfo = CacheClient.GetModLogoVersionFileNames(modId); if (versionInfo == null) { versionInfo = new Dictionary <LogoSize, string>(); } versionInfo[size] = fileName; LocalDataStorage.WriteJSONFile(GenerateModLogoVersionInfoFilePath(modId), versionInfo); } return(success); }
/// <summary>Retrieves the information for the cached mod logos.</summary> public static string GetModLogoFileName(int modId, LogoSize size) { // - Ensure the logo is the correct version - var versionInfo = CacheClient.GetModLogoVersionFileNames(modId); if (versionInfo != null) { string logoFileName = string.Empty; if (versionInfo.TryGetValue(size, out logoFileName) && !String.IsNullOrEmpty(logoFileName)) { return(logoFileName); } } return(null); }
/// <summary>Stores a mod logo in the cache with the given fileName.</summary> public static bool SaveModLogo(int modId, string fileName, LogoSize size, Texture2D logoTexture) { Debug.Assert(!String.IsNullOrEmpty(fileName)); Debug.Assert(logoTexture != null); string logoFilePath = CacheClient.GenerateModLogoFilePath(modId, size); bool isSuccessful = IOUtilities.WritePNGFile(logoFilePath, logoTexture); // - Update the versioning info - var versionInfo = CacheClient.GetModLogoVersionFileNames(modId); if (versionInfo == null) { versionInfo = new Dictionary <LogoSize, string>(); } versionInfo[size] = fileName; isSuccessful = (IOUtilities.WriteJsonObjectFile(GenerateModLogoVersionInfoFilePath(modId), versionInfo) && isSuccessful); return(isSuccessful); }
public static Dictionary <LogoSize, string> LoadModLogoFilePaths(int modId) { return(CacheClient.GetModLogoVersionFileNames(modId)); }