add update UI filter
This commit is contained in:
@@ -36,8 +36,6 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
private ObjectPool<ChatMessageView> _pool;
|
||||
|
||||
private bool _userAtBottom = true;
|
||||
private ChatChannel _currentFilterChannel = ChatChannel.GP_CHAT_LOCAL;
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -86,20 +84,17 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
|
||||
void OnGetItem(ChatMessageView item)
|
||||
{
|
||||
if (item != null && item.gameObject != null)
|
||||
item.gameObject.SetActive(true);
|
||||
item.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
void OnReleaseItem(ChatMessageView item)
|
||||
{
|
||||
if (item != null && item.gameObject != null)
|
||||
item.gameObject.SetActive(false);
|
||||
item.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
void OnDestroyItem(ChatMessageView item)
|
||||
{
|
||||
if (item != null && item.gameObject != null)
|
||||
Destroy(item.gameObject);
|
||||
Destroy(item.gameObject);
|
||||
}
|
||||
|
||||
void OnScrollChanged(Vector2 pos)
|
||||
@@ -128,38 +123,12 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
if (!chatPanelUIGO.activeSelf)
|
||||
return;
|
||||
|
||||
if (ShouldShowMessage(data.channel))
|
||||
{
|
||||
AddMessageView(data);
|
||||
AddMessageView(data);
|
||||
|
||||
if (_userAtBottom)
|
||||
ScrollToBottom();
|
||||
}
|
||||
if (_userAtBottom)
|
||||
ScrollToBottom();
|
||||
}
|
||||
|
||||
private bool ShouldShowMessage(byte channel)
|
||||
{
|
||||
if (_currentFilterChannel == ChatChannel.GP_CHAT_LOCAL)
|
||||
return true;
|
||||
if (channel == (byte)ChatChannel.GP_CHAT_MISC)
|
||||
return true;
|
||||
return channel == (byte)_currentFilterChannel;
|
||||
}
|
||||
|
||||
public void SetChannelFilter(ChatChannel filterChannel)
|
||||
{
|
||||
if (_currentFilterChannel == filterChannel)
|
||||
return;
|
||||
|
||||
_currentFilterChannel = filterChannel;
|
||||
|
||||
if (chatPanelUIGO.activeSelf)
|
||||
{
|
||||
RefreshVisible();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AddMessageView(ChatMessageData data)
|
||||
{
|
||||
var view = _pool.Get();
|
||||
@@ -188,25 +157,15 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
|
||||
_visibleViews.Clear();
|
||||
|
||||
// Filter messages based on the current channel selection
|
||||
var filteredMessages = new List<ChatMessageData>();
|
||||
foreach (var msg in _messages)
|
||||
{
|
||||
if (ShouldShowMessage(msg.channel))
|
||||
{
|
||||
filteredMessages.Add(msg);
|
||||
}
|
||||
}
|
||||
int start = Mathf.Max(0, _messages.Count - maxVisibleMessages);
|
||||
|
||||
int start = Mathf.Max(0, filteredMessages.Count - maxVisibleMessages);
|
||||
|
||||
for (int i = start; i < filteredMessages.Count; i++)
|
||||
for (int i = start; i < _messages.Count; i++)
|
||||
{
|
||||
var view = _pool.Get();
|
||||
view.transform.SetParent(content, false);
|
||||
view.transform.SetAsLastSibling();
|
||||
|
||||
var data = filteredMessages[i];
|
||||
var data = _messages[i];
|
||||
Sprite icon = _iconCache.ContainsKey(data.channel) ? _iconCache[data.channel] : null;
|
||||
view.Bind(icon, data.message);
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: Chat
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
@@ -211,7 +211,7 @@ MonoBehaviour:
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_hasFontAssetChanged: 1
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &541196262870756845
|
||||
@@ -297,7 +297,6 @@ MonoBehaviour:
|
||||
button: {fileID: 1690303811971402318}
|
||||
- channel: 8
|
||||
button: {fileID: 5620031369785857446}
|
||||
chatPanelUI: {fileID: 2621697629504226575}
|
||||
--- !u!1 &726262149639511024
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -579,8 +578,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "\u0110\u1ED9i"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@@ -1247,8 +1246,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: Bang
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@@ -1505,8 +1504,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: Enter text...
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@@ -1990,8 +1989,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "T\u1EA5t c\u1EA3"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@@ -2247,8 +2246,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "\u200B"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@@ -2564,8 +2563,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "H\u1EC7 th\u1ED1ng"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
@@ -2807,8 +2806,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: "M\u1EADt"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_sharedMaterial: {fileID: 9092487103257209053, guid: 369c2e14814cc9a4b8e3ad4e37769134, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
|
||||
@@ -21,7 +21,6 @@ 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;
|
||||
@@ -89,12 +88,6 @@ 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)
|
||||
{
|
||||
@@ -103,17 +96,8 @@ namespace BrewMonster.Scripts.ChatUI
|
||||
inputField.text = config.prefix + currentText;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
inputField.ActivateInputField();
|
||||
inputField.MoveTextEnd(false);
|
||||
}
|
||||
|
||||
private string RemoveKnownPrefix(string text)
|
||||
@@ -322,20 +306,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -876,7 +876,6 @@ public partial class CECGameRun : ITickable
|
||||
if (string.IsNullOrEmpty(pszMsg))
|
||||
return;
|
||||
|
||||
Debug.Log($"[Cuong] AddChatMessage [{cChannel}] {pszMsgOrigion} {pszMsg}");
|
||||
CECGameUIMan pGameUI = m_pUIManager?.GetInGameUIMan();
|
||||
if (pGameUI != null)
|
||||
{
|
||||
|
||||
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f299bbe96fd1b5d45b65642a84b5702a
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user