Ejemplo n.º 1
0
        // ---------[ MOD IMAGES ]---------
        // TODO(@jackson): Look at reconfiguring params
        public static void GetModLogo(ModProfile profile, LogoSize size,
                                      Action <Texture2D> onSuccess,
                                      Action <WebRequestError> onError)
        {
            Debug.Assert(onSuccess != null);

            var logoTexture = CacheClient.LoadModLogo(profile.id, size);

            if (logoTexture != null)
            {
                onSuccess(logoTexture);
            }

            var versionInfo = CacheClient.LoadModLogoVersionInfo(profile.id);

            if (logoTexture == null ||
                versionInfo[size] != profile.logoLocator.GetFileName())
            {
                var textureDownload = DownloadClient.DownloadModLogo(profile, size);

                textureDownload.succeeded += (d) =>
                {
                    CacheClient.SaveModLogo(profile.id, profile.logoLocator.GetFileName(),
                                            size, d.imageTexture);
                };

                textureDownload.succeeded += (d) => onSuccess(d.imageTexture);
                textureDownload.failed    += (d) => onError(d.error);
            }
        }
Ejemplo n.º 2
0
        /// <summary>Retrieves a mod logo from the cache if it matches the given fileName.</summary>
        public static Texture2D LoadModLogo(int modId, string fileName, LogoSize size)
        {
            Debug.Assert(!String.IsNullOrEmpty(fileName));

            string logoFileName = GetModLogoFileName(modId, size);

            if (logoFileName == fileName)
            {
                return(CacheClient.LoadModLogo(modId, size));
            }
            else
            {
                return(null);
            }
        }