add limit char for chat

This commit is contained in:
CuongNV
2026-04-09 16:33:52 +07:00
parent 87e14a1d8a
commit b1fc46b50c
11 changed files with 84 additions and 7 deletions
+24
View File
@@ -259,6 +259,9 @@ namespace BrewMonster.Scripts.ChatUI
FilterBadWords(ref strText);
_chatWireBody = strText;
if (!CanUseRawCharacters(0))
return;
if (HandleDebugCommand(routingLine))
return;
@@ -752,6 +755,14 @@ namespace BrewMonster.Scripts.ChatUI
string segment = ChatWireTmpCodec.BuildMarshaledEmotionWire(emotionSet, emotionIndex);
if (string.IsNullOrEmpty(segment))
return;
int reserveChars = 0;
if (_spriteMap != null && EmotionTMPTagBuilder.TryBuildEmotionTag(_spriteMap, emotionSet, emotionIndex, out string tag))
reserveChars = tag.Length;
if (!CanUseRawCharacters(reserveChars))
return;
_chatWireBody += segment;
RefreshInputDisplayFromWire();
}
@@ -766,5 +777,18 @@ namespace BrewMonster.Scripts.ChatUI
{
AppendEmotionWire(emotionSet, emotionIndex);
}
private bool CanUseRawCharacters(int reserveChars)
{
if (chatSystem == null)
return true;
string rawBody = ExtractMessageBodyFromVisual(inputField != null ? inputField.text ?? "" : "");
if (chatSystem.CanUseRawCharacters(rawBody, reserveChars, out int usedChars, out int limitChars))
return true;
//AddChatMessage($"Tin nhan vuot gioi han: {usedChars}/{limitChars} ky tu.", ChatChannel.GP_CHAT_MISC);
return false;
}
}
}