Make icon marketplace use cache
This commit is contained in:
@@ -29,7 +29,7 @@ public class CustomIconLoader : MonoBehaviour
|
|||||||
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
||||||
if ((bool)jsonResponse["success"])
|
if ((bool)jsonResponse["success"])
|
||||||
{
|
{
|
||||||
var icons = jsonResponse["data"].ToObject<MarketplaceTempIcon[]>();
|
var icons = jsonResponse["data"].ToObject<MarketplaceIconWithData[]>();
|
||||||
foreach (var icon in icons) BazookaManager.Instance.iconCache.Add(new MarketplaceIcon { ID = icon.ID, Data = icon.Data });
|
foreach (var icon in icons) BazookaManager.Instance.iconCache.Add(new MarketplaceIcon { ID = icon.ID, Data = icon.Data });
|
||||||
}
|
}
|
||||||
Debug.Log($"Downloaded {iconsToDownload.Count} custom icons");
|
Debug.Log($"Downloaded {iconsToDownload.Count} custom icons");
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
|
|||||||
{
|
{
|
||||||
GameObject newIcon = Instantiate(sample, content.transform);
|
GameObject newIcon = Instantiate(sample, content.transform);
|
||||||
newIcon.name = "IconEntry";
|
newIcon.name = "IconEntry";
|
||||||
Tools.RenderFromBase64(entry.Data, newIcon.transform.GetChild(0).GetChild(0).GetComponent<Image>());
|
newIcon.transform.GetChild(0).GetChild(0).gameObject.AddComponent<WaitingForCustomIcon>().ID = entry.ID;
|
||||||
newIcon.transform.GetChild(1).GetComponent<TMP_Text>().text = "Icon Name: " + entry.Name;
|
newIcon.transform.GetChild(1).GetComponent<TMP_Text>().text = "Icon Name: " + entry.Name;
|
||||||
newIcon.transform.GetChild(2).GetComponent<TMP_Text>().text = "Price " + Tools.FormatWithCommas(entry.Price) + " coins";
|
newIcon.transform.GetChild(2).GetComponent<TMP_Text>().text = "Price " + Tools.FormatWithCommas(entry.Price) + " coins";
|
||||||
newIcon.transform.GetChild(3).GetComponent<TMP_Text>().text = "Designer Name: " + entry.CreatorUsername;
|
newIcon.transform.GetChild(3).GetComponent<TMP_Text>().text = "Designer Name: " + entry.CreatorUsername;
|
||||||
@@ -213,6 +213,7 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
|
|||||||
newIcon.SetActive(true);
|
newIcon.SetActive(true);
|
||||||
Tools.RefreshHierarchy(newIcon);
|
Tools.RefreshHierarchy(newIcon);
|
||||||
}
|
}
|
||||||
|
CustomIconLoader.Init(FindObjectsByType<WaitingForCustomIcon>(FindObjectsSortMode.None));
|
||||||
refreshButton.interactable = true;
|
refreshButton.interactable = true;
|
||||||
optionsButton.interactable = true;
|
optionsButton.interactable = true;
|
||||||
backButton.interactable = true;
|
backButton.interactable = true;
|
||||||
|
|||||||
35
Assets/Scripts/Types/MarketplaceIconWithData.cs
Normal file
35
Assets/Scripts/Types/MarketplaceIconWithData.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Numerics;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using UnityEngine.Scripting;
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
public class MarketplaceIconWithData
|
||||||
|
{
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string CreatorUsername { get; set; }
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("userid")]
|
||||||
|
public BigInteger CreatorUserID { get; set; }
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("data")]
|
||||||
|
public string Data { get; set; }
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("hash")]
|
||||||
|
public string Hash { get; set; }
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public string ID { get; set; }
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("price")]
|
||||||
|
public BigInteger Price { get; set; }
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
2
Assets/Scripts/Types/MarketplaceIconWithData.cs.meta
Normal file
2
Assets/Scripts/Types/MarketplaceIconWithData.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1717a2bf1d6b2463faf2ef7fde6d3129
|
||||||
@@ -13,10 +13,6 @@ public class MarketplaceTempIcon
|
|||||||
[JsonProperty("userid")]
|
[JsonProperty("userid")]
|
||||||
public BigInteger CreatorUserID { get; set; }
|
public BigInteger CreatorUserID { get; set; }
|
||||||
|
|
||||||
[Preserve]
|
|
||||||
[JsonProperty("data")]
|
|
||||||
public string Data { get; set; }
|
|
||||||
|
|
||||||
[Preserve]
|
[Preserve]
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public string ID { get; set; }
|
public string ID { get; set; }
|
||||||
@@ -25,10 +21,6 @@ public class MarketplaceTempIcon
|
|||||||
[JsonProperty("price")]
|
[JsonProperty("price")]
|
||||||
public BigInteger Price { get; set; }
|
public BigInteger Price { get; set; }
|
||||||
|
|
||||||
[Preserve]
|
|
||||||
[JsonProperty("buyable")]
|
|
||||||
public bool Buyable { get; set; }
|
|
||||||
|
|
||||||
[Preserve]
|
[Preserve]
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user