Should be done with making the icons menu work with marketplace

This commit is contained in:
2025-08-19 22:23:24 -07:00
parent 274a0ee972
commit 583ac47e04
3 changed files with 135 additions and 108 deletions

View File

@@ -2512,7 +2512,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &346076456 --- !u!224 &346076456
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -6421,7 +6421,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &989561979 --- !u!224 &989561979
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -6717,29 +6717,31 @@ MonoBehaviour:
selectionText: {fileID: 283532290} selectionText: {fileID: 283532290}
previewBird: {fileID: 485555076} previewBird: {fileID: 485555076}
previewOverlay: {fileID: 1953625730} previewOverlay: {fileID: 1953625730}
icon1: {fileID: 1374823590} icons:
icon2: {fileID: 1587955963} - {fileID: 1374823590}
icon3: {fileID: 2082761349} - {fileID: 1587955963}
icon4: {fileID: 105058369} - {fileID: 2082761349}
icon5: {fileID: 1275335465} - {fileID: 105058369}
icon6: {fileID: 1682251926} - {fileID: 1275335465}
icon7: {fileID: 2044046146} - {fileID: 1682251926}
icon8: {fileID: 1433968977} - {fileID: 2044046146}
overlay0: {fileID: 437256206} - {fileID: 1433968977}
overlay1: {fileID: 388694500} overlays:
overlay2: {fileID: 606851916} - {fileID: 437256206}
overlay3: {fileID: 1721135576} - {fileID: 388694500}
overlay4: {fileID: 1786729680} - {fileID: 606851916}
overlay5: {fileID: 519880727} - {fileID: 1721135576}
overlay6: {fileID: 2122644443} - {fileID: 1786729680}
overlay7: {fileID: 490807504} - {fileID: 519880727}
overlay8: {fileID: 1197784014} - {fileID: 2122644443}
overlay9: {fileID: 420083143} - {fileID: 490807504}
overlay10: {fileID: 367978220} - {fileID: 1197784014}
overlay11: {fileID: 1860444778} - {fileID: 420083143}
overlay12: {fileID: 1513997428} - {fileID: 367978220}
overlay13: {fileID: 1736703} - {fileID: 1860444778}
overlay14: {fileID: 1798643177} - {fileID: 1513997428}
- {fileID: 1736703}
- {fileID: 1798643177}
previewBirdObject: {fileID: 2072730781} previewBirdObject: {fileID: 2072730781}
iconColorPanel: {fileID: 346076460} iconColorPanel: {fileID: 346076460}
overlayColorPanel: {fileID: 989561983} overlayColorPanel: {fileID: 989561983}

View File

@@ -78,4 +78,20 @@ public class ColorPanel : MonoBehaviour
(int)bSlider.value (int)bSlider.value
)); ));
} }
public void SetColor(Color col)
{
rSlider.SetValueWithoutNotify(col.r * 255f);
gSlider.SetValueWithoutNotify(col.g * 255f);
bSlider.SetValueWithoutNotify(col.b * 255f);
SyncAll();
}
public void SetColor(JArray color)
{
rSlider.SetValueWithoutNotify((int)color[0]);
gSlider.SetValueWithoutNotify((int)color[1]);
bSlider.SetValueWithoutNotify((int)color[2]);
SyncAll();
}
} }

View File

