diff --git a/Assets/PerfectWorld/Scripts/Chat/UI/ChatMessageView.cs b/Assets/PerfectWorld/Scripts/Chat/UI/ChatMessageView.cs index c83e5943df..b49d91a3ec 100644 --- a/Assets/PerfectWorld/Scripts/Chat/UI/ChatMessageView.cs +++ b/Assets/PerfectWorld/Scripts/Chat/UI/ChatMessageView.cs @@ -3,10 +3,13 @@ using BrewMonster.Scripts.UI; using TMPro; using UnityEngine; using UnityEngine.UI; +using UnityEngine.EventSystems; +using BrewMonster.Network; +using CSNetwork.GPDataType; namespace BrewMonster.Scripts.ChatUI { - public class ChatMessageView : MonoBehaviour + public class ChatMessageView : MonoBehaviour, IPointerClickHandler { public Image iconImage; public EC_UIUtility.TextOutlet messageText; @@ -24,5 +27,41 @@ namespace BrewMonster.Scripts.ChatUI messageText.Set(message); GetComponent().RefreshLayout(); } + + public void OnPointerClick(PointerEventData eventData) + { + if (messageText == null || messageText.tmp == null) return; + + int linkIndex = TMP_TextUtilities.FindIntersectingLink(messageText.tmp, eventData.position, eventData.pressEventCamera); + if (linkIndex != -1) + { + TMP_LinkInfo linkInfo = messageText.tmp.textInfo.linkInfo[linkIndex]; + string linkId = linkInfo.GetLinkID(); + if (!string.IsNullOrEmpty(linkId)) + { + string playerName = linkId; + int characterId = 0; + + if (linkId.Contains("|")) + { + string[] parts = linkId.Split('|'); + if (parts.Length == 2) + { + int.TryParse(parts[0], out characterId); + playerName = parts[1]; + } + } + + var host = EC_Game.GetGameRun()?.GetHostPlayer(); + if (host != null && characterId > 0 && characterId != host.GetCharacterID() && GPDataTypeHelper.ISPLAYERID(characterId)) + { + CECUIManager.Instance?.ShowPlayerOptionsDialog(characterId, eventData.position + new Vector2(0, 400)); + } + + Debug.Log("[Cuong] OnWhisper from Chat: name: " + playerName); + EventBus.Publish(new WhisperPlayerEvent(playerName)); + } + } + } } } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 6fe9391a70..4433c48713 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -2132,7 +2132,7 @@ namespace CSNetwork break; case 18: case 19: case 20: case 21: case 22: // Auction Message // pGameUI.AddSysAuctionMessage(...) - Debug.Log("[Auction] " + strTemp); + Debug.Log("[Cuong] Auction " + strTemp); EventBus.Publish(new ChatMessageEvent(strTemp, p.Channel)); break; case 24: // Task Message @@ -2252,7 +2252,7 @@ namespace CSNetwork { // Format: "[Name] whispers to [You]: [Message]" string fmt = AUICommon.ConvertPrintfToCSharpFormat(pStrTab.GetWideString((int)FixedMsg.FIXMSG_PRIVATECHAT1)); - + BMLogger.Log($"[Cuong] OnPrtcPrivateChat {fmt}"); string formatted; try { formatted = string.Format(fmt, strSrcName, strMsg); diff --git a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPlayerOptions.cs b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPlayerOptions.cs index 1254ab6dc8..9240ef47eb 100644 --- a/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPlayerOptions.cs +++ b/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPlayerOptions.cs @@ -91,9 +91,9 @@ namespace BrewMonster.UI void OnWhisper(int characterId) { string name = EC_ManMessageMono.Instance?.GetECManPlayer?.GetElsePlayer(characterId)?.GetName() ?? ""; - Debug.Log("OnWhisper: " + characterId + " name: " + name); - - EventBus.Publish(new BrewMonster.Scripts.ChatUI.WhisperPlayerEvent(name)); + Debug.Log("[Cuong] OnWhisper: " + characterId + " name: " + name); + + EventBus.Publish(new Scripts.ChatUI.WhisperPlayerEvent(name)); } void PositionAtMouse() diff --git a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs index 04891faf0d..d11b434cc6 100644 --- a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs +++ b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs @@ -516,11 +516,11 @@ namespace BrewMonster.UI string parsedMsg = pszMsg; if (parsedMsg.Contains("&")) { - // Convert &Cuong& into Cuong + // Convert &Cuong& into Cuong parsedMsg = System.Text.RegularExpressions.Regex.Replace( parsedMsg, @"&([^&]+)&", - $"$1" + $"$1" ); } else diff --git a/Assets/Scripts/ChatInputHandler.cs b/Assets/Scripts/ChatInputHandler.cs index 3e1750c16a..c44b26a58d 100644 --- a/Assets/Scripts/ChatInputHandler.cs +++ b/Assets/Scripts/ChatInputHandler.cs @@ -429,7 +429,7 @@ namespace BrewMonster.Scripts.ChatUI private void SendPrivateChat(string target, string msg, int pack, int slot) { - Debug.Log($"Whisper to {target}: {msg}"); + BMLogger.Log($"[Cuong] Whisper to {target}: {msg}"); // [Port] C++: CDlgChat::OnCommand_speak → privatechat branch // Gửi tin nhắn mật (whisper) lên server qua GameSession.