Should be done with making the icons menu work with marketplace
This commit is contained in:
@@ -2512,7 +2512,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &346076456
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -6421,7 +6421,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &989561979
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -6717,29 +6717,31 @@ MonoBehaviour:
|
||||
selectionText: {fileID: 283532290}
|
||||
previewBird: {fileID: 485555076}
|
||||
previewOverlay: {fileID: 1953625730}
|
||||
icon1: {fileID: 1374823590}
|
||||
icon2: {fileID: 1587955963}
|
||||
icon3: {fileID: 2082761349}
|
||||
icon4: {fileID: 105058369}
|
||||
icon5: {fileID: 1275335465}
|
||||
icon6: {fileID: 1682251926}
|
||||
icon7: {fileID: 2044046146}
|
||||
icon8: {fileID: 1433968977}
|
||||
overlay0: {fileID: 437256206}
|
||||
overlay1: {fileID: 388694500}
|
||||
overlay2: {fileID: 606851916}
|
||||
overlay3: {fileID: 1721135576}
|
||||
overlay4: {fileID: 1786729680}
|
||||
overlay5: {fileID: 519880727}
|
||||
overlay6: {fileID: 2122644443}
|
||||
overlay7: {fileID: 490807504}
|
||||
overlay8: {fileID: 1197784014}
|
||||
overlay9: {fileID: 420083143}
|
||||
overlay10: {fileID: 367978220}
|
||||
overlay11: {fileID: 1860444778}
|
||||
overlay12: {fileID: 1513997428}
|
||||
overlay13: {fileID: 1736703}
|
||||
overlay14: {fileID: 1798643177}
|
||||
icons:
|
||||
- {fileID: 1374823590}
|
||||
- {fileID: 1587955963}
|
||||
- {fileID: 2082761349}
|
||||
- {fileID: 105058369}
|
||||
- {fileID: 1275335465}
|
||||
- {fileID: 1682251926}
|
||||
- {fileID: 2044046146}
|
||||
- {fileID: 1433968977}
|
||||
overlays:
|
||||
- {fileID: 437256206}
|
||||
- {fileID: 388694500}
|
||||
- {fileID: 606851916}
|
||||
- {fileID: 1721135576}
|
||||
- {fileID: 1786729680}
|
||||
- {fileID: 519880727}
|
||||
- {fileID: 2122644443}
|
||||
- {fileID: 490807504}
|
||||
- {fileID: 1197784014}
|
||||
- {fileID: 420083143}
|
||||
- {fileID: 367978220}
|
||||
- {fileID: 1860444778}
|
||||
- {fileID: 1513997428}
|
||||
- {fileID: 1736703}
|
||||
- {fileID: 1798643177}
|
||||
previewBirdObject: {fileID: 2072730781}
|
||||
iconColorPanel: {fileID: 346076460}
|
||||
overlayColorPanel: {fileID: 989561983}
|
||||
|
||||
@@ -78,4 +78,20 @@ public class ColorPanel : MonoBehaviour
|
||||
(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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -18,67 +18,59 @@ public class Iconsmenu : MonoBehaviour
|
||||
public TMP_Text selectionText;
|
||||
public Image previewBird;
|
||||
public Image previewOverlay;
|
||||
public Button icon1;
|
||||
public Button icon2;
|
||||
public Button icon3;
|
||||
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 Button[] icons;
|
||||
public Button[] overlays;
|
||||
private Dictionary<MarketplaceIconType, Button> customIcons = new();
|
||||
public GameObject previewBirdObject;
|
||||
public ColorPanel iconColorPanel;
|
||||
public ColorPanel overlayColorPanel;
|
||||
|
||||
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);
|
||||
iconEntry.name = "MarketplaceIcon";
|
||||
iconEntry.GetComponent<Button>().onClick.AddListener(() =>
|
||||
var button = iconEntry.GetComponent<Button>();
|
||||
customIcons[icon] = button;
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
SelectCustomIcon(icon);
|
||||
});
|
||||
Tools.RenderFromBase64(icon.Data, iconEntry.transform.GetChild(0).GetComponent<Image>());
|
||||
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 =>
|
||||
{
|
||||
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 =>
|
||||
{
|
||||
BazookaManager.Instance.SetColorSettingOverlay(color);
|
||||
};
|
||||
|
||||
if (customIconData.Selected == null)
|
||||
{
|
||||
defaultIcon = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
|
||||
icon1.transform.GetChild(0).GetComponent<Image>().sprite = defaultIcon;
|
||||
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);
|
||||
backButton.onClick.AddListener(async () =>
|
||||
{
|
||||
@@ -97,29 +89,16 @@ public class Iconsmenu : MonoBehaviour
|
||||
}
|
||||
previewBird.transform.localScale = scale;
|
||||
});
|
||||
icon1.onClick.AddListener(() => SelectIcon(1));
|
||||
icon2.onClick.AddListener(() => SelectIcon(2));
|
||||
icon3.onClick.AddListener(() => SelectIcon(3));
|
||||
icon4.onClick.AddListener(() => SelectIcon(4));
|
||||
icon5.onClick.AddListener(() => SelectIcon(5));
|
||||
icon6.onClick.AddListener(() => SelectIcon(6));
|
||||
icon7.onClick.AddListener(() => SelectIcon(7));
|
||||
icon8.onClick.AddListener(() => SelectIcon(8));
|
||||
overlay0.onClick.AddListener(() => SelectOverlay(0));
|
||||
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));
|
||||
for (int i = 0; i < icons.Length; i++)
|
||||
{
|
||||
int index = i;
|
||||
icons[i].onClick.AddListener(() => SelectIcon(index + 1));
|
||||
}
|
||||
for (int i = 0; i < overlays.Length; i++)
|
||||
{
|
||||
int index = i;
|
||||
overlays[i].onClick.AddListener(() => SelectOverlay(index));
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchToIcon()
|
||||
@@ -129,6 +108,8 @@ public class Iconsmenu : MonoBehaviour
|
||||
marketplaceIconsPanel.SetActive(false);
|
||||
selectionText.text = "Icon selection";
|
||||
placeholderButton.GetComponentInChildren<TMP_Text>().text = "Overlays";
|
||||
iconColorPanel.gameObject.SetActive(true);
|
||||
overlayColorPanel.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void SwitchToOverlay()
|
||||
@@ -147,6 +128,19 @@ public class Iconsmenu : MonoBehaviour
|
||||
marketplaceIconsPanel.SetActive(true);
|
||||
selectionText.text = "Marketplace Icons selection";
|
||||
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()
|
||||
@@ -161,7 +155,20 @@ public class Iconsmenu : MonoBehaviour
|
||||
}
|
||||
else if (GetCurrentKit() == 3)
|
||||
{
|
||||
defaultIcon = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
|
||||
icons[0].transform.GetChild(0).GetComponent<Image>().sprite = defaultIcon;
|
||||
|
||||
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)
|
||||
{
|
||||
var customData = BazookaManager.Instance.GetCustomBirdIconData();
|
||||
customData.Selected = null;
|
||||
BazookaManager.Instance.SetCustomBirdIconData(customData);
|
||||
BazookaManager.Instance.SetBirdIcon(iconID);
|
||||
icon1.interactable = iconID != 1;
|
||||
icon2.interactable = iconID != 2;
|
||||
icon3.interactable = iconID != 3;
|
||||
icon4.interactable = iconID != 4;
|
||||
icon5.interactable = iconID != 5;
|
||||
icon6.interactable = iconID != 6;
|
||||
icon7.interactable = iconID != 7;
|
||||
icon8.interactable = iconID != 8;
|
||||
for (int i = 0; i < icons.Length; i++)
|
||||
{
|
||||
icons[i].interactable = iconID != i + 1;
|
||||
}
|
||||
previewBird.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + iconID);
|
||||
if (iconID == 1)
|
||||
{
|
||||
@@ -211,22 +217,14 @@ public class Iconsmenu : MonoBehaviour
|
||||
|
||||
private void SelectOverlay(int overlayID)
|
||||
{
|
||||
var customData = BazookaManager.Instance.GetCustomBirdIconData();
|
||||
customData.Selected = null;
|
||||
BazookaManager.Instance.SetCustomBirdIconData(customData);
|
||||
BazookaManager.Instance.SetBirdOverlay(overlayID);
|
||||
overlay0.interactable = overlayID != 0;
|
||||
overlay1.interactable = overlayID != 1;
|
||||
overlay2.interactable = overlayID != 2;
|
||||
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;
|
||||
for (int i = 0; i < overlays.Length; i++)
|
||||
{
|
||||
overlays[i].interactable = overlayID != i;
|
||||
}
|
||||
previewOverlay.rectTransform.localPosition = new Vector3(-32f, 44.50001f, 0f);
|
||||
previewOverlay.gameObject.SetActive(true);
|
||||
if (overlayID == 8)
|
||||
@@ -255,6 +253,17 @@ public class Iconsmenu : MonoBehaviour
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user