using System; using System.Collections.Generic; using CSNetwork.GPDataType; using UnityEngine; namespace BrewMonster.Scripts.ChatUI { [Serializable] public struct ChannelIconMapping { public ChatChannel channel; public string iconName; public Sprite icon; public string prefix; } [CreateAssetMenu(fileName = "ChatSystemSO", menuName = "Scriptable Objects/Chat/ChatSystemSO")] public class ChatSystemSO : ScriptableObject { [Header("Button States")] public Sprite selectedSprite; public Sprite unselectedSprite; [Header("Channel Icons")] public List channelIcons = new List(); [Header("Message Limits")] [Tooltip("Giới hạn số ký tự thô cho một tin nhắn. <= 0 nghĩa là không giới hạn. " + "TMP tag như cũng được tính theo đúng số ký tự của tag.")] public int maxRawCharactersPerMessage = 60; /// /// Đếm số ký tự thô (raw) của nội dung đang nhập. /// Count raw characters from current input text. /// public int CountRawCharacters(string rawText) { if (string.IsNullOrEmpty(rawText)) return 0; return rawText.Length; } /// /// Kiểm tra có thể dùng thêm reserveChars mà vẫn không vượt giới hạn ký tự thô. /// Check whether reserveChars can be added without exceeding raw character limit. /// public bool CanUseRawCharacters(string rawText, int reserveChars, out int usedChars, out int limitChars) { limitChars = maxRawCharactersPerMessage; usedChars = CountRawCharacters(rawText) + Mathf.Max(0, reserveChars); if (limitChars <= 0) return true; return usedChars <= limitChars; } } }