Add filter ui chat

This commit is contained in:
CuongNV
2026-03-24 10:58:19 +07:00
parent 813f415147
commit 19820fcf2a
7 changed files with 92 additions and 12 deletions
+32 -2
View File
@@ -21,6 +21,7 @@ namespace BrewMonster.Scripts.ChatUI
}
public List<ChannelButtonMapping> channelButtons = new();
public ChatPanelUI chatPanelUI; // Reference to ChatPanelUI to relay channel changes
private const int MAX_HISTORY = 10;
private ChatChannel m_currentChannel = ChatChannel.GP_CHAT_LOCAL;
@@ -88,6 +89,12 @@ namespace BrewMonster.Scripts.ChatUI
}
m_currentChannel = channel;
if (chatPanelUI != null)
{
chatPanelUI.SetChannelFilter(channel);
}
var config = chatSystem.channelIcons.Find(c => c.channel == channel);
if (config.prefix != null)
{
@@ -96,8 +103,17 @@ namespace BrewMonster.Scripts.ChatUI
inputField.text = config.prefix + currentText;
}
inputField.ActivateInputField();
inputField.MoveTextEnd(false);
if (channel == ChatChannel.GP_CHAT_SYSTEM)
{
inputField.interactable = false;
inputField.text = ""; // Xóa text nếu chuyển sang kênh hệ thống
}
else
{
inputField.interactable = true;
inputField.ActivateInputField();
inputField.MoveTextEnd(false);
}
}
private string RemoveKnownPrefix(string text)
@@ -306,6 +322,20 @@ namespace BrewMonster.Scripts.ChatUI
}
// Không gõ prefix thủ công thì sẽ dùng m_currentChannel đã được gán ở đầu hàm
if (channel == ChatChannel.GP_CHAT_SYSTEM)
{
Debug.Log("[Cuong] ParseAndSendMessage Ngăn người chơi chat ở GP_CHAT_SYSTEM");
return channel;
}
if (channel == ChatChannel.GP_CHAT_WHISPER)
{
// Nếu người chơi đang ở kênh Whisper nhưng (vô tình) xóa mất dấu '/'
// Ta vẫn giả lập thêm '/' vào để parse theo cú pháp "TênNgườiNhận NộiDung"
HandleWhisper("/" + pszMsg, nPack, nSlot);
return channel;
}
SendChat(channel, pszMsg, nPack, nSlot);
return channel;
}