add limit char for chat
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user