public void GenerateEntries(StorefrontEntry[] entries, ref Dictionary <StorefrontEntry, BitmapData> entr) { foreach (var entry in entries) { var item = entry.Items[0]; if (IsInCache(entry.CacheId)) { entr.Add(entry, DataFromCache(entry.CacheId)); continue; } using (var icon = new BaseIcon { DisplayName = entry.IsBundle ? entry.Bundle.Name.ToLowerAndUpper() : item.Name, ShortDescription = (entry.IsBundle ? entry.Bundle.Info : item.Type.DisplayValue).ToUpper(), Banner = entry.HasBanner ? entry.Banner.Value.ToUpper() : "", Price = entry.FinalPrice, IconImage = GetBitmapFromUrl(entry.IsBundle ? entry.Bundle.Image : item.Images.Featured ?? item.Images.Icon ?? item.Images.SmallIcon, $"{item.Id}{(entry.IsBundle ? "_Bundle" : "")}"), RarityBackgroundImage = item.HasSeries && item.Series.Image != null ? GetBitmapFromUrl(item.Series.Image, item.Series.BackendValue) : null, Width = EntryWidth, Height = EntryHeight }) { ChicRarity.GetRarityColors(icon, item.Rarity.BackendValue); entr.Add(entry, SaveToCache(ChicIcon.GenerateIcon(icon), entry.CacheId)); } } }
public SKBitmap DrawEntry(ShopEntry entry) { if (IsInCache(entry.CacheId)) { return(LoadFromCache(entry.CacheId)); } var item = entry.Items[0]; using (var icon = new BaseIcon { DisplayName = entry.IsBundle ? entry.Bundle.Name.ToLowerAndUpper() : item.Name, ShortDescription = "",//(entry.IsBundle ? entry.Bundle.Info : ""/*item.Type.DisplayValue*/).ToUpper(), BundleInfo = entry.IsBundle ? entry.Bundle.Info.ToUpper() : "", Banner = entry.HasBanner ? entry.Banner.Value.ToUpper() : "", Price = entry.FinalPrice, IconImage = GetBitmapFromUrl(entry.IsBundle ? entry.Bundle.Image : item.Image, $"{item.Id}{(entry.IsBundle ? "_Bundle" : "")}"), RarityBackgroundImage = item.HasSeries && item.Series.Image != null ? GetBitmapFromUrl(item.Series.Image, item.Series.BackendValue) : null, Width = EntryWidth, Height = EntryHeight }) { ChicRarity.GetRarityColors(icon, item.Rarity.BackendValue); var bmp = ChicIcon.GenerateIcon(icon); SaveToCache(bmp, entry.CacheId, false); return(bmp); } }
public IActionResult DrawCosmetic(string cosmeticId, [FromQuery] bool cache = true) { try { if (string.IsNullOrEmpty(cosmeticId)) { return(BadRequest("{\"error\": \"emptyId\", \"message\": \"The id is empty dummy\"}")); } if (cache && Program.IsInCache(cosmeticId + ".png")) { return(File(IOFile.ReadAllBytes($"{Program.Root}Cache/{cosmeticId}.png"), "image/png")); } var cosmetic = Program.FortniteApi.V2.Cosmetics.GetBr(cosmeticId).Data; if (cosmetic == null) { throw new Exception($"cosmetic ({cosmeticId}) is null sadge"); } using (var icon = new BaseIcon { DisplayName = cosmetic.Name, Description = cosmetic.Description, ShortDescription = cosmetic.Type.DisplayValue, //CosmeticSource = cosmetic.HasGameplayTags ? cosmetic.GameplayTags.Any(x => x.StartsWith("Cosmetics.Source.")) ? cosmetic.GameplayTags.First(x => x.StartsWith("Cosmetics.Source.")).Replace("Cosmetics.Source.", "") : "" : "", }) { icon.IconImage = Program.BitmapFromUrl(cosmetic.Images.HasFeatured ? cosmetic.Images.Featured : cosmetic.Images.HasIcon ? cosmetic.Images.Icon : cosmetic.Images.HasSmallIcon ? cosmetic.Images.SmallIcon : null, "icon_" + cosmeticId); icon.RarityBackgroundImage = cosmetic.HasSeries ? Program.BitmapFromUrl(cosmetic.Series.Image, cosmetic.Series.Value) : null; ChicRarity.GetRarityColors(icon, cosmetic.Rarity.BackendValue); Program.SaveToCache(ChicIcon.DrawIcon(icon), cosmeticId); } return(File(IOFile.ReadAllBytes($"{Program.Root}Cache/{cosmeticId}.png"), "image/png")); } catch (Exception e) { return(BadRequest(e)); } }