Add unclaim button

This commit is contained in:
2026-01-31 20:31:26 -07:00
parent 7753ce4667
commit 7af1a7c329

View File

@@ -171,49 +171,43 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
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(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(3).GetComponent<TMP_Text>().text = "Designer Name: " + entry.CreatorUsername;
var btnGrid = newIcon.transform.GetChild(4);
var buybtn = btnGrid.transform.GetChild(0).GetComponent<Button>();
var sellbtn = btnGrid.transform.GetChild(1).GetComponent<Button>();
var buyttnText = buybtn.transform.GetChild(0).GetComponent<TMP_Text>();
var BtnGrid = newIcon.transform.GetChild(4);
var buyBtn = BtnGrid.transform.GetChild(0).GetComponent<Button>();
var buyBtnText = buyBtn.transform.GetChild(0).GetComponent<TMP_Text>();
var sellBtn = BtnGrid.transform.GetChild(1).GetComponent<Button>();
var sellBtnText = sellBtn.transform.GetChild(0).GetComponent<TMP_Text>();
sellbtn.onClick.AddListener(() =>
sellBtn.onClick.AddListener(() =>
{
HandleSell(entry, buybtn, buyttnText, sellbtn, localUserID);
HandleSell(entry, buyBtn, buyBtnText, sellBtn, localUserID);
Tools.RefreshHierarchy(newIcon);
});
buybtn.onClick.AddListener(() =>
buyBtn.onClick.AddListener(() =>
{
HandlePurchase(entry, buybtn, sellbtn, localUserID);
HandlePurchase(entry, buyBtn, sellBtn, localUserID);
Tools.RefreshHierarchy(newIcon);
});
bool alreadyBought = BazookaManager.Instance.GetCustomBirdIconData().Purchased.Any(d => d == entry.ID);
if (alreadyBought)
{
buybtn.interactable = false;
buyBtn.interactable = false;
sellBtn.gameObject.SetActive(true);
if (localUserID != entry.CreatorUserID)
{
buyttnText.text = "Purchased";
sellbtn.gameObject.SetActive(true);
}
buyBtnText.text = "Purchased";
else
{
buyttnText.text = "Claimed";
buyBtnText.text = "Claimed";
sellBtnText.text = "Unclaim";
}
}
else
{
if (localUserID != entry.CreatorUserID)
{
buyttnText.text = "Purchase";
}
else
{
buyttnText.text = "Claim";
}
if (localUserID != entry.CreatorUserID) buyBtnText.text = "Purchase";
else buyBtnText.text = "Claim";
}
newIcon.SetActive(true);
@@ -241,20 +235,21 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
iconPurchaseSound.Play();
}
marketplaceIconStorage.Purchased.Add(data.ID);
sellButton.gameObject.SetActive(true);
if (localUserID != data.CreatorUserID)
{
button.transform.GetChild(0).GetComponent<TMP_Text>().text = "Purchased";
sellButton.gameObject.SetActive(true);
}
else
{
button.transform.GetChild(0).GetComponent<TMP_Text>().text = "Claimed";
sellButton.transform.GetChild(0).GetComponent<TMP_Text>().text = "Unclaim";
}
balanceText.text = Tools.FormatWithCommas(marketplaceIconStorage.Balance);
BazookaManager.Instance.SetCustomBirdIconData(marketplaceIconStorage);
}
void HandleSell(MarketplaceTempIcon data, Button buyBtn, TMP_Text buyttnText, Button sellButton, BigInteger? localUserID)
void HandleSell(MarketplaceTempIcon data, Button buyBtn, TMP_Text buyBtnText, Button sellButton, BigInteger? localUserID)
{
MarketplaceIconStorageType marketplaceIconStorage = BazookaManager.Instance.GetCustomBirdIconData();
var owned = marketplaceIconStorage.Purchased.Contains(data.ID);
@@ -267,8 +262,12 @@ public class IconMarketplaceDownloadIcon : MonoBehaviour
iconPurchaseSound.Play();
balanceText.text = Tools.FormatWithCommas(marketplaceIconStorage.Balance);
BazookaManager.Instance.SetCustomBirdIconData(marketplaceIconStorage);
if (localUserID != data.CreatorUserID) buyttnText.text = "Purchase";
else buyttnText.text = "Claim";
if (localUserID != data.CreatorUserID) buyBtnText.text = "Purchase";
else
{
buyBtnText.text = "Claim";
buyBtnText.text = "Claim";
}
buyBtn.interactable = true;
sellButton.gameObject.SetActive(false);
}