@@ -1,4 +1,4 @@
using Newtonsoft.Json; using System.Collections.Generic;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
@@ -18,66 +18,58 @@ public class Iconsmenu : MonoBehaviour
public TMP_Text selectionText; public TMP_Text selectionText;
public Image previewBird; public Image previewBird;
public Image previewOverlay; public Image previewOverlay;
public Button icon1; public Button[] icons;
public Button icon2; public Button[] overlays;
public Button icon3; private Dictionary<MarketplaceIconType, Button> customIcons = new();
public Button icon4;
public Button icon5;
public Button icon6;
public Button icon7;
public Button icon8;
public Button overlay0;
public Button overlay1;
public Button overlay2;
public Button overlay3;
public Button overlay4;
public Button overlay5;
public Button overlay6;
public Button overlay7;
public Button overlay8;
public Button overlay9;
public Button overlay10;
public Button overlay11;
public Button overlay12;
public Button overlay13;
public Button overlay14;
public GameObject previewBirdObject; public GameObject previewBirdObject;
public ColorPanel iconColorPanel; public ColorPanel iconColorPanel;
public ColorPanel overlayColorPanel; public ColorPanel overlayColorPanel;
private void Start() private void Start()
{ {
foreach (var icon in BazookaManager.Instance.GetCustomBirdIconData().Data) var customIconData = BazookaManager.Instance.GetCustomBirdIconData();
foreach (var icon in customIconData.Data)
{ {
var iconEntry = Instantiate(marketplaceIconsSample, marketplaceIconsContent.transform); var iconEntry = Instantiate(marketplaceIconsSample, marketplaceIconsContent.transform);
iconEntry.name = "MarketplaceIcon"; iconEntry.name = "MarketplaceIcon";
iconEntry.GetComponent<Button>().onClick.AddListener(() => var button = iconEntry.GetComponent<Button>();
customIcons[icon] = button;
button.onClick.AddListener(() =>
{ {
SelectCustomIcon(icon); SelectCustomIcon(icon);
}); });
Tools.RenderFromBase64(icon.Data, iconEntry.transform.GetChild(0).GetComponent<Image>()); Tools.RenderFromBase64(icon.Data, iconEntry.transform.GetChild(0).GetComponent<Image>());
iconEntry.SetActive(true); iconEntry.SetActive(true);
} }
iconColorPanel.Init(BazookaManager.Instance.GetColorSettingIcon(), Color.white); iconColorPanel.Init(customIconData.Selected == null ? BazookaManager.Instance.GetColorSettingIcon() : JArray.Parse("[255,255,255]"), Color.white);
iconColorPanel.OnColorChanged += color => iconColorPanel.OnColorChanged += color =>
{ {
BazookaManager.Instance.SetColorSettingIcon(color); BazookaManager.Instance.SetColorSettingIcon(color);
}; };
overlayColorPanel.Init(BazookaManager.Instance.GetColorSettingOverlay(), Color.white); overlayColorPanel.Init(customIconData.Selected == null ? BazookaManager.Instance.GetColorSettingOverlay() : JArray.Parse("[255,255,255]"), Color.white);
overlayColorPanel.OnColorChanged += color => overlayColorPanel.OnColorChanged += color =>
{ {
BazookaManager.Instance.SetColorSettingOverlay(color); BazookaManager.Instance.SetColorSettingOverlay(color);
}; };
defaultIcon = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0); if (customIconData.Selected == null)
icon1.transform.GetChild(0).GetComponent<Image>().sprite = defaultIcon;
SwitchToIcon();
SelectOverlay(BazookaManager.Instance.GetBirdOverlay());
SelectIcon(BazookaManager.Instance.GetBirdIcon());
if (BazookaManager.Instance.GetBirdIcon() == 7)
{ {
SelectOverlay(0); defaultIcon = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
placeholderButton.interactable = false; icons[0].transform.GetChild(0).GetComponent<Image>().sprite = defaultIcon;
SwitchToIcon();
SelectOverlay(BazookaManager.Instance.GetBirdOverlay());
SelectIcon(BazookaManager.Instance.GetBirdIcon());
if (BazookaManager.Instance.GetBirdIcon() == 7)
{
SelectOverlay(0);
placeholderButton.interactable = false;
}
}
else
{
SwitchToMarketplaceIcons();
} }
placeholderButton.onClick.AddListener(ToggleKit); placeholderButton.onClick.AddListener(ToggleKit);
backButton.onClick.AddListener(async () => backButton.onClick.AddListener(async () =>
@@ -97,29 +89,16 @@ public class Iconsmenu : MonoBehaviour
} }
previewBird.transform.localScale = scale; previewBird.transform.localScale = scale;
}); });
icon1.onClick.AddListener(() => SelectIcon(1)); for (int i = 0; i < icons.Length; i++)
icon2.onClick.AddListener(() => SelectIcon(2)); {
icon3.onClick.AddListener(() => SelectIcon(3)); int index = i;
icon4.onClick.AddListener(() => SelectIcon(4)); icons[i].onClick.AddListener(() => SelectIcon(index + 1));
icon5.onClick.AddListener(() => SelectIcon(5)); }
icon6.onClick.AddListener(() => SelectIcon(6)); for (int i = 0; i < overlays.Length; i++)
icon7.onClick.AddListener(() => SelectIcon(7)); {
icon8.onClick.AddListener(() => SelectIcon(8)); int index = i;
overlay0.onClick.AddListener(() => SelectOverlay(0)); overlays[i].onClick.AddListener(() => SelectOverlay(index));
overlay1.onClick.AddListener(() => SelectOverlay(1)); }
overlay2.onClick.AddListener(() => SelectOverlay(2));
overlay3.onClick.AddListener(() => SelectOverlay(3));
overlay4.onClick.AddListener(() => SelectOverlay(4));
overlay5.onClick.AddListener(() => SelectOverlay(5));
overlay6.onClick.AddListener(() => SelectOverlay(6));
overlay7.onClick.AddListener(() => SelectOverlay(7));
overlay8.onClick.AddListener(() => SelectOverlay(8));
overlay9.onClick.AddListener(() => SelectOverlay(9));
overlay10.onClick.AddListener(() => SelectOverlay(10));
overlay11.onClick.AddListener(() => SelectOverlay(11));
overlay12.onClick.AddListener(() => SelectOverlay(12));
overlay13.onClick.AddListener(() => SelectOverlay(13));
overlay14.onClick.AddListener(() => SelectOverlay(14));
} }
private void SwitchToIcon() private void SwitchToIcon()
@@ -129,6 +108,8 @@ public class Iconsmenu : MonoBehaviour
marketplaceIconsPanel.SetActive(false); marketplaceIconsPanel.SetActive(false);
selectionText.text = "Icon selection"; selectionText.text = "Icon selection";
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Overlays"; placeholderButton.GetComponentInChildren<TMP_Text>().text = "Overlays";
iconColorPanel.gameObject.SetActive(true);
overlayColorPanel.gameObject.SetActive(true);
} }
private void SwitchToOverlay() private void SwitchToOverlay()
@@ -147,6 +128,19 @@ public class Iconsmenu : MonoBehaviour
marketplaceIconsPanel.SetActive(true); marketplaceIconsPanel.SetActive(true);
selectionText.text = "Marketplace Icons selection"; selectionText.text = "Marketplace Icons selection";
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Icons"; placeholderButton.GetComponentInChildren<TMP_Text>().text = "Icons";
iconColorPanel.gameObject.SetActive(false);
overlayColorPanel.gameObject.SetActive(false);
var customIconData = BazookaManager.Instance.GetCustomBirdIconData();
if (customIconData.Selected != null)
{
foreach (var icon in customIconData.Data)
{
if (icon.UUID == customIconData.Selected)
{
SelectCustomIcon(icon);
}
}
}
} }
private void ToggleKit() private void ToggleKit()
@@ -161,7 +155,20 @@ public class Iconsmenu : MonoBehaviour
} }
else if (GetCurrentKit() == 3) else if (GetCurrentKit() == 3)
{ {
defaultIcon = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
icons[0].transform.GetChild(0).GetComponent<Image>().sprite = defaultIcon;
SwitchToIcon(); SwitchToIcon();
SelectOverlay(BazookaManager.Instance.GetBirdOverlay());
SelectIcon(BazookaManager.Instance.GetBirdIcon());
iconColorPanel.SetColor(BazookaManager.Instance.GetColorSettingIcon());
overlayColorPanel.SetColor(BazookaManager.Instance.GetColorSettingOverlay());
if (BazookaManager.Instance.GetBirdIcon() == 7)
{
SelectOverlay(0);
placeholderButton.interactable = false;
}
} }
} }
@@ -184,15 +191,14 @@ public class Iconsmenu : MonoBehaviour
private void SelectIcon(int iconID) private void SelectIcon(int iconID)
{ {
var customData = BazookaManager.Instance.GetCustomBirdIconData();
customData.Selected = null;
BazookaManager.Instance.SetCustomBirdIconData(customData);
BazookaManager.Instance.SetBirdIcon(iconID); BazookaManager.Instance.SetBirdIcon(iconID);
icon1.interactable = iconID != 1; for (int i = 0; i < icons.Length; i++)
icon2.interactable = iconID != 2; {
icon3.interactable = iconID != 3; icons[i].interactable = iconID != i + 1;
icon4.interactable = iconID != 4; }
icon5.interactable = iconID != 5;
icon6.interactable = iconID != 6;
icon7.interactable = iconID != 7;
icon8.interactable = iconID != 8;
previewBird.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + iconID); previewBird.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + iconID);
if (iconID == 1) if (iconID == 1)
{ {
@@ -211,22 +217,14 @@ public class Iconsmenu : MonoBehaviour
private void SelectOverlay(int overlayID) private void SelectOverlay(int overlayID)
{ {
var customData = BazookaManager.Instance.GetCustomBirdIconData();
customData.Selected = null;
BazookaManager.Instance.SetCustomBirdIconData(customData);
BazookaManager.Instance.SetBirdOverlay(overlayID); BazookaManager.Instance.SetBirdOverlay(overlayID);
overlay0.interactable = overlayID != 0; for (int i = 0; i < overlays.Length; i++)
overlay1.interactable = overlayID != 1; {
overlay2.interactable = overlayID != 2; overlays[i].interactable = overlayID != i;
overlay3.interactable = overlayID != 3; }
overlay4.interactable = overlayID != 4;
overlay5.interactable = overlayID != 5;
overlay6.interactable = overlayID != 6;
overlay7.interactable = overlayID != 7;
overlay8.interactable = !(BazookaManager.Instance.GetAccountID() == 1 && BazookaManager.Instance.GetBirdIcon() == 1) && overlayID != 8;
overlay9.interactable = overlayID != 9;
overlay10.interactable = overlayID != 10;
overlay11.interactable = overlayID != 11;
overlay12.interactable = overlayID != 12;
overlay13.interactable = overlayID != 13;
overlay14.interactable = overlayID != 14;
previewOverlay.rectTransform.localPosition = new Vector3(-32f, 44.50001f, 0f); previewOverlay.rectTransform.localPosition = new Vector3(-32f, 44.50001f, 0f);
previewOverlay.gameObject.SetActive(true); previewOverlay.gameObject.SetActive(true);
if (overlayID == 8) if (overlayID == 8)
@@ -255,6 +253,17 @@ public class Iconsmenu : MonoBehaviour
void SelectCustomIcon(MarketplaceIconType icon) void SelectCustomIcon(MarketplaceIconType icon)
{ {
Debug.Log(JObject.FromObject(icon)); var customData = BazookaManager.Instance.GetCustomBirdIconData();
customData.Selected = icon.UUID;
BazookaManager.Instance.SetCustomBirdIconData(customData);
Tools.RenderFromBase64(icon.Data, previewBird);
previewBird.color = Color.white;
previewOverlay.gameObject.SetActive(false);
previewOverlay.sprite = null;
previewOverlay.color = Color.white;
foreach (var loopIcon in customData.Data)
{
customIcons[loopIcon].interactable = loopIcon.UUID == icon.UUID;
}
} }
} }