Add more types, should be done for those I think
This commit is contained in:
@@ -2,6 +2,7 @@ using System.IO;
|
||||
using System.Numerics;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class BazookaManager : MonoBehaviour
|
||||
@@ -138,10 +139,10 @@ public class BazookaManager : MonoBehaviour
|
||||
return int.Parse(saveFile["bird"]["pastOverlay"].ToString());
|
||||
}
|
||||
|
||||
public void SetCustomBirdIconData(JObject value)
|
||||
public void SetCustomBirdIconData(MarketplaceIconStorageType value)
|
||||
{
|
||||
if (saveFile["bird"] == null) saveFile["bird"] = new JObject();
|
||||
saveFile["bird"]["customIcon"] = value;
|
||||
saveFile["bird"]["customIcon"] = value.ConvertTo<JObject>();
|
||||
}
|
||||
|
||||
public void UnsetCustomBirdIconData()
|
||||
@@ -151,11 +152,11 @@ public class BazookaManager : MonoBehaviour
|
||||
(saveFile["bird"] as JObject)?.Remove("customIcon");
|
||||
}
|
||||
|
||||
public JObject GetCustomBirdIconData()
|
||||
public MarketplaceIconStorageType GetCustomBirdIconData()
|
||||
{
|
||||
if (saveFile["bird"] == null) return new();
|
||||
if (saveFile["bird"]["customIcon"] == null) return new();
|
||||
return saveFile["bird"]["customIcon"] as JObject;
|
||||
return saveFile["bird"]["customIcon"].ToObject<MarketplaceIconStorageType>();
|
||||
}
|
||||
|
||||
//Settings stuff
|
||||
|
||||
@@ -70,14 +70,14 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
|
||||
var jsonResponse = JArray.Parse(response);
|
||||
foreach (var item in jsonResponse)
|
||||
{
|
||||
DownloadIconType entry = ((JObject)item).ToObject<DownloadIconType>();
|
||||
MarketplaceIconType entry = ((JObject)item).ToObject<MarketplaceIconType>();
|
||||
GameObject newIcon = Instantiate(sample, content.transform);
|
||||
newIcon.name = "IconEntry";
|
||||
|
||||
Tools.RenderFromBase64(entry.Data, newIcon.transform.GetChild(0).GetChild(0).GetComponent<Image>());
|
||||
newIcon.transform.GetChild(1).GetComponent<TMP_Text>().text = "Bird Name: " + entry.Name;
|
||||
newIcon.transform.GetChild(2).GetComponent<TMP_Text>().text = "Price " + entry.Price + " coin";
|
||||
newIcon.transform.GetChild(3).GetComponent<TMP_Text>().text = "Designer Name: " + entry.Username;
|
||||
newIcon.transform.GetChild(3).GetComponent<TMP_Text>().text = "Designer Name: " + entry.CreatorUsername;
|
||||
newIcon.transform.GetChild(4).GetChild(0).GetComponent<TMP_Text>().text = "Purchase";
|
||||
newIcon.transform.GetChild(4).GetComponent<Button>().onClick.AddListener(() => HandlePurchase(entry));
|
||||
|
||||
@@ -86,7 +86,7 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void HandlePurchase(DownloadIconType data)
|
||||
void HandlePurchase(MarketplaceIconType data)
|
||||
{
|
||||
//will work on this
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ public class IconMarketplaceManager : MonoBehaviour
|
||||
switch (panelIndex)
|
||||
{
|
||||
case 0:
|
||||
coinText.text = "You have " + Tools.FormatWithCommas((BazookaManager.Instance.GetCustomBirdIconData()["totalCoins"] ?? "0").ToString()) + " coins";
|
||||
coinText.text = "You have " + Tools.FormatWithCommas(BazookaManager.Instance.GetCustomBirdIconData().Balance) + " coins";
|
||||
normalPanel.SetActive(true);
|
||||
downloadPanel.SetActive(false);
|
||||
uploadPanel.SetActive(false);
|
||||
break;
|
||||
case 1:
|
||||
downloadPanelScript.Load();
|
||||
downloadPanelScript.balanceText.text = "You have " + Tools.FormatWithCommas((BazookaManager.Instance.GetCustomBirdIconData()["totalCoins"] ?? "0").ToString()) + " coins to spend";
|
||||
downloadPanelScript.balanceText.text = "You have " + Tools.FormatWithCommas(BazookaManager.Instance.GetCustomBirdIconData().Balance) + " coins to spend";
|
||||
normalPanel.SetActive(false);
|
||||
downloadPanel.SetActive(true);
|
||||
uploadPanel.SetActive(false);
|
||||
|
||||
12
Assets/Scripts/Types/MarketplaceIconStorageType.cs
Normal file
12
Assets/Scripts/Types/MarketplaceIconStorageType.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class MarketplaceIconStorageType {
|
||||
[JsonProperty("selected")]
|
||||
public string Selected { get; set; } = null;
|
||||
[JsonProperty("balance")]
|
||||
public BigInteger Balance { get; set; } = 0;
|
||||
[JsonProperty("data")]
|
||||
public MarketplaceIconType[] Data { get; set; } = Array.Empty<MarketplaceIconType>();
|
||||
}
|
||||
2
Assets/Scripts/Types/MarketplaceIconStorageType.cs.meta
Normal file
2
Assets/Scripts/Types/MarketplaceIconStorageType.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8760344b405294a99c83390f622524d
|
||||
@@ -1,10 +1,10 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class DownloadIconType {
|
||||
public class MarketplaceIconType {
|
||||
[JsonProperty("username")]
|
||||
public string Username { get; set; }
|
||||
public string CreatorUsername { get; set; }
|
||||
[JsonProperty("userid")]
|
||||
public string UserID { get; set; }
|
||||
public string CreatorUserID { get; set; }
|
||||
[JsonProperty("data")]
|
||||
public string Data { get; set; }
|
||||
[JsonProperty("uuid")]
|
||||
Reference in New Issue
Block a user