Add timestamp & edited to chatroom and also do the same stuff from 2nd last commit in here in edit popup
This commit is contained in:
@@ -356,9 +356,9 @@ Material:
|
|||||||
- _OutlineWidth: 0
|
- _OutlineWidth: 0
|
||||||
- _PerspectiveFilter: 0.875
|
- _PerspectiveFilter: 0.875
|
||||||
- _Reflectivity: 10
|
- _Reflectivity: 10
|
||||||
- _ScaleRatioA: 0.8
|
- _ScaleRatioA: 0.9767442
|
||||||
- _ScaleRatioB: 0.65
|
- _ScaleRatioB: 0.7936047
|
||||||
- _ScaleRatioC: 0.65
|
- _ScaleRatioC: 0.7936047
|
||||||
- _ScaleX: 1
|
- _ScaleX: 1
|
||||||
- _ScaleY: 1
|
- _ScaleY: 1
|
||||||
- _ShaderFlags: 0
|
- _ShaderFlags: 0
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ using MikeSchweitzer.WebSocket;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
@@ -117,7 +118,15 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (data["data"]["newContent"].ToString() != null)
|
if (data["data"]["newContent"].ToString() != null)
|
||||||
{
|
{
|
||||||
content.transform.Find("ChatroomRow_" + data["data"]["id"].ToString()).transform.GetChild(3).GetComponent<TMP_Text>().text = data["data"]["newContent"].ToString();
|
var rowInfo = content.transform.Find("ChatroomRow_" + data["data"]["id"].ToString());
|
||||||
|
var usernameText = rowInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||||
|
if (!usernameText.text.EndsWith(">(edited)</color>"))
|
||||||
|
{
|
||||||
|
var color = BazookaManager.Instance.GetColorSettingText();
|
||||||
|
string hex = new Color((((float)color[0]) - 100f) / 255f, (((float)color[1]) - 100f) / 255f, (((float)color[2]) - 100f) / 255f).ToHexString();
|
||||||
|
rowInfo.transform.GetChild(0).GetComponent<TMP_Text>().text += $" <color=#{hex}>(edited)</color>";
|
||||||
|
}
|
||||||
|
rowInfo.transform.GetChild(2).GetComponent<TMP_Text>().text = data["data"]["newContent"].ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +146,11 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
var messageText = rowInfo.transform.GetChild(2).GetComponent<TMP_Text>();
|
var messageText = rowInfo.transform.GetChild(2).GetComponent<TMP_Text>();
|
||||||
var optionsButton = rowInfo.transform.GetChild(3).GetComponent<Button>();
|
var optionsButton = rowInfo.transform.GetChild(3).GetComponent<Button>();
|
||||||
|
|
||||||
usernameText.text = message.Username;
|
var color = BazookaManager.Instance.GetColorSettingText();
|
||||||
|
string hex1 = new Color((((float)color[0]) - 50f) / 255f, (((float)color[1]) - 50f) / 255f, (((float)color[2]) - 50f) / 255f).ToHexString();
|
||||||
|
string hex2 = new Color((((float)color[0]) - 100f) / 255f, (((float)color[1]) - 100f) / 255f, (((float)color[2]) - 100f) / 255f).ToHexString();
|
||||||
|
|
||||||
|
usernameText.text = $"{message.Username} <color=#{hex1}>{Tools.FormatHumanTime(message.Timestamp)}</color>" + (message.EditedAt != 0 ? $" <color=#{hex2}>(edited)</color>" : null);
|
||||||
messageText.text = message.Content;
|
messageText.text = message.Content;
|
||||||
if (message.CustomIcon == null)
|
if (message.CustomIcon == null)
|
||||||
{
|
{
|
||||||
@@ -227,11 +240,10 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
});
|
});
|
||||||
|
|
||||||
var rowInfo = editMessageChild.GetChild(2);
|
var rowInfo = editMessageChild.GetChild(2);
|
||||||
var usernameText = rowInfo.transform.GetChild(2).GetComponent<TMP_Text>();
|
var usernameText = rowInfo.transform.GetChild(1).GetComponent<TMP_Text>();
|
||||||
var playerIcon = rowInfo.transform.GetChild(3).GetComponent<Image>();
|
var playerIcon = rowInfo.transform.GetChild(2).GetComponent<Image>();
|
||||||
var playerOverlayIcon = playerIcon.transform.GetChild(0).GetComponent<Image>();
|
var playerOverlayIcon = playerIcon.transform.GetChild(0).GetComponent<Image>();
|
||||||
var messageText = rowInfo.transform.GetChild(4).GetComponent<TMP_Text>();
|
var messageText = rowInfo.transform.GetChild(3).GetComponent<TMP_Text>();
|
||||||
var optionsButton = rowInfo.transform.GetChild(5).GetComponent<Button>();
|
|
||||||
|
|
||||||
usernameText.text = selectedMessageForOptions.Username;
|
usernameText.text = selectedMessageForOptions.Username;
|
||||||
messageText.text = selectedMessageForOptions.Content;
|
messageText.text = selectedMessageForOptions.Content;
|
||||||
@@ -258,11 +270,10 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
else playerIcon.gameObject.AddComponent<WaitingForCustomIcon>().ID = selectedMessageForOptions.CustomIcon;
|
else playerIcon.gameObject.AddComponent<WaitingForCustomIcon>().ID = selectedMessageForOptions.CustomIcon;
|
||||||
|
|
||||||
rowInfo = editMessageChild.GetChild(3);
|
rowInfo = editMessageChild.GetChild(3);
|
||||||
usernameText = rowInfo.transform.GetChild(2).GetComponent<TMP_Text>();
|
usernameText = rowInfo.transform.GetChild(1).GetComponent<TMP_Text>();
|
||||||
playerIcon = rowInfo.transform.GetChild(3).GetComponent<Image>();
|
playerIcon = rowInfo.transform.GetChild(2).GetComponent<Image>();
|
||||||
playerOverlayIcon = playerIcon.transform.GetChild(0).GetComponent<Image>();
|
playerOverlayIcon = playerIcon.transform.GetChild(0).GetComponent<Image>();
|
||||||
messageText = rowInfo.transform.GetChild(4).GetComponent<TMP_Text>();
|
messageText = rowInfo.transform.GetChild(3).GetComponent<TMP_Text>();
|
||||||
optionsButton = rowInfo.transform.GetChild(5).GetComponent<Button>();
|
|
||||||
|
|
||||||
usernameText.text = selectedMessageForOptions.Username;
|
usernameText.text = selectedMessageForOptions.Username;
|
||||||
messageText.text = selectedMessageForOptions.Content;
|
messageText.text = selectedMessageForOptions.Content;
|
||||||
|
|||||||
@@ -107,4 +107,22 @@ public static class Tools
|
|||||||
|
|
||||||
return (totalXp, flooredLevel, currentXpInLevel, totalXpForLevel, percentDone);
|
return (totalXp, flooredLevel, currentXpInLevel, totalXpForLevel, percentDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string FormatHumanTime(long unixTimestamp)
|
||||||
|
{
|
||||||
|
DateTime date = DateTimeOffset.FromUnixTimeSeconds(unixTimestamp).LocalDateTime;
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
|
||||||
|
bool isToday = date.Year == now.Year && date.Month == now.Month && date.Day == now.Day;
|
||||||
|
DateTime yesterday = now.AddDays(-1);
|
||||||
|
bool isYesterday = date.Year == yesterday.Year && date.Month == yesterday.Month && date.Day == yesterday.Day;
|
||||||
|
|
||||||
|
string timeStr = date.ToString("t");
|
||||||
|
|
||||||
|
if (isToday) return timeStr;
|
||||||
|
if (isYesterday) return $"Yesterday at {timeStr}";
|
||||||
|
|
||||||
|
string dateStr = date.ToShortDateString();
|
||||||
|
return $"{dateStr}, {timeStr}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,4 +40,12 @@ public class ChatroomMessage
|
|||||||
[Preserve]
|
[Preserve]
|
||||||
[JsonProperty("customIcon")]
|
[JsonProperty("customIcon")]
|
||||||
public string CustomIcon { get; set; }
|
public string CustomIcon { get; set; }
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("timestamp")]
|
||||||
|
public long Timestamp { get; set; }
|
||||||
|
|
||||||
|
[Preserve]
|
||||||
|
[JsonProperty("editedAt")]
|
||||||
|
public long EditedAt { get; set; }
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user