Make icon marketplace icons show up in chatroom and leaderboards
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -44,6 +44,7 @@ public class ChatroomMenu : MonoBehaviour
|
||||
public Button reportMessagePanelExitButton;
|
||||
public Button reportMessagePanelSubmitButton;
|
||||
public TMP_InputField reportMessagePanelReportReason;
|
||||
public Dictionary<string, string> customIcons;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -105,6 +106,8 @@ public class ChatroomMenu : MonoBehaviour
|
||||
|
||||
usernameText.text = selectedMessageForOptions.Username;
|
||||
messageText.text = Encoding.UTF8.GetString(Convert.FromBase64String(selectedMessageForOptions.Content));
|
||||
if (selectedMessageForOptions.CustomIcon == null)
|
||||
{
|
||||
playerIcon.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + selectedMessageForOptions.Icon);
|
||||
if (selectedMessageForOptions.Icon == 1)
|
||||
{
|
||||
@@ -137,6 +140,12 @@ public class ChatroomMenu : MonoBehaviour
|
||||
playerIcon.color = Color.white;
|
||||
playerOverlayIcon.color = Color.white;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Tools.RenderFromBase64(customIcons[selectedMessageForOptions.CustomIcon], playerIcon);
|
||||
playerOverlayIcon.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
rowInfo = editMessageChild.GetChild(3);
|
||||
usernameText = rowInfo.transform.GetChild(2).GetComponent<TMP_Text>();
|
||||
@@ -148,6 +157,8 @@ public class ChatroomMenu : MonoBehaviour
|
||||
usernameText.text = selectedMessageForOptions.Username;
|
||||
messageText.text = Encoding.UTF8.GetString(Convert.FromBase64String(selectedMessageForOptions.Content));
|
||||
editMessageChildNewContentInputBox.onValueChanged.AddListener((value) => messageText.text = value);
|
||||
if (selectedMessageForOptions.CustomIcon == null)
|
||||
{
|
||||
playerIcon.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + selectedMessageForOptions.Icon);
|
||||
if (selectedMessageForOptions.Icon == 1)
|
||||
{
|
||||
@@ -180,6 +191,12 @@ public class ChatroomMenu : MonoBehaviour
|
||||
playerIcon.color = Color.white;
|
||||
playerOverlayIcon.color = Color.white;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Tools.RenderFromBase64(customIcons[selectedMessageForOptions.CustomIcon], playerIcon);
|
||||
playerOverlayIcon.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
optionsPanel.SetActive(false);
|
||||
editMessage.SetActive(true);
|
||||
@@ -361,7 +378,9 @@ public class ChatroomMenu : MonoBehaviour
|
||||
break;
|
||||
default:
|
||||
shouldClear = false;
|
||||
var messages = JsonConvert.DeserializeObject<ChatroomMessage[]>(response);
|
||||
var jsonResponse = JObject.Parse(response);
|
||||
var messages = jsonResponse["messages"].ToObject<ChatroomMessage[]>();
|
||||
customIcons = jsonResponse["customIcons"].ToObject<Dictionary<string, string>>();
|
||||
var localUserId = BazookaManager.Instance.GetAccountID();
|
||||
var sortedMessages = messages.OrderBy(m => m.ID).ToArray();
|
||||
for (int i = 0; i < sortedMessages.Length; i++)
|
||||
@@ -406,6 +425,8 @@ public class ChatroomMenu : MonoBehaviour
|
||||
|
||||
usernameText.text = message.Username;
|
||||
messageText.text = Encoding.UTF8.GetString(Convert.FromBase64String(message.Content));
|
||||
if (message.CustomIcon == null)
|
||||
{
|
||||
playerIcon.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + message.Icon);
|
||||
if (message.Icon == 1)
|
||||
{
|
||||
@@ -438,6 +459,12 @@ public class ChatroomMenu : MonoBehaviour
|
||||
playerIcon.color = Color.white;
|
||||
playerOverlayIcon.color = Color.white;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Tools.RenderFromBase64(customIcons[message.CustomIcon], playerIcon);
|
||||
playerOverlayIcon.gameObject.SetActive(false);
|
||||
}
|
||||
optionsButton.onClick.AddListener(() => OptionsButtonClick(message, localUserId ?? 0));
|
||||
rowInfo.name = "ChatroomRow_" + message.ID;
|
||||
var entryComponet = rowInfo.AddComponent<ChatroomMenuEntry>();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -26,6 +26,7 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
public GameObject berryContent;
|
||||
public TMP_Dropdown berryShowTypeDropdown;
|
||||
public GameObject berrySampleObject;
|
||||
public Dictionary<string, string> customIcons;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -144,10 +145,12 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
var jsonResponse = JArray.Parse(response);
|
||||
for (int i = 0; i < jsonResponse.Count; i++)
|
||||
var jsonResponse = JObject.Parse(response);
|
||||
var entries = (JArray)jsonResponse["entries"];
|
||||
customIcons = jsonResponse["customIcons"].ToObject<Dictionary<string, string>>();
|
||||
for (int i = 0; i < entries.Count; i++)
|
||||
{
|
||||
var entry = JObject.Parse(jsonResponse[i].ToString());
|
||||
var entry = JObject.Parse(entries[i].ToString());
|
||||
var username = (string)entry["username"];
|
||||
var highScore = BigInteger.Parse((string)entry["value"]);
|
||||
var icon = (int)entry["icon"];
|
||||
@@ -155,6 +158,7 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
var uid = BigInteger.Parse((string)entry["userid"]);
|
||||
var birdColor = (JArray)entry["birdColor"];
|
||||
var overlayColor = (JArray)entry["overlayColor"];
|
||||
var customIcon = (string)entry["customIcon"];
|
||||
|
||||
var entryInfo = Instantiate(scoreSampleObject, scoreContent.transform);
|
||||
var usernameText = entryInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||
@@ -170,6 +174,8 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
|
||||
usernameText.text = $"{username} (#{i + 1})";
|
||||
highScoreText.text += Tools.FormatWithCommas(highScore);
|
||||
if (customIcon == null)
|
||||
{
|
||||
playerIcon.sprite = Resources.Load<Sprite>("Icons/Icons/bird_" + icon);
|
||||
if (icon == 1)
|
||||
{
|
||||
@@ -202,6 +208,12 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
playerIcon.color = Color.white;
|
||||
playerOverlayIcon.color = Color.white;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Tools.RenderFromBase64(customIcons[customIcon], playerIcon);
|
||||
playerOverlayIcon.gameObject.SetActive(false);
|
||||
}
|
||||
entryInfo.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,8 @@ public class ChatroomMessage {
|
||||
[Preserve]
|
||||
[JsonProperty("deleted")]
|
||||
public bool Deleted { get; set; }
|
||||
|
||||
[Preserve]
|
||||
[JsonProperty("customIcon")]
|
||||
public string CustomIcon { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user